@redapollos/storm-form 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -50390,10 +50390,10 @@ const v8 = (e, t) => {
50390
50390
  submitForm: h8
50391
50391
  };
50392
50392
  function g8(e) {
50393
- return wn.getData(`/form/${e}`, !1);
50393
+ return wn.getData(`/v1/form/${e}`, !1);
50394
50394
  }
50395
50395
  function h8(e, t = !1) {
50396
- return wn.postData("/form/submission", e, t);
50396
+ return wn.postData("/v1/form/submission", e, t);
50397
50397
  }
50398
50398
  const C8 = ({ formId: e, appKey: t }) => {
50399
50399
  const [n, r] = bt(null), [a, i] = bt("");
@@ -434,4 +434,4 @@ html body {
434
434
  `):" "+_E(i[0]):"as no adapter specified";throw new Bt("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return r},adapters:xv};function wv(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new oi(null,e)}function kE(e){return wv(e),e.headers=lr.from(e.headers),e.data=Cv.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),DE.getAdapter(e.adapter||hl.adapter)(e).then(function(r){return wv(e),r.data=Cv.call(e,e.transformResponse,r),r.headers=lr.from(r.headers),r},function(r){return xE(r)||(wv(e),r&&r.response&&(r.response.data=Cv.call(e,e.transformResponse,r.response),r.response.headers=lr.from(r.response.headers))),Promise.reject(r)})}const jE="1.7.9",qc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{qc[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const FE={};qc.transitional=function(t,n,r){function a(i,l){return"[Axios v"+jE+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,s)=>{if(t===!1)throw new Bt(a(l," has been removed"+(n?" in "+n:"")),Bt.ERR_DEPRECATED);return n&&!FE[l]&&(FE[l]=!0,console.warn(a(l," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,l,s):!0}},qc.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function T6(e,t,n){if(typeof e!="object")throw new Bt("options must be an object",Bt.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let a=r.length;for(;a-- >0;){const i=r[a],l=t[i];if(l){const s=e[i],u=s===void 0||l(s,i,e);if(u!==!0)throw new Bt("option "+i+" must be "+u,Bt.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Bt("Unknown option "+i,Bt.ERR_BAD_OPTION)}}const Uc={assertOptions:T6,validators:qc},Gr=Uc.validators;class oa{constructor(t){this.defaults=t,this.interceptors={request:new bE,response:new bE}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const i=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
435
435
  `+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ra(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&Uc.assertOptions(r,{silentJSONParsing:Gr.transitional(Gr.boolean),forcedJSONParsing:Gr.transitional(Gr.boolean),clarifyTimeoutError:Gr.transitional(Gr.boolean)},!1),a!=null&&(Pe.isFunction(a)?n.paramsSerializer={serialize:a}:Uc.assertOptions(a,{encode:Gr.function,serialize:Gr.function},!0)),Uc.assertOptions(n,{baseUrl:Gr.spelling("baseURL"),withXsrfToken:Gr.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l=i&&Pe.merge(i.common,i[n.method]);i&&Pe.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),n.headers=lr.concat(l,i);const s=[];let u=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(n)===!1||(u=u&&b.synchronous,s.unshift(b.fulfilled,b.rejected))});const d=[];this.interceptors.response.forEach(function(b){d.push(b.fulfilled,b.rejected)});let f,m=0,v;if(!u){const h=[kE.bind(this),void 0];for(h.unshift.apply(h,s),h.push.apply(h,d),v=h.length,f=Promise.resolve(n);m<v;)f=f.then(h[m++],h[m++]);return f}v=s.length;let g=n;for(m=0;m<v;){const h=s[m++],b=s[m++];try{g=h(g)}catch(p){b.call(this,p);break}}try{f=kE.call(this,g)}catch(h){return Promise.reject(h)}for(m=0,v=d.length;m<v;)f=f.then(d[m++],d[m++]);return f}getUri(t){t=ra(this.defaults,t);const n=OE(t.baseURL,t.url);return hE(n,t.params,t.paramsSerializer)}}Pe.forEach(["delete","get","head","options"],function(t){oa.prototype[t]=function(n,r){return this.request(ra(r||{},{method:t,url:n,data:(r||{}).data}))}}),Pe.forEach(["post","put","patch"],function(t){function n(r){return function(i,l,s){return this.request(ra(s||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:l}))}}oa.prototype[t]=n(),oa.prototype[t+"Form"]=n(!0)});class Ev{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(a=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](a);r._listeners=null}),this.promise.then=a=>{let i;const l=new Promise(s=>{r.subscribe(s),i=s}).then(a);return l.cancel=function(){r.unsubscribe(i)},l},t(function(i,l,s){r.reason||(r.reason=new oi(i,l,s),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Ev(function(a){t=a}),cancel:t}}}function _6(e){return function(n){return e.apply(null,n)}}function D6(e){return Pe.isObject(e)&&e.isAxiosError===!0}const $v={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries($v).forEach(([e,t])=>{$v[t]=e});function AE(e){const t=new oa(e),n=tE(oa.prototype.request,t);return Pe.extend(n,oa.prototype,t,{allOwnKeys:!0}),Pe.extend(n,t,null,{allOwnKeys:!0}),n.create=function(a){return AE(ra(e,a))},n}const cn=AE(hl);cn.Axios=oa,cn.CanceledError=oi,cn.CancelToken=Ev,cn.isCancel=xE,cn.VERSION=jE,cn.toFormData=zc,cn.AxiosError=Bt,cn.Cancel=cn.CanceledError,cn.all=function(t){return Promise.all(t)},cn.spread=_6,cn.isAxiosError=D6,cn.mergeConfig=ra,cn.AxiosHeaders=lr,cn.formToJSON=e=>CE(Pe.isHTMLForm(e)?new FormData(e):e),cn.getAdapter=DE.getAdapter,cn.HttpStatusCode=$v,cn.default=cn,cn.defaults.baseURL="https://storm-api.azurewebsites.net",cn.defaults.timeout=1e3*60*10;const gn=cn.create({responseType:"json"});gn.getData=(e,t)=>{const n={headers:Cl(t)};return new Promise((r,a)=>{cn.get(e,n).then(i=>{r(i.data)}).catch(i=>{a(yl(i))})})},gn.upsertData=(e,t,n,r)=>e==null||e===0||e===""?gn.postData(t,n,r):gn.putData(`${t}/${e}`,n,r),gn.postData=(e,t,n)=>{const r={headers:Cl(n)};return new Promise((a,i)=>{cn.post(e,t,r).then(l=>{a(l.data)}).catch(l=>{i(yl(l))})})},gn.putData=(e,t,n)=>{const r={headers:Cl(n)};return new Promise((a,i)=>{cn.put(e,t,r).then(l=>{a(l.data)}).catch(l=>{i(yl(l))})})},gn.deleteData=(e,t)=>{const n={headers:Cl(!0)};return t&&(n.data={...t}),new Promise((r,a)=>{cn.delete(e,n).then(i=>{r(i.data)}).catch(i=>{a(yl(i))})})},gn.deleteMultipleData=(e,t)=>{const n={headers:Cl(!0),data:{ids:t}};return new Promise((r,a)=>{cn.delete(e,n).then(i=>{r(i.data)}).catch(i=>{a(yl(i))})})};function yl(e){return e===null?"error":e.response?Array.isArray(e.response.data)?e.response.data.map(n=>n.description).join(`
436
436
  `):e.response.data:e.request?"network error":"error"}function Cl(e){var t=e===!0||e===void 0;let n=localStorage.getItem("token");return t&&n?{AppKey:localStorage.getItem("appKey"),"Content-Type":"application/json"}:{AppKey:localStorage.getItem("appKey"),"Content-Type":"application/json"}}const k6={getSystemList:j6};function j6(e){return gn.getData(`/api/system/list/${e}`,!0)}const F6=({slug:e,value:t,label:n,opts:r,isRequired:a,values:i,error:l,errors:s,placeholder:u})=>{const[d,f]=F.useState([]),[m,v]=F.useState(!1);if(!e)throw Error("ListInput property: slug required");return!t&&i&&i[e]&&(t=i[e]),!l&&s&&s[e]&&(l=s[e]),F.useEffect(()=>{if(r.listSource==="static list")f(r.listOptions),v(!0);else if(r.listSource.indexOf("list_")>-1){let g=r.listSource.split("_")[1];k6.getSystemList(g).then(h=>{let b=h.items.map(p=>({label:p.label,value:p.value}));f(b),v(!0)}).catch(()=>{})}},[r.listSource]),fe.jsxs(fe.Fragment,{children:[r.fieldStyle==="select"&&fe.jsx(Wt.Item,{label:n,name:e,initialValue:t,rules:[{required:a,message:"Required"}],children:fe.jsxs(Xn,{showSearch:!0,optionFilterProp:"children",filterOption:(g,h)=>h.children&&h.children.toLowerCase().indexOf(g.toLowerCase())>=0,children:[fe.jsx(Xn.Option,{value:"",children:u}),d.map((g,h)=>fe.jsx(Xn.Option,{children:g.label},g.value))]})}),m&&r.fieldStyle==="checkboxes"&&fe.jsx(Wt.Item,{label:n,name:e,initialValue:t,rules:[{required:a,message:"Required"}],children:fe.jsx(Vr.Group,{children:fe.jsx(gc,{direction:"vertical",children:d.map((g,h)=>fe.jsx(Vr,{value:g.value,children:g.label},g.value))})})}),m&&r.fieldStyle==="radios"&&fe.jsx(Wt.Item,{label:n,name:e,initialValue:t,className:"column-vertical",rules:[{required:a,message:"Required"}],children:fe.jsx(Mr.Group,{options:d})})]})},LE=e=>{let{slug:t,value:n,label:r,opts:a,type:i,isRequired:l,error:s,className:u,placeholder:d}=e;if(!t)throw Error("NumberInput property: slug required");return fe.jsx(Wt.Item,{validateStatus:s?"error":"",name:t,help:s||"",label:r,className:u,initialValue:n,rules:[{required:l,message:"Required"}],children:fe.jsx(sm,{min:a.minNumber||0,max:a.maxNumber||9999999999,placeholder:d,formatter:f=>i==="currency"?`$ ${f}`:f,parser:f=>f.replace("$","")})})};function Ov(e){let{slug:t,value:n,fieldType:r,label:a,disableDates:i,showTime:l,disabled:s,isRequired:u}=e;if(!t)throw Error("DatePickerInput property: slug required");return fe.jsxs(Wt.Item,{label:a,children:[r===9&&fe.jsx(Wt.Item,{name:t,initialValue:n,children:fe.jsx(ni,{name:t,use12Hours:!0,rules:[{required:o.isRequired,message:"Required"}]})}),r!==9&&fe.jsx(Wt.Item,{name:t,initialValue:n,help:Intl.DateTimeFormat().resolvedOptions().timeZone,rules:[{required:o.isRequired,message:"Required"}],children:fe.jsx(Zo,{name:t,disabled:s,disabledDate:i,showToday:!1,use12Hours:!0,showTime:l?{use12Hours:!0,format:"HH:mm a"}:!1,format:l?"MM-DD-YYYY h:mm a":"MM-DD-YYYY"})})]})}const A6=e=>{let{slug:t,value:n,label:r,opts:a,error:i,className:l}=e;if(!t)throw Error("YesNoInput property: slug required");const s=[{label:"Yes",value:!0},{label:"No",value:!1}];return fe.jsxs(Wt.Item,{validateStatus:i?"error":"",name:t,help:i||"",label:r,className:l,initialValue:n,children:[a.fieldStyle==="switch"&&fe.jsx(Wt.Item,{name:t,initialValue:n,children:fe.jsx(Im,{})}),a.fieldStyle==="radio"&&fe.jsx(Wt.Item,{name:t,initialValue:n,rules:[{required:o.isRequired,message:"Required"}],children:fe.jsx(Mr.Group,{options:s})})]})};function L6(e){let{slug:t,value:n,label:r,debug:a,className:i}=e;return a?fe.jsx(Wt.Item,{name:t,label:r,className:i,children:fe.jsx(zn,{value:n})}):fe.jsx(Wt.Item,{label:r,className:i,children:n})}const B6=e=>{let{slug:t,value:n,label:r,className:a}=e;if(!t)throw Error("OptInInput property: slug required");return fe.jsx(Wt.Item,{name:t,initialValue:n,valuePropName:"checked",className:a,label:r,rules:[{validator:async(i,l)=>{if(!l)return Promise.reject(new Error("Required"))}}],children:fe.jsx(Vr,{children:"I Agree"})})},BE={get:z6,getByIdOrSlug:H6,getMedias:V6,download:W6,downloadFromUrl:K6};function z6(e){return gn.postData("/api/media/search",e,!0)}function H6(e){return gn.getData(`/api/media/${e}`,!0)}function V6(e){return gn.postData("/api/media/medias",e,!0)}function W6(e){return gn.postData("/api/media/download",e)}function K6(e){return gn.postData("/api/media/download/url",e,!0)}const zE={success:q6,error:U6};function q6(e){$m.success({message:HE[Math.floor(Math.random()*HE.length)],description:e,duration:3})}function U6(e){$m.error({message:VE[Math.floor(Math.random()*VE.length)],description:e,duration:3})}let HE=["Success","Good Job","Excellent","Way to go!","Nice!","That'll do!","That worked!","Ok","Bingo"],VE=["Bummer","Something didn't work","Error","Nope","Shucks"];const{Dragger:G6}=dv;function X6(e){const t=e.size/1024/1024<200;return t||zE.error("File must smaller than 200MB"),t}function Y6({onUploaded:e,accept:t,addToMediaLibrary:n,contentId:r,showUploadList:a=!0,multiple:i=!1}){const l=localStorage.getItem("gatsbyUser"),s=l!==null?JSON.parse(window.atob(l)):null,u=m=>{m.file.status!=="uploading"&&(m.file.status==="done"?e&&e(m.file.response):m.file.status==="error"&&zE.error(`${m.file.name} file upload failed.`))},d={Authorization:"Bearer "+s.token,AppKey:process.env.STORM_APPKEY};let f=`https://${process.env.REACT_APP_WEBAPI_URL_FULL_ACCESS}/api/media/files`;return n&&(f+="?addToMediaLibrary=true",r&&(f+=`&contentId=${r}`)),fe.jsx("div",{children:fe.jsx(G6,{name:"files",accept:t,multiple:i,beforeUpload:X6,action:f,headers:d,showUploadList:a,onChange:u,children:fe.jsxs("div",{className:"p-5 m-5",children:[fe.jsx("p",{className:"ant-upload-drag-icon",children:fe.jsx($x,{})}),fe.jsx("p",{className:"ant-upload-text",children:"Click or drag files to this area to upload"}),t!==void 0&&fe.jsx("p",{className:"ant-upload-hint",children:`must be only ${t} files`})]})})})}const Nv={image:Q6,currency:J6,numWithComma:Z6,phone:e5,timeToRead:t5,timeDiffMinutes:n5,startEndDateTime:r5,dateFormat:o5,getDateFromString:a5};function Q6(e,t){return e?e.indexOf("?")>-1?`${e}&${t}`:`${e}?${t}`:""}function J6(e){var t=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"});return t.format(e)}function Z6(e){return e.toLocaleString()}function e5(e){return e=e.toString().replace(/[^0-9]/g,""),e.length===10?e.substring(0,3)+"."+e.substring(3,6)+"."+e.substring(6):e}function t5(e){return e?Math.ceil(e.split(" ").length/210):0}function n5(e,t){console.log(e,t);const n=e&&typeof e=="object"?e:Date.parse(e.replace(" ","T")),r=t&&typeof t=="object"?t:Date.parse(t.replace(" ","T")),a=Math.abs(r-n);return Math.floor(a/1e3/60)}function r5(e,t="",n=!0){const r={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric"},a={hour:"numeric",minute:"numeric",timeZoneName:"short"},i={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",timeZoneName:"short"},l=new Intl.DateTimeFormat("en",r),s=new Intl.DateTimeFormat("en",a),u=new Intl.DateTimeFormat("en",i);if(!e)return"";const d=e&&typeof e=="object"?e:Date.parse(e.replace(" ","T")),f=t&&typeof t=="object"?t:Date.parse(t.replace(" ","T"));return!Number.isNaN(d)&&!Number.isNaN(f)?fe.jsxs("span",{children:[l.format(d)," - ",s.format(f),n&&fe.jsx("br",{})]}):Number.isNaN(d)?Number.isNaN(f)?"":fe.jsxs("span",{children:[" ",u.format(f),n&&fe.jsx("br",{})]}):fe.jsxs("span",{children:[" ",u.format(d),n&&fe.jsx("br",{})]})}function o5(e,t="medium",n=!1){const r={weekday:"long",year:"numeric",month:"long",day:"numeric"},a={year:"numeric",month:"long",day:"numeric"},i={year:"numeric",month:"short",day:"numeric"},l={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",timeZoneName:"short"},s={hour:"numeric",minute:"numeric",timeZoneName:"short"},u=new Intl.DateTimeFormat("en",r),d=new Intl.DateTimeFormat("en",i),f=new Intl.DateTimeFormat("en",l),m=new Intl.DateTimeFormat("en",a),v=new Intl.DateTimeFormat("en",s);if(!e)return"";const g=e&&typeof e=="object"?e:Date.parse(e.replace(" ","T"));return Number.isNaN(g)?"":fe.jsxs(fe.Fragment,{children:[t==="long"&&u.format(g),t==="short"&&d.format(g),t==="medium"&&m.format(g),t==="datetime"&&f.format(g),t==="time"&&v.format(g),n&&fe.jsx("br",{})]})}function a5(e){if(!e)return null;const t=Date.parse(e.replace(" ","T"));return Number.isNaN(t)?null:t}const{Search:i5}=zn;function l5({fileTypes:e,contentId:t,isMany:n,onSuccess:r,hideScopeFilter:a=!0,showResizer:i=!1}){const[l,s]=F.useState(!1),[u,d]=F.useState([]),[f,m]=F.useState([]),[v,g]=F.useState(0),[h,b]=F.useState([]),[p,y]=F.useState(""),[S,C]=F.useState("content"),[x,w]=F.useState(a?1:0),[E,O]=F.useState({id:"createdOn",desc:!0}),[N,$]=F.useState({current:1,pageSize:20,total:0,position:["topRight","bottomRight"],showSizeChanger:!0}),[I,T]=F.useState([]),[j,D]=F.useState(null),[P,_]=F.useState(null);F.useEffect(()=>{s(!1);let W={keyword:p,mediaTypes:h,orderBy:E,pagination:{pageNum:N.current,pageSize:N.pageSize}};W.mediaPurposes=[1],W.contentId=t,BE.get(W).then(z=>{const V={...N};V.total=z.totalRecords,d(z.media),$(V)}).catch(z=>console.log(z)).finally(()=>{s(!1)})},[v,h,S]);const M=(W,z,V)=>{let U={...E};const J={...N};J.pageSize!==W.pageSize?(J.pageSize=W.pageSize,J.current=1):J.current=W.current,V.field&&(U={id:V.field,desc:V.order==="descend"}),$(J),O(U),g(v+1)},R=(W,z)=>{let V=W.filter(U=>u.find(J=>J.id===U));T(V)},k=W=>{const z={...N};z.current=1,$(z),b(W)},A=W=>{const z={...N};z.current=1,$(z),C(W.target.value)},L=W=>{if(r){if(W){i&&W.mediaType===0?D(W):r([W]);return}r(u.filter(z=>I.find(V=>V===z.id))),T([])}},B=W=>{let z=f.concat(W);m(z)};return fe.jsx(Jf,{items:[{label:"Search",key:"1",children:fe.jsxs(fe.Fragment,{children:[fe.jsxs(uc,{gutter:[16,16],className:"mb-3",children:[fe.jsx(Wr,{xs:6,children:fe.jsxs(Xn,{mode:"multiple",placeholder:"Select Type",value:h,onChange:k,className:"mr-2 w-100",children:[fe.jsx(Xn.Option,{value:0,children:"Image"}),fe.jsx(Xn.Option,{value:1,children:"File"}),fe.jsx(Xn.Option,{value:2,children:"Video"}),fe.jsx(Xn.Option,{value:3,children:"Audio"}),fe.jsx(Xn.Option,{value:4,children:"Embedded"})]})}),fe.jsx(Wr,{xs:6,children:!a&&fe.jsxs(Mr.Group,{buttonStyle:"solid",value:S,onChange:A,children:[fe.jsx(Mr.Button,{value:"global",children:"Global"}),fe.jsx(Mr.Button,{value:"both",children:"Both"}),fe.jsx(Mr.Button,{value:"content",children:"Content"})]})}),fe.jsx(Wr,{xs:12,children:fe.jsx(i5,{id:"keyword",placeholder:"search",onSearch:()=>g(v+1),enterButton:!0,className:"w-100",value:p,onChange:W=>y(W.target.value),loading:l})}),n&&fe.jsx(Wr,{xs:24,children:fe.jsx(Cn,{type:"primary",className:"mr-2",disabled:I.length===0,onClick:()=>L(),children:"Select"})})]}),fe.jsx(ir,{dataSource:u,rowKey:W=>W.id,pagination:N,loading:l,size:"middle",className:"clear-both pointer",onChange:M,rowSelection:n&&{type:"checkbox",onChange:R,selectedRowKeys:I,hideSelectAll:!0},onRow:(W,z)=>({onClick:V=>{!n&&L(W)}}),columns:[{title:"",dataIndex:"thumbnail",width:"6%",responsive:["lg"],render:(W,z)=>fe.jsx("img",{src:z.thumbnail,alt:"Thumbnail",className:"img-fluid avatar-50"})},{title:"Title",dataIndex:"title",sorter:!0},{title:"Type",dataIndex:"lastName",sorter:!0,render:(W,z)=>fe.jsxs("span",{children:[z.mediaType===0&&fe.jsx(mn,{color:"blue",children:"Image"}),z.mediaType===1&&fe.jsx(mn,{color:"gold",children:"File"}),z.mediaType===2&&fe.jsx(mn,{color:"cyan",children:"Video"}),z.mediaType===3&&fe.jsx(mn,{color:"magenta",children:"Audio"}),z.mediaType===4&&fe.jsx(mn,{color:"volcano",children:"Embedded"})]})},{title:"Created",dataIndex:"createdOn",sorter:!0,responsive:["xl"],render:(W,z)=>fe.jsx("span",{children:Nv.dateFormat(z.createdOn)})},{title:"Info",responsive:["lg"],align:"center",render:(W,z)=>fe.jsx(Cn,{type:"secondary",onClick:V=>{V.stopPropagation(),_(z)},children:fe.jsx(Mx,{})})}]})]})},{label:"Upload",key:"2",children:fe.jsxs(fe.Fragment,{children:[fe.jsx(Y6,{onUploaded:B,multiple:!0,showUploadList:!1,addToMediaLibrary:!0,contentId:x===1?t:0}),fe.jsx(ir,{dataSource:f,rowKey:W=>W.id,pagination:!1,loading:l,size:"middle",className:"clear-both pointer",onRow:(W,z)=>({onClick:V=>{L(W)}}),columns:[{title:"",dataIndex:"thumbnail",width:"6%",responsive:["md"],render:(W,z)=>fe.jsx("img",{src:z.url,alt:"Thumbnail",className:"img-fluid"})},{title:"Title",dataIndex:"title",sorter:!0},{title:"Type",dataIndex:"lastName",sorter:!0,render:(W,z)=>fe.jsxs("span",{children:[z.mediaType===0&&fe.jsx(mn,{color:"blue",children:"Image"}),z.mediaType===1&&fe.jsx(mn,{color:"gold",children:"File"}),z.mediaType===2&&fe.jsx(mn,{color:"cyan",children:"Video"}),z.mediaType===3&&fe.jsx(mn,{color:"magenta",children:"Audio"}),z.mediaType===4&&fe.jsx(mn,{color:"volcano",children:"Embedded"})]})},{title:"Created",dataIndex:"createdOn",sorter:!0,responsive:["xl"],render:(W,z)=>fe.jsx("span",{children:Nv.dateFormat(z.createdOn)})}]})]})}]})}const s5=({slug:e,value:t,label:n,opts:r,form:a,onChange:i,media:l,debug:s,isRequired:u,contentId:d,className:f})=>{r=r||{uploadLimit:"1",fileTypes:null};const[m,v]=F.useState(l||[]),[g,h]=F.useState(!1),b=r.uploadLimit!=="1";if(!e)throw Error("MediaInput property: slug required");F.useEffect(()=>{if((l==null?void 0:l.length)>0?v(l):v([]),t&&!l){const C=t.split(",").filter(x=>!isNaN(x)).map(x=>parseInt(x,10));BE.getMedias({ids:C}).then(x=>{v(x)})}},[l]);const p=C=>{const x=m.concat(C);v(x),S(x),h(!1)},y=C=>{var x=m.findIndex(w=>w.id===C.id);if(x>-1){let w=[...m];w.splice(x,1),v(w),S(w)}},S=C=>{const x=C.map((w,E)=>w.id).join(",");a.setFieldsValue({[e]:x}),i&&i(e,x)};return fe.jsxs(Wt.Item,{label:n,className:f,children:[fe.jsxs("div",{className:"text-center",children:[(b||!b&&m.length===0)&&fe.jsx(Cn,{type:"primary",className:"my-2",onClick:()=>h(!0),children:"Select"}),m.length>0&&fe.jsx(ir,{dataSource:m,rowKey:C=>C.id,pagination:!1,size:"middle",className:"clear-both mt-3",columns:[{title:"",dataIndex:"url",render:(C,x)=>fe.jsxs("span",{children:[x.mediaType===0&&fe.jsx("img",{src:x.url,alt:"Thumbnail",className:"img-fluid avatar-50"}),x.mediaType===1&&fe.jsx("img",{src:x.thumbnail,alt:"Thumbnail",className:"img-fluid avatar-50"}),x.mediaType===2&&fe.jsx(fe.Fragment,{}),x.mediaType===3&&fe.jsx(fe.Fragment,{}),x.mediaType===4&&fe.jsx(fe.Fragment,{})]})},{title:"Title",dataIndex:"title",render:(C,x)=>{var w;return fe.jsxs("span",{children:[x.title,((w=x.credit)==null?void 0:w.length)>0&&fe.jsx("div",{dangerouslySetInnerHTML:{__html:x.credit},className:"credit"})]})}},{title:"Type",dataIndex:"lastName",sorter:!0,render:(C,x)=>fe.jsxs("span",{children:[x.mediaType===0&&fe.jsx(mn,{color:"blue",children:"Image"}),x.mediaType===1&&fe.jsx(mn,{color:"gold",children:"File"}),x.mediaType===2&&fe.jsx(mn,{color:"cyan",children:"Video"}),x.mediaType===3&&fe.jsx(mn,{color:"magenta",children:"Audio"}),x.mediaType===4&&fe.jsx(mn,{color:"volcano",children:"Embedded"})]})},{title:"",width:"50px",render:(C,x)=>fe.jsx(wc,{title:"Are you sure you want to delete this?",onConfirm:()=>y(x),okText:"Yes",cancelText:"No",children:fe.jsx(Cn,{type:"primary",danger:!0,children:fe.jsx(Nc,{})})})}]})]}),fe.jsx(Wt.Item,{name:e,initialValue:t,hidden:!s,rules:[{required:u,message:"Required"}],children:fe.jsx(zn,{})}),fe.jsx(pc,{open:g,title:"Search Media",height:"85%",placement:"bottom",onClose:()=>h(!1),children:fe.jsx(l5,{mediaTypes:r.referenceTypes,isMany:b,onSuccess:p,hideScopeFilter:!0,contentId:d})})]})},c5={siteSearch:u5,get:d5,search:f5,getForm:m5,getUserContent:v5,getByIdOrSlug:p5,getContentTypeById:g5};function u5(e){return gn.postData("/api/content/sitesearch",e,!1)}function d5(e){return gn.getData(`/api/content/${e}`,!1)}function f5(e){return gn.postData("/api/content/search",e,!0)}function m5(e,t){return gn.getData(`/api/content/form/${e}/${t}`,!1)}function v5(e,t){return gn.getData(`/api/content/usercontent/?status=${t}&page=${e}`,!0)}function p5(e){return gn.getData(`/api/content/${e}`,!0)}function g5(e,t){let n=`/api/content/contenttype/${e}`;return t&&(n+=`/${t}`),gn.getData(n,!0)}const{Search:h5}=zn;function b5({contentTypes:e,isMany:t,isEcommerce:n,onSuccess:r,showDetails:a=!0,isPreviewable:i=!1,initialStatus:l=[0]}){const[s,u]=F.useState(!1),[d,f]=F.useState([]),[m,v]=F.useState(0),[g,h]=F.useState(""),[b,p]=F.useState({id:"title",desc:!1}),[y,S]=F.useState({current:1,pageSize:20,total:0,position:["topRight","bottomRight"],showSizeChanger:!0}),[C,x]=F.useState(l),[w,E]=F.useState([]);F.useEffect(()=>{u(!1);let j={keyword:g,contentType:e||[],isPreviewable:i,status:C,orderBy:b,pagination:{pageNum:y.current,pageSize:y.pageSize},isEcommerce:n};c5.search(j).then(D=>{const P={...y};P.total=D.totalRecords,f(D.content),S(P)}).catch(D=>console.log(D)).finally(()=>{u(!1)})},[m]);const O=(j,D,P)=>{let _={...b};const M={...y};M.pageSize!==j.pageSize?(M.pageSize=j.pageSize,M.current=1):M.current=j.current,P.field&&(_={id:P.field,desc:P.order==="descend"}),S(M),p(_),v(m+1)},N=()=>{const j={...y};j.current=1,S(j),v(m+1)},$=(j,D)=>{let P=j.filter(_=>d.find(M=>M.id===_));E(P)},I=j=>{if(r){if(j){r([j]);return}r(d.filter(D=>w.find(P=>P===D.id))),E([])}};let T=[{title:"Title",dataIndex:"title",sorter:!0}];return a&&(T.push({title:"Type",dataIndex:"contentType",sorter:!0}),T.push({title:"Status",render:(j,D)=>fe.jsxs("span",{children:[D.status===0&&fe.jsx(mn,{color:"blue",children:"Published"}),D.status===1&&fe.jsx(mn,{color:"gold",children:"Draft"}),D.status===2&&fe.jsx(mn,{color:"magenta",children:"Trashed"}),D.status===3&&fe.jsx(mn,{color:"purple",children:"Published with Pending Updates"})]})})),fe.jsxs("div",{children:[fe.jsxs(uc,{gutter:[16,16],className:"mb-3",children:[fe.jsx(Wr,{xs:12}),fe.jsx(Wr,{xs:12,children:fe.jsx(h5,{id:"keyword",placeholder:"search",onSearch:N,enterButton:!0,className:"w-100",value:g,onChange:j=>h(j.target.value),loading:s})}),t&&fe.jsx(Wr,{xs:24,children:fe.jsx(Cn,{type:"primary",className:"mr-2",disabled:w.length===0,onClick:()=>I(),children:"Select"})})]}),fe.jsx(ir,{dataSource:d,rowKey:j=>j.id,pagination:y,loading:s,size:"middle",className:"clear-both pointer",onChange:O,expandable:{expandedRowRender:j=>fe.jsx("table",{children:fe.jsx("tbody",{children:j.meta.values.filter(D=>D.label.toLowerCase().indexOf("url")>-1).map((D,P)=>{let _=D.fullValue??D.value;return _=(_==null?void 0:_.indexOf("Z"))>-1&&jn(_).isValid()?Nv.dateFormat(_):_,_=_==null?void 0:_.replace(/(<([^>]+)>)/gi,"",""),fe.jsxs("tr",{children:[fe.jsx("td",{style:{verticalAlign:"top",minWidth:150},children:D.label}),fe.jsx("td",{children:fe.jsx("span",{children:_||""})})]},P)})})})},rowSelection:t&&{type:"checkbox",onChange:$,selectedRowKeys:w,hideSelectAll:!0},onRow:(j,D)=>({onClick:P=>{!t&&I(j)}}),columns:T})]})}const y5=({slug:e,value:t,label:n,opts:r,form:a,onChange:i,references:l,debug:s,isRequired:u,values:d,error:f,errors:m,className:v,placeholder:g,disabled:h})=>{const[b,p]=F.useState(l||[]),[y,S]=F.useState(!1),[C,x]=F.useState(null),w=r.referenceAmount!=="1";if(!e)throw Error("ReferenceInput property: slug required");!t&&d&&d[e]&&(t=d[e]),!f&&m&&m[e]&&(f=m[e]);const E=$=>{const I=$.filter(j=>!b.some(D=>j.id===D.id)),T=b.concat(I);p(T),N(T),S(!1)},O=$=>{var I=b.findIndex(T=>T.id===$.id);if(I>-1){let T=[...b];T.splice(I,1),p(T),N(T)}},N=$=>{const I=$.map((T,j)=>T.id).join(",");a.setFieldsValue({[e]:I}),i&&i(e,I)};return F.useEffect(()=>{p(l||[])},[l]),F.useEffect(()=>{C&&setShowEdit(!0)},[C]),fe.jsxs(Wt.Item,{label:n,className:v,children:[fe.jsxs("div",{className:"text-center",children:[(w||!w&&b.length===0)&&fe.jsx(fe.Fragment,{children:fe.jsx(Cn,{type:"primary",className:"my-2",onClick:()=>S(!0),children:"Select"})}),b.length>0&&fe.jsx(ir,{dataSource:b,rowKey:$=>$.id,pagination:!1,size:"middle",className:"clear-both mt-3",columns:[{title:"Title",dataIndex:"title"},{title:"Type",dataIndex:"contentType"},{title:"Status",render:($,I)=>fe.jsxs("span",{children:[I.status===0&&fe.jsx(mn,{color:"blue",children:"Published"}),I.status===1&&fe.jsx(mn,{color:"gold",children:"Draft"}),I.status===2&&fe.jsx(mn,{color:"magenta",children:"Trashed"})]})},{title:"",width:"50px",render:($,I)=>fe.jsx(wc,{title:"Are you sure you want to delete this?",onConfirm:()=>O(I),okText:"Yes",cancelText:"No",children:fe.jsx(Cn,{type:"primary",danger:!0,children:fe.jsx(Nc,{})})})}]})]}),fe.jsx(Wt.Item,{name:e,initialValue:t,hidden:!s,rules:[{required:u,message:"Required"}],children:fe.jsx(zn,{})}),fe.jsx(pc,{open:y,title:"Search References",height:"90%",placement:"bottom",onClose:()=>S(!1),children:fe.jsx(b5,{contentTypes:r.referenceTypes,isMany:w,onSuccess:E})})]})},C5={hasJsonStructure:WE,parseJson:S5};function WE(e){if(typeof e!="string")return!1;try{const t=JSON.parse(e),n=Object.prototype.toString.call(t);return n==="[object Object]"||n==="[object Array]"}catch{return!1}}function S5(e){return WE(e)?JSON.parse(e):JSON.parse("{}")}const x5=(e,t)=>{let{properties:n,loading:r,onSubmit:a,hideSubmit:i,onFieldsChange:l,layout:s,entityId:u,debug:d=!1}=e;const[f]=Wt.useForm(),m=s==="vertical"?24:4,v=s==="vertical"?24:20,g=s==="vertical"?0:4;F.useImperativeHandle(t,()=>({validate(p){f.validateFields().then(y=>{p([])}).catch(y=>{console.log(y),p(y.errorFields)})}})),F.useEffect(()=>{let p=n.reduce((S,C)=>({...S,[C.slug]:C.value}),{});f.setFieldsValue({...p});const y=new URLSearchParams(window.location.search);y.get("utm_source")&&localStorage.setItem("utm_source",y.get("utm_source")),y.get("utm_medium")&&localStorage.setItem("utm_medium",y.get("utm_medium")),y.get("utm_campaign")&&localStorage.setItem("utm_campaign",y.get("utm_campaign")),y.get("utm_term")&&localStorage.setItem("utm_term",y.get("utm_term")),y.get("utm_content")&&localStorage.setItem("utm_content",y.get("utm_content"))},[n]);const h=p=>{for(let S in p)p[S]=Array.isArray(p[S])?JSON.stringify(p[S]):p[S];let y={};localStorage.getItem("utm_source")&&(y.source=localStorage.getItem("utm_source")),localStorage.getItem("utm_medium")&&(y.medium=localStorage.getItem("utm_medium")),localStorage.getItem("utm_campaign")&&(y.campaign=localStorage.getItem("utm_campaign")),localStorage.getItem("utm_term")&&(y.term=localStorage.getItem("utm_term")),localStorage.getItem("utm_content")&&(y.content=localStorage.getItem("utm_content")),a(p,y)},b=p=>{l&&l(p[0].name[0],p[0].value)};return n.length===0?i?fe.jsx(fe.Fragment,{}):fe.jsx("div",{children:"There are no properties at this time."}):fe.jsx("div",{children:fe.jsxs(Wt,{form:f,labelCol:{span:m},wrapperCol:{span:v},onFinish:h,onFieldsChange:b,layout:s,children:[n.map((p,y)=>{var S,C,x,w,E,O,N;switch(p.opts=C5.parseJson(p.options),p.fieldType){case 1:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,rules:[{required:p.isRequired,message:"Required"},{type:"email",message:"Email is not valid"}],initialValue:(S=p.value)==null?void 0:S.replaceAll(`
437
- `,"\\n"),children:fe.jsx(zn,{placeholder:((C=p.opts)==null?void 0:C.placeholder)||""})},y);case 2:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,rules:[{required:p.isRequired,message:"Required"},{type:"url",message:"URL is not valid"}],initialValue:p.value,children:fe.jsx(zn,{placeholder:((x=p.opts)==null?void 0:x.placeholder)||""})},y);case 3:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,rules:[{required:p.isRequired,message:"Required"},{pattern:/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/,message:"Phone is not valid"}],initialValue:p.value,children:fe.jsx(zn,{placeholder:((w=p.opts)==null?void 0:w.placeholder)||""})},y);case 4:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,initialValue:p.value,rules:[{required:p.isRequired,message:"Required"}],children:fe.jsx(zn.Password,{placeholder:((E=p.opts)==null?void 0:E.placeholder)||""})},y);case 5:case 6:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,initialValue:p.value,rules:[{required:p.isRequired,message:"Required"}],children:fe.jsx(zn.TextArea,{placeholder:((O=p.opts)==null?void 0:O.placeholder)||""})},y);case 7:return p.value=p.value?jn(p.value):"",F.createElement(Ov,{...p,key:y,showTime:!0});case 8:return p.value=p.value?jn(p.value):"",F.createElement(Ov,{...p,key:y});case 9:return p.value=p.value?jn(p.value):"",F.createElement(Ov,{...p,key:y});case 10:return F.createElement(LE,{...p,key:y});case 11:return F.createElement(LE,{...p,key:y,type:"currency"});case 12:return F.createElement(s5,{...p,form:f,onChange:l,key:y,debug:d,contentId:u});case 13:return F.createElement(y5,{...p,form:f,onChange:l,key:y,debug:d});case 14:return fe.jsx(fe.Fragment,{});case 15:return F.createElement(A6,{...p,key:y});case 16:return F.createElement(F6,{...p,key:y});case 17:return fe.jsx(fe.Fragment,{});case 18:return fe.jsx(Wt.Item,{children:fe.jsx("div",{dangerouslySetInnerHTML:{__html:p.label}})},y);case 19:return F.createElement(B6,{...p,key:y,debug:d});case 20:return fe.jsx(fe.Fragment,{});case 21:return fe.jsx(fe.Fragment,{});case 22:return fe.jsx(fe.Fragment,{});case 23:return F.createElement(L6,{...p,key:y,debug:d});case 24:return fe.jsx(Wt.Item,{label:fe.jsx("strong",{className:"mt-3",children:p.label}),name:p.slug,children:fe.jsx("hr",{})},y);default:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,initialValue:p.value,rules:[{required:p.isRequired,message:"Required"}],children:fe.jsx(zn,{placeholder:((N=p.opts)==null?void 0:N.placeholder)||""})},y)}}),!i&&fe.jsx(Wt.Item,{wrapperCol:{span:m,offset:g},children:fe.jsx(Cn,{type:"primary",htmlType:"submit",loading:r,children:"Submit"})})]})})},w5=F.forwardRef(x5),KE={getForm:E5,submitForm:$5};function E5(e){return gn.getData(`/form/${e}`,!1)}function $5(e,t=!1){return gn.postData("/form/submission",e,t)}return({formId:e,appKey:t})=>{const[n,r]=F.useState(null),[a,i]=F.useState("");F.useEffect(()=>{if(!e){console.log("formId is required to use the StormForm component");return}if(!t){console.log("appKey is required to use the StormForm component");return}localStorage.setItem("appKey",t),KE.getForm(e).then(s=>{r(s)}).catch(s=>{console.error(s)})},[e,t]);const l=(s,u)=>{const d={formId:e,props:s,utmValues:u};KE.submitForm(d).then(f=>{f.type==="redirect"?window.location.href=f.value:i(f.value)}).catch(f=>{console.error(f)})};return n?fe.jsxs(fe.Fragment,{children:[!a&&fe.jsx(w5,{properties:n.properties,onSubmit:l}),a&&fe.jsx("div",{className:"text-center",children:fe.jsx("div",{dangerouslySetInnerHTML:{__html:a}})})]}):fe.jsx(fe.Fragment,{})}});
437
+ `,"\\n"),children:fe.jsx(zn,{placeholder:((C=p.opts)==null?void 0:C.placeholder)||""})},y);case 2:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,rules:[{required:p.isRequired,message:"Required"},{type:"url",message:"URL is not valid"}],initialValue:p.value,children:fe.jsx(zn,{placeholder:((x=p.opts)==null?void 0:x.placeholder)||""})},y);case 3:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,rules:[{required:p.isRequired,message:"Required"},{pattern:/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/,message:"Phone is not valid"}],initialValue:p.value,children:fe.jsx(zn,{placeholder:((w=p.opts)==null?void 0:w.placeholder)||""})},y);case 4:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,initialValue:p.value,rules:[{required:p.isRequired,message:"Required"}],children:fe.jsx(zn.Password,{placeholder:((E=p.opts)==null?void 0:E.placeholder)||""})},y);case 5:case 6:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,initialValue:p.value,rules:[{required:p.isRequired,message:"Required"}],children:fe.jsx(zn.TextArea,{placeholder:((O=p.opts)==null?void 0:O.placeholder)||""})},y);case 7:return p.value=p.value?jn(p.value):"",F.createElement(Ov,{...p,key:y,showTime:!0});case 8:return p.value=p.value?jn(p.value):"",F.createElement(Ov,{...p,key:y});case 9:return p.value=p.value?jn(p.value):"",F.createElement(Ov,{...p,key:y});case 10:return F.createElement(LE,{...p,key:y});case 11:return F.createElement(LE,{...p,key:y,type:"currency"});case 12:return F.createElement(s5,{...p,form:f,onChange:l,key:y,debug:d,contentId:u});case 13:return F.createElement(y5,{...p,form:f,onChange:l,key:y,debug:d});case 14:return fe.jsx(fe.Fragment,{});case 15:return F.createElement(A6,{...p,key:y});case 16:return F.createElement(F6,{...p,key:y});case 17:return fe.jsx(fe.Fragment,{});case 18:return fe.jsx(Wt.Item,{children:fe.jsx("div",{dangerouslySetInnerHTML:{__html:p.label}})},y);case 19:return F.createElement(B6,{...p,key:y,debug:d});case 20:return fe.jsx(fe.Fragment,{});case 21:return fe.jsx(fe.Fragment,{});case 22:return fe.jsx(fe.Fragment,{});case 23:return F.createElement(L6,{...p,key:y,debug:d});case 24:return fe.jsx(Wt.Item,{label:fe.jsx("strong",{className:"mt-3",children:p.label}),name:p.slug,children:fe.jsx("hr",{})},y);default:return fe.jsx(Wt.Item,{label:p.label,name:p.slug,initialValue:p.value,rules:[{required:p.isRequired,message:"Required"}],children:fe.jsx(zn,{placeholder:((N=p.opts)==null?void 0:N.placeholder)||""})},y)}}),!i&&fe.jsx(Wt.Item,{wrapperCol:{span:m,offset:g},children:fe.jsx(Cn,{type:"primary",htmlType:"submit",loading:r,children:"Submit"})})]})})},w5=F.forwardRef(x5),KE={getForm:E5,submitForm:$5};function E5(e){return gn.getData(`/v1/form/${e}`,!1)}function $5(e,t=!1){return gn.postData("/v1/form/submission",e,t)}return({formId:e,appKey:t})=>{const[n,r]=F.useState(null),[a,i]=F.useState("");F.useEffect(()=>{if(!e){console.log("formId is required to use the StormForm component");return}if(!t){console.log("appKey is required to use the StormForm component");return}localStorage.setItem("appKey",t),KE.getForm(e).then(s=>{r(s)}).catch(s=>{console.error(s)})},[e,t]);const l=(s,u)=>{const d={formId:e,props:s,utmValues:u};KE.submitForm(d).then(f=>{f.type==="redirect"?window.location.href=f.value:i(f.value)}).catch(f=>{console.error(f)})};return n?fe.jsxs(fe.Fragment,{children:[!a&&fe.jsx(w5,{properties:n.properties,onSubmit:l}),a&&fe.jsx("div",{className:"text-center",children:fe.jsx("div",{dangerouslySetInnerHTML:{__html:a}})})]}):fe.jsx(fe.Fragment,{})}});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redapollos/storm-form",
3
3
  "private": false,
4
- "version": "0.1.3",
4
+ "version": "0.1.4",
5
5
  "description": "A form library for StormCMS",
6
6
  "author": "redapollos",
7
7
  "type": "module",