@solostylist/ui-kit 1.0.95 → 1.0.96

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
- /** Alt text for accessibility */
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 skeleton loading states.
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
- * - Skeleton placeholder while image loads
31
- * - Smooth transition from skeleton to loaded image
32
- * - Responsive sizing with fallback dimensions
33
- * - Customizable skeleton variants
34
- * - Automatic dimension handling
35
- * - Accessibility support with alt text
36
- * - Performance optimization with display toggling
37
- *
38
- * @param props - SLazyImageProps with image configuration
39
- * @returns JSX.Element - Image with loading state management
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, alt, height, width, className, style, minWidth, minHeight, }: SLazyImageProps) => React.JSX.Element;
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 s } from "../jsx-runtime-DywqP_6a.js";
2
- import { useId as w, useState as n, useEffect as x } from "react";
3
- import { useTheme as j, Box as L, Skeleton as b } from "@mui/material";
4
- const R = ({
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: o = "rounded",
7
- alt: r,
8
- height: t,
9
- width: i,
10
- className: m,
11
- style: d,
12
- minWidth: g = "auto",
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 l = w(), f = j(), [e, h] = n({
16
- width: i || "100%",
17
- height: t || "auto"
18
- }), [a, p] = n(!1);
19
- return x(() => {
20
- h({
21
- width: i || "100%",
22
- height: t || "auto"
23
- });
24
- }, [i, t]), /* @__PURE__ */ s.jsxs(L, { height: e.height, width: e.width, children: [
25
- !a && /* @__PURE__ */ s.jsx(
26
- b,
27
- {
28
- variant: o,
29
- id: `image-skeleton-${l}`,
30
- animation: "wave",
31
- style: { height: e.height, width: e.width, minWidth: g, minHeight: c, ...d }
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
- R as default
62
+ y as default
59
63
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "registry": "https://registry.npmjs.org"
5
5
  },
6
- "version": "1.0.95",
6
+ "version": "1.0.96",
7
7
  "description": "advanced ui kit for solostylist",
8
8
  "private": false,
9
9
  "type": "module",