@fibery/ui-kit 1.38.2 → 1.39.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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/ui-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"dependencies": {
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"screenfull": "6.0.2",
|
|
48
48
|
"tabbable": "5.2.1",
|
|
49
49
|
"ua-parser-js": "1.0.39",
|
|
50
|
-
"@fibery/emoji-data": "2.7.1",
|
|
51
50
|
"@fibery/helpers": "1.3.4",
|
|
52
|
-
"@fibery/react": "1.4.6"
|
|
51
|
+
"@fibery/react": "1.4.6",
|
|
52
|
+
"@fibery/emoji-data": "2.7.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"react": "18.3.1",
|
package/src/card-container.tsx
CHANGED
|
@@ -283,6 +283,8 @@ type Props = {
|
|
|
283
283
|
after?: ReactNode;
|
|
284
284
|
floating?: ReactNode;
|
|
285
285
|
cover?: ReactNode;
|
|
286
|
+
// TODO: refactor. Extract Cover container
|
|
287
|
+
autoCoverHeight?: boolean;
|
|
286
288
|
size: CardSize;
|
|
287
289
|
contentStyle?: CSSProperties;
|
|
288
290
|
backgroundColors?: string[] | null;
|
|
@@ -298,6 +300,7 @@ const cardContent = css`
|
|
|
298
300
|
|
|
299
301
|
export const CardContainer = ({
|
|
300
302
|
cover,
|
|
303
|
+
autoCoverHeight,
|
|
301
304
|
before,
|
|
302
305
|
title,
|
|
303
306
|
after,
|
|
@@ -333,7 +336,7 @@ export const CardContainer = ({
|
|
|
333
336
|
{showCover && (
|
|
334
337
|
<div
|
|
335
338
|
className={cx(coverClassName, hasContent && coverWithContentClassName)}
|
|
336
|
-
style={{height: coverHeightBySize[size] || 0}}
|
|
339
|
+
style={!autoCoverHeight ? {height: coverHeightBySize[size] || 0} : undefined}
|
|
337
340
|
>
|
|
338
341
|
{cover}
|
|
339
342
|
</div>
|
package/src/use-is-phone.tsx
CHANGED
|
@@ -24,25 +24,26 @@ function isVerticalMobileBreakpointDisabled() {
|
|
|
24
24
|
return urlParams.has("no-vertical-mobile-breakpoint");
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const isPhoneApp =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
export const isPhoneApp = () =>
|
|
28
|
+
Boolean(
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
30
|
+
// @ts-ignore - injected by consumer app
|
|
31
|
+
window.__FIBERY_MOBILE_APP_API
|
|
32
|
+
);
|
|
32
33
|
|
|
33
34
|
export const phoneMediaQuery = isVerticalMobileBreakpointDisabled()
|
|
34
35
|
? "(max-width: 450px)"
|
|
35
36
|
: "(max-width: 450px), (max-height: 450px)";
|
|
36
37
|
|
|
37
38
|
export function isPhoneMode() {
|
|
38
|
-
return isPhoneApp || getMediaQueryList(phoneMediaQuery).matches;
|
|
39
|
+
return isPhoneApp() || getMediaQueryList(phoneMediaQuery).matches;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
export function IsPhoneProvider({children}: {children: ReactNode}) {
|
|
42
43
|
const isPhone = useIsMediaQueryMatched(phoneMediaQuery);
|
|
43
44
|
useLayoutEffect(() => {
|
|
44
45
|
const htmlElement = document.querySelector("html");
|
|
45
|
-
if (!htmlElement || isPhoneApp) {
|
|
46
|
+
if (!htmlElement || isPhoneApp()) {
|
|
46
47
|
if (htmlElement) {
|
|
47
48
|
htmlElement.classList.add(mobileRootClassName);
|
|
48
49
|
return () => {
|
|
@@ -61,5 +62,5 @@ export function IsPhoneProvider({children}: {children: ReactNode}) {
|
|
|
61
62
|
htmlElement.classList.remove(mobileRootClassName);
|
|
62
63
|
};
|
|
63
64
|
}, [isPhone]);
|
|
64
|
-
return <Provider value={isPhoneApp || isPhone}>{children}</Provider>;
|
|
65
|
+
return <Provider value={isPhoneApp() || isPhone}>{children}</Provider>;
|
|
65
66
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ReactNode, useEffect, useState} from "react";
|
|
2
2
|
import {createContext} from "@fibery/react/src/create-context";
|
|
3
3
|
import _ from "lodash";
|
|
4
|
-
import {
|
|
4
|
+
import {isPhoneApp} from "./use-is-phone";
|
|
5
5
|
import {keyboardHeightVar, mobileKeyboardOpenClassName} from "./mobile-styles";
|
|
6
6
|
|
|
7
7
|
const defaultKeyboardHeight = 350;
|
|
@@ -17,13 +17,12 @@ const [IsOnScreenKeyboardOpenedValueProvider, useIsOnScreenKeyboardOpened] = cre
|
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
export function OnScreenKeyboardContextProvider({children}: {children: ReactNode}) {
|
|
20
|
-
const isPhone = useIsPhone();
|
|
21
20
|
const [keyboardHeight, setKeyboardHeight] = useState<number>(defaultKeyboardHeight);
|
|
22
21
|
const [keyboardVisible, setKeyboardVisible] = useState<boolean>(false);
|
|
23
22
|
const [initialViewPortHeight] = useState(() => window.visualViewport?.height || 0);
|
|
24
23
|
useEffect(() => {
|
|
25
24
|
const viewport = window.visualViewport;
|
|
26
|
-
if (!viewport || !
|
|
25
|
+
if (!viewport || !isPhoneApp()) {
|
|
27
26
|
return _.noop;
|
|
28
27
|
}
|
|
29
28
|
|
|
@@ -55,7 +54,7 @@ export function OnScreenKeyboardContextProvider({children}: {children: ReactNode
|
|
|
55
54
|
return () => {
|
|
56
55
|
viewport.removeEventListener("resize", viewportHandler);
|
|
57
56
|
};
|
|
58
|
-
}, [initialViewPortHeight,
|
|
57
|
+
}, [initialViewPortHeight, keyboardHeight, keyboardVisible]);
|
|
59
58
|
return (
|
|
60
59
|
<OnScreenKeyboardHeightValueProvider value={keyboardHeight}>
|
|
61
60
|
<IsOnScreenKeyboardOpenedValueProvider value={keyboardVisible}>{children}</IsOnScreenKeyboardOpenedValueProvider>
|