@clicktap/ui 0.21.2 → 0.22.1
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,3 +1,11 @@
|
|
|
1
1
|
import { ImageProps } from 'next/image';
|
|
2
|
-
export
|
|
2
|
+
export type ExtendedImageProps = ImageProps & {
|
|
3
|
+
/** Reduce opacity to 50% (e.g., while waiting for data) */
|
|
4
|
+
dimmed?: boolean;
|
|
5
|
+
/** Hide image completely — opacity 0 (e.g., before grid rearrange) */
|
|
6
|
+
hidden?: boolean;
|
|
7
|
+
/** Fires when a new image has loaded after a src change */
|
|
8
|
+
onReady?: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function Image({ src, className, style, dimmed, hidden, onReady, onLoad: externalOnLoad, ...rest }: ExtendedImageProps): import("react/jsx-runtime").JSX.Element;
|
|
3
11
|
export default Image;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as u}from"react/jsx-runtime";import{useState as w,useRef as l,Component as j}from"react";import C from"next/image";import{cn as T}from"../../utils/cn.js";import x from"../../hooks/useIsClient.js";const v=new Set;function d(t){return typeof t=="string"?t:JSON.stringify(t)}class L extends j{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){if(this.state.hasError){v.add(d(this.props.src));const{src:r,alt:n,className:a,style:s,width:o,height:c}=this.props,i=typeof r=="string"?r:typeof r=="object"&&"src"in r?r.src:"";return u("img",{src:i,alt:n??"",className:a,style:s,width:o,height:c,loading:"lazy"})}return this.props.children}}function N({src:t,className:r,style:n,dimmed:a,hidden:s,onReady:o,onLoad:c,...i}){const[f,m]=w(!0),[E,I]=w(null),p=l(),y=l(t),S=l(o);S.current=o;const z=x(),h=a!==void 0||s!==void 0||o!==void 0;if(h){const e=d(t),b=d(y.current);e!==b&&(y.current=t,m(!0))}const g="width"in i&&"height"in i&&!("fill"in i)?{height:"auto",...n}:n,K=d(t);if(E===t||v.has(K)){const e=typeof t=="string"?t:typeof t=="object"&&"src"in t?t.src:"";return u("img",{src:e,alt:i.alt??"",className:r,style:g,width:"width"in i?i.width:void 0,height:"height"in i?i.height:void 0,loading:"lazy"})}return u(L,{src:t,alt:i.alt,className:r,style:g,width:"width"in i?i.width:void 0,height:"height"in i?i.height:void 0,children:u(C,{src:t,className:T(h?"transition-opacity duration-200 ease-in-out":"transition-[filter] ease-linear duration-200",!h&&z&&f&&"blur-md",r),style:{...g,...h?{opacity:s?0:f||a?.5:1}:{}},onError:()=>{p.current=setTimeout(()=>I(t),2e3)},onLoad:e=>{clearTimeout(p.current),m(!1),S.current?.(),typeof c=="function"&&c(e)},...i})})}export{N as Image,N as default};
|