@lifesg/web-frontend-engine 2.2.1 → 2.2.2

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.
Files changed (24) hide show
  1. package/README.md +1 -1
  2. package/chunks/{file-upload-manager.27debdaa.js → file-upload-manager.581859a5.js} +2 -2
  3. package/chunks/{file-upload-manager.27debdaa.js.map → file-upload-manager.581859a5.js.map} +1 -1
  4. package/chunks/{index.b5f8bb97.js → index.8cc1cf41.js} +8 -8
  5. package/chunks/{index.b5f8bb97.js.map → index.8cc1cf41.js.map} +1 -1
  6. package/chunks/{index.93ef32cd.js → index.bba30c64.js} +2 -2
  7. package/chunks/{index.93ef32cd.js.map → index.bba30c64.js.map} +1 -1
  8. package/chunks/{index.2f7eb734.js → index.d31714ac.js} +2 -2
  9. package/chunks/{index.2f7eb734.js.map → index.d31714ac.js.map} +1 -1
  10. package/chunks/{location-modal.4a00fa7b.js → location-modal.60f7c5c4.js} +2 -2
  11. package/chunks/{location-modal.4a00fa7b.js.map → location-modal.60f7c5c4.js.map} +1 -1
  12. package/cjs/chunks/{file-upload-manager.75e07efb.js → file-upload-manager.75d19b87.js} +2 -2
  13. package/cjs/chunks/{file-upload-manager.75e07efb.js.map → file-upload-manager.75d19b87.js.map} +1 -1
  14. package/cjs/chunks/{index.bb0ba7ce.js → index.00d4458f.js} +8 -8
  15. package/cjs/chunks/{index.bb0ba7ce.js.map → index.00d4458f.js.map} +1 -1
  16. package/cjs/chunks/{index.fafcc083.js → index.260bcc27.js} +2 -2
  17. package/cjs/chunks/{index.fafcc083.js.map → index.260bcc27.js.map} +1 -1
  18. package/cjs/chunks/{index.d2321141.js → index.b1899917.js} +2 -2
  19. package/cjs/chunks/{index.d2321141.js.map → index.b1899917.js.map} +1 -1
  20. package/cjs/chunks/{location-modal.5d849c88.js → location-modal.ff55a907.js} +2 -2
  21. package/cjs/chunks/{location-modal.5d849c88.js.map → location-modal.ff55a907.js.map} +1 -1
  22. package/cjs/index.js +1 -1
  23. package/index.js +1 -1
  24. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- "use strict";var t=require("react/jsx-runtime"),e=require("@lifesg/react-design-system/modal"),n=require("@lifesg/react-design-system/theme"),i=require("./index.bb0ba7ce.js"),o=require("react"),r=require("styled-components");require("@lifesg/react-design-system/markup");var s=require("react-dom/server"),a=require("@lifesg/react-design-system/popover-v2"),l=require("@lifesg/react-design-system/typography"),h=require("@lifesg/react-icons/navigation"),c=require("@lifesg/react-icons/navigation-fill"),u=require("@lifesg/react-icons"),d=require("@lifesg/react-icons/pin-fill"),p=require("@lifesg/react-icons/cross"),f=require("@lifesg/react-design-system/icon-button"),m=require("@lifesg/react-design-system/card"),_=require("@lifesg/react-icons/magnifier"),g=require("@lifesg/react-design-system/button");function v(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}require("@lifesg/react-design-system/alert"),require("@lifesg/react-design-system/layout"),require("@lifesg/react-design-system/box-container"),require("@lifesg/react-design-system/divider"),require("@lifesg/react-design-system/v2_media"),require("@lifesg/react-design-system/text-list"),require("@lifesg/react-design-system/tab"),require("@lifesg/react-icons/plus-circle-fill"),require("@lifesg/react-design-system/button-with-icon"),require("@lifesg/react-design-system/error-display"),require("@lifesg/react-design-system/filter"),require("@lifesg/react-design-system/uneditable-section"),require("@lifesg/react-design-system/timeline"),require("@lifesg/react-design-system/form"),require("@lifesg/react-design-system/checkbox"),require("@lifesg/react-design-system/toggle"),require("@lifesg/react-design-system/file-upload"),require("@lifesg/react-icons/bin"),require("@lifesg/react-icons/eraser"),require("@lifesg/react-icons/pencil"),require("@lifesg/react-icons/pencil-stroke"),require("@lifesg/react-icons/plus"),require("@lifesg/react-icons/exclamation-triangle"),require("@lifesg/react-design-system/image-button"),require("@lifesg/react-design-system/radio-button"),require("@lifesg/react-design-system/v2_layout");var y=v(r),x=v(s);const b="https://assets.life.gov.sg/web-frontend-engine/img/common/no-network.png";var w={exports:{}};
1
+ "use strict";var t=require("react/jsx-runtime"),e=require("@lifesg/react-design-system/modal"),n=require("@lifesg/react-design-system/theme"),i=require("./index.00d4458f.js"),o=require("react"),r=require("styled-components");require("@lifesg/react-design-system/markup");var s=require("react-dom/server"),a=require("@lifesg/react-design-system/popover-v2"),l=require("@lifesg/react-design-system/typography"),h=require("@lifesg/react-icons/navigation"),c=require("@lifesg/react-icons/navigation-fill"),u=require("@lifesg/react-icons"),d=require("@lifesg/react-icons/pin-fill"),p=require("@lifesg/react-icons/cross"),f=require("@lifesg/react-design-system/icon-button"),m=require("@lifesg/react-design-system/card"),_=require("@lifesg/react-icons/magnifier"),g=require("@lifesg/react-design-system/button");function v(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}require("@lifesg/react-design-system/alert"),require("@lifesg/react-design-system/layout"),require("@lifesg/react-design-system/box-container"),require("@lifesg/react-design-system/divider"),require("@lifesg/react-design-system/v2_media"),require("@lifesg/react-design-system/text-list"),require("@lifesg/react-design-system/tab"),require("@lifesg/react-icons/plus-circle-fill"),require("@lifesg/react-design-system/button-with-icon"),require("@lifesg/react-design-system/error-display"),require("@lifesg/react-design-system/filter"),require("@lifesg/react-design-system/uneditable-section"),require("@lifesg/react-design-system/timeline"),require("@lifesg/react-design-system/form"),require("@lifesg/react-design-system/checkbox"),require("@lifesg/react-design-system/toggle"),require("@lifesg/react-design-system/file-upload"),require("@lifesg/react-icons/bin"),require("@lifesg/react-icons/eraser"),require("@lifesg/react-icons/pencil"),require("@lifesg/react-icons/pencil-stroke"),require("@lifesg/react-icons/plus"),require("@lifesg/react-icons/exclamation-triangle"),require("@lifesg/react-design-system/image-button"),require("@lifesg/react-design-system/radio-button"),require("@lifesg/react-design-system/v2_layout");var y=v(r),x=v(s);const b="https://assets.life.gov.sg/web-frontend-engine/img/common/no-network.png";var w={exports:{}};
2
2
  /* @preserve
3
3
  * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
4
4
  * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
@@ -390,4 +390,4 @@
390
390
  max-width: 16.5rem;
391
391
  }
392
392
  `,Lt=({id:e,cachedImage:n,refreshNetwork:o})=>t.jsxs(vt,{id:i.TestHelper.generateId(e,"no-internet-connectivity"),"data-testid":i.TestHelper.generateId(e,"no-internet-connectivity"),children:[t.jsx(yt,{src:n,alt:"no-connectivity"}),t.jsx(xt,{weight:"semibold",children:"No connection found"}),t.jsx(bt,{children:"Check your internet connection and try again."}),t.jsx(wt,{onClick:o,children:"Try again"})]});exports.default=({id:s="location-modal",className:a,formValues:l,showLocationModal:h,mapPanZoom:c,interactiveMapPinIconUrl:u,mapApi:d,gettingCurrentLocationFetchMessage:p,mapBannerText:f,mustHavePostalCode:m,locationModalStyles:_,onClose:g,onConfirm:v,updateFormValues:y,locationListTitle:x,locationSelectionMode:w,disableSearch:L,addressFieldPlaceholder:P,searchBarIcon:T,bufferRadius:M,pinsOnlyIndicateCurrentLocation:z,legendItems:k})=>{const[C,S]=o.useState("double"),[E,I]=o.useState({}),[Z,B]=o.useState([]),[O,A]=o.useState(!0),[j,R]=o.useState(!1),{dispatchFieldEvent:F,addFieldEventListener:W,removeFieldEventListener:q}=i.useFieldEvent(),[V,U]=o.useState(!0),[G,K]=o.useState(!1),[Y,X]=o.useState(!1),[J,Q]=o.useState(!1),[tt,et]=o.useState(),[nt,it]=o.useState(),ot=o.useRef(!0),rt=o.useContext(r.ThemeContext),st=o.useCallback(((t,e)=>{S((n=>"double"===n||e&&n!==e?n:t))}),[]),at=o.useCallback((async()=>{R(!0);if(!!F("get-current-location",s)){const t={};try{t.payload=await i.GeoLocationHelper.getCurrentLocation()}catch(e){t.errors=e}return F("set-current-location",s,t),t.payload}}),[F,s]),lt=o.useCallback((()=>{I(l||{})}),[l]),ht=o.useCallback((()=>{ot.current=!0,g()}),[g]),ct=o.useCallback((()=>{lt(),ht()}),[ht,lt]),ut=o.useCallback((t=>{const e=i.lodash.exports.isEmpty(t?.detail)?E:t?.detail;v(e),ht()}),[ht,v,E]),dt=()=>{!F("before-hide-permission-modal",s)||K(!1)};o.useEffect((()=>{const t={"error-end":t=>{const e=t.detail?.payload?.errorType;if(e)switch(e){case"OneMapError":case"GetLocationTimeoutError":ht()}},"set-selectable-pins":t=>{const e=t.detail.pins;Array.isArray(e)?B(e):X(!0)},"confirm-location":ut,"hide-permission-modal":()=>{K(!1)},"dismiss-location-modal":ct,"trigger-get-current-location":at};return Object.entries(t).forEach((([t,e])=>{W(t,s,e)})),()=>{Object.entries(t).forEach((([t,e])=>{q(t,s,e)}))}}),[W,at,ct,ht,ut,s,q]),o.useEffect((()=>{if(!window)return;const t=matchMedia(`(max-width: ${n.Breakpoint["lg-max"]({theme:rt})}px)`);S(t.matches?"map":"double");const e=()=>U(!0),i=()=>U(!1),o=t=>{S(t.matches?"map":"double")};return window.addEventListener("online",e),window.addEventListener("offline",i),t.addEventListener("change",o),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",i),t.removeEventListener("change",o)}}),[]),o.useEffect((()=>{if(!h)return void S((t=>"double"!==t?"map":t));(async()=>{const{lat:t,lng:e}=l||{};t||e?ot.current&&F("get-selectable-pins",s,{lat:t,lng:e}):await at(),ot.current=!1})()}),[F,l,at,s,h]),o.useEffect((()=>{i.lodash.exports.isEmpty(E)||st("map","search")}),[E,j,st]),o.useEffect((()=>{I(l||{})}),[l]);return t.jsxs(t.Fragment,{children:[t.jsx($,{src:b,alt:"no internet connectivity"}),t.jsx(e.Modal,{id:i.TestHelper.generateId(s,"modal",h?"show":"hide"),className:`${a}-location-modal`,show:h,children:t.jsx(N,{id:i.TestHelper.generateId(s,"modal-box"),className:`${a}-modal-box`,showCloseButton:!1,locationModalStyles:_,children:V?t.jsxs(t.Fragment,{children:[t.jsx(gt,{id:s,className:a,onCancel:ct,onConfirm:()=>{!F("click-confirm-location",s,E)||ut()},updateFormValues:y,gettingCurrentLocation:j,panelInputMode:C,selectedAddressInfo:E,mapPickedLatLng:tt,formValues:l,onChangeSelectedAddressInfo:I,handleApiErrors:t=>{const e=(e,n)=>{!F("error",s,{payload:{errorType:e},errors:t})||n()};R(!1),t instanceof i.OneMapError?e("OneMapError",(()=>{lt(),X(!0)})):(A(!1),t instanceof i.GeolocationPositionErrorWrapper&&t?.code?.toString()===GeolocationPositionError.TIMEOUT.toString()?e("GetLocationTimeoutError",(()=>{Q(!0)})):e("GetLocationError",(()=>{K(!0)})))},onGetLocationCallback:(t,e)=>{R(!1),A(!0),it({lat:t,lng:e})},setSinglePanelMode:st,showLocationModal:h,mapApi:d,gettingCurrentLocationFetchMessage:p,mustHavePostalCode:m,locationListTitle:x,restrictLocationSelection:"pins-only"===w,selectablePins:Z,disableSearch:L,addressFieldPlaceholder:P,searchBarIcon:T,bufferRadius:M}),t.jsx(D,{id:s,className:a,panelInputMode:C,locationAvailable:O,gettingCurrentLocation:j,showLocationModal:h,legendItems:k,selectedLocationCoord:{lat:E.lat,lng:E.lng},getCurrentLocation:at,onMapCenterChange:t=>{et(t)},interactiveMapPinIconUrl:u,mapPanZoom:c,mapBannerText:f,disableSelectionFromMap:"pins-only"===w,disableSelectedLocationMarker:"pins-only"===w,selectablePins:Z,pinsOnlyIndicateCurrentLocation:z&&"pins-only"===w,currentLocation:nt})]}):t.jsx(Lt,{id:s,cachedImage:b,refreshNetwork:()=>{try{navigator.onLine&&U(!0)}catch(t){}}})})}),(()=>{if(V&&h)return Y?t.jsx(i.Prompt,{id:i.TestHelper.generateId(s,"onemap-error"),"data-testid":i.TestHelper.generateId(s,"onemap-error"),title:"Map not available",size:"large",show:!0,image:t.jsx(H,{src:"https://assets.life.gov.sg/web-frontend-engine/img/common/error.svg"}),description:t.jsxs(i.Description,{weight:"regular",children:["Sorry, there was a problem with the map. You’ll not be able to enter the location right now. Please try again later.",t.jsx("br",{}),t.jsx("br",{}),"Do note that you’ll not be able to submit your report without entering the location."]}),buttons:[{id:"ok",title:"OK",onClick:()=>{X(!1),ht()}}]}):G?t.jsx(i.Prompt,{id:i.TestHelper.generateId(s,"get-location-error"),"data-testid":i.TestHelper.generateId(s,"get-location-error"),title:"Enable location settings",size:"large",show:!0,description:"We need your permission to determine your location. Enable location access in your browser and device settings, or enter your location manually.",buttons:[{id:"ok",title:"OK",onClick:dt}]}):J?t.jsx(i.Prompt,{id:i.TestHelper.generateId(s,"get-location-timeout-error"),"data-testid":i.TestHelper.generateId(s,"get-location-timeout-error"),title:"Something went wrong",size:"large",show:!0,image:t.jsx(H,{src:"https://assets.life.gov.sg/web-frontend-engine/img/icons/get-location-timeout.svg"}),description:t.jsx(i.Description,{weight:"regular",children:"It’s taking longer than expected to retrieve your location. Please exit the map and try again."}),buttons:[{id:"ok",title:"OK",onClick:()=>{Q(!1),ht()}}]}):void 0})()]})};
393
- //# sourceMappingURL=location-modal.5d849c88.js.map
393
+ //# sourceMappingURL=location-modal.ff55a907.js.map