pixelize-design-library 3.3.5 → 3.3.6

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/CHANGELOG.md CHANGED
@@ -9,6 +9,22 @@ Found a bug or a gap? Report it as a GitHub issue and track it to closure — se
9
9
  [COMPONENT-GOTCHAS.md](COMPONENT-GOTCHAS.md#found-a-gap-or-a-bug-report-it-then-track-it). A fix's
10
10
  line below names its issue number.
11
11
 
12
+ ## [3.3.6] — 2026-11-18
13
+
14
+ ### Fixed
15
+
16
+ - **`FileUpload` rejected an allowed Excel file on some Windows PCs** (Bata: `File "x.xls" is not an accepted file
17
+ type.`). `acceptTypes` reached react-dropzone as MIME types with no extensions, so a file was matched only by the
18
+ MIME type the browser reported, which on Windows comes from the registry and need not match. Each extension is now
19
+ listed under its MIME type (`.jpg` and `.jpeg` share `image/jpeg`), so a file passes by name or by type, and the
20
+ browse dialog's `accept` lists the extensions too. Disallowed extensions are still rejected.
21
+
22
+ ### Added
23
+
24
+ - **`FileUpload` `showSizeLimit`** (default `true`): `false` drops "up to X MB" from the limits line and the drop
25
+ zone's name, keeping the types and the file cap, for apps that enforce size server-side. `maxSizeKB` still rejects
26
+ larger files. Omitted, the output is byte-identical to 3.3.5.
27
+
12
28
  ## [3.3.5] — 2026-11-18
13
29
 
14
30
  ### Fixed
@@ -71,7 +71,7 @@ const FileThumbnail = ({ file, radius, onPreview, }) => {
71
71
  } }), (0, jsx_runtime_1.jsx)(react_2.Box, { className: "hover-icon", position: "absolute", top: "0.5rem", left: "0.5rem", opacity: 0, children: (0, jsx_runtime_1.jsx)(lucide_react_1.Eye, { color: "white" }) })] }));
72
72
  };
73
73
  /** Controlled drop zone — you own the `uploadedFiles`/File[] state; `maxSizeKB` defaults to 5 MB. */
74
- const FileUpload = ({ onFilesUploaded, uploadedFiles, onRemoveFile, acceptTypes = [".jpg", ".png"], maxSizeKB = constants_1.DEFAULT_MAX_SIZE_KB, maxFiles = undefined, progress = {}, size = "md", inputAriaLabel = "Upload files", id, label, isRequired = false, isDisabled = false, error = false, errorMessage, helperText, }) => {
74
+ const FileUpload = ({ onFilesUploaded, uploadedFiles, onRemoveFile, acceptTypes = [".jpg", ".png"], maxSizeKB = constants_1.DEFAULT_MAX_SIZE_KB, showSizeLimit = true, maxFiles = undefined, progress = {}, size = "md", inputAriaLabel = "Upload files", id, label, isRequired = false, isDisabled = false, error = false, errorMessage, helperText, }) => {
75
75
  const ids = (0, useFieldIds_1.useFieldIds)(id, { error, errorMessage, helperText });
76
76
  const compact = size === "sm";
77
77
  const { colors, radii } = (0, useCustomTheme_1.useCustomTheme)();
@@ -80,15 +80,9 @@ const FileUpload = ({ onFilesUploaded, uploadedFiles, onRemoveFile, acceptTypes
80
80
  const [previewTitle, setPreviewTitle] = react_1.default.useState(null);
81
81
  const [errors, setErrors] = react_1.default.useState([]);
82
82
  const border = error ? colors.semanticText.error : colors.boxborder[500];
83
- const limitParts = [acceptTypes.join(", "), " up to ", (0, constants_1.toMB)(maxSizeKB), " ", maxFiles ? `- ${maxFiles} file(s) max` : ""];
83
+ const sizeParts = showSizeLimit ? [" up to ", (0, constants_1.toMB)(maxSizeKB)] : [];
84
+ const limitParts = [acceptTypes.join(", "), ...sizeParts, " ", maxFiles ? `- ${maxFiles} file(s) max` : ""];
84
85
  const limits = limitParts.join("").trim();
85
- const mappedAccept = acceptTypes.reduce((acc, ext) => {
86
- const mime = constants_1.mimeMap[ext];
87
- if (mime) {
88
- acc[mime] = []; // File dropzone format
89
- }
90
- return acc;
91
- }, {});
92
86
  const onDrop = (0, react_1.useCallback)((acceptedFiles) => {
93
87
  setErrors([]);
94
88
  const totalFiles = uploadedFiles.length + acceptedFiles.length;
@@ -102,7 +96,7 @@ const FileUpload = ({ onFilesUploaded, uploadedFiles, onRemoveFile, acceptTypes
102
96
  }, [onFilesUploaded, uploadedFiles, maxFiles]);
103
97
  const { getRootProps, getInputProps } = (0, react_dropzone_1.useDropzone)({
104
98
  onDrop,
105
- accept: mappedAccept,
99
+ accept: (0, constants_1.toDropzoneAccept)(acceptTypes),
106
100
  maxSize: maxSizeKB * 1024,
107
101
  maxFiles,
108
102
  disabled: isDisabled,
@@ -10,10 +10,12 @@ export type FileUploaderProps = {
10
10
  uploadedFiles: File[];
11
11
  /** Shows a remove button per file when set; the caller must drop it from `uploadedFiles`. */
12
12
  onRemoveFile?: (file: File) => void;
13
- /** Allowed extensions; defaults to `[".jpg", ".png"]`. Rejected files get an inline message. */
13
+ /** Allowed extensions, matched by file name or MIME type; defaults to `[".jpg", ".png"]`. */
14
14
  acceptTypes?: MimeExtension[];
15
15
  /** Max size per file in KB (not MB); defaults to 5120 (5 MB). */
16
16
  maxSizeKB?: number;
17
+ /** Shows "up to X MB" in the limits line; `false` hides it while `maxSizeKB` is still enforced. */
18
+ showSizeLimit?: boolean;
17
19
  /** Cap on total files including already-uploaded ones; a drop that exceeds it is rejected whole. */
18
20
  maxFiles?: number;
19
21
  /** `sm` is a compact single-row drop zone; defaults to `md`. */
@@ -1,4 +1,5 @@
1
- import { MimeMap } from "./FileUploadProps";
1
+ import { MimeExtension, MimeMap } from "./FileUploadProps";
2
2
  export declare const mimeMap: MimeMap;
3
3
  export declare const DEFAULT_MAX_SIZE_KB: number;
4
4
  export declare const toMB: (size: number) => string;
5
+ export declare const toDropzoneAccept: (acceptTypes: MimeExtension[]) => Record<string, string[]>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toMB = exports.DEFAULT_MAX_SIZE_KB = exports.mimeMap = void 0;
3
+ exports.toDropzoneAccept = exports.toMB = exports.DEFAULT_MAX_SIZE_KB = exports.mimeMap = void 0;
4
4
  exports.mimeMap = {
5
5
  '.jpg': 'image/jpeg',
6
6
  '.jpeg': 'image/jpeg',
@@ -28,3 +28,13 @@ exports.mimeMap = {
28
28
  exports.DEFAULT_MAX_SIZE_KB = 5 * 1024;
29
29
  const toMB = (size) => `${(size / 1024).toFixed(2)} MB`;
30
30
  exports.toMB = toMB;
31
+ const toDropzoneAccept = (acceptTypes) => acceptTypes.reduce((acc, ext) => {
32
+ var _a;
33
+ if (!(ext in exports.mimeMap))
34
+ return acc;
35
+ const mime = exports.mimeMap[ext];
36
+ const listed = (_a = acc[mime]) !== null && _a !== void 0 ? _a : [];
37
+ acc[mime] = listed.includes(ext) ? listed : [...listed, ext];
38
+ return acc;
39
+ }, {});
40
+ exports.toDropzoneAccept = toDropzoneAccept;
@@ -5,7 +5,7 @@ import { useDropzone } from "react-dropzone";
5
5
  import { Upload, FileText, Eye } from "lucide-react";
6
6
  import { useCustomTheme } from "../../Theme/useCustomTheme.js";
7
7
  import { accentTextOnCanvas } from "../../Theme/tokens/builders/accentText.js";
8
- import { DEFAULT_MAX_SIZE_KB, mimeMap, toMB } from "./constants.js";
8
+ import { DEFAULT_MAX_SIZE_KB, toDropzoneAccept, toMB } from "./constants.js";
9
9
  import { useObjectUrl } from "./useObjectUrl.js";
10
10
  import Modal, { ModalBody, ModalHeader } from "../Modal/Modal.js";
11
11
  import { TextLabel } from "../Common/FormLabel.js";
@@ -33,7 +33,7 @@ const FileThumbnail = ({ file, radius, onPreview, }) => {
33
33
  } }), _jsx(Box, { className: "hover-icon", position: "absolute", top: "0.5rem", left: "0.5rem", opacity: 0, children: _jsx(Eye, { color: "white" }) })] }));
34
34
  };
35
35
  /** Controlled drop zone — you own the `uploadedFiles`/File[] state; `maxSizeKB` defaults to 5 MB. */
36
- const FileUpload = ({ onFilesUploaded, uploadedFiles, onRemoveFile, acceptTypes = [".jpg", ".png"], maxSizeKB = DEFAULT_MAX_SIZE_KB, maxFiles = undefined, progress = {}, size = "md", inputAriaLabel = "Upload files", id, label, isRequired = false, isDisabled = false, error = false, errorMessage, helperText, }) => {
36
+ const FileUpload = ({ onFilesUploaded, uploadedFiles, onRemoveFile, acceptTypes = [".jpg", ".png"], maxSizeKB = DEFAULT_MAX_SIZE_KB, showSizeLimit = true, maxFiles = undefined, progress = {}, size = "md", inputAriaLabel = "Upload files", id, label, isRequired = false, isDisabled = false, error = false, errorMessage, helperText, }) => {
37
37
  const ids = useFieldIds(id, { error, errorMessage, helperText });
38
38
  const compact = size === "sm";
39
39
  const { colors, radii } = useCustomTheme();
@@ -42,15 +42,9 @@ const FileUpload = ({ onFilesUploaded, uploadedFiles, onRemoveFile, acceptTypes
42
42
  const [previewTitle, setPreviewTitle] = React.useState(null);
43
43
  const [errors, setErrors] = React.useState([]);
44
44
  const border = error ? colors.semanticText.error : colors.boxborder[500];
45
- const limitParts = [acceptTypes.join(", "), " up to ", toMB(maxSizeKB), " ", maxFiles ? `- ${maxFiles} file(s) max` : ""];
45
+ const sizeParts = showSizeLimit ? [" up to ", toMB(maxSizeKB)] : [];
46
+ const limitParts = [acceptTypes.join(", "), ...sizeParts, " ", maxFiles ? `- ${maxFiles} file(s) max` : ""];
46
47
  const limits = limitParts.join("").trim();
47
- const mappedAccept = acceptTypes.reduce((acc, ext) => {
48
- const mime = mimeMap[ext];
49
- if (mime) {
50
- acc[mime] = []; // File dropzone format
51
- }
52
- return acc;
53
- }, {});
54
48
  const onDrop = useCallback((acceptedFiles) => {
55
49
  setErrors([]);
56
50
  const totalFiles = uploadedFiles.length + acceptedFiles.length;
@@ -64,7 +58,7 @@ const FileUpload = ({ onFilesUploaded, uploadedFiles, onRemoveFile, acceptTypes
64
58
  }, [onFilesUploaded, uploadedFiles, maxFiles]);
65
59
  const { getRootProps, getInputProps } = useDropzone({
66
60
  onDrop,
67
- accept: mappedAccept,
61
+ accept: toDropzoneAccept(acceptTypes),
68
62
  maxSize: maxSizeKB * 1024,
69
63
  maxFiles,
70
64
  disabled: isDisabled,
@@ -24,3 +24,12 @@ export const mimeMap = {
24
24
  };
25
25
  export const DEFAULT_MAX_SIZE_KB = 5 * 1024;
26
26
  export const toMB = (size) => `${(size / 1024).toFixed(2)} MB`;
27
+ export const toDropzoneAccept = (acceptTypes) => acceptTypes.reduce((acc, ext) => {
28
+ var _a;
29
+ if (!(ext in mimeMap))
30
+ return acc;
31
+ const mime = mimeMap[ext];
32
+ const listed = (_a = acc[mime]) !== null && _a !== void 0 ? _a : [];
33
+ acc[mime] = listed.includes(ext) ? listed : [...listed, ext];
34
+ return acc;
35
+ }, {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelize-design-library",
3
- "version": "3.3.5",
3
+ "version": "3.3.6",
4
4
  "description": "React component library for Pixelize apps: themeable Chakra-based components, design tokens and light/dark brand theming.",
5
5
  "keywords": [
6
6
  "react",