@muraldevkit/ui-toolkit 4.61.1 → 4.62.0-dev-3JXS.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.
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import { MrlAnimatedImageProps } from './constants';
3
+ /**
4
+ * MrlAnimatedImage provides an accessible image component with support
5
+ * for animated images (GIFs), reduced motion preferences, and proper ARIA attributes.
6
+ *
7
+ * Features:
8
+ * - Automatic `prefers-reduced-motion` detection
9
+ * - Play/pause controls for animated images
10
+ * - Live region announcements for state changes
11
+ * - Proper decorative image handling
12
+ * - Error state with accessible fallback
13
+ *
14
+ * @param props - component props
15
+ * @returns a MrlAnimatedImage React component.
16
+ */
17
+ export declare const MrlAnimatedImage: React.ForwardRefExoticComponent<Omit<MrlAnimatedImageProps, "ref"> & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,78 @@
1
+ import * as React from 'react';
2
+ export type ImageMotion = 'static' | 'animated';
3
+ export interface MrlAnimatedImageProps extends Omit<React.ComponentPropsWithRef<'figure'>, 'children' | 'onError'> {
4
+ /**
5
+ * Image source URL (string path).
6
+ * Accepts absolute URLs (e.g., "https://example.com/image.jpg") or
7
+ * relative URLs (e.g., "/images/photo.jpg" or "../assets/image.png").
8
+ * Works with images from any domain on the internet.
9
+ */
10
+ src: string;
11
+ /**
12
+ * Alternative text for the image. Required unless decorative={true}
13
+ */
14
+ alt?: string;
15
+ /**
16
+ * Whether the image is decorative (no alt text needed)
17
+ * @default false
18
+ */
19
+ decorative?: boolean;
20
+ /**
21
+ * Image motion type
22
+ * @default 'static'
23
+ */
24
+ motion?: ImageMotion;
25
+ /**
26
+ * Static image source for animated images (used when paused).
27
+ * Accepts absolute or relative URL strings, same format as `src`.
28
+ * Required when motion="animated"
29
+ */
30
+ staticSrc?: string;
31
+ /**
32
+ * Caption text to display below the image
33
+ */
34
+ caption?: string;
35
+ /**
36
+ * Image width (for layout stability)
37
+ */
38
+ width?: number | string;
39
+ /**
40
+ * Image height (for layout stability)
41
+ */
42
+ height?: number | string;
43
+ /**
44
+ * Aspect ratio (for layout stability, e.g., "16/9")
45
+ */
46
+ aspectRatio?: string;
47
+ /**
48
+ * Whether animation should autoplay
49
+ * @default false
50
+ */
51
+ autoplay?: boolean;
52
+ /**
53
+ * Whether animation is essential (bypasses reduced motion)
54
+ * @default false
55
+ */
56
+ motionEssential?: boolean;
57
+ /**
58
+ * Custom CSS class name
59
+ */
60
+ className?: string;
61
+ /**
62
+ * A string value used for data-qa attribute
63
+ */
64
+ ['data-qa']?: string;
65
+ /**
66
+ * Loading behavior
67
+ * @default 'lazy'
68
+ */
69
+ loading?: 'lazy' | 'eager';
70
+ /**
71
+ * Callback when image fails to load
72
+ */
73
+ onError?: (error: Error) => void;
74
+ /**
75
+ * Callback when image loads successfully
76
+ */
77
+ onLoad?: () => void;
78
+ }
@@ -0,0 +1,22 @@
1
+ import { ImageMotion } from '../constants';
2
+ interface UseAnimationControlOptions {
3
+ autoplay?: boolean;
4
+ motion: ImageMotion;
5
+ motionEssential?: boolean;
6
+ }
7
+ interface UseAnimationControlReturn {
8
+ isPaused: boolean;
9
+ isPlaying: boolean;
10
+ shouldDisplayStatic: boolean;
11
+ toggleAnimation: () => void;
12
+ }
13
+ /**
14
+ * Hook to manage animation control state including play/pause and reduced motion integration
15
+ * @param options - Configuration options
16
+ * @param options.autoplay - Whether animation should autoplay
17
+ * @param options.motion - Image motion type
18
+ * @param options.motionEssential - Whether animation is essential (bypasses reduced motion)
19
+ * @returns Animation control state and functions
20
+ */
21
+ export declare function useAnimationControl({ autoplay, motion, motionEssential }: UseAnimationControlOptions): UseAnimationControlReturn;
22
+ export {};
@@ -0,0 +1,2 @@
1
+ export { MrlAnimatedImage } from './MrlAnimatedImage';
2
+ export type { MrlAnimatedImageProps, ImageMotion } from './constants';
@@ -0,0 +1,36 @@
1
+ import { ImageMotion } from './constants';
2
+ /**
3
+ * Determines the image source to display based on animation state
4
+ * @param params - Configuration parameters
5
+ * @param params.motion - Image motion type
6
+ * @param params.shouldDisplayStatic - Whether to display static image
7
+ * @param params.src - Primary image source
8
+ * @param params.staticSrc - Static fallback image source
9
+ * @returns The image source URL to display
10
+ */
11
+ export declare function getDisplayedSrc(params: {
12
+ motion: ImageMotion;
13
+ shouldDisplayStatic: boolean;
14
+ src: string;
15
+ staticSrc?: string;
16
+ }): string;
17
+ /**
18
+ * Resolves alt text based on decorative flag
19
+ * @param decorative - Whether the image is decorative
20
+ * @param alt - Alternative text for the image
21
+ * @returns Resolved alt text (empty string if decorative)
22
+ */
23
+ export declare function getResolvedAltText(decorative: boolean, alt?: string): string;
24
+ /**
25
+ * Generates accessible error message for screen readers
26
+ * @param decorative - Whether the image is decorative
27
+ * @param alt - Alternative text for the image
28
+ * @returns Error message for screen readers
29
+ */
30
+ export declare function getErrorMessage(decorative: boolean, alt?: string): string;
31
+ /**
32
+ * Generates play/pause announcement text
33
+ * @param isPaused - Whether animation is paused
34
+ * @returns Announcement text for screen readers
35
+ */
36
+ export declare function getPlayPauseAnnouncement(isPaused: boolean): string;
@@ -0,0 +1 @@
1
+ export * from './MrlAnimatedImage';
@@ -32,3 +32,4 @@ export * from './rovingTabindex';
32
32
  export * from './toolbar';
33
33
  export * from './filter';
34
34
  export * from './breadcrumb';
35
+ export * from './image';
@@ -2,3 +2,4 @@ export * from './useCoordinate';
2
2
  export * from './useBreakpoint';
3
3
  export * from './useElementDimensions';
4
4
  export * from './useScrollbarInfo';
5
+ export * from './useReducedMotion';
@@ -0,0 +1,26 @@
1
+ interface UseImagePreloadOptions {
2
+ /** Image source URL to preload */
3
+ src: string;
4
+ /** Whether preloading is enabled */
5
+ enabled?: boolean;
6
+ }
7
+ interface UseImagePreloadReturn {
8
+ /** Natural dimensions of the preloaded image */
9
+ dimensions: {
10
+ height: number | null;
11
+ width: number | null;
12
+ };
13
+ /** Whether the preload failed */
14
+ hasError: boolean;
15
+ /** Whether the image is currently loading */
16
+ isLoading: boolean;
17
+ }
18
+ /**
19
+ * Hook to preload an image and capture its natural dimensions.
20
+ * Useful for preventing layout shift when images load.
21
+ *
22
+ * @param options - Configuration options
23
+ * @returns Preload state including dimensions, loading state, and error state
24
+ */
25
+ export declare function useImagePreload({ src, enabled }: UseImagePreloadOptions): UseImagePreloadReturn;
26
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hook to detect user's reduced motion preference.
3
+ * Automatically updates when system preference changes.
4
+ *
5
+ * @returns {boolean} - true if user prefers reduced motion
6
+ */
7
+ export declare function useReducedMotion(): boolean;