@react-form-builder/viewer-bundle 1.0.6 → 1.0.7

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.
@@ -100,7 +100,7 @@ declare class ActionEventArgs {
100
100
  */
101
101
  get data(): Record<string, unknown>
102
102
  }
103
- `,Em=[K9.build("tooltipProps"),$9.build("renderWhen"),Q9.build("htmlAttributes"),U9.build("validation"),Qt.build(Qm),Qt.build(Um)];class Hi{constructor(e,n,c,r,o,u,d,b="component"){this.type=e,this.properties=n,this.css=c,this.wrapperCss=r,this.modules=o,this.customPreview=u,this.valuedAn=d,this.kind=b}}const pf=Symbol("key");function hf(t,e,n={}){return tV("autorun",t,e,n)}function Lr(t,e={}){return tV("observable",t,void 0,e)}function tV(t,e,n,c={}){const r=Object.keys(c).map(o=>`${o}=${c[o]}`).join("_");return`${t}_${e}_${n?`${n}_`:""}${r}`}let eV=0;function nV(t){t[pf]||(++eV,t[pf]=`actionData_${eV}`)}function aV(t){var n;const e=t.events;e&&Object.values(e).forEach(c=>c.forEach(nV)),(n=t.children)==null||n.forEach(aV)}function e1(t){return(t==null?void 0:t.computeType)==="function"}function ff(t){return(t==null?void 0:t.computeType)==="localization"}class pr{constructor(e,n){yt(this,"key","");yt(this,"type","");yt(this,"props",{});yt(this,"css");yt(this,"wrapperCss");yt(this,"events");yt(this,"children");yt(this,"schema");yt(this,"htmlAttributes");yt(this,"tooltipProps");yt(this,"slot");yt(this,"slotCondition");yt(this,"renderWhen");this.key=e,this.type=n,sl(this,void 0,{name:Lr("ComponentStore",{key:e})})}static createFromObject(e){const n=xi(new pr(e.key,e.type),e);return aV(n),n}static addEventHandler(e,n,c){var r;nV(c),e.events??(e.events={}),(r=e.events)[n]??(r[n]=[]),e.events[n].push(c)}}function vf(t){return typeof t=="string"}function Fnt(t){return typeof t=="number"}function _m(t){return typeof t=="object"&&typeof t.then=="function"}function knt(t){return typeof t=="object"}function La(t,e){const n=lw(e);return n.displayName=t,n}const Hnt=new pr("",""),ua=t=>t.replace(new RegExp(" ","g"),"_"),Dnt=t=>typeof t=="string"||typeof t=="number"||t instanceof Date?!0:typeof(t==null?void 0:t.value)<"u",cV=t=>{const e={};for(const[n,c]of Object.entries(t))Dnt(c)&&(e[ua(n)]=c);return e};function vu(t){const e=Z.createContext(null);e.displayName=t;const n=Tnt(e),c=Bnt(e);return[n,c,e]}function Tnt(t){return()=>{const e=Z.useContext(t);if(!e)throw new Error(`The context ${t.displayName} didn't found!`);return e}}function Bnt(t){return t.Provider}class Xf{constructor(){yt(this,"handlers",[])}subscribe(e){this.handlers.push(e)}unsubscribe(e){this.handlers=this.handlers.filter(n=>n!==e)}get isSubscribed(){return this.handlers.length>0}invoke(e,n){this.handlers.slice().forEach(c=>c(e,n))}dispose(){this.handlers=[]}}function Km(t,e){var n;e(t),(n=t.children)==null||n.forEach(c=>Km(c,e))}function rV(t,e,n=0){if(t===e)return n;if(t.children){n=n+1;for(const c of t.children){const r=rV(c,e,n);if(r)return r}}}let Qnt=0;function Unt(t){return`${t}_${++Qnt}`}class lV{constructor(e,n){this.oldKey=e,this.newKey=n}}class iV{constructor(){yt(this,"onAfterKeyChanged",new Xf);yt(this,"onBeforeDelete",new Xf)}dispose(){this.onAfterKeyChanged.dispose(),this.onBeforeDelete.dispose()}}class oV{constructor(e,n,c,r,o){$e(this,by,void 0);$e(this,Uc,void 0);$e(this,ci,void 0);yt(this,"_state",{});yt(this,"id");yt(this,"store");yt(this,"model");yt(this,"field");yt(this,"parent");yt(this,"children",[]);yt(this,"userDefinedProps");yt(this,"validating",!1);var d;this.store=e,this.model=n,this.field=c,this.id=Unt(this.model.type),er(this,ci,o),(d=e.children)==null||d.forEach(b=>{r(b).setParent(this)}),sl(this,void 0,{name:Lr("ComponentData",{key:e.key})}),er(this,by,[(()=>jU(()=>this.key,(b,a)=>{this.invokeOnAfterKeyChanged(this,new lV(a,b))}))()])}setParent(e){var n;(n=this.parent)==null||n.removeChild(this),e.addChild(this),this.parent=e}insertAfterMe(e){this.insert(e,"after")}insertBeforeMe(e){this.insert(e,"before")}get state(){return this._state}get key(){return this.store.key}get events(){return Dt(this,Uc)||er(this,Uc,new iV),Dt(this,Uc)}findByKey(e){if(this.key===e)return this;for(let n=0;n<this.children.length;n++){const r=this.children[n].findByKey(e);if(r)return r}}unifyKeys(e){const n=new Map,c=[];return Km(e,({key:r})=>{c.push(r)}),Km(this,r=>{let o=1;const u=()=>`${r.store.type} ${o}`;for(;c.includes(u());)o++;const d=u();n.set(d,r.key),r.store.key=d,c.push(d)}),n}get fields(){return this.collectAllFields(new Map)}delete(){var n;(n=this.parent)==null||n.removeChild(this);const e=this.collectAllNodesAsArray([]);this.invokeOnBeforeDeleted(e),this.disposeNodes(e)}get data(){const e={};for(const[n,c]of this.fields)if(c.storeDataInParentForm){const r=c.value||{};Object.keys(r).forEach(o=>e[o]=r[o])}else e[n]=c.value;return e}get fluentData(){const e=uV(this);return cV(e)}get errors(){const e={};for(const[n,c]of this.fields){c.error&&(e[n]=c.error);const r=c.errors;r&&c.storeDataInParentForm&&Object.keys(r).forEach(o=>e[o]=r[o]),r&&!c.storeDataInParentForm&&Object.keys(r).length>0&&(e[n]=r)}return e}get hasErrors(){return Object.keys(this.errors).length>0}setAllErrors(e){this.fields.forEach(n=>n.error=e)}async validate(){this.validating=!0;try{if(await Promise.allSettled([...this.fields.values()].map(r=>r.validate())),!Dt(this,ci))return;const e=this.fields,n=Dt(this,ci).map(r=>r(this.data));(await Promise.allSettled(n)).map(r=>{if(r.status==="rejected"){console.error(r.reason);return}return r.value}).forEach(r=>{r&&e.forEach((o,u)=>{if(r[u])return o.setError(r[u]);if(o.storeDataInParentForm)return o.setError(r)})})}finally{this.validating=!1}}async getValidationResult(){let e;const n=async([o,u])=>{const d=await u.getValidationResult();if(A9(d))return;e??(e={});let b=e;if(!u.storeDataInParentForm){const a=Za(d)?[]:{};e[o]??(e[o]=a),b=e[o]}j9(b,d)},c=[...this.fields.entries()];if(await Promise.allSettled(c.map(n)),!Dt(this,ci))return e;const r=async o=>{const u=await o(this.data);A9(u)||(e??(e={}),j9(e,u))};return await Promise.allSettled(Dt(this,ci).map(r)),e}get isValidating(){return this.validating}reset(){this.fields.forEach(e=>e.reset())}clear(){this.fields.forEach(e=>e.clear())}dispose(){const e=this.collectAllNodesAsArray([]);this.disposeNodes(e)}get isRoot(){return!this.parent}insert(e,n){var b,a;const c=n==="before"?0:1;if(!this.parent)throw new Error(`Cannot insert without parent. Key = ${this.key}`);(b=e.parent)==null||b.removeChild(e),e.parent=this.parent;const r=this.parent.children,o=r.indexOf(this);if(o<0)throw new Error(`Cannot insert not existing element into ComponentData. Key = ${this.key}`);r.splice(o+c,0,e),(a=this.parent.store).children??(a.children=[]);const u=this.parent.store.children,d=u.indexOf(this.store);if(d<0)throw new Error(`Cannot insert not existing element into ComponentStore. Key = ${this.key}`);u.splice(d+c,0,e.store),e.store.slot=this.store.slot,e.store.slotCondition=this.store.slotCondition}disposeNodes(e){e.forEach(n=>{var c,r;(c=Dt(n,Uc))==null||c.dispose(),Dt(n,by).forEach(o=>o()),(r=n.field)==null||r.dispose(),n.parent=void 0,n.children=[]})}collectAllNodesAsArray(e){e.push(this);for(let n=0;n<this.children.length;n++)this.children[n].collectAllNodesAsArray(e);return e}collectAllFields(e){this.field&&e.set(this.key,this.field);for(let n=0;n<this.children.length;n++)this.children[n].collectAllFields(e);return e}addChild(e){var n;this.children.indexOf(e)<0&&this.children.push(e),(n=this.store).children??(n.children=[]),this.store.children.indexOf(e.store)<0&&this.store.children.push(e.store)}removeChild(e){var r;const n=this.children.indexOf(e);n>-1&&this.children.splice(n,1),(r=this.store).children??(r.children=[]);const c=this.store.children.indexOf(e.store);c>-1&&this.store.children.splice(c,1)}invokeOnAfterKeyChanged(e,n){var c,r;(c=Dt(this,Uc))!=null&&c.onAfterKeyChanged.isSubscribed&&Dt(this,Uc).onAfterKeyChanged.invoke(e,n),(r=this.parent)==null||r.invokeOnAfterKeyChanged(e,n)}invokeOnBeforeDeleted(e){var n,c;(n=Dt(this,Uc))!=null&&n.onBeforeDelete.isSubscribed&&e.forEach(r=>{var o;return(o=Dt(this,Uc))==null?void 0:o.onBeforeDelete.invoke(r,void 0)}),(c=this.parent)==null||c.invokeOnBeforeDeleted(e)}}by=new WeakMap,Uc=new WeakMap,ci=new WeakMap;const uV=t=>{const e={};return t.fields.forEach((n,c)=>{e[c]=t.data[c]??""}),e},[hr,Gf]=vu("ComponentDataContext"),[Ea,$m,dV]=vu("StoreContext"),[xl,Yf]=vu("FormViewerPropsContext");function Xu(t,e={}){return Rnt(t,(n,c,r)=>{var o;return n.push(((o=c==null?void 0:c.setup(e))==null?void 0:o.build(r))??Ft.setup(e).build(r)),n},[])}function qm(t){return Xu(t,{annotationType:"Style",calculable:!1})}function Pnt(t){const e=Z.useRef(!1),[n,c]=Z.useState(t);return Z.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),[n,o=>{e.current&&c(o)}]}const Ent=new Date(1709897240193),sV=":",yV="-",_nt=`MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEJDKWHzXT9YZw7WDJy4wr/VMXBf+/afNB
103
+ `,Em=[K9.build("tooltipProps"),$9.build("renderWhen"),Q9.build("htmlAttributes"),U9.build("validation"),Qt.build(Qm),Qt.build(Um)];class Hi{constructor(e,n,c,r,o,u,d,b="component"){this.type=e,this.properties=n,this.css=c,this.wrapperCss=r,this.modules=o,this.customPreview=u,this.valuedAn=d,this.kind=b}}const pf=Symbol("key");function hf(t,e,n={}){return tV("autorun",t,e,n)}function Lr(t,e={}){return tV("observable",t,void 0,e)}function tV(t,e,n,c={}){const r=Object.keys(c).map(o=>`${o}=${c[o]}`).join("_");return`${t}_${e}_${n?`${n}_`:""}${r}`}let eV=0;function nV(t){t[pf]||(++eV,t[pf]=`actionData_${eV}`)}function aV(t){var n;const e=t.events;e&&Object.values(e).forEach(c=>c.forEach(nV)),(n=t.children)==null||n.forEach(aV)}function e1(t){return(t==null?void 0:t.computeType)==="function"}function ff(t){return(t==null?void 0:t.computeType)==="localization"}class pr{constructor(e,n){yt(this,"key","");yt(this,"type","");yt(this,"props",{});yt(this,"css");yt(this,"wrapperCss");yt(this,"events");yt(this,"children");yt(this,"schema");yt(this,"htmlAttributes");yt(this,"tooltipProps");yt(this,"slot");yt(this,"slotCondition");yt(this,"renderWhen");this.key=e,this.type=n,sl(this,void 0,{name:Lr("ComponentStore",{key:e})})}static createFromObject(e){const n=xi(new pr(e.key,e.type),e);return aV(n),n}static addEventHandler(e,n,c){var r;nV(c),e.events??(e.events={}),(r=e.events)[n]??(r[n]=[]),e.events[n].push(c)}}function vf(t){return typeof t=="string"}function Fnt(t){return typeof t=="number"}function _m(t){return typeof t=="object"&&typeof t.then=="function"}function knt(t){return typeof t=="object"}function La(t,e){const n=lw(e);return n.displayName=t,n}const Hnt=new pr("",""),ua=t=>t.replace(new RegExp(" ","g"),"_"),Dnt=t=>typeof t=="string"||typeof t=="number"||t instanceof Date?!0:typeof(t==null?void 0:t.value)<"u",cV=t=>{const e={};for(const[n,c]of Object.entries(t))Dnt(c)&&(e[ua(n)]=c);return e};function vu(t){const e=Z.createContext(null);e.displayName=t;const n=Tnt(e),c=Bnt(e);return[n,c,e]}function Tnt(t){return()=>{const e=Z.useContext(t);if(!e)throw new Error(`The context ${t.displayName} didn't found!`);return e}}function Bnt(t){return t.Provider}class Xf{constructor(){yt(this,"handlers",[])}subscribe(e){this.handlers.push(e)}unsubscribe(e){this.handlers=this.handlers.filter(n=>n!==e)}get isSubscribed(){return this.handlers.length>0}invoke(e,n){this.handlers.slice().forEach(c=>c(e,n))}dispose(){this.handlers=[]}}function Km(t,e){var n;e(t),(n=t.children)==null||n.forEach(c=>Km(c,e))}function rV(t,e,n=0){if(t===e)return n;if(t.children){n=n+1;for(const c of t.children){const r=rV(c,e,n);if(r)return r}}}let Qnt=0;function Unt(t){return`${t}_${++Qnt}`}class lV{constructor(e,n){this.oldKey=e,this.newKey=n}}class iV{constructor(){yt(this,"onAfterKeyChanged",new Xf);yt(this,"onBeforeDelete",new Xf)}dispose(){this.onAfterKeyChanged.dispose(),this.onBeforeDelete.dispose()}}class oV{constructor(e,n,c,r,o){$e(this,by,void 0);$e(this,Uc,void 0);$e(this,ci,void 0);yt(this,"_state",{});yt(this,"id");yt(this,"store");yt(this,"model");yt(this,"field");yt(this,"parent");yt(this,"children",[]);yt(this,"userDefinedProps");yt(this,"validating",!1);var d;this.store=e,this.model=n,this.field=c,this.id=Unt(this.model.type),er(this,ci,o),(d=e.children)==null||d.forEach(b=>{r(b).setParent(this)}),sl(this,void 0,{name:Lr("ComponentData",{key:e.key})}),er(this,by,[(()=>jU(()=>this.key,(b,a)=>{this.invokeOnAfterKeyChanged(this,new lV(a,b))}))()])}setParent(e){var n;(n=this.parent)==null||n.removeChild(this),e.addChild(this),this.parent=e}insertAfterMe(e){this.insert(e,"after")}insertBeforeMe(e){this.insert(e,"before")}get state(){return this._state}get key(){return this.store.key}get events(){return Dt(this,Uc)||er(this,Uc,new iV),Dt(this,Uc)}findByKey(e){if(this.key===e)return this;for(let n=0;n<this.children.length;n++){const r=this.children[n].findByKey(e);if(r)return r}}unifyKeys(e){const n=new Map,c=[];return Km(e,({key:r})=>{c.push(r)}),Km(this,r=>{let o=1;const u=()=>`${r.store.type} ${o}`;for(;c.includes(u());)o++;const d=u();n.set(d,r.key),r.store.key=d,c.push(d)}),n}get fields(){return this.collectAllFields(new Map)}delete(){var n;(n=this.parent)==null||n.removeChild(this);const e=this.collectAllNodesAsArray([]);this.invokeOnBeforeDeleted(e),this.disposeNodes(e)}get data(){const e={};for(const[n,c]of this.fields)if(c.storeDataInParentForm){const r=c.value||{};Object.keys(r).forEach(o=>e[o]=r[o])}else e[n]=c.value;return e}get fluentData(){const e=uV(this);return cV(e)}get errors(){const e={};for(const[n,c]of this.fields){c.error&&(e[n]=c.error);const r=c.errors;r&&c.storeDataInParentForm&&Object.keys(r).forEach(o=>e[o]=r[o]),r&&!c.storeDataInParentForm&&Object.keys(r).length>0&&(e[n]=r)}return e}get hasErrors(){return Object.keys(this.errors).length>0}setAllErrors(e){this.fields.forEach(n=>n.error=e)}async validate(){this.validating=!0;try{if(await Promise.allSettled([...this.fields.values()].map(r=>r.validate())),!Dt(this,ci))return;const e=this.fields,n=Dt(this,ci).map(r=>r(this.data));(await Promise.allSettled(n)).map(r=>{if(r.status==="rejected"){console.error(r.reason);return}return r.value}).forEach(r=>{r&&e.forEach((o,u)=>{if(r[u])return o.setError(r[u]);if(o.storeDataInParentForm)return o.setError(r)})})}finally{this.validating=!1}}async getValidationResult(){let e;const n=async([o,u])=>{const d=await u.getValidationResult();if(A9(d))return;e??(e={});let b=e;if(!u.storeDataInParentForm){const a=Za(d)?[]:{};e[o]??(e[o]=a),b=e[o]}j9(b,d)},c=[...this.fields.entries()];if(await Promise.allSettled(c.map(n)),!Dt(this,ci))return e;const r=async o=>{const u=await o(this.data);A9(u)||(e??(e={}),j9(e,u))};return await Promise.allSettled(Dt(this,ci).map(r)),e}get isValidating(){return this.validating}reset(){this.fields.forEach(e=>e.reset())}clear(){this.fields.forEach(e=>e.clear())}dispose(){const e=this.collectAllNodesAsArray([]);this.disposeNodes(e)}get isRoot(){return!this.parent}insert(e,n){var b,a;const c=n==="before"?0:1;if(!this.parent)throw new Error(`Cannot insert without parent. Key = ${this.key}`);(b=e.parent)==null||b.removeChild(e),e.parent=this.parent;const r=this.parent.children,o=r.indexOf(this);if(o<0)throw new Error(`Cannot insert not existing element into ComponentData. Key = ${this.key}`);r.splice(o+c,0,e),(a=this.parent.store).children??(a.children=[]);const u=this.parent.store.children,d=u.indexOf(this.store);if(d<0)throw new Error(`Cannot insert not existing element into ComponentStore. Key = ${this.key}`);u.splice(d+c,0,e.store),e.store.slot=this.store.slot,e.store.slotCondition=this.store.slotCondition}disposeNodes(e){e.forEach(n=>{var c,r;(c=Dt(n,Uc))==null||c.dispose(),Dt(n,by).forEach(o=>o()),(r=n.field)==null||r.dispose(),n.parent=void 0,n.children=[]})}collectAllNodesAsArray(e){e.push(this);for(let n=0;n<this.children.length;n++)this.children[n].collectAllNodesAsArray(e);return e}collectAllFields(e){this.field&&e.set(this.key,this.field);for(let n=0;n<this.children.length;n++)this.children[n].collectAllFields(e);return e}addChild(e){var n;this.children.indexOf(e)<0&&this.children.push(e),(n=this.store).children??(n.children=[]),this.store.children.indexOf(e.store)<0&&this.store.children.push(e.store)}removeChild(e){var r;const n=this.children.indexOf(e);n>-1&&this.children.splice(n,1),(r=this.store).children??(r.children=[]);const c=this.store.children.indexOf(e.store);c>-1&&this.store.children.splice(c,1)}invokeOnAfterKeyChanged(e,n){var c,r;(c=Dt(this,Uc))!=null&&c.onAfterKeyChanged.isSubscribed&&Dt(this,Uc).onAfterKeyChanged.invoke(e,n),(r=this.parent)==null||r.invokeOnAfterKeyChanged(e,n)}invokeOnBeforeDeleted(e){var n,c;(n=Dt(this,Uc))!=null&&n.onBeforeDelete.isSubscribed&&e.forEach(r=>{var o;return(o=Dt(this,Uc))==null?void 0:o.onBeforeDelete.invoke(r,void 0)}),(c=this.parent)==null||c.invokeOnBeforeDeleted(e)}}by=new WeakMap,Uc=new WeakMap,ci=new WeakMap;const uV=t=>{const e={};return t.fields.forEach((n,c)=>{e[c]=t.data[c]??""}),e},[hr,Gf]=vu("ComponentDataContext"),[Ea,$m,dV]=vu("StoreContext"),[xl,Yf]=vu("FormViewerPropsContext");function Xu(t,e={}){return Rnt(t,(n,c,r)=>{var o;return n.push(((o=c==null?void 0:c.setup(e))==null?void 0:o.build(r))??Ft.setup(e).build(r)),n},[])}function qm(t){return Xu(t,{annotationType:"Style",calculable:!1})}function Pnt(t){const e=Z.useRef(!1),[n,c]=Z.useState(t);return Z.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),[n,o=>{e.current&&c(o)}]}const Ent=new Date(1710433867530),sV=":",yV="-",_nt=`MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEJDKWHzXT9YZw7WDJy4wr/VMXBf+/afNB
104
104
  ppCLv1zZFVUQEmDRPhGC5nKux3WQcrtfl18iNFfISjcqN5vplR/kcAvIJd07tacn
105
105
  y1l39NGbMLIoPVzPY6GXTNzQpxRbGn99`;function bV(t){const e=window.atob(t),n=new Uint8Array(e.length);for(let c=0;c<e.length;c++)n[c]=e.charCodeAt(c);return n.buffer}function Knt(t){return window.crypto.subtle.importKey("spki",bV(t),{name:"ECDSA",namedCurve:"P-384"},!0,["verify"])}async function $nt(t,e,n){if(!window.crypto.subtle)return;const c=await Knt(n),r=new TextEncoder().encode(t);return await window.crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-384"}},c,e,r)}function qnt(t,e){const{licenseEndDate:n,restrictions:c,companyName:r}=JSON.parse(e)??{};if(t!==r)return!1;const o=n.split(".");if(o.length!==3)return!1;const u=`${o[2]}-${o[0]}-${o[1]}`,d=new Date(u),b=new Date;return c.StrictCheck===!0&&d<b?!1:d>Ent}async function tat(t){if(t)try{let e=t.indexOf(yV);if(e===-1)return!1;const n=t.slice(0,e),c=t.slice(e+yV.length);if(e=c.indexOf(sV),e===-1)return!1;const r=window.atob(c.slice(0,e)),o=bV(c.slice(e+sV.length));return await $nt(r,o,_nt)?qnt(n,r):!1}catch{return!1}}const eat=()=>{const{licenseKey:t}=xl(),[e,n]=Pnt(!0);return Z.useEffect(()=>{tat(t).then(c=>{n(!!c)})},[t]),dt("div",{children:!e&&dt(nat,{children:vn(aat,{children:["This is a trial version of the product. To purchase a license, go to ",dt("a",{href:"https://formengine.io/pricing",children:"https://formengine.io/pricing"})]})})})},nat=nn.div`
106
106
  display: flex;
package/dist/index.umd.js CHANGED
@@ -100,7 +100,7 @@ declare class ActionEventArgs {
100
100
  */
101
101
  get data(): Record<string, unknown>
102
102
  }
103
- `,Em=[K9.build("tooltipProps"),$9.build("renderWhen"),Q9.build("htmlAttributes"),U9.build("validation"),Qt.build(Qm),Qt.build(Um)];class Hi{constructor(e,n,c,r,o,u,d,b="component"){this.type=e,this.properties=n,this.css=c,this.wrapperCss=r,this.modules=o,this.customPreview=u,this.valuedAn=d,this.kind=b}}const pf=Symbol("key");function hf(t,e,n={}){return tV("autorun",t,e,n)}function Lr(t,e={}){return tV("observable",t,void 0,e)}function tV(t,e,n,c={}){const r=Object.keys(c).map(o=>`${o}=${c[o]}`).join("_");return`${t}_${e}_${n?`${n}_`:""}${r}`}let eV=0;function nV(t){t[pf]||(++eV,t[pf]=`actionData_${eV}`)}function aV(t){var n;const e=t.events;e&&Object.values(e).forEach(c=>c.forEach(nV)),(n=t.children)==null||n.forEach(aV)}function e1(t){return(t==null?void 0:t.computeType)==="function"}function ff(t){return(t==null?void 0:t.computeType)==="localization"}class pr{constructor(e,n){yt(this,"key","");yt(this,"type","");yt(this,"props",{});yt(this,"css");yt(this,"wrapperCss");yt(this,"events");yt(this,"children");yt(this,"schema");yt(this,"htmlAttributes");yt(this,"tooltipProps");yt(this,"slot");yt(this,"slotCondition");yt(this,"renderWhen");this.key=e,this.type=n,sl(this,void 0,{name:Lr("ComponentStore",{key:e})})}static createFromObject(e){const n=xi(new pr(e.key,e.type),e);return aV(n),n}static addEventHandler(e,n,c){var r;nV(c),e.events??(e.events={}),(r=e.events)[n]??(r[n]=[]),e.events[n].push(c)}}function vf(t){return typeof t=="string"}function Fnt(t){return typeof t=="number"}function _m(t){return typeof t=="object"&&typeof t.then=="function"}function knt(t){return typeof t=="object"}function La(t,e){const n=lw(e);return n.displayName=t,n}const Hnt=new pr("",""),ua=t=>t.replace(new RegExp(" ","g"),"_"),Dnt=t=>typeof t=="string"||typeof t=="number"||t instanceof Date?!0:typeof(t==null?void 0:t.value)<"u",cV=t=>{const e={};for(const[n,c]of Object.entries(t))Dnt(c)&&(e[ua(n)]=c);return e};function vu(t){const e=Z.createContext(null);e.displayName=t;const n=Tnt(e),c=Bnt(e);return[n,c,e]}function Tnt(t){return()=>{const e=Z.useContext(t);if(!e)throw new Error(`The context ${t.displayName} didn't found!`);return e}}function Bnt(t){return t.Provider}class Xf{constructor(){yt(this,"handlers",[])}subscribe(e){this.handlers.push(e)}unsubscribe(e){this.handlers=this.handlers.filter(n=>n!==e)}get isSubscribed(){return this.handlers.length>0}invoke(e,n){this.handlers.slice().forEach(c=>c(e,n))}dispose(){this.handlers=[]}}function Km(t,e){var n;e(t),(n=t.children)==null||n.forEach(c=>Km(c,e))}function rV(t,e,n=0){if(t===e)return n;if(t.children){n=n+1;for(const c of t.children){const r=rV(c,e,n);if(r)return r}}}let Qnt=0;function Unt(t){return`${t}_${++Qnt}`}class lV{constructor(e,n){this.oldKey=e,this.newKey=n}}class iV{constructor(){yt(this,"onAfterKeyChanged",new Xf);yt(this,"onBeforeDelete",new Xf)}dispose(){this.onAfterKeyChanged.dispose(),this.onBeforeDelete.dispose()}}class oV{constructor(e,n,c,r,o){$e(this,by,void 0);$e(this,Uc,void 0);$e(this,ci,void 0);yt(this,"_state",{});yt(this,"id");yt(this,"store");yt(this,"model");yt(this,"field");yt(this,"parent");yt(this,"children",[]);yt(this,"userDefinedProps");yt(this,"validating",!1);var d;this.store=e,this.model=n,this.field=c,this.id=Unt(this.model.type),er(this,ci,o),(d=e.children)==null||d.forEach(b=>{r(b).setParent(this)}),sl(this,void 0,{name:Lr("ComponentData",{key:e.key})}),er(this,by,[(()=>jU(()=>this.key,(b,a)=>{this.invokeOnAfterKeyChanged(this,new lV(a,b))}))()])}setParent(e){var n;(n=this.parent)==null||n.removeChild(this),e.addChild(this),this.parent=e}insertAfterMe(e){this.insert(e,"after")}insertBeforeMe(e){this.insert(e,"before")}get state(){return this._state}get key(){return this.store.key}get events(){return Dt(this,Uc)||er(this,Uc,new iV),Dt(this,Uc)}findByKey(e){if(this.key===e)return this;for(let n=0;n<this.children.length;n++){const r=this.children[n].findByKey(e);if(r)return r}}unifyKeys(e){const n=new Map,c=[];return Km(e,({key:r})=>{c.push(r)}),Km(this,r=>{let o=1;const u=()=>`${r.store.type} ${o}`;for(;c.includes(u());)o++;const d=u();n.set(d,r.key),r.store.key=d,c.push(d)}),n}get fields(){return this.collectAllFields(new Map)}delete(){var n;(n=this.parent)==null||n.removeChild(this);const e=this.collectAllNodesAsArray([]);this.invokeOnBeforeDeleted(e),this.disposeNodes(e)}get data(){const e={};for(const[n,c]of this.fields)if(c.storeDataInParentForm){const r=c.value||{};Object.keys(r).forEach(o=>e[o]=r[o])}else e[n]=c.value;return e}get fluentData(){const e=uV(this);return cV(e)}get errors(){const e={};for(const[n,c]of this.fields){c.error&&(e[n]=c.error);const r=c.errors;r&&c.storeDataInParentForm&&Object.keys(r).forEach(o=>e[o]=r[o]),r&&!c.storeDataInParentForm&&Object.keys(r).length>0&&(e[n]=r)}return e}get hasErrors(){return Object.keys(this.errors).length>0}setAllErrors(e){this.fields.forEach(n=>n.error=e)}async validate(){this.validating=!0;try{if(await Promise.allSettled([...this.fields.values()].map(r=>r.validate())),!Dt(this,ci))return;const e=this.fields,n=Dt(this,ci).map(r=>r(this.data));(await Promise.allSettled(n)).map(r=>{if(r.status==="rejected"){console.error(r.reason);return}return r.value}).forEach(r=>{r&&e.forEach((o,u)=>{if(r[u])return o.setError(r[u]);if(o.storeDataInParentForm)return o.setError(r)})})}finally{this.validating=!1}}async getValidationResult(){let e;const n=async([o,u])=>{const d=await u.getValidationResult();if(A9(d))return;e??(e={});let b=e;if(!u.storeDataInParentForm){const a=Za(d)?[]:{};e[o]??(e[o]=a),b=e[o]}j9(b,d)},c=[...this.fields.entries()];if(await Promise.allSettled(c.map(n)),!Dt(this,ci))return e;const r=async o=>{const u=await o(this.data);A9(u)||(e??(e={}),j9(e,u))};return await Promise.allSettled(Dt(this,ci).map(r)),e}get isValidating(){return this.validating}reset(){this.fields.forEach(e=>e.reset())}clear(){this.fields.forEach(e=>e.clear())}dispose(){const e=this.collectAllNodesAsArray([]);this.disposeNodes(e)}get isRoot(){return!this.parent}insert(e,n){var b,a;const c=n==="before"?0:1;if(!this.parent)throw new Error(`Cannot insert without parent. Key = ${this.key}`);(b=e.parent)==null||b.removeChild(e),e.parent=this.parent;const r=this.parent.children,o=r.indexOf(this);if(o<0)throw new Error(`Cannot insert not existing element into ComponentData. Key = ${this.key}`);r.splice(o+c,0,e),(a=this.parent.store).children??(a.children=[]);const u=this.parent.store.children,d=u.indexOf(this.store);if(d<0)throw new Error(`Cannot insert not existing element into ComponentStore. Key = ${this.key}`);u.splice(d+c,0,e.store),e.store.slot=this.store.slot,e.store.slotCondition=this.store.slotCondition}disposeNodes(e){e.forEach(n=>{var c,r;(c=Dt(n,Uc))==null||c.dispose(),Dt(n,by).forEach(o=>o()),(r=n.field)==null||r.dispose(),n.parent=void 0,n.children=[]})}collectAllNodesAsArray(e){e.push(this);for(let n=0;n<this.children.length;n++)this.children[n].collectAllNodesAsArray(e);return e}collectAllFields(e){this.field&&e.set(this.key,this.field);for(let n=0;n<this.children.length;n++)this.children[n].collectAllFields(e);return e}addChild(e){var n;this.children.indexOf(e)<0&&this.children.push(e),(n=this.store).children??(n.children=[]),this.store.children.indexOf(e.store)<0&&this.store.children.push(e.store)}removeChild(e){var r;const n=this.children.indexOf(e);n>-1&&this.children.splice(n,1),(r=this.store).children??(r.children=[]);const c=this.store.children.indexOf(e.store);c>-1&&this.store.children.splice(c,1)}invokeOnAfterKeyChanged(e,n){var c,r;(c=Dt(this,Uc))!=null&&c.onAfterKeyChanged.isSubscribed&&Dt(this,Uc).onAfterKeyChanged.invoke(e,n),(r=this.parent)==null||r.invokeOnAfterKeyChanged(e,n)}invokeOnBeforeDeleted(e){var n,c;(n=Dt(this,Uc))!=null&&n.onBeforeDelete.isSubscribed&&e.forEach(r=>{var o;return(o=Dt(this,Uc))==null?void 0:o.onBeforeDelete.invoke(r,void 0)}),(c=this.parent)==null||c.invokeOnBeforeDeleted(e)}}by=new WeakMap,Uc=new WeakMap,ci=new WeakMap;const uV=t=>{const e={};return t.fields.forEach((n,c)=>{e[c]=t.data[c]??""}),e},[hr,Gf]=vu("ComponentDataContext"),[Ea,$m,dV]=vu("StoreContext"),[xl,Yf]=vu("FormViewerPropsContext");function Xu(t,e={}){return Rnt(t,(n,c,r)=>{var o;return n.push(((o=c==null?void 0:c.setup(e))==null?void 0:o.build(r))??Ft.setup(e).build(r)),n},[])}function qm(t){return Xu(t,{annotationType:"Style",calculable:!1})}function Pnt(t){const e=Z.useRef(!1),[n,c]=Z.useState(t);return Z.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),[n,o=>{e.current&&c(o)}]}const Ent=new Date(1709897240193),sV=":",yV="-",_nt=`MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEJDKWHzXT9YZw7WDJy4wr/VMXBf+/afNB
103
+ `,Em=[K9.build("tooltipProps"),$9.build("renderWhen"),Q9.build("htmlAttributes"),U9.build("validation"),Qt.build(Qm),Qt.build(Um)];class Hi{constructor(e,n,c,r,o,u,d,b="component"){this.type=e,this.properties=n,this.css=c,this.wrapperCss=r,this.modules=o,this.customPreview=u,this.valuedAn=d,this.kind=b}}const pf=Symbol("key");function hf(t,e,n={}){return tV("autorun",t,e,n)}function Lr(t,e={}){return tV("observable",t,void 0,e)}function tV(t,e,n,c={}){const r=Object.keys(c).map(o=>`${o}=${c[o]}`).join("_");return`${t}_${e}_${n?`${n}_`:""}${r}`}let eV=0;function nV(t){t[pf]||(++eV,t[pf]=`actionData_${eV}`)}function aV(t){var n;const e=t.events;e&&Object.values(e).forEach(c=>c.forEach(nV)),(n=t.children)==null||n.forEach(aV)}function e1(t){return(t==null?void 0:t.computeType)==="function"}function ff(t){return(t==null?void 0:t.computeType)==="localization"}class pr{constructor(e,n){yt(this,"key","");yt(this,"type","");yt(this,"props",{});yt(this,"css");yt(this,"wrapperCss");yt(this,"events");yt(this,"children");yt(this,"schema");yt(this,"htmlAttributes");yt(this,"tooltipProps");yt(this,"slot");yt(this,"slotCondition");yt(this,"renderWhen");this.key=e,this.type=n,sl(this,void 0,{name:Lr("ComponentStore",{key:e})})}static createFromObject(e){const n=xi(new pr(e.key,e.type),e);return aV(n),n}static addEventHandler(e,n,c){var r;nV(c),e.events??(e.events={}),(r=e.events)[n]??(r[n]=[]),e.events[n].push(c)}}function vf(t){return typeof t=="string"}function Fnt(t){return typeof t=="number"}function _m(t){return typeof t=="object"&&typeof t.then=="function"}function knt(t){return typeof t=="object"}function La(t,e){const n=lw(e);return n.displayName=t,n}const Hnt=new pr("",""),ua=t=>t.replace(new RegExp(" ","g"),"_"),Dnt=t=>typeof t=="string"||typeof t=="number"||t instanceof Date?!0:typeof(t==null?void 0:t.value)<"u",cV=t=>{const e={};for(const[n,c]of Object.entries(t))Dnt(c)&&(e[ua(n)]=c);return e};function vu(t){const e=Z.createContext(null);e.displayName=t;const n=Tnt(e),c=Bnt(e);return[n,c,e]}function Tnt(t){return()=>{const e=Z.useContext(t);if(!e)throw new Error(`The context ${t.displayName} didn't found!`);return e}}function Bnt(t){return t.Provider}class Xf{constructor(){yt(this,"handlers",[])}subscribe(e){this.handlers.push(e)}unsubscribe(e){this.handlers=this.handlers.filter(n=>n!==e)}get isSubscribed(){return this.handlers.length>0}invoke(e,n){this.handlers.slice().forEach(c=>c(e,n))}dispose(){this.handlers=[]}}function Km(t,e){var n;e(t),(n=t.children)==null||n.forEach(c=>Km(c,e))}function rV(t,e,n=0){if(t===e)return n;if(t.children){n=n+1;for(const c of t.children){const r=rV(c,e,n);if(r)return r}}}let Qnt=0;function Unt(t){return`${t}_${++Qnt}`}class lV{constructor(e,n){this.oldKey=e,this.newKey=n}}class iV{constructor(){yt(this,"onAfterKeyChanged",new Xf);yt(this,"onBeforeDelete",new Xf)}dispose(){this.onAfterKeyChanged.dispose(),this.onBeforeDelete.dispose()}}class oV{constructor(e,n,c,r,o){$e(this,by,void 0);$e(this,Uc,void 0);$e(this,ci,void 0);yt(this,"_state",{});yt(this,"id");yt(this,"store");yt(this,"model");yt(this,"field");yt(this,"parent");yt(this,"children",[]);yt(this,"userDefinedProps");yt(this,"validating",!1);var d;this.store=e,this.model=n,this.field=c,this.id=Unt(this.model.type),er(this,ci,o),(d=e.children)==null||d.forEach(b=>{r(b).setParent(this)}),sl(this,void 0,{name:Lr("ComponentData",{key:e.key})}),er(this,by,[(()=>jU(()=>this.key,(b,a)=>{this.invokeOnAfterKeyChanged(this,new lV(a,b))}))()])}setParent(e){var n;(n=this.parent)==null||n.removeChild(this),e.addChild(this),this.parent=e}insertAfterMe(e){this.insert(e,"after")}insertBeforeMe(e){this.insert(e,"before")}get state(){return this._state}get key(){return this.store.key}get events(){return Dt(this,Uc)||er(this,Uc,new iV),Dt(this,Uc)}findByKey(e){if(this.key===e)return this;for(let n=0;n<this.children.length;n++){const r=this.children[n].findByKey(e);if(r)return r}}unifyKeys(e){const n=new Map,c=[];return Km(e,({key:r})=>{c.push(r)}),Km(this,r=>{let o=1;const u=()=>`${r.store.type} ${o}`;for(;c.includes(u());)o++;const d=u();n.set(d,r.key),r.store.key=d,c.push(d)}),n}get fields(){return this.collectAllFields(new Map)}delete(){var n;(n=this.parent)==null||n.removeChild(this);const e=this.collectAllNodesAsArray([]);this.invokeOnBeforeDeleted(e),this.disposeNodes(e)}get data(){const e={};for(const[n,c]of this.fields)if(c.storeDataInParentForm){const r=c.value||{};Object.keys(r).forEach(o=>e[o]=r[o])}else e[n]=c.value;return e}get fluentData(){const e=uV(this);return cV(e)}get errors(){const e={};for(const[n,c]of this.fields){c.error&&(e[n]=c.error);const r=c.errors;r&&c.storeDataInParentForm&&Object.keys(r).forEach(o=>e[o]=r[o]),r&&!c.storeDataInParentForm&&Object.keys(r).length>0&&(e[n]=r)}return e}get hasErrors(){return Object.keys(this.errors).length>0}setAllErrors(e){this.fields.forEach(n=>n.error=e)}async validate(){this.validating=!0;try{if(await Promise.allSettled([...this.fields.values()].map(r=>r.validate())),!Dt(this,ci))return;const e=this.fields,n=Dt(this,ci).map(r=>r(this.data));(await Promise.allSettled(n)).map(r=>{if(r.status==="rejected"){console.error(r.reason);return}return r.value}).forEach(r=>{r&&e.forEach((o,u)=>{if(r[u])return o.setError(r[u]);if(o.storeDataInParentForm)return o.setError(r)})})}finally{this.validating=!1}}async getValidationResult(){let e;const n=async([o,u])=>{const d=await u.getValidationResult();if(A9(d))return;e??(e={});let b=e;if(!u.storeDataInParentForm){const a=Za(d)?[]:{};e[o]??(e[o]=a),b=e[o]}j9(b,d)},c=[...this.fields.entries()];if(await Promise.allSettled(c.map(n)),!Dt(this,ci))return e;const r=async o=>{const u=await o(this.data);A9(u)||(e??(e={}),j9(e,u))};return await Promise.allSettled(Dt(this,ci).map(r)),e}get isValidating(){return this.validating}reset(){this.fields.forEach(e=>e.reset())}clear(){this.fields.forEach(e=>e.clear())}dispose(){const e=this.collectAllNodesAsArray([]);this.disposeNodes(e)}get isRoot(){return!this.parent}insert(e,n){var b,a;const c=n==="before"?0:1;if(!this.parent)throw new Error(`Cannot insert without parent. Key = ${this.key}`);(b=e.parent)==null||b.removeChild(e),e.parent=this.parent;const r=this.parent.children,o=r.indexOf(this);if(o<0)throw new Error(`Cannot insert not existing element into ComponentData. Key = ${this.key}`);r.splice(o+c,0,e),(a=this.parent.store).children??(a.children=[]);const u=this.parent.store.children,d=u.indexOf(this.store);if(d<0)throw new Error(`Cannot insert not existing element into ComponentStore. Key = ${this.key}`);u.splice(d+c,0,e.store),e.store.slot=this.store.slot,e.store.slotCondition=this.store.slotCondition}disposeNodes(e){e.forEach(n=>{var c,r;(c=Dt(n,Uc))==null||c.dispose(),Dt(n,by).forEach(o=>o()),(r=n.field)==null||r.dispose(),n.parent=void 0,n.children=[]})}collectAllNodesAsArray(e){e.push(this);for(let n=0;n<this.children.length;n++)this.children[n].collectAllNodesAsArray(e);return e}collectAllFields(e){this.field&&e.set(this.key,this.field);for(let n=0;n<this.children.length;n++)this.children[n].collectAllFields(e);return e}addChild(e){var n;this.children.indexOf(e)<0&&this.children.push(e),(n=this.store).children??(n.children=[]),this.store.children.indexOf(e.store)<0&&this.store.children.push(e.store)}removeChild(e){var r;const n=this.children.indexOf(e);n>-1&&this.children.splice(n,1),(r=this.store).children??(r.children=[]);const c=this.store.children.indexOf(e.store);c>-1&&this.store.children.splice(c,1)}invokeOnAfterKeyChanged(e,n){var c,r;(c=Dt(this,Uc))!=null&&c.onAfterKeyChanged.isSubscribed&&Dt(this,Uc).onAfterKeyChanged.invoke(e,n),(r=this.parent)==null||r.invokeOnAfterKeyChanged(e,n)}invokeOnBeforeDeleted(e){var n,c;(n=Dt(this,Uc))!=null&&n.onBeforeDelete.isSubscribed&&e.forEach(r=>{var o;return(o=Dt(this,Uc))==null?void 0:o.onBeforeDelete.invoke(r,void 0)}),(c=this.parent)==null||c.invokeOnBeforeDeleted(e)}}by=new WeakMap,Uc=new WeakMap,ci=new WeakMap;const uV=t=>{const e={};return t.fields.forEach((n,c)=>{e[c]=t.data[c]??""}),e},[hr,Gf]=vu("ComponentDataContext"),[Ea,$m,dV]=vu("StoreContext"),[xl,Yf]=vu("FormViewerPropsContext");function Xu(t,e={}){return Rnt(t,(n,c,r)=>{var o;return n.push(((o=c==null?void 0:c.setup(e))==null?void 0:o.build(r))??Ft.setup(e).build(r)),n},[])}function qm(t){return Xu(t,{annotationType:"Style",calculable:!1})}function Pnt(t){const e=Z.useRef(!1),[n,c]=Z.useState(t);return Z.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),[n,o=>{e.current&&c(o)}]}const Ent=new Date(1710433867530),sV=":",yV="-",_nt=`MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEJDKWHzXT9YZw7WDJy4wr/VMXBf+/afNB
104
104
  ppCLv1zZFVUQEmDRPhGC5nKux3WQcrtfl18iNFfISjcqN5vplR/kcAvIJd07tacn
105
105
  y1l39NGbMLIoPVzPY6GXTNzQpxRbGn99`;function bV(t){const e=window.atob(t),n=new Uint8Array(e.length);for(let c=0;c<e.length;c++)n[c]=e.charCodeAt(c);return n.buffer}function Knt(t){return window.crypto.subtle.importKey("spki",bV(t),{name:"ECDSA",namedCurve:"P-384"},!0,["verify"])}async function $nt(t,e,n){if(!window.crypto.subtle)return;const c=await Knt(n),r=new TextEncoder().encode(t);return await window.crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-384"}},c,e,r)}function qnt(t,e){const{licenseEndDate:n,restrictions:c,companyName:r}=JSON.parse(e)??{};if(t!==r)return!1;const o=n.split(".");if(o.length!==3)return!1;const u=`${o[2]}-${o[0]}-${o[1]}`,d=new Date(u),b=new Date;return c.StrictCheck===!0&&d<b?!1:d>Ent}async function tat(t){if(t)try{let e=t.indexOf(yV);if(e===-1)return!1;const n=t.slice(0,e),c=t.slice(e+yV.length);if(e=c.indexOf(sV),e===-1)return!1;const r=window.atob(c.slice(0,e)),o=bV(c.slice(e+sV.length));return await $nt(r,o,_nt)?qnt(n,r):!1}catch{return!1}}const eat=()=>{const{licenseKey:t}=xl(),[e,n]=Pnt(!0);return Z.useEffect(()=>{tat(t).then(c=>{n(!!c)})},[t]),dt("div",{children:!e&&dt(nat,{children:vn(aat,{children:["This is a trial version of the product. To purchase a license, go to ",dt("a",{href:"https://formengine.io/pricing",children:"https://formengine.io/pricing"})]})})})},nat=nn.div`
106
106
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-form-builder/viewer-bundle",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "private": false,
5
5
  "main": "./dist/index.umd.js",
6
6
  "type": "module",
@@ -15,8 +15,8 @@
15
15
  "email": "support@optimajet.com"
16
16
  },
17
17
  "dependencies": {
18
- "@react-form-builder/components-rsuite": "^1.0.6",
19
- "@react-form-builder/core": "^1.0.6",
18
+ "@react-form-builder/components-rsuite": "^1.0.7",
19
+ "@react-form-builder/core": "^1.0.7",
20
20
  "react": "^18.2.0",
21
21
  "react-dom": "^18.2.0",
22
22
  "react-is": "^18.2.0"