@cerebruminc/cerebellum 19.0.1 → 19.1.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# react-component-lib-boilerplate
|
|
2
2
|
|
|
3
|
+
## [19.1.0](https://github.com/cerebruminc/cerebellum/compare/v19.0.1...v19.1.0) (2026-07-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **image-picker:** add onError callback ([857eb83](https://github.com/cerebruminc/cerebellum/commit/857eb83e2810bdcae981a79db4c13e47b4b55a7f))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* casing in ImagePicker error message ([eb8935f](https://github.com/cerebruminc/cerebellum/commit/eb8935f13da57bfe5333b28d008f8fabbbd36164))
|
|
14
|
+
|
|
3
15
|
## [19.0.1](https://github.com/cerebruminc/cerebellum/compare/v19.0.0...v19.0.1) (2026-07-24)
|
|
4
16
|
|
|
5
17
|
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fireEvent, render, screen } from "@testing-library/react";
|
|
1
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
2
2
|
import { withTheme } from "../../hocs/withTheme";
|
|
3
3
|
// import userEvent from "@testing-library/user-event";
|
|
4
4
|
import { IdFront } from "../Icons";
|
|
@@ -97,6 +97,18 @@ describe("ImagePicker", () => {
|
|
|
97
97
|
expect(text).toBeInTheDocument();
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
+
test("calls onError when an image cannot be processed", async () => {
|
|
101
|
+
const onError = jest.fn();
|
|
102
|
+
const consoleError = jest.spyOn(console, "error").mockImplementation();
|
|
103
|
+
const { container } = render(<ThemedImagePicker onError={onError} />);
|
|
104
|
+
const input = container.querySelector('input[type="file"]') as HTMLInputElement;
|
|
105
|
+
|
|
106
|
+
fireEvent.change(input, { target: { files: [] } });
|
|
107
|
+
|
|
108
|
+
await waitFor(() => expect(onError).toHaveBeenCalledWith(expect.any(Error)));
|
|
109
|
+
consoleError.mockRestore();
|
|
110
|
+
});
|
|
111
|
+
|
|
100
112
|
test("placeholderIcon renders", () => {
|
|
101
113
|
const PlaceholderIcon = IdFront;
|
|
102
114
|
render(<ThemedImagePicker PlaceholderIcon={PlaceholderIcon} />);
|
|
@@ -66,6 +66,7 @@ export const ImagePicker: FC<ImagePickerType> = ({
|
|
|
66
66
|
name,
|
|
67
67
|
onChange,
|
|
68
68
|
onDeleteButtonClick,
|
|
69
|
+
onError,
|
|
69
70
|
onImageSelect,
|
|
70
71
|
onPickerClick,
|
|
71
72
|
PlaceholderIcon,
|
|
@@ -170,9 +171,10 @@ export const ImagePicker: FC<ImagePickerType> = ({
|
|
|
170
171
|
} catch (error) {
|
|
171
172
|
showToast({
|
|
172
173
|
title: "",
|
|
173
|
-
text: "Error processing
|
|
174
|
+
text: "Error processing File",
|
|
174
175
|
colorFamily: ConnotationColorEnum.Negative,
|
|
175
176
|
});
|
|
177
|
+
throw error;
|
|
176
178
|
}
|
|
177
179
|
};
|
|
178
180
|
|
|
@@ -260,6 +262,7 @@ export const ImagePicker: FC<ImagePickerType> = ({
|
|
|
260
262
|
onChange?.(event);
|
|
261
263
|
} catch (error) {
|
|
262
264
|
console.error(`Error processing image: ${error}`);
|
|
265
|
+
onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
263
266
|
} finally {
|
|
264
267
|
setHeicProcessing(false);
|
|
265
268
|
}
|
|
@@ -57,6 +57,8 @@ export interface ImagePickerType {
|
|
|
57
57
|
name?: string;
|
|
58
58
|
/** Called when a file is selected */
|
|
59
59
|
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
60
|
+
/** Called when an image cannot be processed */
|
|
61
|
+
onError?: (error: Error) => void;
|
|
60
62
|
/** Called when the delete button is clicked */
|
|
61
63
|
onDeleteButtonClick?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
62
64
|
/** Sets HTML required attribute */
|