mui-image-alter 3.4.0 → 3.5.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/dist/index.cjs +1 -1
- package/dist/index.js +113 -159
- package/package.json +22 -21
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`@mui/material/styles`),u=require(`@mui/material/SvgIcon`);u=s(u);let d=require(`@mui/material/CircularProgress`);d=s(d);let f=require(`clsx`);f=s(f);let p=require(`react/jsx-runtime`);var m=({observeRef:e})=>{let[t,n]=c.useState(),[r,i]=c.useState(),a=c.useRef(void 0);return c.useEffect(()=>{a.current=new ResizeObserver(e=>{n(e[0].contentRect.height),i(e[0].contentRect.width)})},[]),c.useEffect(()=>(e&&e.current&&a.current&&a.current.observe(e.current),()=>{e&&e.current&&a.current&&a.current.unobserve(e.current)}),[e]),{ref:e,height:t,width:r}},h=e=>(0,p.jsx)(u.default,{...e,children:(0,p.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`})}),g=c.forwardRef(({src:e,alt:t=``,position:n=`relative`,fit:r=`cover`,style:i,className:a=``,showLoading:o=!1,errorIcon:s=!0,shift:l=!1,distance:u=100,shiftDuration:g=void 0,bgColor:_=`inherit`,wrapperStyle:x,iconWrapperStyle:S,wrapperClassName:C=``,iconWrapperClassName:w=``,duration:T=3e3,easing:E=`cubic-bezier(0.7, 0, 0.6, 1)`,onLoad:D,onError:O,sx:k,component:A=`img`,...j},M)=>{let[N,P]=c.useState(!1),[F,I]=c.useState(!1),{ref:L,width:R,height:z}=m({observeRef:M}),B=j.height?j.height:`100%`,V=j.width?j.width:`100%`,H=c.useCallback(()=>{P(!0),I(!1),D&&D()},[D]),U=c.useCallback(()=>{I(!0),P(!1),O&&O()},[O]),W=l!==void 0&&l!==!1&&l!==null?{[l]:N?0:u}:{},G=typeof s!=`boolean`&&s||(0,p.jsx)(h,{sx:{fontSize:56,color:`#bdbdbd`}}),K=typeof o!=`boolean`&&o||(0,p.jsx)(d.default,{size:56,thickness:6});return(0,p.jsxs)(y,{className:(0,f.default)(`MuiImageAlter-wrapper`,C),sx:k,style:x,bgColor:_,rootHeight:z||B,rootWidth:R||V,children:[(0,p.jsx)(v,{ref:L,as:A,src:e,alt:t,style:i,className:(0,f.default)(`MuiImageAlter-img`,a),onLoad:H,onError:U,position:n,fit:r,shift:l,shiftDuration:g,shiftStyles:W,duration:T,easing:E,loaded:N,...j}),(!!o||!!s)&&(0,p.jsxs)(b,{className:(0,f.default)(`MuiImageAlter-iconWrapper`,w),style:S,loaded:N,children:[!!s&&F&&G,!!o&&!F&&!N&&K]})]})}),_=(e,t)=>!t.includes(e),v=c.memo((0,l.styled)(`img`,{shouldForwardProp:e=>_(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}))),y=c.memo((0,l.styled)(`div`,{shouldForwardProp:e=>_(e.toString(),[`bgColor`,`sx`,`rootHeight`,`rootWidth`])})(e=>({display:`flex`,justifyContent:`center`,alignItems:`center`,backgroundColor:e.bgColor,height:`${e.rootHeight}px`,width:`${e.rootWidth}px`}))),b=c.memo((0,l.styled)(`div`,{shouldForwardProp:e=>e!==`loaded`})(e=>({width:`100%`,marginLeft:`-100%`,display:`flex`,justifyContent:`center`,alignItems:`center`,opacity:e.loaded?0:1})));exports.Image=g;
|
package/dist/index.js
CHANGED
|
@@ -1,161 +1,115 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as z, jsx as s } from "react/jsx-runtime";
|
|
3
2
|
import * as e from "react";
|
|
4
|
-
import { styled as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"0%": {
|
|
118
|
-
filter: "saturate(20%) contrast(50%) brightness(120%)"
|
|
119
|
-
},
|
|
120
|
-
"75%": {
|
|
121
|
-
filter: "saturate(60%) contrast(100%) brightness(100%)"
|
|
122
|
-
},
|
|
123
|
-
"100%": {
|
|
124
|
-
filter: "saturate(100%) contrast(100%) brightness(100%)"
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
position: t.position,
|
|
128
|
-
objectFit: t.fit,
|
|
129
|
-
transitionProperty: `${t.shift ? `${t.shift}, ` : ""}opacity`,
|
|
130
|
-
transitionDuration: `${t.shift ? `${t.shiftDuration || t.duration * 0.3}ms, ` : ""}${t.duration / 2}ms`,
|
|
131
|
-
transitionTimingFunction: t.easing,
|
|
132
|
-
opacity: t.loaded ? 1 : 0,
|
|
133
|
-
animation: t.loaded ? `materialize ${t.duration}ms 1 ${t.easing}` : "",
|
|
134
|
-
...!!t.shift && t.shiftStyles
|
|
135
|
-
}))
|
|
136
|
-
), X = e.memo(
|
|
137
|
-
y("div", {
|
|
138
|
-
shouldForwardProp: (t) => v(t.toString(), ["bgColor", "sx", "rootHeight", "rootWidth"])
|
|
139
|
-
})((t) => ({
|
|
140
|
-
display: "flex",
|
|
141
|
-
justifyContent: "center",
|
|
142
|
-
alignItems: "center",
|
|
143
|
-
backgroundColor: t.bgColor,
|
|
144
|
-
height: `${t.rootHeight}px`,
|
|
145
|
-
width: `${t.rootWidth}px`
|
|
146
|
-
}))
|
|
147
|
-
), Y = e.memo(
|
|
148
|
-
y("div", {
|
|
149
|
-
shouldForwardProp: (t) => t !== "loaded"
|
|
150
|
-
})((t) => ({
|
|
151
|
-
width: "100%",
|
|
152
|
-
marginLeft: "-100%",
|
|
153
|
-
display: "flex",
|
|
154
|
-
justifyContent: "center",
|
|
155
|
-
alignItems: "center",
|
|
156
|
-
opacity: t.loaded ? 0 : 1
|
|
157
|
-
}))
|
|
158
|
-
);
|
|
159
|
-
export {
|
|
160
|
-
it as Image
|
|
161
|
-
};
|
|
3
|
+
import { styled as t } from "@mui/material/styles";
|
|
4
|
+
import n from "@mui/material/SvgIcon";
|
|
5
|
+
import r from "@mui/material/CircularProgress";
|
|
6
|
+
import i from "clsx";
|
|
7
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
8
|
+
//#region src/useResizeObserver.ts
|
|
9
|
+
var s = ({ observeRef: t }) => {
|
|
10
|
+
let [n, r] = e.useState(), [i, a] = e.useState(), o = e.useRef(void 0);
|
|
11
|
+
return e.useEffect(() => {
|
|
12
|
+
o.current = new ResizeObserver((e) => {
|
|
13
|
+
r(e[0].contentRect.height), a(e[0].contentRect.width);
|
|
14
|
+
});
|
|
15
|
+
}, []), e.useEffect(() => (t && t.current && o.current && o.current.observe(t.current), () => {
|
|
16
|
+
t && t.current && o.current && o.current.unobserve(t.current);
|
|
17
|
+
}), [t]), {
|
|
18
|
+
ref: t,
|
|
19
|
+
height: n,
|
|
20
|
+
width: i
|
|
21
|
+
};
|
|
22
|
+
}, c = (e) => /* @__PURE__ */ a(n, {
|
|
23
|
+
...e,
|
|
24
|
+
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" })
|
|
25
|
+
}), l = e.forwardRef(({ src: t, alt: n = "", position: l = "relative", fit: u = "cover", style: m, className: h = "", showLoading: g = !1, errorIcon: _ = !0, shift: v = !1, distance: y = 100, shiftDuration: b = void 0, bgColor: x = "inherit", wrapperStyle: S, iconWrapperStyle: C, wrapperClassName: w = "", iconWrapperClassName: T = "", duration: E = 3e3, easing: D = "cubic-bezier(0.7, 0, 0.6, 1)", onLoad: O, onError: k, sx: A, component: j = "img", ...M }, N) => {
|
|
26
|
+
let [P, F] = e.useState(!1), [I, L] = e.useState(!1), { ref: R, width: z, height: B } = s({ observeRef: N }), V = M.height ? M.height : "100%", H = M.width ? M.width : "100%", U = e.useCallback(() => {
|
|
27
|
+
F(!0), L(!1), O && O();
|
|
28
|
+
}, [O]), W = e.useCallback(() => {
|
|
29
|
+
L(!0), F(!1), k && k();
|
|
30
|
+
}, [k]), G = v !== void 0 && v !== !1 && v !== null ? { [v]: P ? 0 : y } : {}, K = typeof _ != "boolean" && _ || /* @__PURE__ */ a(c, { sx: {
|
|
31
|
+
fontSize: 56,
|
|
32
|
+
color: "#bdbdbd"
|
|
33
|
+
} }), q = typeof g != "boolean" && g || /* @__PURE__ */ a(r, {
|
|
34
|
+
size: 56,
|
|
35
|
+
thickness: 6
|
|
36
|
+
});
|
|
37
|
+
return /* @__PURE__ */ o(f, {
|
|
38
|
+
className: i("MuiImageAlter-wrapper", w),
|
|
39
|
+
sx: A,
|
|
40
|
+
style: S,
|
|
41
|
+
bgColor: x,
|
|
42
|
+
rootHeight: B || V,
|
|
43
|
+
rootWidth: z || H,
|
|
44
|
+
children: [/* @__PURE__ */ a(d, {
|
|
45
|
+
ref: R,
|
|
46
|
+
as: j,
|
|
47
|
+
src: t,
|
|
48
|
+
alt: n,
|
|
49
|
+
style: m,
|
|
50
|
+
className: i("MuiImageAlter-img", h),
|
|
51
|
+
onLoad: U,
|
|
52
|
+
onError: W,
|
|
53
|
+
position: l,
|
|
54
|
+
fit: u,
|
|
55
|
+
shift: v,
|
|
56
|
+
shiftDuration: b,
|
|
57
|
+
shiftStyles: G,
|
|
58
|
+
duration: E,
|
|
59
|
+
easing: D,
|
|
60
|
+
loaded: P,
|
|
61
|
+
...M
|
|
62
|
+
}), (!!g || !!_) && /* @__PURE__ */ o(p, {
|
|
63
|
+
className: i("MuiImageAlter-iconWrapper", T),
|
|
64
|
+
style: C,
|
|
65
|
+
loaded: P,
|
|
66
|
+
children: [!!_ && I && K, !!g && !I && !P && q]
|
|
67
|
+
})]
|
|
68
|
+
});
|
|
69
|
+
}), u = (e, t) => !t.includes(e), d = e.memo(t("img", { shouldForwardProp: (e) => u(e.toString(), [
|
|
70
|
+
"position",
|
|
71
|
+
"fit",
|
|
72
|
+
"shift",
|
|
73
|
+
"shiftDuration",
|
|
74
|
+
"shiftStyles",
|
|
75
|
+
"duration",
|
|
76
|
+
"easing",
|
|
77
|
+
"loaded",
|
|
78
|
+
"sx",
|
|
79
|
+
"as"
|
|
80
|
+
]) })((e) => ({
|
|
81
|
+
"@keyframes materialize": {
|
|
82
|
+
"0%": { filter: "saturate(20%) contrast(50%) brightness(120%)" },
|
|
83
|
+
"75%": { filter: "saturate(60%) contrast(100%) brightness(100%)" },
|
|
84
|
+
"100%": { filter: "saturate(100%) contrast(100%) brightness(100%)" }
|
|
85
|
+
},
|
|
86
|
+
position: e.position,
|
|
87
|
+
objectFit: e.fit,
|
|
88
|
+
transitionProperty: `${e.shift ? `${e.shift}, ` : ""}opacity`,
|
|
89
|
+
transitionDuration: `${e.shift ? `${e.shiftDuration || e.duration * .3}ms, ` : ""}${e.duration / 2}ms`,
|
|
90
|
+
transitionTimingFunction: e.easing,
|
|
91
|
+
opacity: e.loaded ? 1 : 0,
|
|
92
|
+
animation: e.loaded ? `materialize ${e.duration}ms 1 ${e.easing}` : "",
|
|
93
|
+
...!!e.shift && e.shiftStyles
|
|
94
|
+
}))), f = e.memo(t("div", { shouldForwardProp: (e) => u(e.toString(), [
|
|
95
|
+
"bgColor",
|
|
96
|
+
"sx",
|
|
97
|
+
"rootHeight",
|
|
98
|
+
"rootWidth"
|
|
99
|
+
]) })((e) => ({
|
|
100
|
+
display: "flex",
|
|
101
|
+
justifyContent: "center",
|
|
102
|
+
alignItems: "center",
|
|
103
|
+
backgroundColor: e.bgColor,
|
|
104
|
+
height: `${e.rootHeight}px`,
|
|
105
|
+
width: `${e.rootWidth}px`
|
|
106
|
+
}))), p = e.memo(t("div", { shouldForwardProp: (e) => e !== "loaded" })((e) => ({
|
|
107
|
+
width: "100%",
|
|
108
|
+
marginLeft: "-100%",
|
|
109
|
+
display: "flex",
|
|
110
|
+
justifyContent: "center",
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
opacity: e.loaded ? 0 : 1
|
|
113
|
+
})));
|
|
114
|
+
//#endregion
|
|
115
|
+
export { l as Image };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mui-image-alter",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Fork of mui-image. Display images as per the Material guidelines using Material-UI v5 and above. With component prop support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -45,28 +45,29 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@emotion/react": "^11.14.0",
|
|
47
47
|
"@emotion/styled": "^11.14.1",
|
|
48
|
-
"@fontsource/fira-code": "^5.2.
|
|
48
|
+
"@fontsource/fira-code": "^5.2.7",
|
|
49
49
|
"@juggle/resize-observer": "^3.4.0",
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@testing-library/
|
|
54
|
-
"@
|
|
55
|
-
"@types/
|
|
56
|
-
"@types/react
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"react
|
|
63
|
-
"
|
|
64
|
-
"
|
|
50
|
+
"@microsoft/api-extractor": "^7.57.7",
|
|
51
|
+
"@mui/material": "^7.3.9",
|
|
52
|
+
"@size-limit/preset-small-lib": "^12.0.1",
|
|
53
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
54
|
+
"@testing-library/react": "^16.3.2",
|
|
55
|
+
"@types/node": "^24.12.0",
|
|
56
|
+
"@types/react": "^19.2.14",
|
|
57
|
+
"@types/react-dom": "^19.2.3",
|
|
58
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
59
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
60
|
+
"jsdom": "^29.0.0",
|
|
61
|
+
"prettier": "^3.8.1",
|
|
62
|
+
"react": "^19.2.4",
|
|
63
|
+
"react-dom": "^19.2.4",
|
|
64
|
+
"rimraf": "^6.1.3",
|
|
65
|
+
"size-limit": "^12.0.1",
|
|
65
66
|
"typeit-react": "^2.7.8",
|
|
66
|
-
"typescript": "^5.9.
|
|
67
|
-
"
|
|
68
|
-
"vite
|
|
69
|
-
"vitest": "^
|
|
67
|
+
"typescript": "^5.9.3",
|
|
68
|
+
"unplugin-dts": "^1.0.0-beta.6",
|
|
69
|
+
"vite": "^8.0.1",
|
|
70
|
+
"vitest": "^4.1.0"
|
|
70
71
|
},
|
|
71
72
|
"size-limit": [
|
|
72
73
|
{
|