@lifesg/web-frontend-engine 2.1.2 → 2.1.3
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/chunks/{file-upload-manager.322f9ebd.js → file-upload-manager.06cbbbef.js} +2 -2
- package/chunks/{file-upload-manager.322f9ebd.js.map → file-upload-manager.06cbbbef.js.map} +1 -1
- package/chunks/{index.001bdfec.js → index.0280bf07.js} +2 -2
- package/chunks/{index.001bdfec.js.map → index.0280bf07.js.map} +1 -1
- package/chunks/{index.525d4dc8.js → index.48f1ff60.js} +5 -5
- package/chunks/{index.525d4dc8.js.map → index.48f1ff60.js.map} +1 -1
- package/chunks/{index.d39dccc1.js → index.4917b447.js} +2 -2
- package/chunks/{index.d39dccc1.js.map → index.4917b447.js.map} +1 -1
- package/chunks/{location-modal.db994c40.js → location-modal.9376e196.js} +2 -2
- package/chunks/{location-modal.db994c40.js.map → location-modal.9376e196.js.map} +1 -1
- package/cjs/chunks/{file-upload-manager.aebae412.js → file-upload-manager.2b5e51c8.js} +2 -2
- package/cjs/chunks/{file-upload-manager.aebae412.js.map → file-upload-manager.2b5e51c8.js.map} +1 -1
- package/cjs/chunks/{index.21340464.js → index.350cbda4.js} +2 -2
- package/cjs/chunks/{index.21340464.js.map → index.350cbda4.js.map} +1 -1
- package/cjs/chunks/{index.594875a2.js → index.5d896247.js} +5 -5
- package/cjs/chunks/{index.594875a2.js.map → index.5d896247.js.map} +1 -1
- package/cjs/chunks/{index.516d4b9b.js → index.eeb93deb.js} +2 -2
- package/cjs/chunks/{index.516d4b9b.js.map → index.eeb93deb.js.map} +1 -1
- package/cjs/chunks/{location-modal.c859475a.js → location-modal.80a5525d.js} +2 -2
- package/cjs/chunks/{location-modal.c859475a.js.map → location-modal.80a5525d.js.map} +1 -1
- package/cjs/index.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -335,7 +335,7 @@ function SO(e){return"[object Object]"===Object.prototype.toString.call(e)}Objec
|
|
|
335
335
|
}
|
|
336
336
|
`,jk={D1:"heading-xxl",D2:"heading-xl",D3:"heading-md",D4:"heading-sm",DBody:"heading-sm",H1:"heading-lg",H2:"heading-md",H3:"heading-sm",H4:"heading-xs",H5:"body-md",H6:"body-sm",Body:"body-baseline",BodySmall:"body-md",XSmall:"body-xs"},Zk={"TEXT-D1":{type:r.Typography.HeadingXXL,weight:"bold"},"TEXT-D2":{type:r.Typography.HeadingXL,weight:"bold"},"TEXT-D3":{type:r.Typography.HeadingMD,weight:"bold"},"TEXT-D4":{type:r.Typography.HeadingSM,weight:"bold"},"TEXT-DBODY":{type:r.Typography.HeadingSM,weight:"light"},"TEXT-H1":{type:r.Typography.HeadingLG,weight:"bold"},"TEXT-H2":{type:r.Typography.HeadingMD,weight:"bold"},"TEXT-H3":{type:r.Typography.HeadingSM,weight:"bold"},"TEXT-H4":{type:r.Typography.HeadingXS,weight:"bold"},"TEXT-H5":{type:r.Typography.BodyMD,weight:"bold"},"TEXT-H6":{type:r.Typography.BodySM,weight:"bold"},"TEXT-BODY":{type:r.Typography.BodyBL,weight:"regular"},"TEXT-BODYSMALL":{type:r.Typography.BodyMD,weight:"regular"},"TEXT-XSMALL":{type:r.Typography.BodyXS,weight:"regular"}},Uk={"HEADING-XXL":r.Typography.HeadingXXL,"HEADING-XL":r.Typography.HeadingXL,"HEADING-MD":r.Typography.HeadingMD,"HEADING-SM":r.Typography.HeadingSM,"HEADING-LG":r.Typography.HeadingLG,"HEADING-XS":r.Typography.HeadingXS,"BODY-MD":r.Typography.BodyMD,"BODY-SM":r.Typography.BodySM,"BODY-BL":r.Typography.BodyBL,"BODY-XS":r.Typography.BodyXS},Bk={300:"light",400:"regular",500:"medium",700:"bold",900:"bold"},Vk={"text-d1":"h1","text-d2":"h1","text-dbody":"h1","text-h1":"h1","text-h2":"h2","text-h3":"h3","text-h4":"h4","text-h5":"h5","text-h6":"h6","text-body":"p","text-bodysmall":"p","text-xsmall":"p"},Hk=V.default(a.Button.Small)`
|
|
337
337
|
padding: 0;
|
|
338
|
-
`;var Gk;exports.EElementType=void 0,(Gk=exports.EElementType||(exports.EElementType={})).ALERT="Alert",Gk["TEXT-D1"]="Text",Gk["TEXT-D2"]="Text",Gk["TEXT-DBODY"]="Text",Gk["TEXT-H1"]="Text",Gk["TEXT-H2"]="Text",Gk["TEXT-H3"]="Text",Gk["TEXT-H4"]="Text",Gk["TEXT-H5"]="Text",Gk["TEXT-H6"]="Text",Gk["TEXT-BODY"]="Text",Gk["TEXT-BODYSMALL"]="Text",Gk["TEXT-XSMALL"]="Text",Gk["HEADING-XXL"]="Text",Gk["HEADING-XL"]="Text",Gk["HEADING-MD"]="Text",Gk["HEADING-SM"]="Text",Gk["HEADING-LG"]="Text",Gk["HEADING-XS"]="Text",Gk["BODY-MD"]="Text",Gk["BODY-SM"]="Text",Gk["BODY-BL"]="Text",Gk["BODY-XS"]="Text",Gk.DIV="Wrapper",Gk.DIVIDER="Divider",Gk.SPAN="Wrapper",Gk.HEADER="Wrapper",Gk.FOOTER="Wrapper",Gk.H1="Wrapper",Gk.H2="Wrapper",Gk.H3="Wrapper",Gk.H4="Wrapper",Gk.H5="Wrapper",Gk.H6="Wrapper",Gk.P="Wrapper",Gk.GRID="Grid",Gk.TAB="Tab",Gk["TAB-ITEM"]="TabItem",Gk["LIST-ITEM"]="ListItem",Gk["ORDERED-LIST"]="List",Gk["UNORDERED-LIST"]="List",Gk.ACCORDION="Accordion",Gk.POPOVER="Popover";var Yk=Object.freeze({__proto__:null,Accordion:t=>{const{schema:n,id:r}=t,{children:i,button:o,title:s,disableContentInset:u,...c}=n,{dispatchFieldEvent:l}=gI();return e.jsx(d.BoxContainer,{id:r,title:"string"==typeof s?s:e.jsx(rU,{children:s}),...c,callToActionComponent:o?e.jsx(a.Button.Default,{styleType:"light",type:"button",onClick:()=>l("accordion","edit",r),children:"object"==typeof o?o.label:"Edit"}):void 0,children:u?e.jsx(rU,{id:r,children:i}):e.jsx(Rk,{children:e.jsx(rU,{id:r,children:i})})})},Alert:t=>{const{id:n,schema:{children:r,...i}}=t;return e.jsx(c.Alert,{id:n,"data-testid":exports.TestHelper.generateId(n,"alert"),...i,children:"string"==typeof r?e.jsx(RL,{id:n,children:r}):U.default.isValidElement(r)||Array.isArray(r)||"number"==typeof r||"boolean"==typeof r||null==typeof r?r:e.jsx(rU,{children:r})})},Divider:t=>{const{id:n,schema:{verticalMargin:r,...i}}=t;return e.jsx(Fk,{id:n,"data-testid":exports.TestHelper.generateId(n,"divider"),$verticalMargin:r,...i})},Grid:t=>{const{id:n,schema:{children:r,customOptions:i={gridType:"v2"},uiType:a,...o}}=t,s="v3"===i.gridType?zk:Pk,u="v3"===i.gridType?"grid":"flex";return e.jsx(s,{type:u,"data-testid":exports.TestHelper.generateId(n,"grid"),...o,children:e.jsx(rU,{children:r})})},List:t=>{const{id:n,schema:{children:r,uiType:i,size:a,...o}}=t,s="ordered-list"===i?h.TextList.Ol:h.TextList.Ul;return e.jsx(s,{id:n,"data-testid":exports.TestHelper.generateId(n,i),size:(e=>e in jk)(a)?jk[a]:a,...o,children:r.map(((t,n)=>"string"==typeof t?e.jsx("li",{children:e.jsx(RL,{inline:!0,children:t})},n):e.jsx(rU,{children:t},n)))})},ListItem:t=>{const{id:n,schema:{children:r,uiType:i,showIf:a,columns:o,...s}}=t;return e.jsx("li",{id:n,...s,children:"string"==typeof r?e.jsx(RL,{inline:!0,children:r}):e.jsx(rU,{children:r})})},Popover:t=>{const{id:n,schema:{children:r,className:i,icon:a,hint:{content:o,...s},...u}}=t;return e.jsx(m.PopoverInline,{id:n,"data-testid":exports.TestHelper.generateId(n,"popover"),className:i,icon:(()=>{if(!a)return null;const t=H[a];return e.jsx(t,{})})(),content:r&&e.jsx(RL,{inline:!0,children:r}),popoverContent:(()=>{const t={allowedTags:$L.defaults.allowedTags.concat(["img"]),allowedAttributes:!1};return"string"==typeof o?e.jsx(RL,{inline:!0,sanitizeOptions:t,children:o}):e.jsx(rU,{children:o})})(),...s,...u})},Tab:n=>{const{id:r,schema:{currentActiveTabId:i,children:a,...o}}=n,[s,u]=t.useState(p()),{removeFieldValidationConfig:c}=Nk(),{unregister:l}=xe(),{dispatchFieldEvent:d}=gI(),f=Object.keys(a);t.useEffect((()=>{u(p())}),[i]),_s((()=>{Object.values(a).forEach(((e,t)=>{if(t===s)return;h(e).forEach((e=>{c(e),l(e)}))}))}),[s,a]);function p(){const e=Object.keys(a).findIndex((e=>e===i));return e<0?0:e}const h=e=>{const t=e.children,n=[];return dE(t)||!un(t)||Object.entries(t).forEach((([e,t])=>{n.push(e),"chips"===t.uiType&&n.push(e+"-textarea"),t.children&&n.push(...h(t))})),n};return e.jsx(y.Tab,{...o,id:r,"data-testid":exports.TestHelper.generateId(r,"tab"),currentActive:s,onTabClick:(e,t)=>{t!==s&&(u(t),d("change",r,{previousTabId:f[s],currentTabId:f[t]}))},children:Object.entries(a).map((([n,r])=>{const{title:i,children:a,...o}=r;return t.createElement(y.Tab.Item,{...o,key:n,id:n,"data-testid":exports.TestHelper.generateId(n,"tab-item"),title:i},e.jsx(rU,{children:a}))}))})},Text:n=>{const{id:r,schema:{children:i,uiType:a,maxLines:o,weight:s,...u}}=n,c=t.useRef(null),[l,d]=t.useState(!1),[f,p]=t.useState(!1),h=Zk[a.toUpperCase()]?.type||Uk[a.toUpperCase()]||void 0,m=Vk[a]||void 0;t.useEffect((()=>{if(d(!o),p(o>0),!o||!c.current)return;const e=c.current.clientHeight,t=c.current.scrollHeight;p(t-e>1)}),[i,o]);const g=e=>exports.TestHelper.generateId(e,"text"),y=()=>{const e=Hr(i)&&i.length>1,t=un(i)&&Object.keys(i).length>1;return e||t},_={allowedTags:$L.defaults.allowedTags.concat(["img"]),allowedAttributes:!1};return e.jsxs(e.Fragment,{children:[e.jsx(h,{id:r,ref:c,maxLines:l?void 0:o,"data-testid":g(r),weight:s?aI(s)?Bk[s]:s:a.toUpperCase()in Zk?Zk[a.toUpperCase()].weight:void 0,...u,...m&&!y()&&{as:m},...y()&&{as:"div"},children:Hr(i)?i.map(((t,n)=>{const i=`${r}-${n}`;return e.jsx(h,{id:i,"data-testid":g(i),children:e.jsx(RL,{id:i,inline:!0,sanitizeOptions:_,children:t})},n)})):"object"==typeof i?e.jsx(rU,{children:i}):e.jsx(RL,{inline:!0,sanitizeOptions:_,children:i})}),f&&e.jsx(Hk,{styleType:"link",onClick:()=>d(!l),children:l?"View less":"View more"})]})},get EElementType(){return exports.EElementType}});const Wk=t.forwardRef((({onChange:n,formValues:r,schema:i,error:a},o)=>{const s=t.useRef(null),u=t.useRef(void 0),{customComponents:
|
|
338
|
+
`;var Gk;exports.EElementType=void 0,(Gk=exports.EElementType||(exports.EElementType={})).ALERT="Alert",Gk["TEXT-D1"]="Text",Gk["TEXT-D2"]="Text",Gk["TEXT-DBODY"]="Text",Gk["TEXT-H1"]="Text",Gk["TEXT-H2"]="Text",Gk["TEXT-H3"]="Text",Gk["TEXT-H4"]="Text",Gk["TEXT-H5"]="Text",Gk["TEXT-H6"]="Text",Gk["TEXT-BODY"]="Text",Gk["TEXT-BODYSMALL"]="Text",Gk["TEXT-XSMALL"]="Text",Gk["HEADING-XXL"]="Text",Gk["HEADING-XL"]="Text",Gk["HEADING-MD"]="Text",Gk["HEADING-SM"]="Text",Gk["HEADING-LG"]="Text",Gk["HEADING-XS"]="Text",Gk["BODY-MD"]="Text",Gk["BODY-SM"]="Text",Gk["BODY-BL"]="Text",Gk["BODY-XS"]="Text",Gk.DIV="Wrapper",Gk.DIVIDER="Divider",Gk.SPAN="Wrapper",Gk.HEADER="Wrapper",Gk.FOOTER="Wrapper",Gk.H1="Wrapper",Gk.H2="Wrapper",Gk.H3="Wrapper",Gk.H4="Wrapper",Gk.H5="Wrapper",Gk.H6="Wrapper",Gk.P="Wrapper",Gk.GRID="Grid",Gk.TAB="Tab",Gk["TAB-ITEM"]="TabItem",Gk["LIST-ITEM"]="ListItem",Gk["ORDERED-LIST"]="List",Gk["UNORDERED-LIST"]="List",Gk.ACCORDION="Accordion",Gk.POPOVER="Popover";var Yk=Object.freeze({__proto__:null,Accordion:t=>{const{schema:n,id:r}=t,{children:i,button:o,title:s,disableContentInset:u,...c}=n,{dispatchFieldEvent:l}=gI();return e.jsx(d.BoxContainer,{id:r,title:"string"==typeof s?s:e.jsx(rU,{children:s}),...c,callToActionComponent:o?e.jsx(a.Button.Default,{styleType:"light",type:"button",onClick:()=>l("accordion","edit",r),children:"object"==typeof o?o.label:"Edit"}):void 0,children:u?e.jsx(rU,{id:r,children:i}):e.jsx(Rk,{children:e.jsx(rU,{id:r,children:i})})})},Alert:t=>{const{id:n,schema:{children:r,...i}}=t;return e.jsx(c.Alert,{id:n,"data-testid":exports.TestHelper.generateId(n,"alert"),...i,children:"string"==typeof r?e.jsx(RL,{id:n,children:r}):U.default.isValidElement(r)||Array.isArray(r)||"number"==typeof r||"boolean"==typeof r||null==typeof r?r:e.jsx(rU,{children:r})})},Divider:t=>{const{id:n,schema:{verticalMargin:r,...i}}=t;return e.jsx(Fk,{id:n,"data-testid":exports.TestHelper.generateId(n,"divider"),$verticalMargin:r,...i})},Grid:t=>{const{id:n,schema:{children:r,customOptions:i={gridType:"v2"},uiType:a,...o}}=t,s="v3"===i.gridType?zk:Pk,u="v3"===i.gridType?"grid":"flex";return e.jsx(s,{type:u,"data-testid":exports.TestHelper.generateId(n,"grid"),...o,children:e.jsx(rU,{children:r})})},List:t=>{const{id:n,schema:{children:r,uiType:i,size:a,...o}}=t,s="ordered-list"===i?h.TextList.Ol:h.TextList.Ul;return e.jsx(s,{id:n,"data-testid":exports.TestHelper.generateId(n,i),size:(e=>e in jk)(a)?jk[a]:a,...o,children:r.map(((t,n)=>"string"==typeof t?e.jsx("li",{children:e.jsx(RL,{inline:!0,children:t})},n):e.jsx(rU,{children:t},n)))})},ListItem:t=>{const{id:n,schema:{children:r,uiType:i,showIf:a,columns:o,...s}}=t;return e.jsx("li",{id:n,...s,children:"string"==typeof r?e.jsx(RL,{inline:!0,children:r}):e.jsx(rU,{children:r})})},Popover:t=>{const{id:n,schema:{children:r,className:i,icon:a,hint:{content:o,...s},...u}}=t;return e.jsx(m.PopoverInline,{id:n,"data-testid":exports.TestHelper.generateId(n,"popover"),className:i,icon:(()=>{if(!a)return null;const t=H[a];return e.jsx(t,{})})(),content:r&&e.jsx(RL,{inline:!0,children:r}),popoverContent:(()=>{const t={allowedTags:$L.defaults.allowedTags.concat(["img"]),allowedAttributes:!1};return"string"==typeof o?e.jsx(RL,{inline:!0,sanitizeOptions:t,children:o}):e.jsx(rU,{children:o})})(),...s,...u})},Tab:n=>{const{id:r,schema:{currentActiveTabId:i,children:a,...o}}=n,[s,u]=t.useState(p()),{removeFieldValidationConfig:c}=Nk(),{unregister:l}=xe(),{dispatchFieldEvent:d}=gI(),f=Object.keys(a);t.useEffect((()=>{u(p())}),[i]),_s((()=>{Object.values(a).forEach(((e,t)=>{if(t===s)return;h(e).forEach((e=>{c(e),l(e)}))}))}),[s,a]);function p(){const e=Object.keys(a).findIndex((e=>e===i));return e<0?0:e}const h=e=>{const t=e.children,n=[];return dE(t)||!un(t)||Object.entries(t).forEach((([e,t])=>{n.push(e),"chips"===t.uiType&&n.push(e+"-textarea"),t.children&&n.push(...h(t))})),n};return e.jsx(y.Tab,{...o,id:r,"data-testid":exports.TestHelper.generateId(r,"tab"),currentActive:s,onTabClick:(e,t)=>{t!==s&&(u(t),d("change",r,{previousTabId:f[s],currentTabId:f[t]}))},children:Object.entries(a).map((([n,r])=>{const{title:i,children:a,...o}=r;return t.createElement(y.Tab.Item,{...o,key:n,id:n,"data-testid":exports.TestHelper.generateId(n,"tab-item"),title:i},e.jsx(rU,{children:a}))}))})},Text:n=>{const{id:r,schema:{children:i,uiType:a,maxLines:o,weight:s,...u}}=n,c=t.useRef(null),[l,d]=t.useState(!1),[f,p]=t.useState(!1),h=Zk[a.toUpperCase()]?.type||Uk[a.toUpperCase()]||void 0,m=Vk[a]||void 0;t.useEffect((()=>{if(d(!o),p(o>0),!o||!c.current)return;const e=c.current.clientHeight,t=c.current.scrollHeight;p(t-e>1)}),[i,o]);const g=e=>exports.TestHelper.generateId(e,"text"),y=()=>{const e=Hr(i)&&i.length>1,t=un(i)&&Object.keys(i).length>1;return e||t},_={allowedTags:$L.defaults.allowedTags.concat(["img"]),allowedAttributes:!1};return e.jsxs(e.Fragment,{children:[e.jsx(h,{id:r,ref:c,maxLines:l?void 0:o,"data-testid":g(r),weight:s?aI(s)?Bk[s]:s:a.toUpperCase()in Zk?Zk[a.toUpperCase()].weight:void 0,...u,...m&&!y()&&{as:m},...y()&&{as:"div"},children:Hr(i)?i.map(((t,n)=>{const i=`${r}-${n}`;return e.jsx(h,{id:i,"data-testid":g(i),children:e.jsx(RL,{id:i,inline:!0,sanitizeOptions:_,children:t})},n)})):"object"==typeof i?e.jsx(rU,{children:i}):e.jsx(RL,{inline:!0,sanitizeOptions:_,children:i})}),f&&e.jsx(Hk,{styleType:"link",onClick:()=>d(!l),children:l?"View less":"View more"})]})},get EElementType(){return exports.EElementType}});const Wk=t.forwardRef((({onChange:n,formValues:r,schema:i,error:a},o)=>{const s=t.useRef(null),u=t.useRef(void 0),c=t.useRef(null),{customComponents:l}=hI(),[d,f]=t.useState({}),[p,h]=t.useState(),{isSubmitting:m,isDirty:g}=Le(),{formSchema:{restoreMode:y,revalidationMode:_,validationMode:v,stripUnknown:b}}=Ok(),E=Ik(g);t.useImperativeHandle(o,(()=>s.current)),t.useEffect((()=>{g||void 0===E||E===g||s.current?.reset()}),[g]),t.useEffect((()=>{g?tI(r,d)||r&&Object.entries(r).forEach((([e,t])=>{s.current?.setValue(e,t)})):h(r)}),[r]),t.useEffect((()=>{m&&s.current?.validate()}),[m]),t.useEffect((()=>{u.current=a,a?s.current?.setErrors(a):s.current?.clearErrors()}),[a]);const S=t.useCallback((()=>{u.current&&setTimeout((()=>{u.current&&s.current?.setErrors(u.current)}),0)}),[]);return e.jsx("div",{ref:c,onBlurCapture:S,children:e.jsx(lU,{ref:s,data:{sections:{section:{uiType:"section",children:i}},defaultValues:p,restoreMode:y,revalidationMode:_,validationMode:v,stripUnknown:b},onValueChange:(e,t=!1)=>{(g||void 0===E||E===g)&&(f(e),n(e,t))},wrapInForm:!1,components:l})})})),qk=V.default.div`
|
|
339
339
|
${({$inset:e})=>e&&`\n\tpadding-left: ${e};\n\tpadding-right: ${e};\n\t`}
|
|
340
340
|
|
|
341
341
|
&:not(:last-child) {
|
|
@@ -478,7 +478,7 @@ function SO(e){return"[object Object]"===Object.prototype.toString.call(e)}Objec
|
|
|
478
478
|
cursor: pointer;
|
|
479
479
|
`,uz=V.default(c.Alert)`
|
|
480
480
|
margin-top: ${n.Spacing["spacing-8"]};
|
|
481
|
-
`;var cz=Vr,lz=Hr,dz=qt?qt.isConcatSpreadable:void 0;var fz=sa,pz=function(e){return lz(e)||cz(e)||!!(dz&&e&&e[dz])};var hz=function e(t,n,r,i,a){var o=-1,s=t.length;for(r||(r=pz),a||(a=[]);++o<s;){var u=t[o];n>0&&r(u)?n>1?e(u,n-1,r,i,a):fz(a,u):i||(a[a.length]=u)}return a};var mz=Na,gz=function(){},yz=mz&&1/FS(new mz([,-0]))[1]==1/0?function(e){return new mz(e)}:gz,_z=CS,vz=S$,bz=A$,Ez=DS,Sz=yz,Az=FS;var xz=function(e,t,n){var r=-1,i=vz,a=e.length,o=!0,s=[],u=s;if(n)o=!1,i=bz;else if(a>=200){var c=t?null:Sz(e);if(c)return Az(c);o=!1,i=Ez,u=new _z}else u=t?[]:s;e:for(;++r<a;){var l=e[r],d=t?t(l):l;if(l=n||0!==l?l:0,o&&d==d){for(var f=u.length;f--;)if(u[f]===d)continue e;t&&u.push(d),s.push(l)}else i(u,d,n)||(u!==s&&u.push(d),s.push(l))}return s},wz=N$,Tz=hz,Mz=xz;var Oz=function(e,t,n){var r=e.length;if(r<2)return r?Mz(e[0]):[];for(var i=-1,a=Array(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=wz(a[i]||o,e[s],t,n));return Mz(Tz(a,1),t,n)},Cz=Ki,Nz=Oz,Dz=SI,Lz=gk((function(e){return Nz(Cz(e,Dz))}));const Iz=t.createContext({files:[],setFiles:()=>null,currentFileIds:[],setCurrentFileIds:()=>null}),kz=({children:n})=>{const[r,i]=t.useState([]),[a,o]=t.useState([]),s=t.useMemo((()=>({files:r,setFiles:i,currentFileIds:a,setCurrentFileIds:o})),[r,a]);return e.jsx(Iz.Provider,{value:s,children:n})};var $z,Rz;!function(e){e.findAvailableSlot=e=>{const t=e.reduce(((e,{slot:t})=>t>e?t:e),0),n=Math.max(t,e.length),r=Array(n).fill(0).map(((e,t)=>t)),i=e.map((({slot:e})=>e));return r.filter((e=>!i.includes(e)))[0]??n}}($z||($z={})),exports.EFileStatus=void 0,(Rz=exports.EFileStatus||(exports.EFileStatus={}))[Rz.INJECTED=-99]="INJECTED",Rz[Rz.INJECTING=-98]="INJECTING",Rz[Rz.TO_DELETE=-4]="TO_DELETE",Rz[Rz.ERROR_FORMAT=-3]="ERROR_FORMAT",Rz[Rz.ERROR_GENERIC=-2]="ERROR_GENERIC",Rz[Rz.ERROR_SIZE=-1]="ERROR_SIZE",Rz[Rz.NONE=0]="NONE",Rz[Rz.UPLOAD_READY=4]="UPLOAD_READY",Rz[Rz.UPLOADING=5]="UPLOADING",Rz[Rz.UPLOADED=6]="UPLOADED";const Fz=t.lazy((()=>Promise.resolve().then((function(){return require("./file-upload-manager.
|
|
481
|
+
`;var cz=Vr,lz=Hr,dz=qt?qt.isConcatSpreadable:void 0;var fz=sa,pz=function(e){return lz(e)||cz(e)||!!(dz&&e&&e[dz])};var hz=function e(t,n,r,i,a){var o=-1,s=t.length;for(r||(r=pz),a||(a=[]);++o<s;){var u=t[o];n>0&&r(u)?n>1?e(u,n-1,r,i,a):fz(a,u):i||(a[a.length]=u)}return a};var mz=Na,gz=function(){},yz=mz&&1/FS(new mz([,-0]))[1]==1/0?function(e){return new mz(e)}:gz,_z=CS,vz=S$,bz=A$,Ez=DS,Sz=yz,Az=FS;var xz=function(e,t,n){var r=-1,i=vz,a=e.length,o=!0,s=[],u=s;if(n)o=!1,i=bz;else if(a>=200){var c=t?null:Sz(e);if(c)return Az(c);o=!1,i=Ez,u=new _z}else u=t?[]:s;e:for(;++r<a;){var l=e[r],d=t?t(l):l;if(l=n||0!==l?l:0,o&&d==d){for(var f=u.length;f--;)if(u[f]===d)continue e;t&&u.push(d),s.push(l)}else i(u,d,n)||(u!==s&&u.push(d),s.push(l))}return s},wz=N$,Tz=hz,Mz=xz;var Oz=function(e,t,n){var r=e.length;if(r<2)return r?Mz(e[0]):[];for(var i=-1,a=Array(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=wz(a[i]||o,e[s],t,n));return Mz(Tz(a,1),t,n)},Cz=Ki,Nz=Oz,Dz=SI,Lz=gk((function(e){return Nz(Cz(e,Dz))}));const Iz=t.createContext({files:[],setFiles:()=>null,currentFileIds:[],setCurrentFileIds:()=>null}),kz=({children:n})=>{const[r,i]=t.useState([]),[a,o]=t.useState([]),s=t.useMemo((()=>({files:r,setFiles:i,currentFileIds:a,setCurrentFileIds:o})),[r,a]);return e.jsx(Iz.Provider,{value:s,children:n})};var $z,Rz;!function(e){e.findAvailableSlot=e=>{const t=e.reduce(((e,{slot:t})=>t>e?t:e),0),n=Math.max(t,e.length),r=Array(n).fill(0).map(((e,t)=>t)),i=e.map((({slot:e})=>e));return r.filter((e=>!i.includes(e)))[0]??n}}($z||($z={})),exports.EFileStatus=void 0,(Rz=exports.EFileStatus||(exports.EFileStatus={}))[Rz.INJECTED=-99]="INJECTED",Rz[Rz.INJECTING=-98]="INJECTING",Rz[Rz.TO_DELETE=-4]="TO_DELETE",Rz[Rz.ERROR_FORMAT=-3]="ERROR_FORMAT",Rz[Rz.ERROR_GENERIC=-2]="ERROR_GENERIC",Rz[Rz.ERROR_SIZE=-1]="ERROR_SIZE",Rz[Rz.NONE=0]="NONE",Rz[Rz.UPLOAD_READY=4]="UPLOAD_READY",Rz[Rz.UPLOADING=5]="UPLOADING",Rz[Rz.UPLOADED=6]="UPLOADED";const Fz=t.lazy((()=>Promise.resolve().then((function(){return require("./file-upload-manager.2b5e51c8.js")})))),zz=n=>{const{id:r,error:i,isDirty:a,isTouched:o,value:s,schema:{compressImages:u,description:c,hideThumbnail:l,label:d,uploadOnAddingFile:f,validation:p,warning:h,...m},warning:g}=n,{files:y,currentFileIds:_,setFiles:v}=t.useContext(Iz),b=t.useRef({}),E=t.useRef({}),S=t.useRef({}),A=t.useRef({}),x=t.useRef({}),{setFieldValidationConfig:w}=Nk(),{dispatchFieldEvent:T}=gI(),{clearErrors:O,setError:C}=xe(),[N,D]=t.useState(),L=t.useRef(y),I=t.useCallback(((e,t)=>{const n=[...t],i=n.length;e.forEach(((e,t)=>{!S.current.max||i+t<S.current.max?(n.push({...e,slot:$z.findAvailableSlot(n)}),O(r)):C(r,{type:"max",message:S.current.errorMessage||om.UPLOAD().MAX_FILES(S.current.max)})})),v(n)}),[O,r,C,v]);t.useEffect((()=>{L.current=y}),[y]),t.useEffect((()=>{T("mount",r)}),[T,r]),t.useEffect((()=>{const e=p?.find((e=>"required"in e)),t=p?.find((e=>"fileType"in e)),n=p?.find((e=>"fileExtension"in e)),i=p?.find((e=>"maxSizeInKb"in e)),a=p?.find((e=>"upload"in e&&e.upload));b.current=t?.fileType?t:{},E.current=t?.fileType&&n?.fileExtension?n:{},A.current=i?.maxSizeInKb>0?i:{},x.current=a||{};const o=p?.find((e=>"length"in e)),s=p?.find((e=>"max"in e));S.current=o?{max:o.length,errorMessage:o.errorMessage}:s?{max:s.max,errorMessage:s.errorMessage}:{},w(r,tT().of(Qw().shape({dataURL:zx(),fileId:zx(),fileName:zx(),fileUrl:zx(),uploadResponse:Qw()})).test("is-empty-array",e?.errorMessage||om.UPLOAD().REQUIRED,(t=>!t||!e?.required||t.length>0)).test("max-size-in-kb",A.current.errorMessage||om.UPLOAD().MAX_FILE_SIZE(A.current.maxSizeInKb),(e=>!(e&&Array.isArray(e)&&A.current.maxSizeInKb)||y.filter((e=>e.status===exports.EFileStatus.UPLOADED)).every((e=>{if("base64"===f.type&&e.dataURL)return exports.FileHelper.getFilesizeFromBase64(e.dataURL)<=1024*A.current.maxSizeInKb;if("multipart"===f.type){const t=e.uploadResponse?.data||e.uploadResponse;let n=e.rawFile?.size||t?.fileSize;return isNaN(n)&&(n=0),n<=1024*A.current.maxSizeInKb}})))).test("max-files",S.current.errorMessage||om.UPLOAD().MAX_FILES(S.current.max),(e=>!(e&&Array.isArray(e)&&S.current.max)||e.length<=S.current.max)).test("no-interim-statuses",om.UPLOAD().UPLOADING,(()=>{const e=new Set([exports.EFileStatus.INJECTED,exports.EFileStatus.INJECTING,exports.EFileStatus.NONE,exports.EFileStatus.UPLOAD_READY,exports.EFileStatus.UPLOADING]);return!L.current.some((t=>e.has(t.status)))})),p)}),[p,y.map((e=>e.status)).join(",")]),t.useEffect((()=>{if(!a&&!o){const e=Array.isArray(s)?s:[];if(!(Lz(e.map((({fileId:e})=>e)),_).length>0))return;const t=[];e.forEach((({dataURL:e,fileId:n,fileName:r,fileUrl:i,uploadResponse:a})=>{t.push({addedFrom:"schema",dataURL:e,fileItem:{id:n},uploadResponse:a,fileUrl:i,rawFile:{name:r},slot:null,status:exports.EFileStatus.INJECTED})})),I(t,[])}}),[I,a,o,_,s]),t.useEffect((()=>{if(i?.message)try{const{message:e,fileErrors:t}=JSON.parse(i.message);t&&v(L.current.map((e=>{const n=t[e.fileItem.id];return n?{...e,fileItem:{...e.fileItem,errorMessage:n}}:e}))),e&&D(e)}catch(e){D(i.message)}else D(void 0)}),[i?.message,v]);const k=t=>t?e.jsx(RL,{children:t}):null;return e.jsxs(e.Fragment,{children:[e.jsx(t.Suspense,{fallback:null,children:e.jsx(Fz,{compressImages:!!u,fileTypeRule:b.current,fileExtensionRule:E.current,hideThumbnail:l,id:r,maxFileSizeRule:A.current,upload:f,uploadRule:x.current,value:s})}),e.jsx(M.FileUpload,{...m,accept:b.current.fileType?.map((e=>`.${e}`)).join(","),description:k(c),errorMessage:k(N),fileItems:y.filter((({fileItem:e,status:t})=>!!e&&t!==exports.EFileStatus.INJECTED&&t!==exports.EFileStatus.INJECTING)).map((({fileItem:e})=>e)),id:r,maxFiles:S.current.max,onChange:e=>{I(e.map((e=>({addedFrom:"input",rawFile:e,slot:null,status:exports.EFileStatus.NONE}))),y)},onDelete:e=>{v(y.map((t=>t.fileItem.id!==e.id?t:{...t,status:exports.EFileStatus.TO_DELETE}))),O(r)},title:k(d),warning:k(g||h)})]})},Pz=t.createContext({images:[],setImages:()=>null,errorCount:0,setErrorCount:()=>null,currentFileIds:[],setCurrentFileIds:()=>null}),jz=({children:n})=>{const[r,i]=t.useState([]),[a,o]=t.useState(0),[s,u]=t.useState([]);return e.jsx(Pz.Provider,{value:{images:r,setImages:i,errorCount:a,setErrorCount:o,currentFileIds:s,setCurrentFileIds:u},children:n})};var Zz;!function(e){e.findAvailableSlot=e=>{const t=e.reduce(((e,{slot:t})=>t>e?t:e),0),n=Math.max(t,e.length),r=Array(n).fill(0).map(((e,t)=>t)),i=e.map((({slot:e})=>e));return r.filter((e=>!i.includes(e)))[0]??n}}(Zz||(Zz={}));const Uz=["jpg","gif","png","heic","heif","webp"];var Bz;exports.EImageStatus=void 0,(Bz=exports.EImageStatus||(exports.EImageStatus={}))[Bz.INJECTED=-99]="INJECTED",Bz[Bz.ERROR_FILENAME=-8]="ERROR_FILENAME",Bz[Bz.ERROR_CUSTOM_MUTED=-7]="ERROR_CUSTOM_MUTED",Bz[Bz.ERROR_EXCEED=-6]="ERROR_EXCEED",Bz[Bz.ERROR_CUSTOM=-5]="ERROR_CUSTOM",Bz[Bz.TO_DELETE=-4]="TO_DELETE",Bz[Bz.ERROR_FORMAT=-3]="ERROR_FORMAT",Bz[Bz.ERROR_GENERIC=-2]="ERROR_GENERIC",Bz[Bz.ERROR_SIZE=-1]="ERROR_SIZE",Bz[Bz.NONE=0]="NONE",Bz[Bz.TO_RECOMPRESS=1]="TO_RECOMPRESS",Bz[Bz.COMPRESSED=2]="COMPRESSED",Bz[Bz.RECOMPRESSED=2]="RECOMPRESSED",Bz[Bz.CONVERTED=2]="CONVERTED",Bz[Bz.EDITED=3]="EDITED",Bz[Bz.UPLOAD_READY=4]="UPLOAD_READY",Bz[Bz.UPLOADING=5]="UPLOADING",Bz[Bz.UPLOADED=6]="UPLOADED",Bz[Bz.PENDING=7]="PENDING";var Vz,Hz={exports:{}},Gz={exports:{}},Yz={};var Wz,qz,Kz,Jz,Xz,Qz,eP,tP,nP,rP,iP,aP,oP,sP,uP={};
|
|
482
482
|
/** @license React v16.13.1
|
|
483
483
|
* react-is.development.js
|
|
484
484
|
*
|
|
@@ -984,7 +984,7 @@ object-assign
|
|
|
984
984
|
stroke: ${n.Colour["icon-primary"]};
|
|
985
985
|
stroke-width: 1;
|
|
986
986
|
}
|
|
987
|
-
`,TZ=n=>{const{accepts:r,activeFileIndex:i,capture:a,id:o="image-thumbnails",images:s,maxFiles:u,onClickThumbnail:c,onSelectFile:l,multiple:d}=n,f=t.useRef(null),p=async e=>{const t=Array.from(e.target.files||[]);t.length&&setTimeout((()=>{l(t)}),100)},h=()=>f?.current?.click();return e.jsxs(yZ,{id:exports.TestHelper.generateId(o),children:[s.map(((t,n)=>t.status===exports.EImageStatus.NONE?e.jsx(SZ,{children:[...Array(4)].map(((t,n)=>e.jsx(EZ,{},`dot-${n}`)))},n):t.status>exports.EImageStatus.NONE||t.status===exports.EImageStatus.ERROR_CUSTOM_MUTED?e.jsx(_Z,{id:exports.TestHelper.generateId(o,`item-${n+1}`),"data-testid":exports.TestHelper.generateId(o,`item-${n+1}`),src:t.thumbnailDataURL||t.dataURL||"https://assets.life.gov.sg/web-frontend-engine/img/icons/photo-placeholder-add.svg",type:"button","aria-label":`thumbnail of ${t.name}`,onClick:()=>c(n),children:e.jsx(AZ,{isSelected:i===n})},n):"reviewModal"===t.addedFrom||t.status<exports.EImageStatus.NONE?e.jsxs(_Z,{id:exports.TestHelper.generateId(o,`item-${n+1}`),"data-testid":exports.TestHelper.generateId(o,`item-${n+1}`),type:"button","aria-label":`error with ${t.name}`,onClick:()=>c(n),error:!0,children:[e.jsx(AZ,{isSelected:i===n}),e.jsx(vZ,{})]},n):void 0)),(s.filter((({status:e,addedFrom:t})=>e>=exports.EImageStatus.NONE||e===exports.EImageStatus.ERROR_CUSTOM_MUTED||"reviewModal"===t)).length<u||!u)&&e.jsxs(e.Fragment,{children:[e.jsx(xZ,{id:exports.TestHelper.generateId(o,"file-input"),"data-testid":exports.TestHelper.generateId(o,"file-input"),type:"file","aria-hidden":"true",tabIndex:-1,capture:a,ref:f,accept:r.map((e=>`.${e}`)).join(", "),onChange:p,multiple:d,value:""}),e.jsx(wZ,{type:"button",id:exports.TestHelper.generateId(o,"add-image-button"),"data-testid":exports.TestHelper.generateId(o,"add-image-button"),"aria-label":"add image",styleType:"secondary",onClick:h,children:e.jsx(k.PlusIcon,{})})]})]})},MZ=t.lazy((()=>Promise.resolve().then((function(){return require("./index.21340464.js")})))),OZ=[{color:"#282828",label:"black"},{color:"#FFF",colorScheme:"light",label:"white"},{color:"#017cd3",label:"blue"},{color:"#fb0101",label:"red"},{color:"#22910c",label:"green"},{color:"#f8e821",label:"yellow"}],CZ=n=>{const{accepts:r,capture:i,className:a,compress:s,dimensions:u,id:c="image-review",maxFiles:l,maxSizeInKb:d,onExit:f,outputType:p,show:h,multiple:m,maxFilesErrorMessage:g,imageReviewModalStyles:y}=n,{images:_,setImages:v}=t.useContext(Pz),{dispatchFieldEvent:b,addFieldEventListener:E,removeFieldEventListener:S}=gI(),A=Ik(h),[x,w]=t.useState(_.length-1),[T,M]=t.useState(!1),[C,N]=t.useState(),D=!!_?.find((({status:e})=>e===exports.EImageStatus.NONE)),[L,I]=t.useState(OZ[0].color),[k,$]=t.useState(!1),R=t.useRef(null),F=!!_?.find((({addedFrom:e,status:t})=>"reviewModal"===e&&t<=exports.EImageStatus.NONE))||!_.length,z=t.useCallback((e=>{e.detail.removePendingImages&&v((e=>e.filter((({status:e})=>e===exports.EImageStatus.UPLOADED||e===exports.EImageStatus.ERROR_CUSTOM_MUTED)))),f()}),[f,v]),P=e=>{!l||e.length+_.filter((({status:e,addedFrom:t})=>e>=exports.EImageStatus.NONE||"reviewModal"===t)).length<=l?e.forEach((e=>{v((t=>{const n=Zz.findAvailableSlot(t);return[...t,{id:um(),file:e,name:e.name,dimensions:u,status:exports.EImageStatus.NONE,uploadProgress:0,addedFrom:"reviewModal",slot:n}]}))})):v((t=>{const n=Zz.findAvailableSlot(t);return[...t,{id:um(),file:e[0],name:e[0].name,dimensions:u,status:exports.EImageStatus.ERROR_EXCEED,uploadProgress:0,addedFrom:"reviewModal",slot:n}]}))},j=e=>{e&&(v((e=>e.map(((e,t)=>({...e,...t===x?{status:exports.EImageStatus.TO_DELETE}:{}}))))),w(Math.max(0,x-1))),N(null)},Z=t.useCallback((()=>{v((e=>e.filter((({status:e})=>e>=exports.EImageStatus.NONE||e===exports.EImageStatus.ERROR_CUSTOM_MUTED)).map((e=>{const t={...e};return e.drawingDataURL&&(t.dataURL=e.drawingDataURL),e.status<exports.EImageStatus.UPLOAD_READY&&e.status>exports.EImageStatus.NONE&&(t.status=exports.EImageStatus.UPLOAD_READY),t.drawingDataURL=void 0,t.drawing=void 0,t}))))}),[v]),U=()=>{!b("save-review-images",c,{images:_,retry:U})||(Z(),f())},B=()=>{M(!0),I(OZ[0].color)},V=async()=>{const{dataURL:e,drawing:t}=R.current?.export()||{},n=await exports.ImageHelper.dataUrlToImage(e),r=await exports.ImageHelper.resampleImage(n,{scale:96/n.width,type:exports.FileHelper.fileExtensionToMimeType(p)}),i=await exports.FileHelper.fileToDataUrl(r);v((n=>{const r=[...n];return r[x]={...r[x],thumbnailDataURL:i,drawingDataURL:e,drawing:t,status:s?exports.EImageStatus.TO_RECOMPRESS:exports.EImageStatus.EDITED},r})),M(!1),G()},H=()=>{G(),$(!0)},G=()=>{I(""),$(!1)};t.useEffect((()=>{const e={"trigger-save-review-images":Z,"dismiss-review-modal":z};return Object.entries(e).forEach((([e,t])=>{E(e,c,t)})),()=>{Object.entries(e).forEach((([e,t])=>{S(e,c,t)}))}}),[E,z,Z,c,S]),t.useEffect((()=>{w(_.length-1)}),[_.length]),t.useEffect((()=>{h?b("show-review-modal",c):A&&b("hide-review-modal",c)}),[h]);return e.jsx(o.Modal,{id:exports.TestHelper.generateId(c,void 0,h?"show":"hide"),className:a?`${a}-review`:void 0,show:h,children:e.jsx(Kj,{className:a?`${a}-review-modal-box`:void 0,imageReviewModalStyles:y,showCloseButton:!1,children:h?e.jsxs(e.Fragment,{children:[e.jsx(Jj,{className:a?`${a}-header`:void 0,$drawActive:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(tZ,{id:exports.TestHelper.generateId(c,"clear-drawing-button"),"data-testid":exports.TestHelper.generateId(c,"clear-drawing-button"),onClick:()=>N("clear-drawing"),children:"Clear"}),e.jsx(tZ,{id:exports.TestHelper.generateId(c,"save-drawing"),"data-testid":exports.TestHelper.generateId(c,"save-drawing"),onClick:V,children:"Save"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Xj,{id:exports.TestHelper.generateId(c,"close-button"),"data-testid":exports.TestHelper.generateId(c,"close-button"),"aria-label":"exit review modal",onClick:()=>N("exit"),children:e.jsx(O.CrossIcon,{type:"cross"})}),e.jsx(Qj,{weight:"semibold",children:"Review photos"})]})}),e.jsxs(nZ,{children:[_.length>0&&e.jsx(cZ,{className:a?`${a}-editor`:void 0,children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(MZ,{baseImageDataURL:_[x]?.dataURL,drawing:_[x]?.drawing,color:T?L:void 0,erase:!!T&&k,ref:R,maxSizeInKb:d})})}),_.length>0&&e.jsx(rZ,{children:"Loading Preview..."}),!T&&_[x]?.status>=exports.EImageStatus.NONE&&e.jsxs(iZ,{children:[e.jsxs(aZ,{id:exports.TestHelper.generateId(c,"draw-button"),"data-testid":exports.TestHelper.generateId(c,"draw-button"),onClick:B,disabled:D,children:[e.jsx(sZ,{$disabled:D}),e.jsx(oZ,{weight:"semibold",$disabled:D,children:"Draw"})]}),e.jsxs(aZ,{id:exports.TestHelper.generateId(c,"delete-button"),"data-testid":exports.TestHelper.generateId(c,"delete-button"),onClick:()=>N("delete"),disabled:D,children:[e.jsx(uZ,{$disabled:D}),e.jsx(oZ,{weight:"semibold",$disabled:D,children:"Delete"})]})]}),_[x]?.status<exports.EImageStatus.NONE&&e.jsx(Wj,{id:`${c}-photo-error`,image:_[x],accepts:r,maxSizeInKb:d,onClickOk:()=>j(!0),maxFilesErrorMessage:g,maxFiles:l})]}),e.jsx(lZ,{className:a?`${a}-footer`:void 0,children:T?e.jsxs(e.Fragment,{children:[e.jsx(fZ,{id:exports.TestHelper.generateId(c,"eraser-button"),"data-testid":exports.TestHelper.generateId(c,"eraser-button"),"aria-label":"eraser",onClick:H,children:e.jsx(pZ,{$eraseMode:k})}),e.jsx(mZ,{children:OZ.map((({color:t,colorScheme:n,label:r},i)=>e.jsx(gZ,{id:exports.TestHelper.generateId(c,`palette-color-${i}`),"aria-label":`${r} brush`,$color:t,$colorScheme:n,onClick:()=>(e=>{G(),I(e)})(t),children:L===t&&e.jsx(hZ,{$colorScheme:n})},t)))})]}):e.jsxs(e.Fragment,{children:[e.jsx(TZ,{id:`${c}-image-thumbnails`,activeFileIndex:x,accepts:r,capture:i,maxFiles:l,images:_,onClickThumbnail:w,onSelectFile:P,multiple:m}),e.jsx(dZ,{id:exports.TestHelper.generateId(c,"save-button"),"data-testid":exports.TestHelper.generateId(c,"save-button"),onClick:U,disabled:F,children:"Save"})]})}),e.jsx(qj,{images:_,show:C,onDecideClearDrawing:e=>{e&&R.current.clearDrawing(),N(null)},onDecideDelete:j,onDecideExit:e=>{e&&(v(_.filter((({addedFrom:e,status:t})=>t>=exports.EImageStatus.UPLOADED||t<exports.EImageStatus.NONE&&"dragInput"===e)).map((e=>({...e,drawingDataURL:void 0,drawing:void 0})))),f()),N(null)}})]}):e.jsx(e.Fragment,{})})})},NZ=t.lazy((()=>Promise.resolve().then((function(){return require("./index.516d4b9b.js")})))),DZ=n=>{const{schema:{buttonLabel:r,capture:i,className:a,compress:o,crop:s,description:u,dimensions:c={width:1e3,height:1e3},editImage:l,label:d,outputType:f="jpg",uploadOnAddingFile:p,validation:h,multiple:m,imageReviewModalStyles:g},id:y,isDirty:_,isTouched:v,value:b,warning:E,...S}=n,{images:A,setImages:x,currentFileIds:w}=t.useContext(Pz),T=Ik(A),[M,O]=t.useState([...Uz]),[C,N]=t.useState(0),[D,L]=t.useState(0),[I,k]=t.useState(!1),[$,R]=t.useState(!1),{setFieldValidationConfig:F}=Nk(),{dispatchFieldEvent:z}=gI(),P=$k();t.useEffect((()=>{z("mount",y)}),[z,y]),t.useEffect((()=>{if(!_&&!v){const e=Array.isArray(b)?b:[];if(!(Lz(e.map((({fileId:e})=>e)),w).length>0))return;const t=[];e.forEach((({fileId:e,fileName:n,dataURL:r,uploadResponse:i},a)=>{const o={id:e||um(),file:{},name:n,dimensions:{width:10,height:10},dataURL:r,status:exports.EImageStatus.INJECTED,addedFrom:"schema",uploadProgress:100,slot:a,uploadResponse:i};t.push(o)})),x(t)}}),[_,v,w,x,b]),t.useEffect((()=>{const e=h?.find((e=>"required"in e)),t=h?.find((e=>"fileType"in e)),n=h?.find((e=>"maxSizeInKb"in e));t?.fileType&&t?.fileType!==M&&O(t?.fileType),n?.maxSizeInKb&&n?.maxSizeInKb!==D&&L(n?.maxSizeInKb);const r=h?.find((e=>"length"in e)),i=h?.find((e=>"max"in e));let a;r?a={maxFiles:r.length,errorMessage:r.errorMessage}:i&&(a={maxFiles:i.max,errorMessage:i.errorMessage}),a?.maxFiles&&C!==a.maxFiles&&N(a.maxFiles),F(y,tT().of(Qw().shape({fileName:zx(),dataURL:zx()})).test("is-empty-array",e?.errorMessage||om.UPLOAD("photo").REQUIRED,(t=>!t||!e?.required||t.length>0)).test("max-size-in-kb",n?.errorMessage||om.UPLOAD("photo").MAX_FILE_SIZE(n?.maxSizeInKb),(e=>!(e&&Array.isArray(e)&&n?.maxSizeInKb)||e.every((e=>exports.FileHelper.getFilesizeFromBase64(e.dataURL)<=1024*n?.maxSizeInKb)))),h)}),[h]),t.useEffect((()=>{A.some((e=>e.status===exports.EImageStatus.NONE))||(A.some(((e,t)=>{const n=T?.[t];if(e.status!==n?.status||e.dataURL!==n.dataURL)switch(e.status){case exports.EImageStatus.COMPRESSED:case exports.EImageStatus.CONVERTED:if(l&&!$)return P()?R(!0):k(!0),!0}})),0===A.length&&R(!1))}),[A.map((e=>e.status)).join(","),A.map((e=>e.dataURL)).join(",")]);const j=(e=!1)=>{e?l&&(document.body.classList.remove("lifesg-ds-overlay-open"),R(!0)):x((e=>e.map((e=>e.status<exports.EImageStatus.UPLOAD_READY&&e.status>exports.EImageStatus.NONE?{...e,status:exports.EImageStatus.UPLOAD_READY}:e)))),k(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(t.Suspense,{fallback:null,children:e.jsx(NZ,{accepts:M,compress:!!o,crop:!!s,dimensions:c,editImage:l,id:y,maxSizeInKb:D,outputType:f,upload:p,filenameMatches:h?.find((e=>"matches"in e))?.matches,filenameMatchesErrorMessage:h?.find((e=>"matches"in e))?.errorMessage,value:b})}),e.jsx(jj,{id:y,capture:i,className:a,label:d,description:u,buttonLabel:r,accepts:M,maxFiles:C,maxSizeInKb:D,dimensions:c,errorMessage:S.error?.message,validation:h,multiple:m,warning:E}),e.jsx(_T,{id:`${y}-review-prompt`,title:"Review photos?",size:"large",show:I,description:"This lets you check if you've selected the correct photos, and draw on them to highlight the issue.",buttons:[{id:"ok",title:"Ok",onClick:()=>j(!0)},{id:"skip",title:"Skip",buttonStyle:"secondary",onClick:()=>j()}]}),(()=>{const t=h?.find((e=>"max"in e));return e.jsx(CZ,{accepts:M,dimensions:c,id:y,className:a,maxFiles:C,maxFilesErrorMessage:t?.errorMessage,maxSizeInKb:D,onExit:()=>R(!1),outputType:f,show:$,multiple:m,capture:i,imageReviewModalStyles:g})})()]})},LZ=i.css`
|
|
987
|
+
`,TZ=n=>{const{accepts:r,activeFileIndex:i,capture:a,id:o="image-thumbnails",images:s,maxFiles:u,onClickThumbnail:c,onSelectFile:l,multiple:d}=n,f=t.useRef(null),p=async e=>{const t=Array.from(e.target.files||[]);t.length&&setTimeout((()=>{l(t)}),100)},h=()=>f?.current?.click();return e.jsxs(yZ,{id:exports.TestHelper.generateId(o),children:[s.map(((t,n)=>t.status===exports.EImageStatus.NONE?e.jsx(SZ,{children:[...Array(4)].map(((t,n)=>e.jsx(EZ,{},`dot-${n}`)))},n):t.status>exports.EImageStatus.NONE||t.status===exports.EImageStatus.ERROR_CUSTOM_MUTED?e.jsx(_Z,{id:exports.TestHelper.generateId(o,`item-${n+1}`),"data-testid":exports.TestHelper.generateId(o,`item-${n+1}`),src:t.thumbnailDataURL||t.dataURL||"https://assets.life.gov.sg/web-frontend-engine/img/icons/photo-placeholder-add.svg",type:"button","aria-label":`thumbnail of ${t.name}`,onClick:()=>c(n),children:e.jsx(AZ,{isSelected:i===n})},n):"reviewModal"===t.addedFrom||t.status<exports.EImageStatus.NONE?e.jsxs(_Z,{id:exports.TestHelper.generateId(o,`item-${n+1}`),"data-testid":exports.TestHelper.generateId(o,`item-${n+1}`),type:"button","aria-label":`error with ${t.name}`,onClick:()=>c(n),error:!0,children:[e.jsx(AZ,{isSelected:i===n}),e.jsx(vZ,{})]},n):void 0)),(s.filter((({status:e,addedFrom:t})=>e>=exports.EImageStatus.NONE||e===exports.EImageStatus.ERROR_CUSTOM_MUTED||"reviewModal"===t)).length<u||!u)&&e.jsxs(e.Fragment,{children:[e.jsx(xZ,{id:exports.TestHelper.generateId(o,"file-input"),"data-testid":exports.TestHelper.generateId(o,"file-input"),type:"file","aria-hidden":"true",tabIndex:-1,capture:a,ref:f,accept:r.map((e=>`.${e}`)).join(", "),onChange:p,multiple:d,value:""}),e.jsx(wZ,{type:"button",id:exports.TestHelper.generateId(o,"add-image-button"),"data-testid":exports.TestHelper.generateId(o,"add-image-button"),"aria-label":"add image",styleType:"secondary",onClick:h,children:e.jsx(k.PlusIcon,{})})]})]})},MZ=t.lazy((()=>Promise.resolve().then((function(){return require("./index.350cbda4.js")})))),OZ=[{color:"#282828",label:"black"},{color:"#FFF",colorScheme:"light",label:"white"},{color:"#017cd3",label:"blue"},{color:"#fb0101",label:"red"},{color:"#22910c",label:"green"},{color:"#f8e821",label:"yellow"}],CZ=n=>{const{accepts:r,capture:i,className:a,compress:s,dimensions:u,id:c="image-review",maxFiles:l,maxSizeInKb:d,onExit:f,outputType:p,show:h,multiple:m,maxFilesErrorMessage:g,imageReviewModalStyles:y}=n,{images:_,setImages:v}=t.useContext(Pz),{dispatchFieldEvent:b,addFieldEventListener:E,removeFieldEventListener:S}=gI(),A=Ik(h),[x,w]=t.useState(_.length-1),[T,M]=t.useState(!1),[C,N]=t.useState(),D=!!_?.find((({status:e})=>e===exports.EImageStatus.NONE)),[L,I]=t.useState(OZ[0].color),[k,$]=t.useState(!1),R=t.useRef(null),F=!!_?.find((({addedFrom:e,status:t})=>"reviewModal"===e&&t<=exports.EImageStatus.NONE))||!_.length,z=t.useCallback((e=>{e.detail.removePendingImages&&v((e=>e.filter((({status:e})=>e===exports.EImageStatus.UPLOADED||e===exports.EImageStatus.ERROR_CUSTOM_MUTED)))),f()}),[f,v]),P=e=>{!l||e.length+_.filter((({status:e,addedFrom:t})=>e>=exports.EImageStatus.NONE||"reviewModal"===t)).length<=l?e.forEach((e=>{v((t=>{const n=Zz.findAvailableSlot(t);return[...t,{id:um(),file:e,name:e.name,dimensions:u,status:exports.EImageStatus.NONE,uploadProgress:0,addedFrom:"reviewModal",slot:n}]}))})):v((t=>{const n=Zz.findAvailableSlot(t);return[...t,{id:um(),file:e[0],name:e[0].name,dimensions:u,status:exports.EImageStatus.ERROR_EXCEED,uploadProgress:0,addedFrom:"reviewModal",slot:n}]}))},j=e=>{e&&(v((e=>e.map(((e,t)=>({...e,...t===x?{status:exports.EImageStatus.TO_DELETE}:{}}))))),w(Math.max(0,x-1))),N(null)},Z=t.useCallback((()=>{v((e=>e.filter((({status:e})=>e>=exports.EImageStatus.NONE||e===exports.EImageStatus.ERROR_CUSTOM_MUTED)).map((e=>{const t={...e};return e.drawingDataURL&&(t.dataURL=e.drawingDataURL),e.status<exports.EImageStatus.UPLOAD_READY&&e.status>exports.EImageStatus.NONE&&(t.status=exports.EImageStatus.UPLOAD_READY),t.drawingDataURL=void 0,t.drawing=void 0,t}))))}),[v]),U=()=>{!b("save-review-images",c,{images:_,retry:U})||(Z(),f())},B=()=>{M(!0),I(OZ[0].color)},V=async()=>{const{dataURL:e,drawing:t}=R.current?.export()||{},n=await exports.ImageHelper.dataUrlToImage(e),r=await exports.ImageHelper.resampleImage(n,{scale:96/n.width,type:exports.FileHelper.fileExtensionToMimeType(p)}),i=await exports.FileHelper.fileToDataUrl(r);v((n=>{const r=[...n];return r[x]={...r[x],thumbnailDataURL:i,drawingDataURL:e,drawing:t,status:s?exports.EImageStatus.TO_RECOMPRESS:exports.EImageStatus.EDITED},r})),M(!1),G()},H=()=>{G(),$(!0)},G=()=>{I(""),$(!1)};t.useEffect((()=>{const e={"trigger-save-review-images":Z,"dismiss-review-modal":z};return Object.entries(e).forEach((([e,t])=>{E(e,c,t)})),()=>{Object.entries(e).forEach((([e,t])=>{S(e,c,t)}))}}),[E,z,Z,c,S]),t.useEffect((()=>{w(_.length-1)}),[_.length]),t.useEffect((()=>{h?b("show-review-modal",c):A&&b("hide-review-modal",c)}),[h]);return e.jsx(o.Modal,{id:exports.TestHelper.generateId(c,void 0,h?"show":"hide"),className:a?`${a}-review`:void 0,show:h,children:e.jsx(Kj,{className:a?`${a}-review-modal-box`:void 0,imageReviewModalStyles:y,showCloseButton:!1,children:h?e.jsxs(e.Fragment,{children:[e.jsx(Jj,{className:a?`${a}-header`:void 0,$drawActive:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(tZ,{id:exports.TestHelper.generateId(c,"clear-drawing-button"),"data-testid":exports.TestHelper.generateId(c,"clear-drawing-button"),onClick:()=>N("clear-drawing"),children:"Clear"}),e.jsx(tZ,{id:exports.TestHelper.generateId(c,"save-drawing"),"data-testid":exports.TestHelper.generateId(c,"save-drawing"),onClick:V,children:"Save"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Xj,{id:exports.TestHelper.generateId(c,"close-button"),"data-testid":exports.TestHelper.generateId(c,"close-button"),"aria-label":"exit review modal",onClick:()=>N("exit"),children:e.jsx(O.CrossIcon,{type:"cross"})}),e.jsx(Qj,{weight:"semibold",children:"Review photos"})]})}),e.jsxs(nZ,{children:[_.length>0&&e.jsx(cZ,{className:a?`${a}-editor`:void 0,children:e.jsx(t.Suspense,{fallback:null,children:e.jsx(MZ,{baseImageDataURL:_[x]?.dataURL,drawing:_[x]?.drawing,color:T?L:void 0,erase:!!T&&k,ref:R,maxSizeInKb:d})})}),_.length>0&&e.jsx(rZ,{children:"Loading Preview..."}),!T&&_[x]?.status>=exports.EImageStatus.NONE&&e.jsxs(iZ,{children:[e.jsxs(aZ,{id:exports.TestHelper.generateId(c,"draw-button"),"data-testid":exports.TestHelper.generateId(c,"draw-button"),onClick:B,disabled:D,children:[e.jsx(sZ,{$disabled:D}),e.jsx(oZ,{weight:"semibold",$disabled:D,children:"Draw"})]}),e.jsxs(aZ,{id:exports.TestHelper.generateId(c,"delete-button"),"data-testid":exports.TestHelper.generateId(c,"delete-button"),onClick:()=>N("delete"),disabled:D,children:[e.jsx(uZ,{$disabled:D}),e.jsx(oZ,{weight:"semibold",$disabled:D,children:"Delete"})]})]}),_[x]?.status<exports.EImageStatus.NONE&&e.jsx(Wj,{id:`${c}-photo-error`,image:_[x],accepts:r,maxSizeInKb:d,onClickOk:()=>j(!0),maxFilesErrorMessage:g,maxFiles:l})]}),e.jsx(lZ,{className:a?`${a}-footer`:void 0,children:T?e.jsxs(e.Fragment,{children:[e.jsx(fZ,{id:exports.TestHelper.generateId(c,"eraser-button"),"data-testid":exports.TestHelper.generateId(c,"eraser-button"),"aria-label":"eraser",onClick:H,children:e.jsx(pZ,{$eraseMode:k})}),e.jsx(mZ,{children:OZ.map((({color:t,colorScheme:n,label:r},i)=>e.jsx(gZ,{id:exports.TestHelper.generateId(c,`palette-color-${i}`),"aria-label":`${r} brush`,$color:t,$colorScheme:n,onClick:()=>(e=>{G(),I(e)})(t),children:L===t&&e.jsx(hZ,{$colorScheme:n})},t)))})]}):e.jsxs(e.Fragment,{children:[e.jsx(TZ,{id:`${c}-image-thumbnails`,activeFileIndex:x,accepts:r,capture:i,maxFiles:l,images:_,onClickThumbnail:w,onSelectFile:P,multiple:m}),e.jsx(dZ,{id:exports.TestHelper.generateId(c,"save-button"),"data-testid":exports.TestHelper.generateId(c,"save-button"),onClick:U,disabled:F,children:"Save"})]})}),e.jsx(qj,{images:_,show:C,onDecideClearDrawing:e=>{e&&R.current.clearDrawing(),N(null)},onDecideDelete:j,onDecideExit:e=>{e&&(v(_.filter((({addedFrom:e,status:t})=>t>=exports.EImageStatus.UPLOADED||t<exports.EImageStatus.NONE&&"dragInput"===e)).map((e=>({...e,drawingDataURL:void 0,drawing:void 0})))),f()),N(null)}})]}):e.jsx(e.Fragment,{})})})},NZ=t.lazy((()=>Promise.resolve().then((function(){return require("./index.eeb93deb.js")})))),DZ=n=>{const{schema:{buttonLabel:r,capture:i,className:a,compress:o,crop:s,description:u,dimensions:c={width:1e3,height:1e3},editImage:l,label:d,outputType:f="jpg",uploadOnAddingFile:p,validation:h,multiple:m,imageReviewModalStyles:g},id:y,isDirty:_,isTouched:v,value:b,warning:E,...S}=n,{images:A,setImages:x,currentFileIds:w}=t.useContext(Pz),T=Ik(A),[M,O]=t.useState([...Uz]),[C,N]=t.useState(0),[D,L]=t.useState(0),[I,k]=t.useState(!1),[$,R]=t.useState(!1),{setFieldValidationConfig:F}=Nk(),{dispatchFieldEvent:z}=gI(),P=$k();t.useEffect((()=>{z("mount",y)}),[z,y]),t.useEffect((()=>{if(!_&&!v){const e=Array.isArray(b)?b:[];if(!(Lz(e.map((({fileId:e})=>e)),w).length>0))return;const t=[];e.forEach((({fileId:e,fileName:n,dataURL:r,uploadResponse:i},a)=>{const o={id:e||um(),file:{},name:n,dimensions:{width:10,height:10},dataURL:r,status:exports.EImageStatus.INJECTED,addedFrom:"schema",uploadProgress:100,slot:a,uploadResponse:i};t.push(o)})),x(t)}}),[_,v,w,x,b]),t.useEffect((()=>{const e=h?.find((e=>"required"in e)),t=h?.find((e=>"fileType"in e)),n=h?.find((e=>"maxSizeInKb"in e));t?.fileType&&t?.fileType!==M&&O(t?.fileType),n?.maxSizeInKb&&n?.maxSizeInKb!==D&&L(n?.maxSizeInKb);const r=h?.find((e=>"length"in e)),i=h?.find((e=>"max"in e));let a;r?a={maxFiles:r.length,errorMessage:r.errorMessage}:i&&(a={maxFiles:i.max,errorMessage:i.errorMessage}),a?.maxFiles&&C!==a.maxFiles&&N(a.maxFiles),F(y,tT().of(Qw().shape({fileName:zx(),dataURL:zx()})).test("is-empty-array",e?.errorMessage||om.UPLOAD("photo").REQUIRED,(t=>!t||!e?.required||t.length>0)).test("max-size-in-kb",n?.errorMessage||om.UPLOAD("photo").MAX_FILE_SIZE(n?.maxSizeInKb),(e=>!(e&&Array.isArray(e)&&n?.maxSizeInKb)||e.every((e=>exports.FileHelper.getFilesizeFromBase64(e.dataURL)<=1024*n?.maxSizeInKb)))),h)}),[h]),t.useEffect((()=>{A.some((e=>e.status===exports.EImageStatus.NONE))||(A.some(((e,t)=>{const n=T?.[t];if(e.status!==n?.status||e.dataURL!==n.dataURL)switch(e.status){case exports.EImageStatus.COMPRESSED:case exports.EImageStatus.CONVERTED:if(l&&!$)return P()?R(!0):k(!0),!0}})),0===A.length&&R(!1))}),[A.map((e=>e.status)).join(","),A.map((e=>e.dataURL)).join(",")]);const j=(e=!1)=>{e?l&&(document.body.classList.remove("lifesg-ds-overlay-open"),R(!0)):x((e=>e.map((e=>e.status<exports.EImageStatus.UPLOAD_READY&&e.status>exports.EImageStatus.NONE?{...e,status:exports.EImageStatus.UPLOAD_READY}:e)))),k(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(t.Suspense,{fallback:null,children:e.jsx(NZ,{accepts:M,compress:!!o,crop:!!s,dimensions:c,editImage:l,id:y,maxSizeInKb:D,outputType:f,upload:p,filenameMatches:h?.find((e=>"matches"in e))?.matches,filenameMatchesErrorMessage:h?.find((e=>"matches"in e))?.errorMessage,value:b})}),e.jsx(jj,{id:y,capture:i,className:a,label:d,description:u,buttonLabel:r,accepts:M,maxFiles:C,maxSizeInKb:D,dimensions:c,errorMessage:S.error?.message,validation:h,multiple:m,warning:E}),e.jsx(_T,{id:`${y}-review-prompt`,title:"Review photos?",size:"large",show:I,description:"This lets you check if you've selected the correct photos, and draw on them to highlight the issue.",buttons:[{id:"ok",title:"Ok",onClick:()=>j(!0)},{id:"skip",title:"Skip",buttonStyle:"secondary",onClick:()=>j()}]}),(()=>{const t=h?.find((e=>"max"in e));return e.jsx(CZ,{accepts:M,dimensions:c,id:y,className:a,maxFiles:C,maxFilesErrorMessage:t?.errorMessage,maxSizeInKb:D,onExit:()=>R(!1),outputType:f,show:$,multiple:m,capture:i,imageReviewModalStyles:g})})()]})},LZ=i.css`
|
|
988
988
|
border: ${n.Border["width-010"]} ${n.Border.solid} ${n.Colour["border-focus"]};
|
|
989
989
|
box-shadow: none;
|
|
990
990
|
`,IZ=i.css`
|
|
@@ -1063,7 +1063,7 @@ object-assign
|
|
|
1063
1063
|
${e=>i.css`
|
|
1064
1064
|
margin-left: ${e.$readOnly?n.Spacing["spacing-4"]:n.Spacing["spacing-12"]};
|
|
1065
1065
|
`}
|
|
1066
|
-
`,zZ=t=>{const{id:n,"data-testid":r,className:i,disabled:a,readOnly:o,onFocus:s,value:u,placeholder:c,error:l}=t;return e.jsxs($Z,{id:n,"data-testid":r,type:"button",className:i,disabled:a,$readOnly:o,$error:l,onFocus:s,onClick:e=>{a||e.currentTarget.focus()},tabIndex:a?-1:0,"aria-disabled":a||void 0,"aria-haspopup":"dialog","aria-readonly":o,children:[c&&!u?e.jsx(RZ,{$placeholder:!0,$disabled:a,children:c}):e.jsx(RZ,{$disabled:a,children:u}),e.jsx(FZ,{$disabled:a,$readOnly:o,"aria-hidden":"true",children:e.jsx(R.PinFillIcon,{})})]})},PZ=t=>{const{id:n,label:r,className:i,locationInputPlaceholder:a="",onFocus:o,value:s,errorMessage:u,disabled:c,readOnly:l}=t;return e.jsx(x.Form.CustomField,{id:exports.TestHelper.generateId(n,"location-input"),"data-testid":exports.TestHelper.generateId(n,"location-input"),label:r,errorMessage:u,children:e.jsx(zZ,{id:exports.TestHelper.generateId(n,"location-input-base"),"data-testid":exports.TestHelper.generateId(n,"location-input-base"),disabled:c,readOnly:l,placeholder:a,onFocus:o,value:s,error:!!u,className:i})})},jZ=t.lazy((()=>Promise.resolve().then((function(){return require("./location-modal.
|
|
1066
|
+
`,zZ=t=>{const{id:n,"data-testid":r,className:i,disabled:a,readOnly:o,onFocus:s,value:u,placeholder:c,error:l}=t;return e.jsxs($Z,{id:n,"data-testid":r,type:"button",className:i,disabled:a,$readOnly:o,$error:l,onFocus:s,onClick:e=>{a||e.currentTarget.focus()},tabIndex:a?-1:0,"aria-disabled":a||void 0,"aria-haspopup":"dialog","aria-readonly":o,children:[c&&!u?e.jsx(RZ,{$placeholder:!0,$disabled:a,children:c}):e.jsx(RZ,{$disabled:a,children:u}),e.jsx(FZ,{$disabled:a,$readOnly:o,"aria-hidden":"true",children:e.jsx(R.PinFillIcon,{})})]})},PZ=t=>{const{id:n,label:r,className:i,locationInputPlaceholder:a="",onFocus:o,value:s,errorMessage:u,disabled:c,readOnly:l}=t;return e.jsx(x.Form.CustomField,{id:exports.TestHelper.generateId(n,"location-input"),"data-testid":exports.TestHelper.generateId(n,"location-input"),label:r,errorMessage:u,children:e.jsx(zZ,{id:exports.TestHelper.generateId(n,"location-input-base"),"data-testid":exports.TestHelper.generateId(n,"location-input-base"),disabled:c,readOnly:l,placeholder:a,onFocus:o,value:s,error:!!u,className:i})})},jZ=t.lazy((()=>Promise.resolve().then((function(){return require("./location-modal.80a5525d.js")}))));class ZZ extends Error{code;message;constructor(e){super(),Object.assign(this,e)}}const UZ=V.default(r.Typography.BodyMD)`
|
|
1067
1067
|
cursor: ${e=>e.disabled?"not-allowed":"pointer"};
|
|
1068
1068
|
`,BZ=V.default(z.RadioButton)`
|
|
1069
1069
|
margin-right: ${n.Spacing["spacing-4"]};
|
|
@@ -1116,4 +1116,4 @@ object-assign
|
|
|
1116
1116
|
`,oU=V.default.div`
|
|
1117
1117
|
flex: 1;
|
|
1118
1118
|
`,sU=t=>{const{sectionSchema:{children:n,layoutType:r,customOptions:i={gridType:"v2"}},...a}=t;switch(r){case"grid":return(()=>{const t="v3"===i.gridType?iU:aU,r="v3"===i.gridType?"grid":"flex";return e.jsx(l.Layout.Section,{children:e.jsx(t,{type:r,children:e.jsx(rU,{...a,children:n})})})})();case"contain":return e.jsx(l.Layout.Content,{children:e.jsx(oU,{children:e.jsx(rU,{...a,children:n})})});default:return e.jsx(rU,{...a,children:n})}},uU=()=>{const{formSchema:{sections:t,overrides:n},overrideSchema:r}=Ok();return e.jsx(e.Fragment,{children:(()=>{const i=r(t,n);return i?Object.entries(i).map((([t,n],r)=>e.jsx(sU,{id:t,sectionSchema:n},`section-${r}`))):e.jsxs(e.Fragment,{children:["Unable to render Frontend Engine schema, make sure schema is declared within ",e.jsx("code",{children:"sections"}),"."]})})()})},cU=t.forwardRef(((n,r)=>{const{data:i,className:a=null,components:o,onSubmit:s,onSubmitError:u,wrapInForm:c=!0}=n,{className:l=null,defaultValues:d,id:f,stripUnknown:p,revalidationMode:h="onChange",validationMode:m="onTouched"}=i||{},{addFieldEventListener:g,dispatchFieldEvent:y,removeFieldEventListener:_}=gI(),{setCustomComponents:v}=hI(),{setSubmitHandler:b,setWrapInForm:E}=Dk(),{addWarnings:S,performSoftValidation:A,softValidationSchema:x,hardValidationSchema:w,rebuildValidationSchema:T,yupId:M}=kk(),O=function(e={}){const t=U.default.useRef(void 0),n=U.default.useRef(void 0),[r,i]=U.default.useState({isDirty:!1,isValidating:!1,isLoading:Be(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Be(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={..._t(e),formState:r});const a=t.current.control;return a._options=e,De({subject:a._subjects.state,next:e=>{Oe(e,a._proxyFormState,a._updateFormState,!0)&&i({...a._formState})}}),U.default.useEffect((()=>a._disableForm(e.disabled)),[a,e.disabled]),U.default.useEffect((()=>{if(a._proxyFormState.isDirty){const e=a._getDirty();e!==r.isDirty&&a._subjects.state.next({isDirty:e})}}),[a,r.isDirty]),U.default.useEffect((()=>{e.values&&!at(e.values,n.current)?(a._reset(e.values,a._options.resetOptions),n.current=e.values,i((e=>({...e})))):a._resetDefaultValues()}),[e.values,a]),U.default.useEffect((()=>{e.errors&&a._setErrors(e.errors)}),[e.errors,a]),U.default.useEffect((()=>{a._state.mount||(a._updateValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()})),U.default.useEffect((()=>{e.shouldUnregister&&a._subjects.values.next({values:a._getWatch()})}),[e.shouldUnregister,a]),t.current.formState=Te(r,a),t.current}({mode:m,reValidateMode:h,defaultValues:d,resolver:async(e,t,n)=>(A(x,e),await function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),function(r,i,a){try{return Promise.resolve(function(o,s){try{var u=(t.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(e["sync"===n.mode?"validateSync":"validate"](r,Object.assign({abortEarly:!1},t,{context:i}))).then((function(e){return a.shouldUseNativeValidation&&bt({},a),{values:n.rawValues?r:e,errors:{}}})))}catch(e){return s(e)}return u&&u.then?u.then(void 0,s):u}(0,(function(e){if(!e.inner)throw e;return{values:{},errors:Et((t=e,n=!a.shouldUseNativeValidation&&"all"===a.criteriaMode,(t.inner||[]).reduce((function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var r=e[t.path].types,i=r&&r[t.type];e[t.path]=Fe(t.path,n,e,t.type,i?[].concat(i,t.message):t.message)}return e}),{})),a)};var t,n})))}catch(e){return Promise.reject(e)}}}(w)(e,t,n))}),{setFormSchema:C}=Ok(),{reset:N,handleSubmit:D,getValues:L,setValue:I,setError:k,trigger:$,formState:R,clearErrors:F}=O,{resetFields:z,setFields:P,getFormValues:j,registeredFields:Z}=Ck(O),B=t.useRef(Z),{checkIsFormValid:V}=((e,n)=>{const{data:r,onChange:i,onValueChange:a}=e,{stripUnknown:o}=r||{},{hardValidationSchema:s}=kk(),{formValidationConfig:u}=Nk(),{watch:c,getValues:l,formState:d,clearErrors:f}=n,{setFields:p,setField:h,getFormValues:m}=Ck(n),[g,y]=t.useState({}),[_,v]=t.useState(!1),b=Ik(u),E=Ik(s),S=t.useRef(void 0),A=t.useRef(void 0),x=t.useCallback(((e=!1)=>{if(!e)try{return s.validateSync(l()),!0}catch(e){return!1}return(async()=>{try{return await s.validate(l()),!0}catch(e){return!1}})()}),[l,s]),w=t.useRef((async()=>{}));return w.current=async()=>{const e=m(void 0,o),t=await x(!0);a&&Object.keys(u||{}).length&&(A.current===t&&tI(S.current,e)||a(e,t)),S.current=e,A.current=t},t.useEffect((()=>{const e=c(((e,{name:t})=>{t?h(t,e[t]):p(e)}));return()=>e.unsubscribe()}),[]),t.useEffect((()=>{if(i&&Object.keys(u||{}).length){const e=c((async()=>{const e=await x(!0);i(m(void 0,o),e)}));return x(!0).then((e=>i(m(void 0,o),e))),()=>e.unsubscribe()}}),[x,i,c,u]),t.useEffect((()=>{const e=c((async()=>{await w.current()}));return()=>e.unsubscribe()}),[c]),t.useEffect((()=>{if(b){const e=e=>Object.entries(e).map((([e,{validationRules:t}])=>[e,t])),t=e(b),n=e(u);tI(t,n)||v(!0)}}),[u]),t.useEffect((()=>{_&&E!==s&&w.current().then((()=>v(!1)))}),[_,s]),t.useEffect((()=>{const e=d.errors;if(e&&!dE(e)){const e=c((e=>{const t=Object.fromEntries(Object.entries(d.errors).filter((([e,t])=>"api"===t.type)));t&&!dE(t)&&Object.keys(t).forEach((t=>{g[t]!==e[t]&&f(t)})),y(e)}));return()=>e.unsubscribe()}}),[d,c]),{checkIsFormValid:x}})(n,O);t.useImperativeHandle(r,(()=>({addFieldEventListener:g,addCustomValidation:H,dispatchFieldEvent:y,getValues:e=>j(e,p),isDirty:R.isDirty,isValid:V,validate:$,removeFieldEventListener:_,reset:(e,t)=>{N(e,t),z("function"==typeof e?e(O.getValues())??d:e??d)},setErrors:W,clearErrors:F,setWarnings:q,setValue:I,submit:D(G,Y)})));const H=(e,t,n,r=!1)=>{KL.addCondition(e,t,n,M,r),T()},G=t.useCallback((()=>{s?.(j(void 0,p))}),[j,s,p]),Y=t.useCallback((e=>{setTimeout((()=>u?.(e)))}),[u]),W=e=>{Object.entries(e).forEach((([e,t])=>{B.current.includes(e)&&(Array.isArray(t)?k(e,{type:"api",message:t[0]}):k(e,"object"==typeof t?{type:"api",message:JSON.stringify(t)}:{type:"api",message:t}))}))},q=e=>{const t={};Object.entries(e).forEach((([e,n])=>{B.current.includes(e)&&(t[e]=n)})),S(t)};t.useEffect((()=>{P(L())}),[]),_s((()=>{N(ds(d))}),[d]),ys((()=>{C(i)}),[i||{}]),t.useEffect((()=>{v(o)}),[o]),t.useEffect((()=>{b((()=>D(G,Y)))}),[G,Y]),t.useEffect((()=>{E(c)}),[c]),t.useEffect((()=>{B.current=Z}),[Z]);const K=f?`frontend-engine-${f}`:"frontend-engine",J=[a,l].join(" ").trim(),X=c?"form":"div";return i?e.jsx(we,{...O,children:e.jsx(X,{id:K,"data-testid":f?exports.TestHelper.generateId(f,"frontend-engine"):K,className:J,noValidate:!0,onSubmit:D(G,Y),ref:r,children:e.jsx(uU,{})})}):e.jsxs(e.Fragment,{children:["Missing ",e.jsx("code",{children:"data"})," prop, unable to render Frontend Engine."]})})),lU=t.forwardRef(((t,n)=>e.jsx(pI,{recaptchaSiteKey:t.recaptchaSiteKey,children:e.jsx(cU,{...t,ref:n})})));exports.AxiosApiClient=fl,exports.Description=gT,exports.ERROR_MESSAGES=om,exports.FileUploadContext=Iz,exports.FrontendEngine=lU,exports.GeolocationPositionErrorWrapper=ZZ,exports.ImageContext=Pz,exports.OneMapError=UL,exports.OneMapService=jL,exports.Prompt=_T,exports.RecaptchaContext=Ds,exports.Sanitize=RL,exports.commonjsGlobal=St,exports.generateRandomId=um,exports.lodash=FL,exports.useFieldEvent=gI,exports.useFormContext=xe,exports.useFrontendEngineComponent=()=>{const{addFieldEventListener:e,dispatchFieldEvent:t,removeFieldEventListener:n}=gI(),r=xe(),{setFieldValidationConfig:i,removeFieldValidationConfig:a}=Nk();return{event:{addFieldEventListener:e,dispatchFieldEvent:t,removeFieldEventListener:n},formContext:r,validation:{setValidation:i,removeValidation:a}}},exports.usePrevious=Ik,exports.useWindowHelper=$k;
|
|
1119
|
-
//# sourceMappingURL=index.
|
|
1119
|
+
//# sourceMappingURL=index.5d896247.js.map
|