next-helios-fe 1.9.7 → 1.9.8
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/components/media/audioPlayer.d.ts +10 -0
- package/dist/components/media/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/form/input/file.tsx +58 -11
- package/src/components/media/index.tsx +1 -1
- /package/src/components/media/{audio-player.tsx → audioPlayer.tsx} +0 -0
package/package.json
CHANGED
@@ -27,6 +27,7 @@ export const File: React.FC<FileProps> = ({
|
|
27
27
|
defaultValue,
|
28
28
|
value,
|
29
29
|
required,
|
30
|
+
onChange,
|
30
31
|
...rest
|
31
32
|
}) => {
|
32
33
|
const inputRef = useRef<HTMLInputElement>(null);
|
@@ -44,10 +45,18 @@ export const File: React.FC<FileProps> = ({
|
|
44
45
|
.querySelector("input[type=file]")
|
45
46
|
?.addEventListener("cancel", (e) => {
|
46
47
|
setTempFile([]);
|
47
|
-
|
48
|
+
onChange && onChange({ target: { files: [] } } as any);
|
48
49
|
});
|
49
50
|
}, []);
|
50
51
|
|
52
|
+
useEffect(() => {
|
53
|
+
if (tempFile.length === 0) {
|
54
|
+
inputRef.current?.setCustomValidity("Please select a file.");
|
55
|
+
} else {
|
56
|
+
inputRef.current?.setCustomValidity("");
|
57
|
+
}
|
58
|
+
}, [tempFile]);
|
59
|
+
|
51
60
|
useEffect(() => {
|
52
61
|
if (value) {
|
53
62
|
setTempFile(value);
|
@@ -136,12 +145,31 @@ export const File: React.FC<FileProps> = ({
|
|
136
145
|
type="file"
|
137
146
|
className={`peer/file w-full px-4 border-default border rounded-md bg-secondary-bg text-transparent file:hidden focus:outline-none focus:ring-1 focus:ring-primary focus:shadow focus:shadow-primary focus:border-primary-dark disabled:bg-secondary-light ${height}`}
|
138
147
|
onChange={(e) => {
|
139
|
-
if (
|
140
|
-
|
141
|
-
|
142
|
-
|
148
|
+
if (
|
149
|
+
!e.target.files?.[0]?.type.includes("svg") &&
|
150
|
+
!e.target.files?.[0]?.name.includes(".svg")
|
151
|
+
) {
|
152
|
+
if (onChange) {
|
153
|
+
onChange({
|
154
|
+
target: { files: e.target.files } as HTMLInputElement,
|
155
|
+
} as any);
|
156
|
+
} else {
|
157
|
+
setTempFile(e.target.files);
|
158
|
+
}
|
143
159
|
} else {
|
144
|
-
|
160
|
+
if (typeof window !== "undefined") {
|
161
|
+
alert(
|
162
|
+
"SVG files are not allowed due to security concerns."
|
163
|
+
);
|
164
|
+
}
|
165
|
+
|
166
|
+
if (onChange) {
|
167
|
+
onChange({
|
168
|
+
target: { files: [] } as any,
|
169
|
+
} as any);
|
170
|
+
} else {
|
171
|
+
setTempFile([]);
|
172
|
+
}
|
145
173
|
}
|
146
174
|
}}
|
147
175
|
required={required && value?.length === 0}
|
@@ -165,12 +193,31 @@ export const File: React.FC<FileProps> = ({
|
|
165
193
|
options?.height === "full" ? "min-h-60 h-full" : "h-60"
|
166
194
|
}`}
|
167
195
|
onChange={(e) => {
|
168
|
-
if (
|
169
|
-
|
170
|
-
|
171
|
-
|
196
|
+
if (
|
197
|
+
!e.target.files?.[0]?.type.includes("svg") &&
|
198
|
+
!e.target.files?.[0]?.name.includes(".svg")
|
199
|
+
) {
|
200
|
+
if (onChange) {
|
201
|
+
onChange({
|
202
|
+
target: { files: e.target.files } as HTMLInputElement,
|
203
|
+
} as any);
|
204
|
+
} else {
|
205
|
+
setTempFile(e.target.files);
|
206
|
+
}
|
172
207
|
} else {
|
173
|
-
|
208
|
+
if (typeof window !== "undefined") {
|
209
|
+
alert(
|
210
|
+
"SVG files are not allowed due to security concerns."
|
211
|
+
);
|
212
|
+
}
|
213
|
+
|
214
|
+
if (onChange) {
|
215
|
+
onChange({
|
216
|
+
target: { files: [] } as any,
|
217
|
+
} as any);
|
218
|
+
} else {
|
219
|
+
setTempFile([]);
|
220
|
+
}
|
174
221
|
}
|
175
222
|
}}
|
176
223
|
onDragEnter={(e) => {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import React from "react";
|
3
|
-
import { AudioPlayer, type AudioPlayerProps } from "./
|
3
|
+
import { AudioPlayer, type AudioPlayerProps } from "./audioPlayer";
|
4
4
|
|
5
5
|
interface MediaProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
6
6
|
children: React.ReactNode;
|
File without changes
|