From 849e1bee8803d6740e8e55668d1470a5ddf79c6f Mon Sep 17 00:00:00 2001 From: Shobhit Singhal Date: Wed, 23 Mar 2022 23:54:01 +0530 Subject: [PATCH 01/22] fix: fixed same key for multiple children error due to stack flattening --- src/utils/getSpacedChildren.tsx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/utils/getSpacedChildren.tsx b/src/utils/getSpacedChildren.tsx index 6bfc37d40..aaa53a4b2 100644 --- a/src/utils/getSpacedChildren.tsx +++ b/src/utils/getSpacedChildren.tsx @@ -17,15 +17,29 @@ type SpaceType = // Thanks @gregberge for code and @nandorojo for suggestion. // Original source: https://github.com/gregberge/react-flatten-children type ReactChildArray = ReturnType; -function flattenChildren(children: React.ReactNode): ReactChildArray { +function flattenChildren( + children: React.ReactNode, + keys: (string | number)[] = [] +): ReactChildArray { const childrenArray = React.Children.toArray(children); - return childrenArray.reduce((flatChildren: ReactChildArray, child) => { + return childrenArray.reduce((flatChildren: ReactChildArray, child, index: number) => { if ((child as React.ReactElement).type === React.Fragment) { return flatChildren.concat( - flattenChildren((child as React.ReactElement).props.children) + flattenChildren( + (child as React.ReactElement).props.children, + keys.concat(child.key || index) + ) ); } - flatChildren.push(child); + if (React.isValidElement(child)) { + flatChildren.push( + React.cloneElement(child, { + key: keys.concat(String(child.key || index)).join('.') + }) + ); + } else { + flatChildren.push(child); + } return flatChildren; }, []); } From d8e783b1c8af5d61cb60270a8d87f8f154055849 Mon Sep 17 00:00:00 2001 From: Viraj-10 Date: Tue, 21 Jun 2022 17:23:08 +0530 Subject: [PATCH 02/22] fix: adding position fixed in web for toast --- src/theme/components/toast.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/theme/components/toast.ts b/src/theme/components/toast.ts index d2130ca1b..d3325ee80 100644 --- a/src/theme/components/toast.ts +++ b/src/theme/components/toast.ts @@ -16,6 +16,7 @@ const baseStyle = (props: Record) => { alignItems: 'center', justifyContent: 'center', pointerEvents: 'box-none', + _web: { position: 'fixed' }, }, _overlay: {}, _presenceTransition: { From 13218c711515acf7f4c7be97d52c38b8ed923273 Mon Sep 17 00:00:00 2001 From: Viraj-10 Date: Wed, 22 Jun 2022 20:35:03 +0530 Subject: [PATCH 03/22] fix: toast keyboardavoiding view using bottom inset --- src/components/composites/Toast/Toast.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/composites/Toast/Toast.tsx b/src/components/composites/Toast/Toast.tsx index 5e03102ec..e380de53f 100644 --- a/src/components/composites/Toast/Toast.tsx +++ b/src/components/composites/Toast/Toast.tsx @@ -11,7 +11,7 @@ import { AccessibilityInfo, Platform, SafeAreaView } from 'react-native'; import Box from '../../primitives/Box'; import { usePropsResolution } from '../../../hooks'; import type { IToastContext, IToastInfo, IToast, IToastProps } from './types'; - +import { useKeyboardBottomInset } from '../../../utils'; const INSET = 50; const POSITIONS = { @@ -71,6 +71,7 @@ const CustomToast = ({ _overlay, _stack, _presenceTransition }: any) => { ToastContext ); + const bottomInset = useKeyboardBottomInset() * 2; const getPositions = () => { return Object.keys(toastInfo); }; @@ -110,7 +111,19 @@ const CustomToast = ({ _overlay, _stack, _presenceTransition }: any) => { translateY: transitionConfig[position], }} > - {toast.component} + + + {toast.component} + + )) } From b48769673524a386c47439e3dd5bc55484493c21 Mon Sep 17 00:00:00 2001 From: Viraj-10 Date: Thu, 23 Jun 2022 19:38:11 +0530 Subject: [PATCH 04/22] fix: animation api fade scalefade --- .../composites/Transitions/Fade.tsx | 20 ++++++++++++++----- .../composites/Transitions/ScaleFade.tsx | 18 +++++++++++++---- .../composites/Transitions/types.tsx | 12 ++++++++++- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/components/composites/Transitions/Fade.tsx b/src/components/composites/Transitions/Fade.tsx index 8953869be..a3406fd79 100644 --- a/src/components/composites/Transitions/Fade.tsx +++ b/src/components/composites/Transitions/Fade.tsx @@ -5,16 +5,26 @@ import { useHasResponsiveProps } from '../../../hooks/useHasResponsiveProps'; import { usePropsResolution } from '../../../hooks/'; const Fade = ({ children, ...props }: IFadeProps, ref?: any) => { - const { in: animationState, ...resolvedProps } = usePropsResolution( - 'Fade', - props - ); + const { + in: animationState, + entryDuration, + exitDuration, + ...resolvedProps + } = usePropsResolution('Fade', props); //TODO: refactor for responsive prop if (useHasResponsiveProps(props)) { return null; } + + if (entryDuration) { + resolvedProps.animate.transition.duration = entryDuration; + } + if (exitDuration) { + resolvedProps.exit.transition.duration = exitDuration; + } + return ( - + {children} ); diff --git a/src/components/composites/Transitions/ScaleFade.tsx b/src/components/composites/Transitions/ScaleFade.tsx index 47c9acfa3..b8cf03206 100644 --- a/src/components/composites/Transitions/ScaleFade.tsx +++ b/src/components/composites/Transitions/ScaleFade.tsx @@ -5,14 +5,24 @@ import { useHasResponsiveProps } from '../../../hooks/useHasResponsiveProps'; import { usePropsResolution } from '../../../hooks/'; const ScaleFade = ({ children, ...props }: IScaleFadeProps, ref?: any) => { - const { in: animationState, ...resolvedProps } = usePropsResolution( - 'ScaleFade', - props - ); + const { + in: animationState, + duration, + initialScale, + ...resolvedProps + } = usePropsResolution('ScaleFade', props); //TODO: refactor for responsive prop if (useHasResponsiveProps(props)) { return null; } + if (duration) { + resolvedProps.animate.transition.duration = duration; + resolvedProps.exit.transition.duration = duration; + } + if (initialScale) { + resolvedProps.animate.initial.scale = initialScale; + resolvedProps.exit.initial.scale = initialScale; + } return ( diff --git a/src/components/composites/Transitions/types.tsx b/src/components/composites/Transitions/types.tsx index cd108415c..d55f995ab 100644 --- a/src/components/composites/Transitions/types.tsx +++ b/src/components/composites/Transitions/types.tsx @@ -1,18 +1,24 @@ import type { ReactNode } from 'react'; import type { ViewProps } from 'react-native'; import type { InterfaceBoxProps } from '../../primitives/Box'; - +import type { IOverlayProps } from '../../primitives/Overlay'; export type IFadeProps = InterfaceBoxProps & { in?: boolean; entryDuration?: number; exitDuration?: number; delay?: number; + initial?: ISupportedTransitions; + animate?: ITransitionStyleProps; + exit?: ITransitionStyleProps; }; export type IScaleFadeProps = InterfaceBoxProps & { in?: boolean; duration?: number; delay?: number; initialScale?: number; + initial?: ISupportedTransitions; + animate?: ITransitionStyleProps; + exit?: ITransitionStyleProps; }; export type ISlideProps = InterfaceBoxProps & { in?: boolean; @@ -20,6 +26,10 @@ export type ISlideProps = InterfaceBoxProps & { delay?: number; placement?: 'top' | 'bottom' | 'right' | 'left'; overlay?: boolean; + /** + * Props to be passed to the Overlay used inside of Slide when overlay is true. + */ + _overlay?: IOverlayProps; }; export type ISlideFadeProps = InterfaceBoxProps & { in?: boolean; From 0b0431a64d38cfb4de94cc09ffe59e786a0c78cb Mon Sep 17 00:00:00 2001 From: Viraj-10 Date: Fri, 24 Jun 2022 15:59:18 +0530 Subject: [PATCH 05/22] fix: actionsheet scrollview for web --- src/components/composites/Actionsheet/Actionsheet.tsx | 5 +++++ src/components/composites/Modal/Modal.tsx | 2 ++ src/components/composites/Modal/types.ts | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/src/components/composites/Actionsheet/Actionsheet.tsx b/src/components/composites/Actionsheet/Actionsheet.tsx index f8aca915a..edc06715a 100644 --- a/src/components/composites/Actionsheet/Actionsheet.tsx +++ b/src/components/composites/Actionsheet/Actionsheet.tsx @@ -4,6 +4,7 @@ import type { IActionsheetProps } from './types'; import { usePropsResolution } from '../../../hooks'; import { ActionSheetContext } from './ActionSheetContext'; import { useHasResponsiveProps } from '../../../hooks/useHasResponsiveProps'; +import { Platform } from 'react-native'; const Actionsheet = ( { children, hideDragIndicator = false, ...props }: IActionsheetProps, @@ -20,6 +21,9 @@ const Actionsheet = ( if (useHasResponsiveProps(props)) { return null; } + //Fixing overlay position for Web due to scrollView issue + let overlayStyle = Platform.OS === 'web' ? { position: 'fixed' } : {}; + return ( {children} diff --git a/src/components/composites/Modal/Modal.tsx b/src/components/composites/Modal/Modal.tsx index c75731069..d818dc846 100644 --- a/src/components/composites/Modal/Modal.tsx +++ b/src/components/composites/Modal/Modal.tsx @@ -37,6 +37,7 @@ const Modal = ( _backdropFade, _fade, _slide, + _overlay, ...resolvedProps } = usePropsResolution('Modal', rest); @@ -83,6 +84,7 @@ const Modal = ( isKeyboardDismissable={isKeyboardDismissable} animationPreset={animationPreset} useRNModalOnAndroid + {..._overlay} > diff --git a/src/components/composites/Modal/types.ts b/src/components/composites/Modal/types.ts index 7ed1d52f1..9e1411748 100644 --- a/src/components/composites/Modal/types.ts +++ b/src/components/composites/Modal/types.ts @@ -5,6 +5,7 @@ import type { CustomProps } from '../../../components/types'; import type { IScrollViewProps } from '../../basic/ScrollView'; import type { IFadeProps, ISlideProps } from '../Transitions'; import type { ThemeComponentSizeType } from '../../../components/types/utils'; +import type { IOverlayProps } from '../../primitives/Overlay'; export interface InterfaceModalProps extends InterfaceBoxProps { /** * If true, the modal will open. Useful for controllable state behaviour @@ -76,6 +77,10 @@ export interface InterfaceModalProps extends InterfaceBoxProps { * Props applied on Child Slide Animation. */ _slide?: Partial; + /** + * Props to be passed to the Overlay used inside of Modal. + */ + _overlay?: IOverlayProps; } export type IModalComponentType = (( From 7dcb4bcfe8432cda0876a253dfbf7575e9258483 Mon Sep 17 00:00:00 2001 From: Viraj-10 Date: Mon, 27 Jun 2022 13:47:14 +0530 Subject: [PATCH 06/22] fix: revert transfromer of font --- src/theme/styled-system.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/theme/styled-system.ts b/src/theme/styled-system.ts index fcb02181e..954b83087 100644 --- a/src/theme/styled-system.ts +++ b/src/theme/styled-system.ts @@ -531,10 +531,10 @@ export const typography = { fontFamily: { property: 'fontFamily', scale: 'fonts', - transformer: (val: any, scale: any) => { - const value = get(scale, val); - return value ? value.toString() : undefined; - }, + // transformer: (val: any, scale: any) => { + // const value = get(scale, val); + // return value ? value.toString() : undefined; + // }, }, fontSize: { property: 'fontSize', From 05388a5740943047ad95aa56dec252bfa67bf4e3 Mon Sep 17 00:00:00 2001 From: ankit-tailor Date: Tue, 28 Jun 2022 13:45:44 +0530 Subject: [PATCH 07/22] fix: status condition --- .../stories/components/composites/Toast/StatusRecipies.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/example/storybook/stories/components/composites/Toast/StatusRecipies.tsx b/example/storybook/stories/components/composites/Toast/StatusRecipies.tsx index e26f9ef5c..ee3d661f0 100644 --- a/example/storybook/stories/components/composites/Toast/StatusRecipies.tsx +++ b/example/storybook/stories/components/composites/Toast/StatusRecipies.tsx @@ -52,7 +52,7 @@ export const Example = () => { maxWidth="100%" alignSelf="center" flexDirection="row" - status={status ?? 'info'} + status={status ? status : 'info'} variant={variant as any} {...rest} > @@ -91,8 +91,9 @@ export const Example = () => { return (
- {ToastDetails.map((item) => ( + {ToastDetails.map((item, index) => ( + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; From 0c0a563f92669f238701400578c1654c15197019 Mon Sep 17 00:00:00 2001 From: Suraj Ahmed Date: Wed, 6 Jul 2022 16:25:22 +0530 Subject: [PATCH 20/22] fix: avatar badge size prop --- src/components/composites/Avatar/Avatar.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/composites/Avatar/Avatar.tsx b/src/components/composites/Avatar/Avatar.tsx index f0e635740..adb54ccc6 100644 --- a/src/components/composites/Avatar/Avatar.tsx +++ b/src/components/composites/Avatar/Avatar.tsx @@ -22,7 +22,11 @@ const Avatar = ({ children, ...props }: IAvatarProps, ref: any) => { child?.type.displayName === 'AvatarBadge' ) { Badge = React.cloneElement(child, { - size: _badgeSize ? _badgeSize[0] : undefined, + size: child?.props?.size + ? child?.props?.size + : _badgeSize + ? _badgeSize[0] + : undefined, }); } else { remainingChildren.push(child); From d6997feaaec047aa4369f6eb956205028b1a175e Mon Sep 17 00:00:00 2001 From: Suraj Ahmed Date: Wed, 6 Jul 2022 16:36:00 +0530 Subject: [PATCH 21/22] v3.4.8-rc.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b405188cf..e19165ee6 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "prettier --write" ] }, - "version": "3.4.8-rc.0", + "version": "3.4.8-rc.1", "license": "MIT", "private": false, "main": "lib/commonjs/index", From 6f3f1603c630eb4d4396c3865669e72b8241272f Mon Sep 17 00:00:00 2001 From: Suraj Ahmed Date: Wed, 6 Jul 2022 17:25:37 +0530 Subject: [PATCH 22/22] v3.4.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e19165ee6..dcd9e2be8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "prettier --write" ] }, - "version": "3.4.8-rc.1", + "version": "3.4.8", "license": "MIT", "private": false, "main": "lib/commonjs/index",