@verifiedinc-public/shared-ui-elements 3.1.3 → 3.2.0

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.
@@ -0,0 +1 @@
1
+ "use strict";import{useRef as y,useInsertionEffect as O,useCallback as w,useState as d,useId as C,useEffect as m,useLayoutEffect as x}from"react";function k(e){return{set:t=>{const o=typeof t=="string"?t:JSON.stringify(t);localStorage.setItem(e,o)},get:()=>{const t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch{return t}return null},remove:()=>{localStorage.removeItem(e)}}}function A({type:e="text/plain"}){return{copy:async t=>{var o;if((o=navigator.clipboard)!=null&&o.write){const n={};switch(e){case"text/html":n["text/plain"]=new Blob([t],{type:"text/plain"}),n[e]=new Blob([t],{type:e});break;default:n[e]=new Blob([t],{type:e})}const s=[new ClipboardItem(n)];await navigator.clipboard.write(s)}else{const n=document.createElement("textarea");t instanceof Blob?n.value=await t.text():n.value=t.toString(),n.select(),document.execCommand("copy")}}}}function b(e,t=[]){const o=y(()=>{throw new Error("Cannot call an event handler while rendering.")});return O(()=>{o.current=e}),w((...n)=>{var s;return(s=o.current)==null?void 0:s.call(o,...n)},t)}function B(e={}){const{onClose:t,onOpen:o,open:n,id:s}=e,r=b(o),i=b(t),[u,l]=d(e.defaultOpen??!1),c=n??u,a=n!==void 0,g=C(),f=s??`disclosure-${g}`,v=w(()=>{a||l(!1),i?.()},[a,i]),h=w(()=>{a||l(!0),r?.()},[a,r]),E=w(()=>{c?v():h()},[c,h,v]);function S(p={}){return{...p,"aria-expanded":c,"aria-controls":f,onClick(L){var I;(I=p.onClick)==null||I.call(p,L),E()}}}function T(p={}){return{...p,hidden:!c,id:f}}return{open:c,onOpen:h,onClose:v,onToggle:E,isControlled:a,getButtonProps:S,getDisclosureProps:T}}function z(e){return new URLSearchParams(e??window.location.search)}function D(e,t=250){const[o,n]=d(e);return m(()=>{const s=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(s)}},[e,t]),o}function U(e,t={removeOnUnmount:!1}){const[o,n]=d("loading"),s=y(t);return m(()=>{let r=document.querySelector(`script[src="${e}"]`);const i=r?.getAttribute("data-status");if(i){n(i);return}if(r===null){r=document.createElement("script"),r.src=e,r.async=!0,r.setAttribute("data-status","loading"),document.body.appendChild(r);const u=()=>{r?.setAttribute("data-status","ready"),n("ready"),c()},l=()=>{r?.setAttribute("data-status","error"),n("error"),c()},c=()=>{r?.removeEventListener("load",u),r?.removeEventListener("error",l)};r.addEventListener("load",u),r.addEventListener("error",l);const a=s.current.removeOnUnmount;return()=>{a&&(r?.remove(),c())}}else n("unknown")},[e]),o}function W(e,t=500){const[o,n]=d(e),s=y(Date.now());return m(()=>{const r=Date.now(),i=r-s.current;if(i>=t)s.current=r,n(e);else{const u=t-i,l=window.setTimeout(()=>{s.current=Date.now(),n(e)},u);return()=>{window.clearTimeout(l)}}},[e,t]),o}function j(e){const[t,o]=d(()=>typeof e=="boolean"?e:!!e),n=w(s=>{if(typeof s=="boolean"){o(s);return}o(r=>!r)},[]);return[t,n]}function P(){const[e,t]=d({x:0,y:0}),o=w((...n)=>{if(n.length===1&&typeof n[0]=="object")window.scrollTo(n[0]);else if(n.length===2)window.scrollTo(n[0],n[1]);else throw new Error("Invalid arguments passed to scrollTo. Expected either ScrollToOptions object or x,y coordinates. See https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo")},[]);return x(()=>{const n=()=>{t({x:window.scrollX,y:window.scrollY})};return n(),window.addEventListener("scroll",n),()=>{window.removeEventListener("scroll",n)}},[]),{...e,scrollTo:o}}function H(){const[e,t]=d({width:window.innerWidth,height:window.innerHeight});return x(()=>{const o=()=>{t({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o)}},[]),e}function J(e,{threshold:t=0,root:o=null,rootMargin:n="0%",freezeOnceVisible:s=!1}={}){const[r,i]=d({isIntersecting:!1,entry:null});return m(()=>{const u=e?.current;let l;if(u){if(s&&r.isIntersecting)return;const c=g=>{const[f]=g;i({isIntersecting:f.isIntersecting,entry:f})},a=new IntersectionObserver(c,{threshold:t,root:o,rootMargin:n});a.observe(u),l=()=>{a.disconnect()}}return()=>{l&&l()}},[e,t,o,n,s,r.isIntersecting]),r}export{A as a,B as b,b as c,z as d,D as e,U as f,W as g,j as h,P as i,H as j,J as k,k as u};
@@ -0,0 +1 @@
1
+ "use strict";import f,{useMemo as d,useEffect as w}from"react";import*as m from"qrcode";function $(e){const[t,r]=f.useState(e),[s,o]=f.useState();return e!==t&&(o(t),r(e)),s}function v(e){const t=d(()=>m.create(e.data),[e.data]).modules.data;return d(()=>{const r=e.size/Math.sqrt(t.length);let s=`<svg viewBox="0 0 ${e.size} ${e.size}" xmlns="http://www.w3.org/2000/svg">`;const o=e.imageSize,i=(e.size-o)/2,a=(e.size-o)/2;for(let n=0;n<t.length;n++){const c=n%Math.sqrt(t.length)*r,u=Math.floor(n/Math.sqrt(t.length))*r,l=r/2,g=t[n]===1,h=c+r>=i&&c<i+o&&u+r>=a&&u<a+o;!g||h||(s+=`<rect x="${c}" y="${u}" width="${r}" height="${r}" rx="${l}" ry="${l}" fill='${e.fill||"#000000"}' />`)}return s+="</svg>",s},[t,e])}function z(e,t,r="mousedown",s={}){w(()=>{const o=i=>{const a=i.target;!a||!a.isConnected||(Array.isArray(e)?e.filter(n=>!!n.current).every(n=>n.current&&!n.current.contains(a)):e.current&&!e.current.contains(a))&&t(i)};return window.addEventListener(r,o,s),()=>{window.removeEventListener(r,o,s)}},[s,r,t,e])}export{z as a,$ as b,v as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "3.1.3",
3
+ "version": "3.2.0",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "keywords": [],
@@ -114,16 +114,17 @@
114
114
  "@mona-health/react-input-mask": "^3.0.3",
115
115
  "@mui/icons-material": "^5 || ^6",
116
116
  "@mui/material": "^5 || ^6",
117
+ "framer-motion": ">=11.15.0",
117
118
  "libphonenumber-js": "^1.11.11",
118
119
  "notistack": "^3.0.1",
119
120
  "qrcode": "^1.5.4",
120
121
  "react": "^18",
122
+ "react-datepicker": ">=7.6.0",
121
123
  "react-dnd": "^16.0.1",
122
124
  "react-dnd-html5-backend": "^16.0.1",
123
125
  "react-dom": "^18",
124
126
  "react-hook-form": "^7.52.1",
125
127
  "react-imask": "^7.6.1",
126
- "zod": "^3.23.8",
127
- "framer-motion": ">=11.15.0"
128
+ "zod": "^3.23.8"
128
129
  }
129
130
  }