@muraldevkit/ui-toolkit 4.61.2-dev-L2yg.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.
- package/dist/components/image/MrlAnimatedImage/MrlAnimatedImage.d.ts +17 -0
- package/dist/components/image/MrlAnimatedImage/constants.d.ts +78 -0
- package/dist/components/image/MrlAnimatedImage/hooks/useAnimationControl.d.ts +22 -0
- package/dist/components/image/MrlAnimatedImage/index.d.ts +2 -0
- package/dist/components/image/MrlAnimatedImage/utils.d.ts +36 -0
- package/dist/components/image/index.d.ts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/panel/MrlPanelContext/MrlPanelContext.d.ts +9 -4
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useImagePreload/index.d.ts +26 -0
- package/dist/hooks/useReducedMotion/index.d.ts +7 -0
- package/dist/hooks/useScrollbarInfo/index.d.ts +4 -14
- package/dist/index.js +1 -1
- package/dist/styles/MrlAnimatedImage/module.scss +46 -0
- package/dist/styles.css +1 -0
- package/package.json +1 -1
|
@@ -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,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';
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export type MrlPanelContextState = {
|
|
3
|
+
hasScrollbar: boolean;
|
|
4
|
+
scrollbarWidth: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const initialState: {
|
|
7
|
+
hasScrollbar: boolean;
|
|
8
|
+
scrollbarWidth: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const MrlPanelContext: React.Context<MrlPanelContextState>;
|
|
6
11
|
/**
|
|
7
12
|
* Returns the MrlPanelContext state.
|
|
8
13
|
*
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -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 {};
|
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export type
|
|
3
|
-
/** Indicates if a horizontal scrollbar is present */
|
|
2
|
+
export type UseScrollbarInfoReturn<T extends HTMLElement> = {
|
|
4
3
|
hasHorizontalScrollbar: boolean;
|
|
5
|
-
/** Indicates if a vertical scrollbar is present */
|
|
6
4
|
hasVerticalScrollbar: boolean;
|
|
7
|
-
/** Width in pixels of the vertical scrollbar (0 for overlay scrollbars) */
|
|
8
|
-
verticalScrollbarWidth: number;
|
|
9
|
-
/** Height in pixels of the horizontal scrollbar (0 for overlay scrollbars) */
|
|
10
|
-
horizontalScrollbarHeight: number;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Return type for the `useScrollbarInfo` hook.
|
|
14
|
-
*/
|
|
15
|
-
export type UseScrollbarInfoReturn<T extends HTMLElement> = ScrollbarInfo & {
|
|
16
5
|
scrollableContainerRef: React.MutableRefObject<T | null>;
|
|
6
|
+
scrollbarWidth: number;
|
|
17
7
|
};
|
|
18
8
|
/**
|
|
19
|
-
* Custom hook that provides information about the presence and
|
|
9
|
+
* Custom hook that provides information about the presence and width of scrollbars
|
|
20
10
|
* in a scrollable container.
|
|
21
11
|
*
|
|
22
|
-
* @returns {UseScrollbarInfoReturn}
|
|
12
|
+
* @returns {UseScrollbarInfoReturn} hasHorizontalScrollbar, hasVerticalScrollbar and scrollbarWidth values.
|
|
23
13
|
*/
|
|
24
14
|
export declare function useScrollbarInfo<T extends HTMLElement>(): UseScrollbarInfoReturn<T>;
|