@clicktap/ui 0.18.10 → 0.19.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 +1 @@
1
- import{jsx as i}from"react/jsx-runtime";import{forwardRef as g,useId as E,useEffect as w,useCallback as A}from"react";import{ModalOverlay as p}from"react-aria-components";import{motion as _,AnimatePresence as C}from"framer-motion";import{useDialogTrigger as I}from"../DialogTrigger/DialogTrigger.js";import{cn as P}from"../../utils/cn.js";const k="body > [inert]:not(#__next):not([data-overlay-container])";function f(){document.querySelectorAll(k).forEach(e=>e.removeAttribute("inert"))}function F(e){return!!(e.closest("[data-overlay-container]")||e.closest("#__next"))}const N=g(({style:e,children:o,...t},r)=>{const a=typeof e=="function"?e(t):e;return i(p,{...t,ref:r,style:a,children:o})});let s=null;function S(){return typeof window>"u"?null:(s||(s=_.create(N)),s)}const m=S();function v({animate:e,animation:o,setAnimation:t,className:r,animationVariants:a,isDismissable:b=!0,children:d,...y}){const O=E();w(()=>{f();const n=new MutationObserver(()=>{f()});return n.observe(document.body,{attributes:!0,attributeFilter:["inert"],subtree:!1}),()=>n.disconnect()},[]);const{key:h,shouldCloseOnInteractOutside:l,...M}=y,x=A(n=>l?l(n):F(n),[l]),u={isDismissable:b,shouldCloseOnInteractOutside:x,className:P("bg-black/30","fixed top-0 left-0","z-[1000]","w-screen h-[var(--visual-viewport-height)]",r),...M};return m?i(m,{isExiting:o==="hidden",onAnimationComplete:n=>{t(c=>n==="hidden"&&c==="hidden"?"unmounted":c)},variants:a||{hidden:{opacity:0,backdropFilter:"blur(0px)",transition:{delay:.08}},visible:{opacity:1,backdropFilter:"blur(8px)"}},initial:"hidden",animate:e,exit:"hidden",...u,children:d},h||O):i(p,{...u,children:d})}function L(e){const{isOpen:o}=e,{animation:t,setAnimation:r}=I();return o!==void 0?i(C,{children:o&&i(v,{...e,animate:"visible",animation:t,setAnimation:r})}):i(v,{...e,animate:t,animation:t,setAnimation:r})}export{L as ModalOverlay,L as default};
1
+ import{jsx as i}from"react/jsx-runtime";import{forwardRef as _,useId as A,useEffect as w,useCallback as k}from"react";import{ModalOverlay as y}from"react-aria-components";import{motion as C,AnimatePresence as I}from"framer-motion";import{useDialogTrigger as N}from"../DialogTrigger/DialogTrigger.js";import{cn as P}from"../../utils/cn.js";const F="body > [inert]:not(#__next):not([data-overlay-container])";function R(t){return Object.keys(t).some(e=>e.startsWith("__react"))}function b(){document.querySelectorAll(F).forEach(t=>t.removeAttribute("inert"))}function S(t){return!!(t.closest("[data-overlay-container]")||t.closest("#__next"))}const T=_(({style:t,children:e,...n},o)=>{const s=typeof t=="function"?t(n):t;return i(y,{...n,ref:o,style:s,children:e})});let d=null;function j(){return typeof window>"u"?null:(d||(d=C.create(T)),d)}const v=j();function p({animate:t,animation:e,setAnimation:n,className:o,animationVariants:s,isDismissable:O=!0,children:m,...h}){const M=A();w(()=>{b();const r=new MutationObserver(a=>{for(const u of a)if(u.type==="attributes"&&u.attributeName==="inert"){const c=u.target;c.parentElement===document.body?b():R(c)||c.removeAttribute("inert")}});return r.observe(document.body,{attributes:!0,attributeFilter:["inert"],subtree:!0}),()=>r.disconnect()},[]);const{key:E,shouldCloseOnInteractOutside:l,...g}=h,x=k(r=>l?l(r):S(r),[l]),f={isDismissable:O,shouldCloseOnInteractOutside:x,className:P("bg-black/30","fixed top-0 left-0","z-[1000]","w-screen h-[var(--visual-viewport-height)]",o),...g};return v?i(v,{isExiting:e==="hidden",onAnimationComplete:r=>{n(a=>r==="hidden"&&a==="hidden"?"unmounted":a)},variants:s||{hidden:{opacity:0,backdropFilter:"blur(0px)",transition:{delay:.08}},visible:{opacity:1,backdropFilter:"blur(8px)"}},initial:"hidden",animate:t,exit:"hidden",...f,children:m},E||M):i(y,{...f,children:m})}function B(t){const{isOpen:e}=t,{animation:n,setAnimation:o}=N();return e!==void 0?i(I,{children:e&&i(p,{...t,animate:"visible",animation:n,setAnimation:o})}):i(p,{...t,animate:n,animation:n,setAnimation:o})}export{B as ModalOverlay,B as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clicktap/ui",
3
- "version": "0.18.10",
3
+ "version": "0.19.0",
4
4
  "private": false,
5
5
  "author": "Clicktap",
6
6
  "description": "A library of React UI components and low-level hooks.",
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns a safe, user-facing error message.
3
+ *
4
+ * In development, logs the full error (including HTTP status when available)
5
+ * to the console. In all environments, returns the `fallback` string instead
6
+ * of leaking internal details to the UI.
7
+ */
8
+ export declare function getSafeErrorMessage(error: unknown, fallback?: string): string;
9
+ export default getSafeErrorMessage;
package/utils/error.js ADDED
@@ -0,0 +1 @@
1
+ import{isDevelopment as o}from"./env.js";const n="Something went wrong. Please try again later.";function i(e,s=n){if(o){const t=e!=null&&typeof e=="object"&&"response"in e&&typeof e.response=="object"?e.response?.status:void 0;console.error("[Request Error]",...t?[t]:[],e)}return s}export{i as default,i as getSafeErrorMessage};