mui-file-input
Advanced tools
Comparing version 4.0.5 to 4.0.6
import { jsxs as y, jsx as a } from "react/jsx-runtime"; | ||
import u from "react"; | ||
import p from "react"; | ||
import { styled as M } from "@mui/material/styles"; | ||
@@ -64,12 +64,12 @@ import R from "@mui/material/IconButton"; | ||
return ` 0${n}${t[0]}`; | ||
const l = e < 0, s = l ? "-" : i.signed ? "+" : ""; | ||
l && (e = -e); | ||
let r; | ||
if (i.minimumFractionDigits !== void 0 && (r = { minimumFractionDigits: i.minimumFractionDigits }), i.maximumFractionDigits !== void 0 && (r = { maximumFractionDigits: i.maximumFractionDigits, ...r }), e < 1) { | ||
const p = F(e, i.locale, r); | ||
return s + p + n + t[0]; | ||
const r = e < 0, s = r ? "-" : i.signed ? "+" : ""; | ||
r && (e = -e); | ||
let l; | ||
if (i.minimumFractionDigits !== void 0 && (l = { minimumFractionDigits: i.minimumFractionDigits }), i.maximumFractionDigits !== void 0 && (l = { maximumFractionDigits: i.maximumFractionDigits, ...l }), e < 1) { | ||
const f = F(e, i.locale, l); | ||
return s + f + n + t[0]; | ||
} | ||
const f = Math.min(Math.floor(i.binary ? Math.log(e) / Math.log(1024) : Math.log10(e) / 3), t.length - 1); | ||
e /= (i.binary ? 1024 : 1e3) ** f, r || (e = e.toPrecision(3)); | ||
const g = F(Number(e), i.locale, r), d = t[f]; | ||
const u = Math.min(Math.floor(i.binary ? Math.log(e) / Math.log(1024) : Math.log10(e) / 3), t.length - 1); | ||
e /= (i.binary ? 1024 : 1e3) ** u, l || (e = e.toPrecision(3)); | ||
const g = F(Number(e), i.locale, l), d = t[u]; | ||
return s + g + n + d; | ||
@@ -120,11 +120,11 @@ } | ||
Filename: H | ||
}, K = u.forwardRef( | ||
}, K = p.forwardRef( | ||
(e, i) => { | ||
const { text: t, isPlaceholder: n, placeholder: l, ...s } = e, r = u.useId(); | ||
return /* @__PURE__ */ y(P.Label, { htmlFor: r, children: [ | ||
/* @__PURE__ */ a("input", { ...s, ref: i, id: r }), | ||
const { text: t, isPlaceholder: n, placeholder: r, ...s } = e; | ||
return /* @__PURE__ */ y(P.Label, { children: [ | ||
/* @__PURE__ */ a("input", { ...s, ref: i }), | ||
t ? /* @__PURE__ */ a( | ||
"span", | ||
{ | ||
"aria-placeholder": l, | ||
"aria-placeholder": r, | ||
className: n ? "MuiFileInput-placeholder" : "", | ||
@@ -149,3 +149,3 @@ children: typeof t == "string" ? t : /* @__PURE__ */ y(P.Filename, { children: [ | ||
} | ||
function x(e) { | ||
function I(e) { | ||
return typeof window < "u" && e instanceof File; | ||
@@ -157,3 +157,3 @@ } | ||
function Q(e) { | ||
const t = (x(e) ? e.name : e[0]?.name || "").split("."), n = t.pop(); | ||
const t = (I(e) ? e.name : e[0]?.name || "").split("."), n = t.pop(); | ||
return { | ||
@@ -164,3 +164,3 @@ filename: t.join("."), | ||
} | ||
const X = typeof window < "u" ? u.useLayoutEffect : u.useEffect, st = u.forwardRef( | ||
const X = typeof window < "u" ? p.useLayoutEffect : p.useEffect, st = p.forwardRef( | ||
(e, i) => { | ||
@@ -170,21 +170,21 @@ const { | ||
onChange: n, | ||
disabled: l, | ||
disabled: r, | ||
getInputText: s, | ||
getSizeText: r, | ||
placeholder: f, | ||
getSizeText: l, | ||
placeholder: u, | ||
hideSizeText: g, | ||
inputProps: d, | ||
InputProps: p, | ||
multiple: I, | ||
InputProps: f, | ||
multiple: x, | ||
className: N, | ||
clearIconButtonProps: S = {}, | ||
...E | ||
} = e, { className: w = "", ...v } = S, m = u.useRef(null), { startAdornment: C, ...z } = p || {}, L = I || d?.multiple || p?.inputProps?.multiple || !1, B = () => { | ||
} = e, { className: w = "", ...v } = S, m = p.useRef(null), { startAdornment: C, ...z } = f || {}, L = x || d?.multiple || f?.inputProps?.multiple || !1, B = () => { | ||
m.current && (m.current.value = ""); | ||
}, D = (o) => { | ||
const T = o.target.files, h = T ? J(T) : []; | ||
I ? (n?.(h), h.length === 0 && B()) : (n?.(h[0] || null), h[0] || B()); | ||
x ? (n?.(h), h.length === 0 && B()) : (n?.(h[0] || null), h[0] || B()); | ||
}, k = (o) => { | ||
o.preventDefault(), !l && n?.(I ? [] : null); | ||
}, c = Array.isArray(t) ? V(t) : x(t); | ||
o.preventDefault(), !r && n?.(x ? [] : null); | ||
}, c = Array.isArray(t) ? V(t) : I(t); | ||
X(() => { | ||
@@ -194,5 +194,5 @@ const o = m.current; | ||
}, [c]); | ||
const $ = () => t === null || Array.isArray(t) && t.length === 0 ? f || "" : typeof s == "function" && t !== void 0 ? s(t) : t && c ? Array.isArray(t) && t.length > 1 ? `${t.length} files` : Q(t) : "", Y = () => { | ||
if (typeof r == "function" && t !== void 0) | ||
return r(t); | ||
const $ = () => t === null || Array.isArray(t) && t.length === 0 ? u || "" : typeof s == "function" && t !== void 0 ? s(t) : t && c ? Array.isArray(t) && t.length > 1 ? `${t.length} files` : Q(t) : "", Y = () => { | ||
if (typeof l == "function" && t !== void 0) | ||
return l(t); | ||
if (c) { | ||
@@ -203,3 +203,3 @@ if (Array.isArray(t)) { | ||
} | ||
if (x(t)) | ||
if (I(t)) | ||
return A(t.size); | ||
@@ -214,3 +214,3 @@ } | ||
type: "file", | ||
disabled: l, | ||
disabled: r, | ||
onChange: D, | ||
@@ -242,3 +242,3 @@ className: `MuiFileInput-TextField ${N || ""}`, | ||
size: "small", | ||
disabled: l, | ||
disabled: r, | ||
className: `${w} MuiFileInput-ClearIconButton`, | ||
@@ -258,5 +258,5 @@ onClick: k, | ||
isPlaceholder: !c, | ||
placeholder: f, | ||
placeholder: u, | ||
...d, | ||
...p?.inputProps | ||
...f?.inputProps | ||
}, | ||
@@ -263,0 +263,0 @@ inputComponent: K |
@@ -10,3 +10,3 @@ { | ||
"homepage": "https://viclafouch.github.io/mui-file-input", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"files": [ | ||
@@ -78,5 +78,5 @@ "dist" | ||
"@emotion/styled": "^11.11.5", | ||
"@mui/base": "^5.0.0-beta.40", | ||
"@mui/icons-material": "^5.16.0", | ||
"@mui/material": "^5.16.0", | ||
"@mui/base": "^5.0.0-beta.40", | ||
"@storybook/addon-actions": "^8.1.11", | ||
@@ -96,2 +96,3 @@ "@storybook/addon-essentials": "^8.1.11", | ||
"@vitejs/plugin-react": "^4.3.1", | ||
"axe-core": "^4.9.1", | ||
"babel-loader": "^9.1.3", | ||
@@ -98,0 +99,0 @@ "eslint": "^8.56.0", |
@@ -45,3 +45,3 @@ <div align="center"> | ||
Learn how to use MUI file input with Next.js | ||
Learn how to use MUI File Input with [Next.js](https://nextjs.org/). | ||
@@ -48,0 +48,0 @@ Once you have installed `MUI File Input` in your next.js project, it is important to transpile it as it is an ESM package first. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
53454
0
35