@griddo/ax 11.14.2-rc.1 → 11.14.2
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "11.14.2
|
|
4
|
+
"version": "11.14.2",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -219,5 +219,5 @@
|
|
|
219
219
|
"publishConfig": {
|
|
220
220
|
"access": "public"
|
|
221
221
|
},
|
|
222
|
-
"gitHead": "
|
|
222
|
+
"gitHead": "92256859b4b631e6fbd04d6ab48804b42b293614"
|
|
223
223
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Provider } from "react-redux";
|
|
2
2
|
|
|
3
3
|
import ImageDragAndDrop from "@ax/components/ImageDragAndDrop";
|
|
4
|
+
import { VALID_IMAGE_FORMATS } from "@ax/constants";
|
|
4
5
|
import { parseTheme } from "@ax/helpers";
|
|
5
6
|
import globalTheme from "@ax/themes/theme.json";
|
|
6
7
|
|
|
@@ -37,7 +38,7 @@ const renderImageDragAndDrop = (props = {}, storeData = initialStore) => {
|
|
|
37
38
|
return render(
|
|
38
39
|
<Provider store={store}>
|
|
39
40
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
40
|
-
<ImageDragAndDrop siteID="global"
|
|
41
|
+
<ImageDragAndDrop siteID="global" handleUpload={jest.fn()} {...props} />
|
|
41
42
|
</ThemeProvider>
|
|
42
43
|
</Provider>,
|
|
43
44
|
);
|
|
@@ -61,7 +62,9 @@ describe("ImageDragAndDrop rendering", () => {
|
|
|
61
62
|
|
|
62
63
|
it("should render valid formats text", () => {
|
|
63
64
|
renderImageDragAndDrop();
|
|
64
|
-
const validFormatsTexts = screen.getAllByText(
|
|
65
|
+
const validFormatsTexts = screen.getAllByText((_, element) => {
|
|
66
|
+
return VALID_IMAGE_FORMATS.every((format) => element?.textContent?.includes(format));
|
|
67
|
+
});
|
|
65
68
|
expect(validFormatsTexts.length).toBeGreaterThan(0);
|
|
66
69
|
});
|
|
67
70
|
|
|
@@ -75,7 +78,8 @@ describe("ImageDragAndDrop rendering", () => {
|
|
|
75
78
|
renderImageDragAndDrop();
|
|
76
79
|
const fileInput = document.querySelector('input[type="file"]') as HTMLInputElement;
|
|
77
80
|
expect(fileInput).toBeTruthy();
|
|
78
|
-
|
|
81
|
+
const expectedAccept = VALID_IMAGE_FORMATS.map((format) => `.${format}`).join(",");
|
|
82
|
+
expect(fileInput.accept).toBe(expectedAccept);
|
|
79
83
|
});
|
|
80
84
|
|
|
81
85
|
it("should render placeholder when isAllowedToUpload is false", () => {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
2
|
|
|
3
|
-
import { isEmptyObj } from "@ax/helpers";
|
|
4
3
|
import { Loading } from "@ax/components";
|
|
4
|
+
import { isEmptyObj } from "@ax/helpers";
|
|
5
|
+
import { useFirefoxScrollLock } from "@ax/hooks";
|
|
5
6
|
import type { IBreadcrumbItem, IUserEditing } from "@ax/types";
|
|
6
7
|
|
|
7
8
|
import Form from "./Form";
|
|
8
|
-
import NavigationForm from "./NavigationForm";
|
|
9
9
|
import GlobalPageForm from "./GlobalPageForm";
|
|
10
|
-
import PreviewForm from "./PreviewForm";
|
|
11
10
|
import Header from "./Header";
|
|
11
|
+
import NavigationForm from "./NavigationForm";
|
|
12
|
+
import PreviewForm from "./PreviewForm";
|
|
12
13
|
|
|
13
14
|
import * as S from "./style";
|
|
14
15
|
|
|
@@ -53,6 +54,8 @@ const ConfigPanel = (props: IStateProps) => {
|
|
|
53
54
|
}
|
|
54
55
|
}, [lastElementAddedId]);
|
|
55
56
|
|
|
57
|
+
useFirefoxScrollLock(wrapperRef);
|
|
58
|
+
|
|
56
59
|
if (isLoading || isEmptyObj(schema)) {
|
|
57
60
|
return <Loading />;
|
|
58
61
|
}
|
package/src/hooks/index.tsx
CHANGED
|
@@ -14,7 +14,7 @@ import { useHandleClickOutside, useModal, useModals, useToast } from "./modals";
|
|
|
14
14
|
import { useNetworkStatus } from "./network";
|
|
15
15
|
import { useResizable } from "./resize";
|
|
16
16
|
import { useGlobalPermission, usePermission, usePermissions } from "./users";
|
|
17
|
-
import { useWindowSize } from "./window";
|
|
17
|
+
import { useFirefoxScrollLock, useWindowSize } from "./window";
|
|
18
18
|
|
|
19
19
|
export {
|
|
20
20
|
useAdaptiveText,
|
|
@@ -24,6 +24,7 @@ export {
|
|
|
24
24
|
useDebouncedCallback,
|
|
25
25
|
useEmptyState,
|
|
26
26
|
useEqualStructured,
|
|
27
|
+
useFirefoxScrollLock,
|
|
27
28
|
useGlobalPermission,
|
|
28
29
|
useHandleClickOutside,
|
|
29
30
|
useIsDirty,
|
package/src/hooks/window.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useLayoutEffect, useState } from "react";
|
|
1
|
+
import { useEffect, useLayoutEffect, useState } from "react";
|
|
2
2
|
|
|
3
3
|
const useWindowSize = (): number[] => {
|
|
4
4
|
const [size, setSize] = useState([0, 0]);
|
|
@@ -13,4 +13,52 @@ const useWindowSize = (): number[] => {
|
|
|
13
13
|
return size;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Firefox auto-scrolls the window when typing in form fields if a scrollable
|
|
18
|
+
* element (e.g. Froala .fr-wrapper with overflow:auto) is present in the page.
|
|
19
|
+
* This hook blocks any window scroll not initiated by the user (wheel/touch)
|
|
20
|
+
* while a field inside the given container has focus.
|
|
21
|
+
*
|
|
22
|
+
* @see https://bugzilla.mozilla.org/show_bug.cgi?id=1422524
|
|
23
|
+
* @see https://bugzilla.mozilla.org/show_bug.cgi?id=1660932
|
|
24
|
+
*/
|
|
25
|
+
const useFirefoxScrollLock = (containerRef: React.RefObject<HTMLElement | null>) => {
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!navigator.userAgent.includes("Firefox")) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let savedScrollY = window.scrollY;
|
|
32
|
+
let userScrolling = false;
|
|
33
|
+
let scrollTimer: ReturnType<typeof setTimeout>;
|
|
34
|
+
|
|
35
|
+
const markUserScroll = () => {
|
|
36
|
+
userScrolling = true;
|
|
37
|
+
clearTimeout(scrollTimer);
|
|
38
|
+
scrollTimer = setTimeout(() => {
|
|
39
|
+
userScrolling = false;
|
|
40
|
+
}, 150);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const onScroll = () => {
|
|
44
|
+
if (!userScrolling && containerRef.current?.contains(document.activeElement)) {
|
|
45
|
+
window.scrollTo(0, savedScrollY);
|
|
46
|
+
} else {
|
|
47
|
+
savedScrollY = window.scrollY;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
window.addEventListener("wheel", markUserScroll, { passive: true });
|
|
52
|
+
window.addEventListener("touchmove", markUserScroll, { passive: true });
|
|
53
|
+
window.addEventListener("scroll", onScroll);
|
|
54
|
+
|
|
55
|
+
return () => {
|
|
56
|
+
window.removeEventListener("wheel", markUserScroll);
|
|
57
|
+
window.removeEventListener("touchmove", markUserScroll);
|
|
58
|
+
window.removeEventListener("scroll", onScroll);
|
|
59
|
+
clearTimeout(scrollTimer);
|
|
60
|
+
};
|
|
61
|
+
}, [containerRef]);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { useFirefoxScrollLock, useWindowSize };
|