@tantainnovative/ndpr-toolkit
Version:
Nigeria Data Protection Toolkit — enterprise-grade compliance components for the Nigeria Data Protection Act (NDPA) 2023
1 lines • 1.87 kB
JavaScript
;var chunk7563FVMY_js=require('./chunk-7563FVMY.js'),chunkRFPLZDIO_js=require('./chunk-RFPLZDIO.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var p=react.createContext({}),l=class extends react.Component{constructor(e){super(e);this.reset=()=>{this.setState({error:null});};this.state={error:null};}static getDerivedStateFromError(e){return {error:e}}componentDidCatch(e,r){var o,n;(n=(o=this.props).onError)==null||n.call(o,e,r);}render(){var r;let{error:e}=this.state;if(e){let{fallback:o}=this.props;return typeof o=="function"?o(e,this.reset):o!==void 0?o:jsxRuntime.jsxs("div",{role:"alert",style:{padding:"16px",border:"1px solid #e53e3e",borderRadius:"4px",backgroundColor:"#fff5f5",color:"#c53030"},children:[jsxRuntime.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"16px"},children:(r=this.props.errorTitle)!=null?r:"Something went wrong"}),jsxRuntime.jsx("p",{style:{margin:0,fontSize:"14px"},children:e.message})]})}return this.props.children}},x=o=>{var n=o,{children:t,fallback:c,onError:e}=n,r=chunkRFPLZDIO_js.c(n,["children","fallback","onError"]);var u;let m=react.useMemo(()=>{if(!r.theme)return;let i={};return r.theme.primary&&(i["--ndpr-primary"]=r.theme.primary),r.theme.primaryHover&&(i["--ndpr-primary-hover"]=r.theme.primaryHover),r.theme.primaryForeground&&(i["--ndpr-primary-foreground"]=r.theme.primaryForeground),Object.keys(i).length>0?i:void 0},[r.theme]),y=(u=react.useMemo(()=>chunk7563FVMY_js.b(r.locale),[r.locale]).common.error)!=null?u:"Something went wrong";return jsxRuntime.jsx(p.Provider,{value:r,children:jsxRuntime.jsx(l,{fallback:c,onError:e,errorTitle:y,children:m?jsxRuntime.jsx("div",{style:m,children:t}):t})})};function C(){return react.useContext(p)}function S(){let{locale:t}=react.useContext(p);return react.useMemo(()=>chunk7563FVMY_js.b(t),[t])}exports.a=x;exports.b=C;exports.c=S;