@solostylist/ui-kit 1.0.95 → 1.0.97
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,42 +1,75 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { SkeletonProps } from '@mui/material';
|
|
3
3
|
/**
|
|
4
|
-
* Props interface for SLazyImage component
|
|
4
|
+
* Props interface for SLazyImage component with enhanced lazy loading capabilities
|
|
5
|
+
*
|
|
6
|
+
* Extends standard HTML image attributes while providing additional configuration
|
|
7
|
+
* for skeleton loading states, responsive dimensions, and performance optimizations.
|
|
5
8
|
*/
|
|
6
|
-
export interface SLazyImageProps {
|
|
7
|
-
/** Image source URL */
|
|
9
|
+
export interface SLazyImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
10
|
+
/** Image source URL - triggers loading and skeleton-to-image transition */
|
|
8
11
|
src: string;
|
|
9
|
-
/**
|
|
10
|
-
alt: string;
|
|
11
|
-
/** CSS class name */
|
|
12
|
-
className?: string;
|
|
13
|
-
/** Skeleton variant while loading */
|
|
12
|
+
/** Skeleton variant while loading - affects border radius and animation style */
|
|
14
13
|
variant?: SkeletonProps['variant'];
|
|
15
|
-
/** Custom styles */
|
|
14
|
+
/** Custom styles applied to both skeleton and loaded image */
|
|
16
15
|
style?: React.CSSProperties;
|
|
17
|
-
/** Image height */
|
|
16
|
+
/** Image height - supports responsive units, falls back to 'auto' if not provided */
|
|
18
17
|
height?: number | string;
|
|
19
|
-
/** Image width */
|
|
18
|
+
/** Image width - supports responsive units, falls back to '100%' if not provided */
|
|
20
19
|
width?: number | string;
|
|
21
|
-
/** Minimum width */
|
|
20
|
+
/** Minimum width constraint for skeleton and image */
|
|
22
21
|
minWidth?: number | string;
|
|
23
|
-
/** Minimum height */
|
|
22
|
+
/** Minimum height constraint for skeleton and image */
|
|
24
23
|
minHeight?: number | string;
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
|
-
* SLazyImage - An optimized image component with
|
|
26
|
+
* SLazyImage - An optimized lazy-loading image component with enhanced performance and UX.
|
|
27
|
+
*
|
|
28
|
+
* This component provides a seamless loading experience by displaying a Material-UI skeleton
|
|
29
|
+
* placeholder while the image loads, then smoothly transitioning to the loaded image.
|
|
30
|
+
* Built with performance optimizations and proper theme integration.
|
|
28
31
|
*
|
|
29
32
|
* Key features:
|
|
30
|
-
* -
|
|
31
|
-
* -
|
|
32
|
-
* -
|
|
33
|
-
* -
|
|
34
|
-
* -
|
|
35
|
-
* -
|
|
36
|
-
* -
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
33
|
+
* - **Performance Optimized**: Uses display toggling instead of opacity for better rendering performance
|
|
34
|
+
* - **Theme Integration**: Leverages useTheme hook for consistent border radius handling across variants
|
|
35
|
+
* - **Smooth Transitions**: Clean skeleton-to-image transition with proper dimension management
|
|
36
|
+
* - **Responsive Design**: Intelligent dimension handling with responsive fallbacks
|
|
37
|
+
* - **Customizable Variants**: Supports Material-UI skeleton variants (rectangular, rounded, circular)
|
|
38
|
+
* - **Memory Efficient**: Proper state management prevents unnecessary re-renders
|
|
39
|
+
* - **Accessibility Ready**: Maintains all standard HTML image attributes and behaviors
|
|
40
|
+
*
|
|
41
|
+
* Performance improvements:
|
|
42
|
+
* - Display toggling (display: none/block) instead of opacity transitions for better GPU performance
|
|
43
|
+
* - Direct prop usage eliminates unnecessary state and re-renders
|
|
44
|
+
* - Theme-aware border radius calculation reduces style recalculations
|
|
45
|
+
* - Simplified onLoad handler reduces execution overhead
|
|
46
|
+
*
|
|
47
|
+
* @param props - SLazyImageProps configuration object
|
|
48
|
+
* @returns JSX.Element - Optimized image component with loading state management
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* // Basic usage with skeleton loading
|
|
53
|
+
* <SLazyImage src="/image.jpg" width={300} height={200} />
|
|
54
|
+
*
|
|
55
|
+
* // Circular avatar with custom dimensions
|
|
56
|
+
* <SLazyImage
|
|
57
|
+
* src="/avatar.jpg"
|
|
58
|
+
* variant="circular"
|
|
59
|
+
* width={80}
|
|
60
|
+
* height={80}
|
|
61
|
+
* alt="User avatar"
|
|
62
|
+
* />
|
|
63
|
+
*
|
|
64
|
+
* // Responsive image with custom styling
|
|
65
|
+
* <SLazyImage
|
|
66
|
+
* src="/hero.jpg"
|
|
67
|
+
* variant="rounded"
|
|
68
|
+
* style={{ objectFit: 'cover' }}
|
|
69
|
+
* width="100%"
|
|
70
|
+
* height={400}
|
|
71
|
+
* />
|
|
72
|
+
* ```
|
|
40
73
|
*/
|
|
41
|
-
declare const SLazyImage: ({ src, variant,
|
|
74
|
+
declare const SLazyImage: ({ src, variant, height, width, style, minWidth, minHeight, ...props }: SLazyImageProps) => React.JSX.Element;
|
|
42
75
|
export default SLazyImage;
|
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { useId as
|
|
3
|
-
import { useTheme as j, Box as
|
|
4
|
-
const
|
|
1
|
+
import { j as a } from "../jsx-runtime-DywqP_6a.js";
|
|
2
|
+
import { useId as x, useState as f } from "react";
|
|
3
|
+
import { useTheme as j, Box as d, Skeleton as L } from "@mui/material";
|
|
4
|
+
const y = ({
|
|
5
5
|
src: u,
|
|
6
|
-
variant:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
minHeight: c = "auto"
|
|
6
|
+
variant: e = "rounded",
|
|
7
|
+
height: o = "auto",
|
|
8
|
+
width: s = "100%",
|
|
9
|
+
style: t,
|
|
10
|
+
minWidth: m = "auto",
|
|
11
|
+
minHeight: n = "auto",
|
|
12
|
+
...i
|
|
14
13
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/* @__PURE__ */ s.jsx(
|
|
35
|
-
"img",
|
|
36
|
-
{
|
|
37
|
-
src: u,
|
|
38
|
-
alt: r,
|
|
39
|
-
style: {
|
|
40
|
-
height: e.height,
|
|
41
|
-
width: e.width,
|
|
42
|
-
display: a ? "block" : "none",
|
|
43
|
-
borderRadius: o === "circular" ? "50%" : o === "rounded" ? f.shape.borderRadius : "0px",
|
|
44
|
-
...d
|
|
45
|
-
},
|
|
46
|
-
className: m,
|
|
47
|
-
onLoad: () => {
|
|
48
|
-
(!t || !i) && h({
|
|
49
|
-
width: e.width,
|
|
50
|
-
height: e.height
|
|
51
|
-
}), p(!0);
|
|
14
|
+
const c = x(), l = j(), [r, p] = f(!1);
|
|
15
|
+
return (
|
|
16
|
+
// Container box maintains consistent dimensions throughout the loading process
|
|
17
|
+
// This prevents layout shifts and provides stable positioning for both skeleton and image
|
|
18
|
+
/* @__PURE__ */ a.jsxs(d, { height: o, width: s, children: [
|
|
19
|
+
!r && /* @__PURE__ */ a.jsx(
|
|
20
|
+
L,
|
|
21
|
+
{
|
|
22
|
+
variant: e,
|
|
23
|
+
id: `image-skeleton-${c}`,
|
|
24
|
+
animation: "wave",
|
|
25
|
+
style: {
|
|
26
|
+
height: o,
|
|
27
|
+
width: s,
|
|
28
|
+
minWidth: m,
|
|
29
|
+
minHeight: n,
|
|
30
|
+
...t
|
|
31
|
+
// User styles applied to skeleton for consistency
|
|
32
|
+
}
|
|
52
33
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
),
|
|
35
|
+
/* @__PURE__ */ a.jsx(
|
|
36
|
+
d,
|
|
37
|
+
{
|
|
38
|
+
component: "img",
|
|
39
|
+
src: u,
|
|
40
|
+
style: {
|
|
41
|
+
height: o,
|
|
42
|
+
width: s,
|
|
43
|
+
// Performance optimization: display toggling instead of opacity transitions
|
|
44
|
+
// This approach reduces GPU usage and improves rendering performance
|
|
45
|
+
display: r ? "block" : "none",
|
|
46
|
+
// Theme-aware border radius calculation for consistent styling
|
|
47
|
+
// Matches Material-UI skeleton variants with proper theme integration
|
|
48
|
+
borderRadius: e === "circular" ? "50%" : e === "rounded" ? l.shape.borderRadius : "0px",
|
|
49
|
+
...t
|
|
50
|
+
// User-provided styles override defaults
|
|
51
|
+
},
|
|
52
|
+
onLoad: () => {
|
|
53
|
+
p(!0);
|
|
54
|
+
},
|
|
55
|
+
...i
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
] })
|
|
59
|
+
);
|
|
56
60
|
};
|
|
57
61
|
export {
|
|
58
|
-
|
|
62
|
+
y as default
|
|
59
63
|
};
|
|
@@ -6020,6 +6020,10 @@ export declare const components: {
|
|
|
6020
6020
|
};
|
|
6021
6021
|
};
|
|
6022
6022
|
MuiTooltip: {
|
|
6023
|
+
defaultProps: {
|
|
6024
|
+
placement: "top";
|
|
6025
|
+
arrow: true;
|
|
6026
|
+
};
|
|
6023
6027
|
styleOverrides: {
|
|
6024
6028
|
tooltip: {
|
|
6025
6029
|
backgroundColor: "var(--s-palette-background-default)";
|