@ainias42/react-bootstrap-mobile 0.2.11 → 0.2.12
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
|
@@ -16,7 +16,7 @@ export const FileInputController = withMemo(function FileInputController<Values
|
|
|
16
16
|
const {field, fieldState} = useController({name});
|
|
17
17
|
const {errors} = useFormState();
|
|
18
18
|
|
|
19
|
-
const {clearErrors} = useFormContext();
|
|
19
|
+
const {clearErrors, setError} = useFormContext();
|
|
20
20
|
const errorMessage = fieldState.error?.message ?? errors[`${name}.src`]?.message as string|undefined ?? errors[`${name}.name`]?.message as string|undefined ?? errors[`${name}.type`]?.message as string|undefined;
|
|
21
21
|
|
|
22
22
|
const internalOnChange = useCallback(
|
|
@@ -30,11 +30,18 @@ export const FileInputController = withMemo(function FileInputController<Values
|
|
|
30
30
|
[clearErrors, field, name]
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
+
const setErrorMessage = useCallback((error: string) => {
|
|
34
|
+
setError(name, {
|
|
35
|
+
message: error,
|
|
36
|
+
})
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
33
39
|
return (
|
|
34
40
|
<FileInput
|
|
35
41
|
{...otherProps}
|
|
36
42
|
{...field}
|
|
37
43
|
onChangeFile={internalOnChange}
|
|
44
|
+
onError={setErrorMessage}
|
|
38
45
|
value={field.value}
|
|
39
46
|
error={errorMessage}
|
|
40
47
|
/>
|
|
@@ -13,13 +13,13 @@ export type FullScreenProps<AsType extends keyof JSX.IntrinsicElements> = RbmCom
|
|
|
13
13
|
>;
|
|
14
14
|
|
|
15
15
|
export const FullScreen = withMemo(function FullScreen<AsTag extends keyof JSX.IntrinsicElements = 'span'>({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}: FullScreenProps<AsTag>) {
|
|
16
|
+
children,
|
|
17
|
+
as,
|
|
18
|
+
fullscreenKey,
|
|
19
|
+
onEnterFullscreen,
|
|
20
|
+
onLeaveFullscreen,
|
|
21
|
+
...otherProps
|
|
22
|
+
}: FullScreenProps<AsTag>) {
|
|
23
23
|
// Variables
|
|
24
24
|
|
|
25
25
|
// Refs
|
|
@@ -34,7 +34,8 @@ export const FullScreen = withMemo(function FullScreen<AsTag extends keyof JSX.I
|
|
|
34
34
|
const toggleFullscreen = useCallback(() => {
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
36
36
|
// @ts-ignore
|
|
37
|
-
|
|
37
|
+
const fullscreenElement = document.fullscreenElement || document.webkitFullscreenElement;
|
|
38
|
+
if (fullscreenElement === containerRef.current) {
|
|
38
39
|
if ('exitFullscreen' in document) {
|
|
39
40
|
document.exitFullscreen();
|
|
40
41
|
} else {
|
|
@@ -42,9 +43,9 @@ export const FullScreen = withMemo(function FullScreen<AsTag extends keyof JSX.I
|
|
|
42
43
|
// @ts-ignore
|
|
43
44
|
document.webkitCancelFullScreen();
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
return;
|
|
46
|
+
return;
|
|
47
47
|
}
|
|
48
|
+
|
|
48
49
|
if ('webkitRequestFullscreen' in document.body) {
|
|
49
50
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
51
|
// @ts-ignore
|
|
@@ -52,7 +53,6 @@ export const FullScreen = withMemo(function FullScreen<AsTag extends keyof JSX.I
|
|
|
52
53
|
} else {
|
|
53
54
|
containerRef.current?.requestFullscreen();
|
|
54
55
|
}
|
|
55
|
-
onEnterFullscreen?.();
|
|
56
56
|
}, [onEnterFullscreen, onLeaveFullscreen]);
|
|
57
57
|
|
|
58
58
|
// Effects
|
|
@@ -69,11 +69,37 @@ export const FullScreen = withMemo(function FullScreen<AsTag extends keyof JSX.I
|
|
|
69
69
|
return () => window?.removeEventListener('keyup', listener);
|
|
70
70
|
}, [fullscreenKey, toggleFullscreen, window]);
|
|
71
71
|
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!containerRef.current) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const container = containerRef.current;
|
|
78
|
+
const listener = () => {
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
const fullscreenElement = document.fullscreenElement || document.webkitFullscreenElement;
|
|
81
|
+
if (fullscreenElement === container) {
|
|
82
|
+
console.log("LOG-d enter fullscreen")
|
|
83
|
+
onEnterFullscreen?.();
|
|
84
|
+
} else {
|
|
85
|
+
console.log("LOG-d leave fullscreen")
|
|
86
|
+
onLeaveFullscreen?.();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
container.addEventListener('fullscreenchange', listener);
|
|
90
|
+
container.addEventListener('webkitfullscreenchange', listener);
|
|
91
|
+
|
|
92
|
+
return () => {
|
|
93
|
+
container.removeEventListener('fullscreenchange', listener);
|
|
94
|
+
container.removeEventListener('webkitfullscreenchange', listener);
|
|
95
|
+
}
|
|
96
|
+
}, [onEnterFullscreen, onLeaveFullscreen]);
|
|
97
|
+
|
|
72
98
|
// Other
|
|
73
99
|
|
|
74
100
|
// Render Functions
|
|
75
101
|
const element = as ?? 'span';
|
|
76
|
-
const props = useMemo(() => ({
|
|
102
|
+
const props = useMemo(() => ({...otherProps, ref: containerRef}), [otherProps]);
|
|
77
103
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
78
104
|
// @ts-ignore
|
|
79
105
|
return React.createElement(element, props, children);
|