next-helios-fe 1.8.135 → 1.8.136

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-helios-fe",
3
- "version": "1.8.135",
3
+ "version": "1.8.136",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -51,9 +51,26 @@ export const File: React.FC<FileProps> = ({
51
51
  useEffect(() => {
52
52
  if (value) {
53
53
  setTempFile(value);
54
+
55
+ if (value[0]?.size > (options?.maxSizeInMb || 0) * (1024 * 1024)) {
56
+ inputRef.current?.setCustomValidity(
57
+ `Please select a file less than ${options?.maxSizeInMb} MB.`
58
+ );
59
+ } else {
60
+ inputRef.current?.setCustomValidity("");
61
+ }
62
+
54
63
  return;
55
64
  } else if (defaultValue) {
56
65
  setTempFile(defaultValue);
66
+
67
+ if (defaultValue[0]?.size > (options?.maxSizeInMb || 0) * (1024 * 1024)) {
68
+ inputRef.current?.setCustomValidity(
69
+ `Please select a file less than ${options?.maxSizeInMb} MB.`
70
+ );
71
+ } else {
72
+ inputRef.current?.setCustomValidity("");
73
+ }
57
74
  return;
58
75
  }
59
76
  }, [value, defaultValue]);
@@ -137,6 +154,7 @@ export const File: React.FC<FileProps> = ({
137
154
  ) : (
138
155
  <div className="relative flex-1 flex items-center h-full">
139
156
  <input
157
+ ref={inputRef}
140
158
  type="file"
141
159
  className={`w-full px-4 border-default border border-dashed rounded-md bg-secondary-bg text-transparent cursor-pointer file:hidden focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light disabled:cursor-default ${
142
160
  options?.height === "full" ? "min-h-60 h-full" : "h-60"
@@ -214,9 +232,11 @@ export const File: React.FC<FileProps> = ({
214
232
  >
215
233
  {tempFile.length !== 0
216
234
  ? `${
217
- tempFile[0]?.size < 1000000
218
- ? `${(tempFile[0]?.size / 1000).toFixed(2)} KB`
219
- : `${(tempFile[0]?.size / 1000000).toFixed(2)} MB`
235
+ tempFile[0]?.size < 1024 * 1024
236
+ ? `${(tempFile[0]?.size / 1024).toFixed(2)} KB`
237
+ : `${(tempFile[0]?.size / (1024 * 1024)).toFixed(
238
+ 2
239
+ )} MB`
220
240
  }`
221
241
  : `Maximum file size ${options?.maxSizeInMb} MB`}
222
242
  </span>