@verifiedinc-public/shared-ui-elements 2.0.0 → 2.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.
@@ -1 +0,0 @@
1
- "use strict";import{useRef as S,useInsertionEffect as I,useCallback as s,useState as B,useId as O}from"react";function k(n){return{set:e=>{const r=typeof e=="string"?e:JSON.stringify(e);localStorage.setItem(n,r)},get:()=>{const e=localStorage.getItem(n);if(e)try{return JSON.parse(e)}catch{return e}return null},remove:()=>{localStorage.removeItem(n)}}}function P({type:n="text/plain"}){return{copy:async e=>{var r;if((r=navigator.clipboard)!=null&&r.write){const t={};switch(n){case"text/html":t["text/plain"]=new Blob([e],{type:"text/plain"}),t[n]=new Blob([e],{type:n});break;default:t[n]=new Blob([e],{type:n})}const o=[new ClipboardItem(t)];await navigator.clipboard.write(o)}else{const t=document.createElement("textarea");e instanceof Blob?t.value=await e.text():t.value=e.toString(),t.select(),document.execCommand("copy")}}}}function f(n,e=[]){const r=S(()=>{throw new Error("Cannot call an event handler while rendering.")});return I(()=>{r.current=n}),s((...t)=>{var o;return(o=r.current)==null?void 0:o.call(r,...t)},e)}function E(n={}){const{onClose:e,onOpen:r,open:t,id:o}=n,i=f(r),u=f(e),[b,g]=B(n.defaultOpen??!1),a=t??b,l=t!==void 0,y=O(),m=o??`disclosure-${y}`,p=s(()=>{l||g(!1),u?.()},[l,u]),d=s(()=>{l||g(!0),i?.()},[l,i]),w=s(()=>{a?p():d()},[a,d,p]);function x(c={}){return{...c,"aria-expanded":a,"aria-controls":m,onClick(h){var v;(v=c.onClick)==null||v.call(c,h),w()}}}function C(c={}){return{...c,hidden:!a,id:m}}return{open:a,onOpen:d,onClose:p,onToggle:w,isControlled:l,getButtonProps:x,getDisclosureProps:C}}function J(n){return new URLSearchParams(n??window.location.search)}export{P as a,E as b,f as c,J as d,k as u};