mui-image-alter 3.1.0 → 3.2.0

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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  </p>
7
7
  <div align="center">
8
8
 
9
- ![GitHub License](https://img.shields.io/github/license/mddanish00/mui-image-alter?style=flat-square) [![npm](https://img.shields.io/npm/v/mui-image-alter?style=flat-square)](https://www.npmjs.com/package/mui-image-alter) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/mui-image-alter%40latest?style=flat-square) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mddanish00/mui-image-alter/test.yml?style=flat-square) ![Coverage from badge.yml](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/mddanish00/83c2a74197bb80b661019a2747e71daa/raw/mui-image-alter_coverage__main.json) [![Buy Me A Coffee](https://img.shields.io/badge/mddanish00-black?style=flat-square&logo=buymeacoffee&logoColor=black&label=Buy%20Me%20A%20Coffee&labelColor=%23FFDD00)](https://www.buymeacoffee.com/mddanish00)
9
+ ![GitHub License](https://img.shields.io/github/license/mddanish00/mui-image-alter?style=flat-square) [![npm](https://img.shields.io/npm/v/mui-image-alter?style=flat-square)](https://www.npmjs.com/package/mui-image-alter) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/mui-image-alter%40latest?style=flat-square) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mddanish00/mui-image-alter/test.yml?style=flat-square) ![Coverage from badge.yml](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/mddanish00/83c2a74197bb80b661019a2747e71daa/raw/mui-image-alter_coverage__main.json) [![Buy Me A Coffee](https://img.shields.io/badge/mddanish00-black?style=flat-square&logo=buymeacoffee&logoColor=black&label=Buy%20Me%20A%20Coffee&labelColor=%23FFDD00)](https://www.buymeacoffee.com/mddanish00) [![Ko-fi](https://img.shields.io/badge/mddanish00-%2372A4F2?style=flat-square&logo=kofi&label=Ko-fi&labelColor=%23F4EFE7)](https://ko-fi.com/mddanish00)
10
10
 
11
11
  </div>
12
12
  <p align="center">
@@ -16,7 +16,7 @@
16
16
  <strong><a href="https://mddanish00.github.io/mui-image-alter/">Demo Playground ↗️</a></strong> <br />
17
17
  </p>
18
18
 
19
- ### If you're already using [Material UI v5](https://material-ui.com), why not display your images according to the Material guidelines too?
19
+ ### If you're already using [Material UI v5 or v6](https://material-ui.com), why not display your images according to the Material guidelines too?
20
20
 
21
21
  > Illustrations and photographs may load and transition in three phases at staggered durations, rather than relying on opacity changes alone.
22
22
  >
@@ -28,56 +28,57 @@
28
28
 
29
29
  Alter from alternative.
30
30
 
31
- I actually just to make a fork with small modification for my website but somehow I ended changed many things... How it became like this?
31
+ I just to make a fork with small modifications for my website but somehow I ended up changing many things... How did it become like this?
32
32
 
33
33
  ### Why should I use this?
34
34
 
35
- If you satisfied with original project, you probably not need this. This is for users with a specific need.
35
+ If you are satisfied with the original project, you probably not need this. This is for users with a specific need.
36
36
 
37
37
  To put it simply, you only needed this if:
38
38
 
39
- - You want to change the component root element, `img` with other component like `Image` from `next/image`.
40
- - You want to use `styled` function from `styled-components` or `emotion` or `MUI` on `Image` component but noticed some style not working properly.[^1]
39
+ - You want to change the component root element, `img` with another component like `Image` from `next/image`.
40
+ - You want to use `styled` function from `styled-components` or `emotion` or `MUI` on `Image` component but noticed some styles are not working properly.[^1]
41
41
 
42
- [^1]: This happen on original project because the styles set using style prop. To correct this for original project, you need to use style or wrapperStyle or iconWrapperStyle that provided to overwrite the default style.
42
+ [^1]: This happens on the original project because the styles were set using style props. To correct this for the original project, you need to use style or wrapperStyle or iconWrapperStyle that provided to overwrite the default style.
43
43
 
44
44
  ### Changes in this fork
45
45
 
46
46
  - Breaking Changes
47
- - Height and width prop forwarded to the component root element (by default, `img`) instead of using CSS to set height and width of component wrapper element. Some alternate image components like `next/image` actually need for height and width prop.
48
- - Put all styles that set though style prop in styled for better compability with MUI's styled.
47
+ - Height and width prop forwarded to the component root element (by default, `img`) instead of using CSS to set the height and width of the component wrapper element. Some alternate image components like `next/image` actually need for height and width prop.
48
+ - Put all styles that set through style prop in styled for better compatibility with MUI's styled.
49
49
  - No UMD build. Go post an issue if you want UMD to be added.
50
50
  - Only named exports. Read this [article](https://esbuild.github.io/content-types/#default-interop).
51
51
 
52
52
  - Other Changes
53
53
  - Rewritten fully in Typescript with types built-in based on MUI component types.
54
- - Add support to MUI's component prop; That's means you can subtitute component root element with `Image` from `next/image` if you want. Component supported are `img`, `img`-derived HTML element and component with `src` prop.
54
+ - Add support to MUI's component prop; That means you can substitute the component root element with `Image` from `next/image` if you want. Components supported are `img`, `img`-derived HTML element and component with `src` prop.
55
55
  - Properly export esm and cjs build via package.json exports.
56
+ - (NEW) Support for MUI v6 added.
56
57
 
57
58
  - Development Changes
58
59
  - Use Vite instead of nwb for development and building the library for fast and better developer experience for me!
59
- - Added unit tests for testing mui-image-alter component. Also, added new Github Action that will automatically run these tests every pull request.
60
+ - Added unit tests for testing the mui-image-alter component. Also, added a new Github Action that will automatically run these tests for every pull request.
60
61
 
61
62
  ## Simple Q & A
62
63
 
63
64
  - **Q**: Why you created this fork?
64
- **A**: MUI's styled don't work very well with the original mui-image because some of default styling and it use style prop instead of using styled to set some of the styling. So, I want to modify a little bit... And I end up doing at lot.
65
- Originally, I want to just post an issue for this but I am suck in comunication. 😅
65
+ **A**: MUI's styled don't work very well with the original mui-image because some of the default styling and it use style prop instead of using styled to set some of the styling. So, I want to modify a little bit... And I end up doing a lot.
66
+ Originally, I want to just post an issue for this but I suck in communication. 😅
66
67
 
67
68
  - **Q**: Why you change nwb to Vite?
68
- **A**: I just wanted to fork for my own benefit. So, I thought maybe I can write this in TypeScript... but it don't work with nwb. I am so frustrated that I cannot find how to do it and try migarating to Vite instead. (Also, looks like nwb is abandoned too...) It took a lot of work but never thought it work so well...
69
+ **A**: I just wanted to fork for my own benefit. So, I thought maybe I could write this in TypeScript... but it doesn't work with nwb. I am so frustrated that I cannot find how to do it and try migrating to Vite instead. (Also, looks like nwb is abandoned too...) It took a lot of work but never thought it work so well...
69
70
  Maybe there is actually a way to use Typescript with nwb but I never regret switching to Vite.
70
71
 
71
72
  Vite is so fast!!! 😍
72
73
 
73
- - **Q**: Will you intergrate changes from the original project?
74
+ - **Q**: Will you integrate changes from the original project?
74
75
  **A**: Yeah. As many as possible. 💪
75
76
 
76
77
  ---
77
78
 
78
79
  ### 1. Install
79
80
 
80
- Install the `mui-image-alter` peer dependencies first. (Can skip if you already done it.)
81
+ Install the `mui-image-alter` peer dependencies first. (Can skip if you have already done it.)
81
82
 
82
83
  If you haven't yet install MUI, please follow the [official guide](https://mui.com/material-ui/getting-started/installation/). Only MUI v5 or v6 are supported.
83
84
 
@@ -174,7 +175,7 @@ If you want to get fancy 💃 you can also add inline styles and additional `cla
174
175
 
175
176
  ### Fork Exclusive Usage
176
177
 
177
- With this fork, you can use MUI's styled normally like this. More info on MUI's [official doccumentation](https://mui.com/system/styled/).
178
+ With this fork, you can use MUI's styled normally like this. More info on MUI's [official documentation](https://mui.com/system/styled/).
178
179
 
179
180
  ```ts
180
181
  import { styled } from '@mui/material/styles';
@@ -328,7 +329,9 @@ Star this project and also the original project too if it is useful for you.
328
329
 
329
330
  Also, consider buying me a coffee!
330
331
 
331
- [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/mddanish00)
332
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/mddanish00)
333
+
334
+ [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/mddanish00)
332
335
 
333
336
  ## License
334
337
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),V=require("react"),m=require("@mui/material/styles"),G=require("@mui/material/SvgIcon"),J=require("@mui/material/CircularProgress"),K=require("clsx"),Q=require("use-resize-observer"),u=e=>e&&e.__esModule?e:{default:e};function U(e){if(e&&e.__esModule)return e;const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(i,a,r.get?r:{enumerable:!0,get:()=>e[a]})}}return i.default=e,Object.freeze(i)}const t=U(V),X=u(G),Y=u(J),h=u(K),Z=u(Q),p=e=>o.jsx(X.default,{...e,children:o.jsx("path",{d:"M21 5v6.59l-2.29-2.3c-.39-.39-1.03-.39-1.42 0L14 12.59 10.71 9.3a.9959.9959 0 0 0-1.41 0L6 12.59 3 9.58V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2zm-3 6.42 3 3.01V19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-6.58l2.29 2.29c.39.39 1.02.39 1.41 0l3.3-3.3 3.29 3.29c.39.39 1.02.39 1.41 0l3.3-3.28z"})}),ee=t.forwardRef(({src:e,alt:i="",position:a="relative",fit:r="cover",style:I,className:S="",showLoading:l=!1,errorIcon:c=!0,shift:n=!1,distance:M=100,shiftDuration:z=void 0,bgColor:w="inherit",wrapperStyle:C,iconWrapperStyle:k,wrapperClassName:B="",iconWrapperClassName:O="",duration:q=3e3,easing:R="cubic-bezier(0.7, 0, 0.6, 1)",onLoad:f,onError:g,sx:W,component:$="img",...s},P)=>{const[d,b]=t.useState(!1),[y,j]=t.useState(!1),{ref:D,width:_,height:x}=Z.default({ref:P}),F=s.height?s.height:"100%",H=s.width?s.width:"100%",N=t.useCallback(()=>{b(!0),j(!1),f&&f()},[f]),A=t.useCallback(()=>{j(!0),b(!1),g&&g()},[g]),E=n!==void 0&&n!==!1&&n!==null?{[n]:d?0:M}:{},T=typeof c!="boolean"&&c||o.jsx(p,{sx:{fontSize:56,color:"#bdbdbd"}}),L=typeof l!="boolean"&&l||o.jsx(Y.default,{size:56,thickness:6});return o.jsxs(ie,{className:h.default("MuiImageAlter-wrapper",B),sx:W,style:C,bgColor:w,rootHeight:x||F,rootWidth:_||H,children:[o.jsx(te,{ref:D,as:$,src:e,alt:i,style:I,className:h.default("MuiImageAlter-img",S),onLoad:N,onError:A,position:a,fit:r,shift:n,shiftDuration:z,shiftStyles:E,duration:q,easing:R,loaded:d,...s}),(!!l||!!c)&&o.jsxs(oe,{className:h.default("MuiImageAlter-iconWrapper",O),style:k,loaded:d,children:[!!c&&y&&T,!!l&&!y&&!d&&L]})]})}),v=(e,i)=>!i.includes(e),te=t.memo(m.styled("img",{shouldForwardProp:e=>v(e.toString(),["position","fit","shift","shiftDuration","shiftStyles","duration","easing","loaded","sx","as"])})(e=>({"@keyframes materialize":{"0%":{filter:"saturate(20%) contrast(50%) brightness(120%)"},"75%":{filter:"saturate(60%) contrast(100%) brightness(100%)"},"100%":{filter:"saturate(100%) contrast(100%) brightness(100%)"}},position:e.position,objectFit:e.fit,transitionProperty:`${e.shift?`${e.shift}, `:""}opacity`,transitionDuration:`${e.shift?`${e.shiftDuration||e.duration*.3}ms, `:""}${e.duration/2}ms`,transitionTimingFunction:e.easing,opacity:e.loaded?1:0,animation:e.loaded?`materialize ${e.duration}ms 1 ${e.easing}`:"",...!!e.shift&&e.shiftStyles}))),ie=t.memo(m.styled("div",{shouldForwardProp:e=>v(e.toString(),["bgColor","sx","rootHeight","rootWidth"])})(e=>({display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:e.bgColor,height:e.rootHeight,width:e.rootWidth}))),oe=t.memo(m.styled("div",{shouldForwardProp:e=>e!=="loaded"})(e=>({width:"100%",marginLeft:"-100%",display:"flex",justifyContent:"center",alignItems:"center",opacity:e.loaded?0:1})));exports.Image=ee;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),V=require("react"),y=require("@mui/material/styles"),G=require("@mui/material/SvgIcon"),J=require("@mui/material/CircularProgress"),K=require("clsx"),b=t=>t&&t.__esModule?t:{default:t};function Q(t){if(t&&t.__esModule)return t;const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(i,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return i.default=t,Object.freeze(i)}const e=Q(V),U=b(G),X=b(J),m=b(K),Y=({observeRef:t})=>{const[i,n]=e.useState(),[s,f]=e.useState(),o=e.useRef(void 0);return e.useEffect(()=>{o.current=new ResizeObserver(r=>{n(r[0].contentRect.height),f(r[0].contentRect.width)})},[]),e.useEffect(()=>(t&&t.current&&o.current&&o.current.observe(t.current),()=>{t&&t.current&&o.current&&o.current.unobserve(t.current)}),[t]),{ref:t,height:i,width:s}},Z=t=>a.jsx(U.default,{...t,children:a.jsx("path",{d:"M21 5v6.59l-2.29-2.3c-.39-.39-1.03-.39-1.42 0L14 12.59 10.71 9.3a.9959.9959 0 0 0-1.41 0L6 12.59 3 9.58V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2zm-3 6.42 3 3.01V19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-6.58l2.29 2.29c.39.39 1.02.39 1.41 0l3.3-3.3 3.29 3.29c.39.39 1.02.39 1.41 0l3.3-3.28z"})}),p=e.forwardRef(({src:t,alt:i="",position:n="relative",fit:s="cover",style:f,className:o="",showLoading:r=!1,errorIcon:u=!0,shift:c=!1,distance:w=100,shiftDuration:z=void 0,bgColor:M="inherit",wrapperStyle:k,iconWrapperStyle:C,wrapperClassName:O="",iconWrapperClassName:$="",duration:B=3e3,easing:W="cubic-bezier(0.7, 0, 0.6, 1)",onLoad:h,onError:g,sx:q,component:H="img",...l},P)=>{const[d,x]=e.useState(!1),[j,S]=e.useState(!1),{ref:R,width:I,height:_}=Y({observeRef:P}),D=l.height?l.height:"100%",E=l.width?l.width:"100%",F=e.useCallback(()=>{x(!0),S(!1),h&&h()},[h]),N=e.useCallback(()=>{S(!0),x(!1),g&&g()},[g]),A=c!==void 0&&c!==!1&&c!==null?{[c]:d?0:w}:{},T=typeof u!="boolean"&&u||a.jsx(Z,{sx:{fontSize:56,color:"#bdbdbd"}}),L=typeof r!="boolean"&&r||a.jsx(X.default,{size:56,thickness:6});return a.jsxs(et,{className:m.default("MuiImageAlter-wrapper",O),sx:q,style:k,bgColor:M,rootHeight:_||D,rootWidth:I||E,children:[a.jsx(tt,{ref:R,as:H,src:t,alt:i,style:f,className:m.default("MuiImageAlter-img",o),onLoad:F,onError:N,position:n,fit:s,shift:c,shiftDuration:z,shiftStyles:A,duration:B,easing:W,loaded:d,...l}),(!!r||!!u)&&a.jsxs(it,{className:m.default("MuiImageAlter-iconWrapper",$),style:C,loaded:d,children:[!!u&&j&&T,!!r&&!j&&!d&&L]})]})}),v=(t,i)=>!i.includes(t),tt=e.memo(y.styled("img",{shouldForwardProp:t=>v(t.toString(),["position","fit","shift","shiftDuration","shiftStyles","duration","easing","loaded","sx","as"])})(t=>({"@keyframes materialize":{"0%":{filter:"saturate(20%) contrast(50%) brightness(120%)"},"75%":{filter:"saturate(60%) contrast(100%) brightness(100%)"},"100%":{filter:"saturate(100%) contrast(100%) brightness(100%)"}},position:t.position,objectFit:t.fit,transitionProperty:`${t.shift?`${t.shift}, `:""}opacity`,transitionDuration:`${t.shift?`${t.shiftDuration||t.duration*.3}ms, `:""}${t.duration/2}ms`,transitionTimingFunction:t.easing,opacity:t.loaded?1:0,animation:t.loaded?`materialize ${t.duration}ms 1 ${t.easing}`:"",...!!t.shift&&t.shiftStyles}))),et=e.memo(y.styled("div",{shouldForwardProp:t=>v(t.toString(),["bgColor","sx","rootHeight","rootWidth"])})(t=>({display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:t.bgColor,height:`${t.rootHeight}px`,width:`${t.rootWidth}px`}))),it=e.memo(y.styled("div",{shouldForwardProp:t=>t!=="loaded"})(t=>({width:"100%",marginLeft:"-100%",display:"flex",justifyContent:"center",alignItems:"center",opacity:t.loaded?0:1})));exports.Image=p;
package/dist/index.js CHANGED
@@ -1,86 +1,96 @@
1
1
  "use client";
2
- import { jsxs as I, jsx as a } from "react/jsx-runtime";
2
+ import { jsxs as z, jsx as s } from "react/jsx-runtime";
3
3
  import * as e from "react";
4
- import { styled as h } from "@mui/material/styles";
4
+ import { styled as y } from "@mui/material/styles";
5
5
  import G from "@mui/material/SvgIcon";
6
6
  import J from "@mui/material/CircularProgress";
7
- import m from "clsx";
8
- import K from "use-resize-observer";
9
- const Q = (t) => /* @__PURE__ */ a(G, { ...t, children: /* @__PURE__ */ a("path", { d: "M21 5v6.59l-2.29-2.3c-.39-.39-1.03-.39-1.42 0L14 12.59 10.71 9.3a.9959.9959 0 0 0-1.41 0L6 12.59 3 9.58V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2zm-3 6.42 3 3.01V19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-6.58l2.29 2.29c.39.39 1.02.39 1.41 0l3.3-3.3 3.29 3.29c.39.39 1.02.39 1.41 0l3.3-3.28z" }) }), ot = e.forwardRef(
7
+ import g from "clsx";
8
+ const K = ({
9
+ observeRef: t
10
+ }) => {
11
+ const [n, d] = e.useState(), [u, h] = e.useState(), i = e.useRef(void 0);
12
+ return e.useEffect(() => {
13
+ i.current = new ResizeObserver((o) => {
14
+ d(o[0].contentRect.height), h(o[0].contentRect.width);
15
+ });
16
+ }, []), e.useEffect(() => (t && t.current && i.current && i.current.observe(t.current), () => {
17
+ t && t.current && i.current && i.current.unobserve(t.current);
18
+ }), [t]), { ref: t, height: n, width: u };
19
+ }, Q = (t) => /* @__PURE__ */ s(G, { ...t, children: /* @__PURE__ */ s("path", { d: "M21 5v6.59l-2.29-2.3c-.39-.39-1.03-.39-1.42 0L14 12.59 10.71 9.3a.9959.9959 0 0 0-1.41 0L6 12.59 3 9.58V5c0-1.1.9-2 2-2h14c1.1 0 2 .9 2 2zm-3 6.42 3 3.01V19c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2v-6.58l2.29 2.29c.39.39 1.02.39 1.41 0l3.3-3.3 3.29 3.29c.39.39 1.02.39 1.41 0l3.3-3.28z" }) }), it = e.forwardRef(
10
20
  ({
11
21
  src: t,
12
- alt: l = "",
13
- position: x = "relative",
14
- fit: S = "cover",
15
- style: w,
16
- className: z = "",
17
- showLoading: n = !1,
18
- errorIcon: r = !0,
19
- shift: i = !1,
20
- distance: B = 100,
21
- shiftDuration: C = void 0,
22
- bgColor: k = "inherit",
23
- wrapperStyle: M,
22
+ alt: n = "",
23
+ position: d = "relative",
24
+ fit: u = "cover",
25
+ style: h,
26
+ className: i = "",
27
+ showLoading: o = !1,
28
+ errorIcon: c = !0,
29
+ shift: a = !1,
30
+ distance: $ = 100,
31
+ shiftDuration: k = void 0,
32
+ bgColor: B = "inherit",
33
+ wrapperStyle: C,
24
34
  iconWrapperStyle: W,
25
- wrapperClassName: $ = "",
26
- iconWrapperClassName: j = "",
27
- duration: F = 3e3,
28
- easing: H = "cubic-bezier(0.7, 0, 0.6, 1)",
35
+ wrapperClassName: M = "",
36
+ iconWrapperClassName: H = "",
37
+ duration: j = 3e3,
38
+ easing: E = "cubic-bezier(0.7, 0, 0.6, 1)",
29
39
  // "heavy move" from https://sprawledoctopus.com/easing/,
30
- onLoad: c,
31
- onError: d,
32
- sx: R,
33
- component: A = "img",
34
- ...o
35
- }, D) => {
36
- const [s, f] = e.useState(!1), [u, g] = e.useState(!1), { ref: E, width: b, height: y } = K({ ref: D }), N = o.height ? o.height : "100%", L = o.width ? o.width : "100%", P = e.useCallback(() => {
37
- f(!0), g(!1), c && c();
38
- }, [c]), V = e.useCallback(() => {
39
- g(!0), f(!1), d && d();
40
- }, [d]), O = i !== void 0 && i !== !1 && i !== null ? {
41
- [i]: s ? 0 : B
42
- } : {}, T = typeof r != "boolean" && r || /* @__PURE__ */ a(Q, { sx: { fontSize: 56, color: "#bdbdbd" } }), q = typeof n != "boolean" && n || /* @__PURE__ */ a(J, { size: 56, thickness: 6 });
43
- return /* @__PURE__ */ I(
40
+ onLoad: m,
41
+ onError: f,
42
+ sx: F,
43
+ component: R = "img",
44
+ ...r
45
+ }, A) => {
46
+ const [l, b] = e.useState(!1), [I, w] = e.useState(!1), { ref: D, width: x, height: S } = K({ observeRef: A }), N = r.height ? r.height : "100%", O = r.width ? r.width : "100%", L = e.useCallback(() => {
47
+ b(!0), w(!1), m && m();
48
+ }, [m]), P = e.useCallback(() => {
49
+ w(!0), b(!1), f && f();
50
+ }, [f]), V = a !== void 0 && a !== !1 && a !== null ? {
51
+ [a]: l ? 0 : $
52
+ } : {}, T = typeof c != "boolean" && c || /* @__PURE__ */ s(Q, { sx: { fontSize: 56, color: "#bdbdbd" } }), q = typeof o != "boolean" && o || /* @__PURE__ */ s(J, { size: 56, thickness: 6 });
53
+ return /* @__PURE__ */ z(
44
54
  X,
45
55
  {
46
- className: m("MuiImageAlter-wrapper", $),
47
- sx: R,
48
- style: M,
49
- bgColor: k,
50
- rootHeight: y || N,
51
- rootWidth: b || L,
56
+ className: g("MuiImageAlter-wrapper", M),
57
+ sx: F,
58
+ style: C,
59
+ bgColor: B,
60
+ rootHeight: S || N,
61
+ rootWidth: x || O,
52
62
  children: [
53
- /* @__PURE__ */ a(
63
+ /* @__PURE__ */ s(
54
64
  U,
55
65
  {
56
- ref: E,
57
- as: A,
66
+ ref: D,
67
+ as: R,
58
68
  src: t,
59
- alt: l,
60
- style: w,
61
- className: m("MuiImageAlter-img", z),
62
- onLoad: P,
63
- onError: V,
64
- position: x,
65
- fit: S,
66
- shift: i,
67
- shiftDuration: C,
68
- shiftStyles: O,
69
- duration: F,
70
- easing: H,
71
- loaded: s,
72
- ...o
69
+ alt: n,
70
+ style: h,
71
+ className: g("MuiImageAlter-img", i),
72
+ onLoad: L,
73
+ onError: P,
74
+ position: d,
75
+ fit: u,
76
+ shift: a,
77
+ shiftDuration: k,
78
+ shiftStyles: V,
79
+ duration: j,
80
+ easing: E,
81
+ loaded: l,
82
+ ...r
73
83
  }
74
84
  ),
75
- (!!n || !!r) && /* @__PURE__ */ I(
85
+ (!!o || !!c) && /* @__PURE__ */ z(
76
86
  Y,
77
87
  {
78
- className: m("MuiImageAlter-iconWrapper", j),
88
+ className: g("MuiImageAlter-iconWrapper", H),
79
89
  style: W,
80
- loaded: s,
90
+ loaded: l,
81
91
  children: [
82
- !!r && u && T,
83
- !!n && !u && !s && q
92
+ !!c && I && T,
93
+ !!o && !I && !l && q
84
94
  ]
85
95
  }
86
96
  )
@@ -88,8 +98,8 @@ const Q = (t) => /* @__PURE__ */ a(G, { ...t, children: /* @__PURE__ */ a("path"
88
98
  }
89
99
  );
90
100
  }
91
- ), v = (t, l) => !l.includes(t), U = e.memo(
92
- h("img", {
101
+ ), v = (t, n) => !n.includes(t), U = e.memo(
102
+ y("img", {
93
103
  shouldForwardProp: (t) => v(t.toString(), [
94
104
  "position",
95
105
  "fit",
@@ -124,18 +134,18 @@ const Q = (t) => /* @__PURE__ */ a(G, { ...t, children: /* @__PURE__ */ a("path"
124
134
  ...!!t.shift && t.shiftStyles
125
135
  }))
126
136
  ), X = e.memo(
127
- h("div", {
137
+ y("div", {
128
138
  shouldForwardProp: (t) => v(t.toString(), ["bgColor", "sx", "rootHeight", "rootWidth"])
129
139
  })((t) => ({
130
140
  display: "flex",
131
141
  justifyContent: "center",
132
142
  alignItems: "center",
133
143
  backgroundColor: t.bgColor,
134
- height: t.rootHeight,
135
- width: t.rootWidth
144
+ height: `${t.rootHeight}px`,
145
+ width: `${t.rootWidth}px`
136
146
  }))
137
147
  ), Y = e.memo(
138
- h("div", {
148
+ y("div", {
139
149
  shouldForwardProp: (t) => t !== "loaded"
140
150
  })((t) => ({
141
151
  width: "100%",
@@ -147,5 +157,5 @@ const Q = (t) => /* @__PURE__ */ a(G, { ...t, children: /* @__PURE__ */ a("path"
147
157
  }))
148
158
  );
149
159
  export {
150
- ot as Image
160
+ it as Image
151
161
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mui-image-alter",
3
- "version": "3.1.0",
4
- "description": "Fork of mui-image. Display images as per the Material guidelines using Material-UI v5. With component prop support.",
3
+ "version": "3.2.0",
4
+ "description": "Fork of mui-image. Display images as per the Material guidelines using Material-UI v5 or v6. With component prop support.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "types": "./dist/index.d.cts",
@@ -29,42 +29,42 @@
29
29
  "format": "prettier {demo,src}/**/*.{js,jsx,ts,tsx,json} --write",
30
30
  "clean": "rimraf dist es lib umd coverage jest-setup.d.ts mui-image-alter-*",
31
31
  "prepare": "npm run build",
32
- "preversion": "npm run clean && npm run format",
33
- "postversion": "git push && git push --tags",
34
32
  "test": "vitest run",
35
33
  "test:watch": "vitest",
36
34
  "test:coverage": "vitest run --coverage",
37
35
  "test:coverage-ci": "vitest run --coverage.enabled --coverage.reporter='text-summary'"
38
36
  },
39
37
  "dependencies": {
40
- "clsx": "^2.1.1",
41
- "use-resize-observer": "^9.1.0"
38
+ "clsx": "^2.1.1"
42
39
  },
43
40
  "peerDependencies": {
44
41
  "@mui/material": "^5.0.0 || ^6.0.0",
45
- "react": "^17.0.0 || ^18.0.0",
46
- "react-dom": "^17.0.0 || ^18.0.0"
42
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
43
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
47
44
  },
48
45
  "devDependencies": {
49
- "@emotion/react": "^11.13.3",
50
- "@emotion/styled": "^11.13.0",
51
- "@fontsource/fira-code": "^5.0.19",
52
- "@size-limit/preset-small-lib": "^11.1.4",
53
- "@testing-library/jest-dom": "^6.5.0",
54
- "@testing-library/react": "^16.0.1",
55
- "@types/react": "^18.3.5",
56
- "@types/react-dom": "^18.3.0",
57
- "@vitejs/plugin-react": "^4.3.1",
58
- "@vitest/coverage-v8": "^2.0.5",
59
- "jsdom": "^25.0.0",
60
- "prettier": "^3.3.3",
46
+ "@emotion/react": "^11.14.0",
47
+ "@emotion/styled": "^11.14.0",
48
+ "@fontsource/fira-code": "^5.1.0",
49
+ "@mui/material": "^6.1.10",
50
+ "@size-limit/preset-small-lib": "^11.1.6",
51
+ "@testing-library/jest-dom": "^6.6.3",
52
+ "@testing-library/react": "^16.1.0",
53
+ "@types/node": "^20.17.9",
54
+ "@types/react": "^19.0.1",
55
+ "@types/react-dom": "^19.0.1",
56
+ "@vitejs/plugin-react": "^4.3.4",
57
+ "@vitest/coverage-v8": "^2.1.8",
58
+ "jsdom": "^25.0.1",
59
+ "prettier": "^3.4.2",
60
+ "react": "^19.0.0",
61
+ "react-dom": "^19.0.0",
61
62
  "rimraf": "^6.0.1",
62
- "size-limit": "^11.1.4",
63
- "typeit-react": "^2.7.2",
64
- "typescript": "^5.5.4",
65
- "vite": "^5.4.2",
66
- "vite-plugin-dts": "^4.1.0",
67
- "vitest": "^2.0.5"
63
+ "size-limit": "^11.1.6",
64
+ "typescript": "^5.7.2",
65
+ "vite": "^6.0.3",
66
+ "vite-plugin-dts": "^4.3.0",
67
+ "vitest": "^2.1.8"
68
68
  },
69
69
  "size-limit": [
70
70
  {
@@ -95,5 +95,11 @@
95
95
  "material design",
96
96
  "react",
97
97
  "loading image"
98
+ ],
99
+ "funding": [
100
+ {
101
+ "type": "github",
102
+ "url": "https://github.com/mddanish00/mui-image-alter?sponsor=1"
103
+ }
98
104
  ]
99
- }
105
+ }