@codeleap/mobile 5.8.9 → 5.8.11

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.
Files changed (47) hide show
  1. package/dist/components/Avatar/components/Badge.d.ts +3 -0
  2. package/dist/components/Avatar/components/Badge.js +13 -0
  3. package/dist/components/Avatar/components/Badge.js.map +1 -0
  4. package/dist/components/Avatar/components/Content.d.ts +2 -0
  5. package/dist/components/Avatar/components/Content.js +19 -0
  6. package/dist/components/Avatar/components/Content.js.map +1 -0
  7. package/dist/components/Avatar/components/Illustration.d.ts +3 -0
  8. package/dist/components/Avatar/components/Illustration.js +14 -0
  9. package/dist/components/Avatar/components/Illustration.js.map +1 -0
  10. package/dist/components/Avatar/components/OverlayIcon.d.ts +3 -0
  11. package/dist/components/Avatar/components/OverlayIcon.js +12 -0
  12. package/dist/components/Avatar/components/OverlayIcon.js.map +1 -0
  13. package/dist/components/Avatar/components/Text.d.ts +3 -0
  14. package/dist/components/Avatar/components/Text.js +18 -0
  15. package/dist/components/Avatar/components/Text.js.map +1 -0
  16. package/dist/components/Avatar/components/Wrapper.d.ts +4 -0
  17. package/dist/components/Avatar/components/Wrapper.js +28 -0
  18. package/dist/components/Avatar/components/Wrapper.js.map +1 -0
  19. package/dist/components/Avatar/context.d.ts +134 -0
  20. package/dist/components/Avatar/context.js +13 -0
  21. package/dist/components/Avatar/context.js.map +1 -0
  22. package/dist/components/Avatar/index.d.ts +6 -2
  23. package/dist/components/Avatar/index.js +18 -52
  24. package/dist/components/Avatar/index.js.map +1 -1
  25. package/dist/components/Avatar/styles.d.ts +1 -1
  26. package/dist/components/Avatar/types.d.ts +21 -16
  27. package/dist/components/Grid/index.js +2 -1
  28. package/dist/components/Grid/index.js.map +1 -1
  29. package/dist/components/List/index.js +1 -1
  30. package/dist/components/List/index.js.map +1 -1
  31. package/dist/components/Sections/index.js +1 -1
  32. package/dist/components/Sections/index.js.map +1 -1
  33. package/package.json +17 -17
  34. package/package.json.bak +1 -1
  35. package/src/components/Avatar/components/Badge.tsx +16 -0
  36. package/src/components/Avatar/components/Content.tsx +25 -0
  37. package/src/components/Avatar/components/Illustration.tsx +17 -0
  38. package/src/components/Avatar/components/OverlayIcon.tsx +22 -0
  39. package/src/components/Avatar/components/Text.tsx +24 -0
  40. package/src/components/Avatar/components/Wrapper.tsx +44 -0
  41. package/src/components/Avatar/context.ts +19 -0
  42. package/src/components/Avatar/index.tsx +23 -87
  43. package/src/components/Avatar/styles.ts +3 -7
  44. package/src/components/Avatar/types.ts +26 -18
  45. package/src/components/Grid/index.tsx +2 -1
  46. package/src/components/List/index.tsx +2 -2
  47. package/src/components/Sections/index.tsx +2 -2
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { AvatarBadgeProps } from '../types';
3
+ export declare const AvatarBadge: (props: AvatarBadgeProps) => JSX.Element;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { useAvatarContext } from '../context';
3
+ import { Badge } from '../../Badge';
4
+ import { useCompositionStyles } from '@codeleap/styles';
5
+ import { TypeGuards } from '@codeleap/types';
6
+ export const AvatarBadge = (props) => {
7
+ const { badge, styles, ...badgeProps } = useAvatarContext(props);
8
+ const compositionsStyles = useCompositionStyles('badge', styles);
9
+ if (TypeGuards.isNil(badge))
10
+ return null;
11
+ return <Badge badge={badge} {...badgeProps} style={compositionsStyles.badge}/>;
12
+ };
13
+ //# sourceMappingURL=Badge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../../src/components/Avatar/components/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IACrD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IAEhE,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAEhE,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAExC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAG,CAAA;AACjF,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const AvatarContent: ({ children }: React.PropsWithChildren) => JSX.Element;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { useAvatarContext } from '../context';
3
+ import { AvatarBadge } from './Badge';
4
+ import { AvatarIllustration } from './Illustration';
5
+ import { AvatarText } from './Text';
6
+ import { AvatarOverlayIcon } from './OverlayIcon';
7
+ import { AvatarWrapper } from './Wrapper';
8
+ export const AvatarContent = ({ children }) => {
9
+ const { icon, image } = useAvatarContext();
10
+ if (children) {
11
+ return (<AvatarWrapper>{children}</AvatarWrapper>);
12
+ }
13
+ return (<AvatarWrapper>
14
+ {(!!icon || !!image) ? <AvatarIllustration /> : <AvatarText />}
15
+ <AvatarBadge />
16
+ <AvatarOverlayIcon />
17
+ </AvatarWrapper>);
18
+ };
19
+ //# sourceMappingURL=Content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../src/components/Avatar/components/Content.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE;IACrE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAE1C,IAAI,QAAQ,EAAE;QACZ,OAAO,CACL,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,CAC1C,CAAA;KACF;IAED,OAAO,CACL,CAAC,aAAa,CACZ;MAAA,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,AAAD,EAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,AAAD,EAAG,CAC9D;MAAA,CAAC,WAAW,CAAC,AAAD,EACZ;MAAA,CAAC,iBAAiB,CAAC,AAAD,EACpB;IAAA,EAAE,aAAa,CAAC,CACjB,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { AvatarIllustrationProps } from '../types';
3
+ export declare const AvatarIllustration: (props: AvatarIllustrationProps) => JSX.Element;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { Icon } from '../../Icon';
3
+ import { Image } from '../../Image';
4
+ import { useAvatarContext } from '../context';
5
+ import { TypeGuards } from '@codeleap/types';
6
+ export const AvatarIllustration = (props) => {
7
+ const { icon, image, styles } = useAvatarContext(props);
8
+ const source = TypeGuards.isString(image) ? { uri: image } : image;
9
+ return <>
10
+ {icon ? <Icon name={icon} style={styles.icon}/> : null}
11
+ {image ? <Image source={source} style={styles.image}/> : null}
12
+ </>;
13
+ };
14
+ //# sourceMappingURL=Illustration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Illustration.js","sourceRoot":"","sources":["../../../../src/components/Avatar/components/Illustration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAA8B,EAAE,EAAE;IACnE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IAEvD,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;IAElE,OAAO,EACL;IAAA,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CACvD;IAAA,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAChE;EAAA,GAAG,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { AvatarOverlayIconProps } from '../types';
3
+ export declare const AvatarOverlayIcon: (props: AvatarOverlayIconProps) => JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { useAvatarContext } from '../context';
2
+ import { Touchable } from '../../Touchable';
3
+ import { Icon } from '../../Icon';
4
+ export const AvatarOverlayIcon = (props) => {
5
+ const { overlayIcon, styles, onPressOverlayIcon, ...touchableProps } = useAvatarContext(props);
6
+ if (!overlayIcon)
7
+ return null;
8
+ return (<Touchable debugName='avatar:overlayIcon' onPress={onPressOverlayIcon} noFeedback {...touchableProps} style={styles.overlayIconWrapper}>
9
+ <Icon name={overlayIcon} style={styles.overlayIcon}/>
10
+ </Touchable>);
11
+ };
12
+ //# sourceMappingURL=OverlayIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverlayIcon.js","sourceRoot":"","sources":["../../../../src/components/Avatar/components/OverlayIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAE,EAAE;IACjE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG,cAAc,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IAE9F,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAA;IAE7B,OAAO,CACL,CAAC,SAAS,CACR,SAAS,CAAC,oBAAoB,CAC9B,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAC5B,UAAU,CACV,IAAI,cAAc,CAAC,CACnB,KAAK,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAEjC;MAAA,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EACrD;IAAA,EAAE,SAAS,CAAC,CACb,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { AvatarTextProps } from '../types';
3
+ export declare const AvatarText: (props: AvatarTextProps) => JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { useAvatarContext } from '../context';
2
+ import { Text } from '../../Text';
3
+ import { useMemo } from 'react';
4
+ import { TypeGuards } from '@codeleap/types';
5
+ export const AvatarText = (props) => {
6
+ const { text, name, firstNameOnly, styles } = useAvatarContext(props);
7
+ const initials = useMemo(() => {
8
+ const [first = '', last = ''] = TypeGuards.isString(name) ? name.split(' ') : name ?? [];
9
+ const initials = [first[0]];
10
+ if (!firstNameOnly)
11
+ initials.push(last[0]);
12
+ return initials?.join('');
13
+ }, [name, firstNameOnly]);
14
+ if (!text && !initials)
15
+ return null;
16
+ return (<Text text={text || initials} style={styles.text}/>);
17
+ };
18
+ //# sourceMappingURL=Text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.js","sourceRoot":"","sources":["../../../../src/components/Avatar/components/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;IACnD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IAErE,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,CAAC,KAAK,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAA;QACxF,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAE3B,IAAI,CAAC,aAAa;YAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QAE1C,OAAO,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;IAC3B,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAA;IAEzB,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAEnC,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAG,CACrD,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const AvatarWrapper: import("react").NamedExoticComponent<{
3
+ children?: import("react").ReactNode;
4
+ }>;
@@ -0,0 +1,28 @@
1
+ import { TypeGuards } from '@codeleap/types';
2
+ import { useAvatarContext } from '../context';
3
+ import { useMemo } from 'react';
4
+ import { matchInitialToColor, memoBy } from '@codeleap/utils';
5
+ import { Touchable } from '../../Touchable';
6
+ import { View } from '../../View';
7
+ const UnMemoizedAvatarWrapper = ({ children }) => {
8
+ const { styles, onPress, name, icon, image, ...wrapperProps } = useAvatarContext();
9
+ // @ts-expect-error ICSS
10
+ const bgColor = styles?.touchable?.backgroundColor;
11
+ const randomBgColor = useMemo(() => {
12
+ if (!!bgColor)
13
+ return bgColor;
14
+ const firstLetter = TypeGuards.isString(name) ? name[0] : name?.[0]?.[0];
15
+ return matchInitialToColor(firstLetter);
16
+ }, [bgColor, name]);
17
+ const isPressable = TypeGuards.isFunction(onPress);
18
+ if (isPressable) {
19
+ return (<Touchable debugName='avatar' {...wrapperProps} onPress={onPress} style={[styles.wrapper, { backgroundColor: randomBgColor }]}>
20
+ {children}
21
+ </Touchable>);
22
+ }
23
+ return (<View {...wrapperProps} style={[styles.wrapper, { backgroundColor: randomBgColor }]}>
24
+ {children}
25
+ </View>);
26
+ };
27
+ export const AvatarWrapper = memoBy(UnMemoizedAvatarWrapper, 'children');
28
+ //# sourceMappingURL=Wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Wrapper.js","sourceRoot":"","sources":["../../../../src/components/Avatar/components/Wrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,MAAM,uBAAuB,GAAG,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE;IACxE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAElF,wBAAwB;IACxB,MAAM,OAAO,GAAG,MAAM,EAAE,SAAS,EAAE,eAAe,CAAA;IAElD,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE;QACjC,IAAI,CAAC,CAAC,OAAO;YAAE,OAAO,OAAO,CAAA;QAE7B,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAExE,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAA;IACzC,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;IAEnB,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAElD,IAAI,WAAW,EAAE;QACf,OAAO,CACL,CAAC,SAAS,CACR,SAAS,CAAC,QAAQ,CAClB,IAAI,YAAY,CAAC,CACjB,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC,CAAC,CAE5D;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,SAAS,CAAC,CACb,CAAA;KACF;IAED,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC,CAAC,CAClF;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAA"}
@@ -0,0 +1,134 @@
1
+ /// <reference types="react" />
2
+ import { AvatarCtxValue } from './types';
3
+ export declare const AvatarContext: import("react").Context<AvatarCtxValue>;
4
+ export declare const useAvatarContext: <T = AvatarCtxValue>(providedProps?: Partial<T>) => {
5
+ name?: string | string[];
6
+ hitSlop?: number | import("react-native/types").Insets;
7
+ id?: string;
8
+ needsOffscreenAlphaCompositing?: boolean;
9
+ onLayout?: (event: import("react-native/types").LayoutChangeEvent) => void;
10
+ pointerEvents?: "none" | "auto" | "box-none" | "box-only";
11
+ removeClippedSubviews?: boolean;
12
+ testID?: string;
13
+ nativeID?: string;
14
+ experimental_layoutConformance?: "strict" | "classic";
15
+ collapsable?: boolean;
16
+ collapsableChildren?: boolean;
17
+ renderToHardwareTextureAndroid?: boolean;
18
+ focusable?: boolean;
19
+ tabIndex?: 0 | -1;
20
+ shouldRasterizeIOS?: boolean;
21
+ isTVSelectable?: boolean;
22
+ hasTVPreferredFocus?: boolean;
23
+ tvParallaxShiftDistanceX?: number;
24
+ tvParallaxShiftDistanceY?: number;
25
+ tvParallaxTiltAngle?: number;
26
+ tvParallaxMagnification?: number;
27
+ onStartShouldSetResponder?: (event: import("react-native/types").GestureResponderEvent) => boolean;
28
+ onMoveShouldSetResponder?: (event: import("react-native/types").GestureResponderEvent) => boolean;
29
+ onResponderEnd?: (event: import("react-native/types").GestureResponderEvent) => void;
30
+ onResponderGrant?: (event: import("react-native/types").GestureResponderEvent) => void;
31
+ onResponderReject?: (event: import("react-native/types").GestureResponderEvent) => void;
32
+ onResponderMove?: (event: import("react-native/types").GestureResponderEvent) => void;
33
+ onResponderRelease?: (event: import("react-native/types").GestureResponderEvent) => void;
34
+ onResponderStart?: (event: import("react-native/types").GestureResponderEvent) => void;
35
+ onResponderTerminationRequest?: (event: import("react-native/types").GestureResponderEvent) => boolean;
36
+ onResponderTerminate?: (event: import("react-native/types").GestureResponderEvent) => void;
37
+ onStartShouldSetResponderCapture?: (event: import("react-native/types").GestureResponderEvent) => boolean;
38
+ onMoveShouldSetResponderCapture?: (event: import("react-native/types").GestureResponderEvent) => boolean;
39
+ onTouchStart?: (event: import("react-native/types").GestureResponderEvent) => void;
40
+ onTouchMove?: (event: import("react-native/types").GestureResponderEvent) => void;
41
+ onTouchEnd?: (event: import("react-native/types").GestureResponderEvent) => void;
42
+ onTouchCancel?: (event: import("react-native/types").GestureResponderEvent) => void;
43
+ onTouchEndCapture?: (event: import("react-native/types").GestureResponderEvent) => void;
44
+ onPointerEnter?: (event: import("react-native/types").PointerEvent) => void;
45
+ onPointerEnterCapture?: (event: import("react-native/types").PointerEvent) => void;
46
+ onPointerLeave?: (event: import("react-native/types").PointerEvent) => void;
47
+ onPointerLeaveCapture?: (event: import("react-native/types").PointerEvent) => void;
48
+ onPointerMove?: (event: import("react-native/types").PointerEvent) => void;
49
+ onPointerMoveCapture?: (event: import("react-native/types").PointerEvent) => void;
50
+ onPointerCancel?: (event: import("react-native/types").PointerEvent) => void;
51
+ onPointerCancelCapture?: (event: import("react-native/types").PointerEvent) => void;
52
+ onPointerDown?: (event: import("react-native/types").PointerEvent) => void;
53
+ onPointerDownCapture?: (event: import("react-native/types").PointerEvent) => void;
54
+ onPointerUp?: (event: import("react-native/types").PointerEvent) => void;
55
+ onPointerUpCapture?: (event: import("react-native/types").PointerEvent) => void;
56
+ accessible?: boolean;
57
+ accessibilityActions?: readonly Readonly<{
58
+ name: string;
59
+ label?: string;
60
+ }>[];
61
+ accessibilityLabel?: string;
62
+ 'aria-label'?: string;
63
+ accessibilityRole?: import("react-native/types").AccessibilityRole;
64
+ accessibilityState?: import("react-native/types").AccessibilityState;
65
+ 'aria-busy'?: boolean;
66
+ 'aria-checked'?: boolean | "mixed";
67
+ 'aria-disabled'?: boolean;
68
+ 'aria-expanded'?: boolean;
69
+ 'aria-selected'?: boolean;
70
+ accessibilityHint?: string;
71
+ accessibilityValue?: import("react-native/types").AccessibilityValue;
72
+ 'aria-valuemax'?: number;
73
+ 'aria-valuemin'?: number;
74
+ 'aria-valuenow'?: number;
75
+ 'aria-valuetext'?: string;
76
+ onAccessibilityAction?: (event: import("react-native/types").AccessibilityActionEvent) => void;
77
+ importantForAccessibility?: "auto" | "yes" | "no" | "no-hide-descendants";
78
+ 'aria-hidden'?: boolean;
79
+ 'aria-modal'?: boolean;
80
+ role?: import("react-native/types").Role;
81
+ accessibilityLabelledBy?: string | string[];
82
+ 'aria-labelledby'?: string;
83
+ accessibilityLiveRegion?: "none" | "polite" | "assertive";
84
+ 'aria-live'?: "polite" | "assertive" | "off";
85
+ accessibilityElementsHidden?: boolean;
86
+ accessibilityViewIsModal?: boolean;
87
+ onAccessibilityEscape?: () => void;
88
+ onAccessibilityTap?: () => void;
89
+ onMagicTap?: () => void;
90
+ accessibilityIgnoresInvertColors?: boolean;
91
+ accessibilityLanguage?: string;
92
+ accessibilityShowsLargeContentViewer?: boolean;
93
+ accessibilityLargeContentTitle?: string;
94
+ debounce?: number;
95
+ onPress?: import("@codeleap/types").AnyFunction;
96
+ debugName?: string;
97
+ ref?: import("react").Ref<import("react-native/types").View>;
98
+ image?: string | number;
99
+ text?: string;
100
+ disabled?: boolean;
101
+ onBlur?: (event: import("react-native/types").NativeSyntheticEvent<import("react-native/types").TargetedEvent>) => void;
102
+ onPressIn?: (event: import("react-native/types").GestureResponderEvent) => void;
103
+ onPressOut?: (event: import("react-native/types").GestureResponderEvent) => void;
104
+ onFocus?: (event: import("react-native/types").NativeSyntheticEvent<import("react-native/types").TargetedEvent>) => void;
105
+ onLongPress?: (event: import("react-native/types").GestureResponderEvent) => void;
106
+ setPressed?: (param: boolean) => void;
107
+ badge?: number | boolean;
108
+ icon?: never;
109
+ delayLongPress?: number;
110
+ pressRetentionOffset?: number | import("react-native/types").Insets;
111
+ onHoverIn?: (event: import("react-native/types").MouseEvent) => void;
112
+ onHoverOut?: (event: import("react-native/types").MouseEvent) => void;
113
+ cancelable?: boolean;
114
+ delayHoverIn?: number;
115
+ delayHoverOut?: number;
116
+ android_disableSound?: boolean;
117
+ android_ripple?: import("react-native/types").PressableAndroidRippleConfig;
118
+ testOnly_pressed?: boolean;
119
+ unstable_pressDelay?: number;
120
+ component?: any;
121
+ activeOpacity?: number;
122
+ debugComponent?: string;
123
+ noFeedback?: boolean;
124
+ leadingDebounce?: boolean;
125
+ rippleDisabled?: boolean;
126
+ analyticsEnabled?: boolean;
127
+ analyticsName?: string;
128
+ analyticsData?: Record<string, any>;
129
+ dismissKeyboard?: boolean;
130
+ overlayIcon?: never;
131
+ firstNameOnly?: boolean;
132
+ onPressOverlayIcon?: import("@codeleap/types").AnyFunction;
133
+ styles: import("@codeleap/styles").StyleRecord<import("./styles").AvatarComposition>;
134
+ } & Partial<T>;
@@ -0,0 +1,13 @@
1
+ import { createContext, useContext } from 'react';
2
+ export const AvatarContext = createContext({});
3
+ export const useAvatarContext = (providedProps = {}) => {
4
+ const ctx = useContext(AvatarContext);
5
+ if (!ctx) {
6
+ throw new Error('[Avatar] useAvatarContext must be used within an Avatar component.');
7
+ }
8
+ return {
9
+ ...ctx,
10
+ ...providedProps,
11
+ };
12
+ };
13
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/Avatar/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGjD,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC,EAAoB,CAAC,CAAA;AAEhE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAqB,gBAA4B,EAAE,EAAE,EAAE;IACrF,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IAErC,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAA;KACF;IAED,OAAO;QACL,GAAG,GAAG;QACN,GAAG,aAAa;KACjB,CAAA;AACH,CAAC,CAAA"}
@@ -8,6 +8,10 @@ export declare const Avatar: {
8
8
  styleRegistryName: string;
9
9
  elements: string[];
10
10
  rootElement: string;
11
- withVariantTypes<S extends AnyRecord>(styles: S): (props: StyledComponentProps<AvatarProps, S>) => IJSX;
12
- defaultProps: AvatarProps;
11
+ Illustration: (props: import("./types").AvatarIllustrationProps) => JSX.Element;
12
+ Text: (props: import("./types").AvatarTextProps) => JSX.Element;
13
+ Badge: (props: import("./types").AvatarBadgeProps) => JSX.Element;
14
+ OverlayIcon: (props: import("./types").AvatarOverlayIconProps) => JSX.Element;
15
+ withVariantTypes<S extends AnyRecord>(styles: S): ((props: StyledComponentProps<AvatarProps, S>) => IJSX) & Pick<any, "Text" | "Badge" | "Illustration" | "OverlayIcon">;
16
+ defaultProps: Partial<AvatarProps>;
13
17
  };
@@ -1,73 +1,39 @@
1
1
  import React from 'react';
2
- import { TypeGuards } from '@codeleap/types';
3
- import { useMemo } from '@codeleap/hooks';
4
- import { matchInitialToColor } from '@codeleap/utils';
5
- import { Image } from '../Image';
6
- import { Touchable } from '../Touchable';
7
- import { Text } from '../Text';
8
- import { View } from '../View';
9
- import { Icon } from '../Icon';
10
- import { Badge } from '../Badge';
11
2
  import { MobileStyleRegistry } from '../../Registry';
12
- import { useNestedStylesByKey } from '@codeleap/styles';
3
+ import { AvatarContext } from './context';
4
+ import { AvatarContent } from './components/Content';
13
5
  import { useStylesFor } from '../../hooks';
6
+ import { AvatarIllustration } from './components/Illustration';
7
+ import { AvatarText } from './components/Text';
8
+ import { AvatarBadge } from './components/Badge';
9
+ import { AvatarOverlayIcon } from './components/OverlayIcon';
14
10
  export * from './styles';
15
11
  export * from './types';
16
12
  export const Avatar = (props) => {
17
- const { debugName, name = '', firstNameOnly, image, icon, badgeIcon, text, description, onPress, noFeedback, badge, badgeProps = {}, imageProps, badgeIconTouchProps, style, ...viewProps } = {
13
+ const { children, style, ...contextValue } = {
18
14
  ...Avatar.defaultProps,
19
15
  ...props,
20
16
  };
21
17
  const styles = useStylesFor(Avatar.styleRegistryName, style);
22
- const hasImage = !!image;
23
- const { initials, randomColor } = useMemo(() => {
24
- const [first = '', last = ''] = TypeGuards.isString(name) ? name.split(' ') : name;
25
- const initials = [first[0]];
26
- if (!firstNameOnly)
27
- initials.push(last[0]);
28
- return {
29
- initials: initials?.join(' '),
30
- randomColor: matchInitialToColor(first[0]),
31
- };
32
- }, [name, firstNameOnly]);
33
- const renderContent = () => {
34
- if (hasImage)
35
- return <Image source={image} {...imageProps} style={styles.image}/>;
36
- if (icon)
37
- return <Icon name={icon} style={styles.icon}/>;
38
- return <Text text={text || initials} style={styles.initials}/>;
39
- };
40
- // @ts-expect-error icss type
41
- const hasBackgroundColor = !!styles?.touchable?.backgroundColor;
42
- const badgeStyles = useNestedStylesByKey('badge', styles);
43
- return (<View {...viewProps} style={styles.wrapper}>
44
- <Touchable debugName={'Avatar:' + debugName} onPress={() => onPress?.()} style={[
45
- styles.touchable,
46
- !hasBackgroundColor && { backgroundColor: randomColor },
47
- ]} noFeedback={noFeedback || !onPress}>
48
- {renderContent()}
49
-
50
- {!!description ? (<View style={styles.descriptionOverlay}>
51
- <Text text={description} style={styles.description}/>
52
- </View>) : null}
53
-
54
- <Badge badge={badge} {...badgeProps} style={badgeStyles}/>
55
- </Touchable>
56
-
57
- {badgeIcon ? (<Touchable onPress={() => onPress?.()} noFeedback {...badgeIconTouchProps} debugName={`AvatarBadge:${debugName}`} style={styles.badgeIconWrapper}>
58
- <Icon name={badgeIcon} style={styles.badgeIcon}/>
59
- </Touchable>) : null}
60
- </View>);
18
+ return (<AvatarContext.Provider value={{ ...contextValue, styles }}>
19
+ <AvatarContent>
20
+ {children}
21
+ </AvatarContent>
22
+ </AvatarContext.Provider>);
61
23
  };
62
24
  Avatar.styleRegistryName = 'Avatar';
63
- Avatar.elements = ['wrapper', 'touchable', 'initials', 'image', 'icon', 'description', 'badge'];
25
+ Avatar.elements = ['wrapper', 'text', 'image', 'icon', 'overlayIcon', 'badge'];
64
26
  Avatar.rootElement = 'wrapper';
27
+ Avatar.Illustration = AvatarIllustration;
28
+ Avatar.Text = AvatarText;
29
+ Avatar.Badge = AvatarBadge;
30
+ Avatar.OverlayIcon = AvatarOverlayIcon;
65
31
  Avatar.withVariantTypes = (styles) => {
66
32
  return Avatar;
67
33
  };
68
34
  Avatar.defaultProps = {
69
35
  badge: false,
70
- firstNameOnly: true,
36
+ firstNameOnly: false,
71
37
  };
72
38
  MobileStyleRegistry.registerComponent(Avatar);
73
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Avatar/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,mBAAmB,EA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AiB,EAAE,KAAK,CAAC,CAAA;IAE5D,OAAO,CACL,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,MAAM,EAAE,CAAC,CACzD;MAAA,CAAC,aAAa,CACZ;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,aAAa,CACjB;IAAA,EAAE,aAAa,CAAC,QAAQ,CAAC,CAC1B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,iBAAiB,GAAG,QAAQ,CAAA;AACnC,MAAM,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;AAC9E,MAAM,CAAC,WAAW,GAAG,SAAS,CAAA;AAE9B,MAAM,CAAC,YAAY,GAAG,kBAAkB,CAAA;AACxC,MAAM,CAAC,IAAI,GAAG,UAAU,CAAA;AACxB,MAAM,CAAC,KAAK,GAAG,WAAW,CAAA;AAC1B,MAAM,CAAC,WAAW,GAAG,iBAAiB,CAAA;AAEtC,MAAM,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAC3D,OAAO,MAAsJ,CAAA;AAC/J,CAAC,CAAA;AAED,MAAM,CAAC,YAAY,GAAG;IACpB,KAAK,EAAE,KAAK;IACZ,aAAa,EAAE,KAAK;CACG,CAAA;AAEzB,mBAAmB,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA"}
@@ -1,2 +1,2 @@
1
1
  import { BadgeComposition } from '../Badge';
2
- export type AvatarComposition = 'wrapper' | 'touchable' | 'initials' | 'image' | 'icon' | 'iconWrapper' | 'description' | 'descriptionOverlay' | 'badgeIconWrapper' | 'badgeIcon' | `badge${Capitalize<BadgeComposition>}`;
2
+ export type AvatarComposition = 'wrapper' | 'text' | 'image' | 'icon' | 'overlayIconWrapper' | 'overlayIcon' | `badge${Capitalize<BadgeComposition>}`;
@@ -1,22 +1,27 @@
1
- import { StyledProp } from '@codeleap/styles';
2
- import { BadgeComponentProps } from '../Badge';
3
- import { IconProps } from '../Icon';
4
- import { ImageProps } from '../Image';
5
- import { ViewProps } from '../View';
1
+ import { AppIcon, StyledProp, StyleRecord } from '@codeleap/styles';
2
+ import { BadgeProps } from '../Badge';
6
3
  import { AvatarComposition } from './styles';
4
+ import { ReactNode } from 'react';
7
5
  import { TouchableProps } from '../Touchable';
8
- export type AvatarProps = Omit<ViewProps, 'style'> & BadgeComponentProps & {
9
- image?: ImageProps['source'];
6
+ import { AnyFunction } from '@codeleap/types';
7
+ import { ImageRequireSource } from 'react-native/types';
8
+ export type AvatarProps = Omit<TouchableProps, 'debugName' | 'style'> & {
9
+ text?: string;
10
+ image?: ImageRequireSource | string;
11
+ icon?: AppIcon;
12
+ badge?: BadgeProps['badge'];
10
13
  name?: string | string[];
11
- debugName: string;
12
14
  firstNameOnly?: boolean;
13
- text?: string;
14
- description?: string;
15
- icon?: IconProps['name'];
16
- badgeIcon?: IconProps['name'];
17
- badgeIconTouchProps?: Partial<TouchableProps>;
15
+ overlayIcon?: AppIcon;
16
+ onPressOverlayIcon?: AnyFunction;
17
+ debugName?: string;
18
18
  style?: StyledProp<AvatarComposition>;
19
- onPress?: () => void;
20
- noFeedback?: boolean;
21
- imageProps?: Partial<ImageProps>;
19
+ children?: ReactNode;
20
+ };
21
+ export type AvatarTextProps = Pick<AvatarProps, 'text' | 'firstNameOnly' | 'name'>;
22
+ export type AvatarIllustrationProps = Pick<AvatarProps, 'image' | 'icon'>;
23
+ export type AvatarBadgeProps = Pick<AvatarProps, 'badge'> & Omit<BadgeProps, 'badge' | 'style'>;
24
+ export type AvatarOverlayIconProps = Pick<AvatarProps, 'overlayIcon'> & Omit<TouchableProps, 'onPress' | 'style' | 'debugName'>;
25
+ export type AvatarCtxValue = Omit<AvatarProps, 'style' | 'children'> & {
26
+ styles: StyleRecord<AvatarComposition>;
22
27
  };
@@ -6,6 +6,7 @@ import { List } from '../List';
6
6
  import { useTheme } from '@codeleap/styles';
7
7
  import { MobileStyleRegistry } from '../../Registry';
8
8
  import { useStylesFor } from '../../hooks';
9
+ import { TypeGuards } from '@codeleap/types';
9
10
  export * from './styles';
10
11
  export * from './types';
11
12
  const RenderSeparator = (props) => {
@@ -41,7 +42,7 @@ export const Grid = forwardRef((flatGridProps, ref) => {
41
42
  }, [RenderItem, props?.data?.length]);
42
43
  const separatorStyles = { height: themeSpacing?.value?.(spacing), ...styles.separator };
43
44
  const separator = props?.separators || (!!spacing ? <RenderSeparator separatorStyles={separatorStyles}/> : null);
44
- const refreshControl = !!onRefresh && <RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps}/>;
45
+ const refreshControl = TypeGuards.isFunction(onRefresh) ? <RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps}/> : null;
45
46
  return (<List
46
47
  // @ts-expect-error
47
48
  ref={ref} {...props} ListEmptyComponent={<EmptyPlaceholder {...placeholder}/>} ListHeaderComponentStyle={styles.header} ListFooterComponentStyle={styles.footer} ItemSeparatorComponent={separator} refreshControl={refreshControl} style={styles.wrapper} contentContainerStyle={[styles.content, props?.contentContainerStyle]} showsVerticalScrollIndicator={false} numColumns={numColumns} renderItem={renderItem}/>);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Grid/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAiB,MAAM,OAAO,CAAA;AAErE,OAAO,EAAE,IAAI,EAAa,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAA;AAExC,OAAO,EAAmE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAC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,CAAC,CAAC,UAAU,CAAC,EACvB,CACH,CAAA;AACH,CAAC,CAAwC,CAAA;AAEzC,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAA;AAC/B,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAA;AACxG,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;AAE5B,IAAI,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACzD,OAAO,IAAgG,CAAA;AACzG,CAAC,CAAA;AAED,IAAI,CAAC,YAAY,GAAG;IAClB,yBAAyB,EAAE,SAAS;IACpC,mBAAmB,EAAE,EAAE;CACF,CAAA;AAEvB,mBAAmB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA"}
@@ -47,7 +47,7 @@ export const List = forwardRef((flatListProps, ref) => {
47
47
  loading && styles['content:loading'],
48
48
  ], keyboardAware && !props.horizontal);
49
49
  const wrapperStyle = [styles.wrapper, isEmpty && styles['wrapper:empty'], loading && styles['wrapper:loading']];
50
- return (<FlatList ItemSeparatorComponent={separator} refreshControl={!!onRefresh && (<RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps}/>)} ListEmptyComponent={<EmptyPlaceholder {..._placeholder}/>} showsVerticalScrollIndicator={false} showsHorizontalScrollIndicator={false} {...props} ListHeaderComponentStyle={styles.header} style={wrapperStyle} contentContainerStyle={keyboardStyle} data={fakeEmpty ? [] : data} ref={ref} renderItem={renderItem}/>);
50
+ return (<FlatList ItemSeparatorComponent={separator} refreshControl={TypeGuards.isFunction(onRefresh) ? (<RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps}/>) : null} ListEmptyComponent={<EmptyPlaceholder {..._placeholder}/>} showsVerticalScrollIndicator={false} showsHorizontalScrollIndicator={false} {...props} ListHeaderComponentStyle={styles.header} style={wrapperStyle} contentContainerStyle={keyboardStyle} data={fakeEmpty ? [] : data} ref={ref} renderItem={renderItem}/>);
51
51
  });
52
52
  List.styleRegistryName = 'List';
53
53
  List.elements = ['wrapper', 'content', 'separator', 'header', 'refreshControl'];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAsB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,IAAI,EAAa,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAGrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,eAAe,GAAG,CAAC,KAA8C,EAAE,EAAE;IACzE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,EAAG,CAAA;AAC/C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAA0B,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE;IAC7E,MAAM,EACJ,KAAK,EACL,SAAS,EACT,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,OAAO,EACP,aAAa,EACb,SAAS,GAAG,OAAO,EACnB,qBAAqB,EACrB,UAAU,EAAE,UAAU,EACtB,IAAI,EACJ,GAAG,KAAK,EACT,GAAG;QACF,GAAG,IAAI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IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;AAE5B,IAAI,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACzD,OAAO,IAAkG,CAAA;AAC3G,CAAC,CAAA;AAED,IAAI,CAAC,YAAY,GAAG;IAClB,yBAAyB,EAAE,SAAS;IACpC,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,IAAI;CACM,CAAA;AAE3B,mBAAmB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA"}
@@ -72,7 +72,7 @@ export function Sections(sectionsProps) {
72
72
  loading && styles['content:loading'],
73
73
  ], keyboardAware && !props.horizontal);
74
74
  const wrapperStyle = [styles.wrapper, isEmpty && styles['wrapper:empty'], loading && styles['wrapper:loading']];
75
- return (<SectionList ItemSeparatorComponent={separator} refreshControl={!!onRefresh && (<RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps}/>)} ListEmptyComponent={<EmptyPlaceholder {..._placeholder}/>} showsVerticalScrollIndicator={false} showsHorizontalScrollIndicator={false} {...props} ListHeaderComponentStyle={styles.header} ListFooterComponentStyle={styles.footer} style={wrapperStyle} contentContainerStyle={keyboardStyle} sections={sections} renderItem={renderItem} renderSectionHeader={renderSectionHeader} renderSectionFooter={renderSectionFooter}/>);
75
+ return (<SectionList ItemSeparatorComponent={separator} refreshControl={TypeGuards.isFunction(onRefresh) ? (<RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps}/>) : null} ListEmptyComponent={<EmptyPlaceholder {..._placeholder}/>} showsVerticalScrollIndicator={false} showsHorizontalScrollIndicator={false} {...props} ListHeaderComponentStyle={styles.header} ListFooterComponentStyle={styles.footer} style={wrapperStyle} contentContainerStyle={keyboardStyle} sections={sections} renderItem={renderItem} renderSectionHeader={renderSectionHeader} renderSectionFooter={renderSectionFooter}/>);
76
76
  }
77
77
  Sections.styleRegistryName = 'Sections';
78
78
  Sections.elements = ['wrapper', 'content', 'separator', 'header', 'footer', 'refreshControl'];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Sections/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAsC,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,IAAI,EAAa,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAGrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,eAAe,GAAG,CAAC,KAA8C,EAAE,EAAE;IACzE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,EAAG,CAAA;AAC/C,CAAC,CAAA;AAED,MAAM,UAAU,QAAQ,CAAI,aAA8B;IACxD,MAAM,EACJ,KAAK,EACL,SAAS,EACT,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,OAAO,EACP,aAAa,EACb,SAAS,GAAG,OAAO,EACnB,qBAAqB,EACrB,cAAc,EACd,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,IAAI,EACd,mBAAmB,EAAE,mBAAmB,EACxC,mBAAmB,EAAE,mBAAmB,EACxC,GAAG,KAAK,EACT,GAAG;QACF,GAAG,QAAQ,CAAC,YAAY;QACxB,GAAG,aAAa;KACjB,CAAA;IAED,MAAM,QAAQ,GAAG,OAAO,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AE,SAAS;IACpC,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,IAAI;CACK,CAAA;AAE1B,mBAAmB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "5.8.9",
3
+ "version": "5.8.11",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -9,28 +9,28 @@
9
9
  "directory": "packages/mobile"
10
10
  },
11
11
  "devDependencies": {
12
- "@codeleap/types": "5.8.9",
13
- "@codeleap/utils": "5.8.9",
14
- "@codeleap/hooks": "5.8.9",
15
- "@codeleap/form": "5.8.9",
16
- "@codeleap/query": "5.8.9",
17
- "@codeleap/logger": "5.8.9",
18
- "@codeleap/config": "5.8.9",
19
- "@codeleap/modals": "5.8.9"
12
+ "@codeleap/types": "5.8.11",
13
+ "@codeleap/utils": "5.8.11",
14
+ "@codeleap/hooks": "5.8.11",
15
+ "@codeleap/form": "5.8.11",
16
+ "@codeleap/query": "5.8.11",
17
+ "@codeleap/logger": "5.8.11",
18
+ "@codeleap/config": "5.8.11",
19
+ "@codeleap/modals": "5.8.11"
20
20
  },
21
21
  "scripts": {
22
22
  "build": "tsc --build",
23
23
  "lint": "eslint -c .eslintrc.js --fix \"./src/**/*.{ts,tsx,js,jsx}\""
24
24
  },
25
25
  "peerDependencies": {
26
- "@codeleap/types": "5.8.9",
27
- "@codeleap/utils": "5.8.9",
28
- "@codeleap/hooks": "5.8.9",
29
- "@codeleap/form": "5.8.9",
30
- "@codeleap/query": "5.8.9",
31
- "@codeleap/logger": "5.8.9",
32
- "@codeleap/styles": "5.8.9",
33
- "@codeleap/modals": "5.8.9",
26
+ "@codeleap/types": "5.8.11",
27
+ "@codeleap/utils": "5.8.11",
28
+ "@codeleap/hooks": "5.8.11",
29
+ "@codeleap/form": "5.8.11",
30
+ "@codeleap/query": "5.8.11",
31
+ "@codeleap/logger": "5.8.11",
32
+ "@codeleap/styles": "5.8.11",
33
+ "@codeleap/modals": "5.8.11",
34
34
  "@d11/react-native-fast-image": "8.9.2",
35
35
  "@react-native-firebase/messaging": "21.12.0",
36
36
  "@react-navigation/bottom-tabs": "7.3.10",
package/package.json.bak CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "5.8.9",
3
+ "version": "5.8.11",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -0,0 +1,16 @@
1
+ import React from 'react'
2
+ import { useAvatarContext } from '../context'
3
+ import { Badge } from '../../Badge'
4
+ import { useCompositionStyles } from '@codeleap/styles'
5
+ import { AvatarBadgeProps } from '../types'
6
+ import { TypeGuards } from '@codeleap/types'
7
+
8
+ export const AvatarBadge = (props: AvatarBadgeProps) => {
9
+ const { badge, styles, ...badgeProps } = useAvatarContext(props)
10
+
11
+ const compositionsStyles = useCompositionStyles('badge', styles)
12
+
13
+ if (TypeGuards.isNil(badge)) return null
14
+
15
+ return <Badge badge={badge} {...badgeProps} style={compositionsStyles.badge} />
16
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react'
2
+ import { useAvatarContext } from '../context'
3
+ import { AvatarBadge } from './Badge'
4
+ import { AvatarIllustration } from './Illustration'
5
+ import { AvatarText } from './Text'
6
+ import { AvatarOverlayIcon } from './OverlayIcon'
7
+ import { AvatarWrapper } from './Wrapper'
8
+
9
+ export const AvatarContent = ({ children }: React.PropsWithChildren) => {
10
+ const { icon, image } = useAvatarContext()
11
+
12
+ if (children) {
13
+ return (
14
+ <AvatarWrapper>{children}</AvatarWrapper>
15
+ )
16
+ }
17
+
18
+ return (
19
+ <AvatarWrapper>
20
+ {(!!icon || !!image) ? <AvatarIllustration /> : <AvatarText />}
21
+ <AvatarBadge />
22
+ <AvatarOverlayIcon />
23
+ </AvatarWrapper>
24
+ )
25
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import { Icon } from '../../Icon'
3
+ import { AvatarIllustrationProps } from '../types'
4
+ import { Image } from '../../Image'
5
+ import { useAvatarContext } from '../context'
6
+ import { TypeGuards } from '@codeleap/types'
7
+
8
+ export const AvatarIllustration = (props: AvatarIllustrationProps) => {
9
+ const { icon, image, styles } = useAvatarContext(props)
10
+
11
+ const source = TypeGuards.isString(image) ? { uri: image } : image
12
+
13
+ return <>
14
+ {icon ? <Icon name={icon} style={styles.icon} /> : null}
15
+ {image ? <Image source={source} style={styles.image} /> : null}
16
+ </>
17
+ }
@@ -0,0 +1,22 @@
1
+ import { useAvatarContext } from '../context'
2
+ import { AvatarOverlayIconProps } from '../types'
3
+ import { Touchable } from '../../Touchable'
4
+ import { Icon } from '../../Icon'
5
+
6
+ export const AvatarOverlayIcon = (props: AvatarOverlayIconProps) => {
7
+ const { overlayIcon, styles, onPressOverlayIcon, ...touchableProps } = useAvatarContext(props)
8
+
9
+ if (!overlayIcon) return null
10
+
11
+ return (
12
+ <Touchable
13
+ debugName='avatar:overlayIcon'
14
+ onPress={onPressOverlayIcon}
15
+ noFeedback
16
+ {...touchableProps}
17
+ style={styles.overlayIconWrapper}
18
+ >
19
+ <Icon name={overlayIcon} style={styles.overlayIcon} />
20
+ </Touchable>
21
+ )
22
+ }
@@ -0,0 +1,24 @@
1
+ import { useAvatarContext } from '../context'
2
+ import { AvatarTextProps } from '../types'
3
+ import { Text } from '../../Text'
4
+ import { useMemo } from 'react'
5
+ import { TypeGuards } from '@codeleap/types'
6
+
7
+ export const AvatarText = (props: AvatarTextProps) => {
8
+ const { text, name, firstNameOnly, styles } = useAvatarContext(props)
9
+
10
+ const initials = useMemo(() => {
11
+ const [first = '', last = ''] = TypeGuards.isString(name) ? name.split(' ') : name ?? []
12
+ const initials = [first[0]]
13
+
14
+ if (!firstNameOnly) initials.push(last[0])
15
+
16
+ return initials?.join('')
17
+ }, [name, firstNameOnly])
18
+
19
+ if (!text && !initials) return null
20
+
21
+ return (
22
+ <Text text={text || initials} style={styles.text} />
23
+ )
24
+ }
@@ -0,0 +1,44 @@
1
+ import { TypeGuards } from '@codeleap/types'
2
+ import { useAvatarContext } from '../context'
3
+ import { useMemo } from 'react'
4
+ import { matchInitialToColor, memoBy } from '@codeleap/utils'
5
+ import { Touchable } from '../../Touchable'
6
+ import { View } from '../../View'
7
+
8
+ const UnMemoizedAvatarWrapper = ({ children }: React.PropsWithChildren) => {
9
+ const { styles, onPress, name, icon, image, ...wrapperProps } = useAvatarContext()
10
+
11
+ // @ts-expect-error ICSS
12
+ const bgColor = styles?.touchable?.backgroundColor
13
+
14
+ const randomBgColor = useMemo(() => {
15
+ if (!!bgColor) return bgColor
16
+
17
+ const firstLetter = TypeGuards.isString(name) ? name[0] : name?.[0]?.[0]
18
+
19
+ return matchInitialToColor(firstLetter)
20
+ }, [bgColor, name])
21
+
22
+ const isPressable = TypeGuards.isFunction(onPress)
23
+
24
+ if (isPressable) {
25
+ return (
26
+ <Touchable
27
+ debugName='avatar'
28
+ {...wrapperProps}
29
+ onPress={onPress}
30
+ style={[styles.wrapper, { backgroundColor: randomBgColor }]}
31
+ >
32
+ {children}
33
+ </Touchable>
34
+ )
35
+ }
36
+
37
+ return (
38
+ <View {...wrapperProps} style={[styles.wrapper, { backgroundColor: randomBgColor }]}>
39
+ {children}
40
+ </View>
41
+ )
42
+ }
43
+
44
+ export const AvatarWrapper = memoBy(UnMemoizedAvatarWrapper, 'children')
@@ -0,0 +1,19 @@
1
+ import { createContext, useContext } from 'react'
2
+ import { AvatarCtxValue } from './types'
3
+
4
+ export const AvatarContext = createContext({} as AvatarCtxValue)
5
+
6
+ export const useAvatarContext = <T = AvatarCtxValue>(providedProps: Partial<T> = {}) => {
7
+ const ctx = useContext(AvatarContext)
8
+
9
+ if (!ctx) {
10
+ throw new Error(
11
+ '[Avatar] useAvatarContext must be used within an Avatar component.',
12
+ )
13
+ }
14
+
15
+ return {
16
+ ...ctx,
17
+ ...providedProps,
18
+ }
19
+ }
@@ -1,39 +1,23 @@
1
1
  import React from 'react'
2
- import { TypeGuards } from '@codeleap/types'
3
- import { useMemo } from '@codeleap/hooks'
4
- import { matchInitialToColor } from '@codeleap/utils'
5
- import { Image } from '../Image'
6
- import { Touchable } from '../Touchable'
7
- import { Text } from '../Text'
8
- import { View, ViewProps } from '../View'
9
- import { Icon } from '../Icon'
10
- import { Badge } from '../Badge'
11
2
  import { AvatarProps } from './types'
12
3
  import { MobileStyleRegistry } from '../../Registry'
13
- import { AnyRecord, useNestedStylesByKey, IJSX, StyledComponentProps } from '@codeleap/styles'
4
+ import { AnyRecord, IJSX, StyledComponentProps } from '@codeleap/styles'
5
+ import { AvatarContext } from './context'
6
+ import { AvatarContent } from './components/Content'
14
7
  import { useStylesFor } from '../../hooks'
8
+ import { AvatarIllustration } from './components/Illustration'
9
+ import { AvatarText } from './components/Text'
10
+ import { AvatarBadge } from './components/Badge'
11
+ import { AvatarOverlayIcon } from './components/OverlayIcon'
15
12
 
16
13
  export * from './styles'
17
14
  export * from './types'
18
15
 
19
16
  export const Avatar = (props: AvatarProps) => {
20
17
  const {
21
- debugName,
22
- name = '',
23
- firstNameOnly,
24
- image,
25
- icon,
26
- badgeIcon,
27
- text,
28
- description,
29
- onPress,
30
- noFeedback,
31
- badge,
32
- badgeProps = {},
33
- imageProps,
34
- badgeIconTouchProps,
18
+ children,
35
19
  style,
36
- ...viewProps
20
+ ...contextValue
37
21
  } = {
38
22
  ...Avatar.defaultProps,
39
23
  ...props,
@@ -41,79 +25,31 @@ export const Avatar = (props: AvatarProps) => {
41
25
 
42
26
  const styles = useStylesFor(Avatar.styleRegistryName, style)
43
27
 
44
- const hasImage = !!image
45
-
46
- const { initials, randomColor } = useMemo(() => {
47
- const [first = '', last = ''] = TypeGuards.isString(name) ? name.split(' ') : name
48
- const initials = [first[0]]
49
-
50
- if (!firstNameOnly) initials.push(last[0])
51
-
52
- return {
53
- initials: initials?.join(' '),
54
- randomColor: matchInitialToColor(first[0]),
55
- }
56
- }, [name, firstNameOnly])
57
-
58
- const renderContent = () => {
59
- if (hasImage) return <Image source={image} {...imageProps} style={styles.image} />
60
- if (icon) return <Icon name={icon} style={styles.icon} />
61
- return <Text text={text || initials} style={styles.initials} />
62
- }
63
-
64
- // @ts-expect-error icss type
65
- const hasBackgroundColor = !!styles?.touchable?.backgroundColor
66
-
67
- const badgeStyles = useNestedStylesByKey('badge', styles)
68
-
69
28
  return (
70
- <View {...viewProps as ViewProps} style={styles.wrapper}>
71
- <Touchable
72
- debugName={'Avatar:' + debugName}
73
- onPress={() => onPress?.()}
74
- style={[
75
- styles.touchable,
76
- !hasBackgroundColor && { backgroundColor: randomColor },
77
- ]}
78
- noFeedback={noFeedback || !onPress}
79
- >
80
- {renderContent()}
81
-
82
- {!!description ? (
83
- <View style={styles.descriptionOverlay}>
84
- <Text text={description} style={styles.description} />
85
- </View>
86
- ) : null}
87
-
88
- <Badge badge={badge} {...badgeProps} style={badgeStyles} />
89
- </Touchable>
90
-
91
- {badgeIcon ? (
92
- <Touchable
93
- onPress={() => onPress?.()}
94
- noFeedback
95
- {...badgeIconTouchProps}
96
- debugName={`AvatarBadge:${debugName}`}
97
- style={styles.badgeIconWrapper}
98
- >
99
- <Icon name={badgeIcon} style={styles.badgeIcon} />
100
- </Touchable>
101
- ) : null}
102
- </View>
29
+ <AvatarContext.Provider value={{ ...contextValue, styles }}>
30
+ <AvatarContent>
31
+ {children}
32
+ </AvatarContent>
33
+ </AvatarContext.Provider>
103
34
  )
104
35
  }
105
36
 
106
37
  Avatar.styleRegistryName = 'Avatar'
107
- Avatar.elements = ['wrapper', 'touchable', 'initials', 'image', 'icon', 'description', 'badge']
38
+ Avatar.elements = ['wrapper', 'text', 'image', 'icon', 'overlayIcon', 'badge']
108
39
  Avatar.rootElement = 'wrapper'
109
40
 
41
+ Avatar.Illustration = AvatarIllustration
42
+ Avatar.Text = AvatarText
43
+ Avatar.Badge = AvatarBadge
44
+ Avatar.OverlayIcon = AvatarOverlayIcon
45
+
110
46
  Avatar.withVariantTypes = <S extends AnyRecord>(styles: S) => {
111
- return Avatar as (props: StyledComponentProps<AvatarProps, typeof styles>) => IJSX
47
+ return Avatar as ((props: StyledComponentProps<AvatarProps, typeof styles>) => IJSX) & Pick<typeof Avatar, 'Text' | 'Illustration' | 'Badge' | 'OverlayIcon'>
112
48
  }
113
49
 
114
50
  Avatar.defaultProps = {
115
51
  badge: false,
116
- firstNameOnly: true,
117
- } as AvatarProps
52
+ firstNameOnly: false,
53
+ } as Partial<AvatarProps>
118
54
 
119
55
  MobileStyleRegistry.registerComponent(Avatar)
@@ -2,13 +2,9 @@ import { BadgeComposition } from '../Badge'
2
2
 
3
3
  export type AvatarComposition =
4
4
  | 'wrapper'
5
- | 'touchable'
6
- | 'initials'
5
+ | 'text'
7
6
  | 'image'
8
7
  | 'icon'
9
- | 'iconWrapper'
10
- | 'description'
11
- | 'descriptionOverlay'
12
- | 'badgeIconWrapper'
13
- | 'badgeIcon'
8
+ | 'overlayIconWrapper'
9
+ | 'overlayIcon'
14
10
  | `badge${Capitalize<BadgeComposition>}`
@@ -1,26 +1,34 @@
1
- import { StyledProp } from '@codeleap/styles'
2
- import { BadgeComponentProps } from '../Badge'
3
- import { IconProps } from '../Icon'
4
- import { ImageProps } from '../Image'
5
- import { ViewProps } from '../View'
1
+ import { AppIcon, StyledProp, StyleRecord } from '@codeleap/styles'
2
+ import { BadgeProps } from '../Badge'
6
3
  import { AvatarComposition } from './styles'
4
+ import { ReactNode } from 'react'
7
5
  import { TouchableProps } from '../Touchable'
6
+ import { AnyFunction } from '@codeleap/types'
7
+ import { ImageRequireSource } from 'react-native/types'
8
8
 
9
- export type AvatarProps =
10
- Omit<ViewProps, 'style'> &
11
- BadgeComponentProps &
9
+ export type AvatarProps = Omit<TouchableProps, 'debugName' | 'style'> &
12
10
  {
13
- image?: ImageProps['source']
11
+ text?: string
12
+ image?: ImageRequireSource | string
13
+ icon?: AppIcon
14
+ badge?: BadgeProps['badge']
14
15
  name?: string | string[]
15
- debugName: string
16
16
  firstNameOnly?: boolean
17
- text?: string
18
- description?: string
19
- icon?: IconProps['name']
20
- badgeIcon?: IconProps['name']
21
- badgeIconTouchProps?: Partial<TouchableProps>
17
+ overlayIcon?: AppIcon
18
+ onPressOverlayIcon?: AnyFunction
19
+ debugName?: string
22
20
  style?: StyledProp<AvatarComposition>
23
- onPress?: () => void
24
- noFeedback?: boolean
25
- imageProps?: Partial<ImageProps>
21
+ children?: ReactNode
26
22
  }
23
+
24
+ export type AvatarTextProps = Pick<AvatarProps, 'text' | 'firstNameOnly' | 'name'>
25
+
26
+ export type AvatarIllustrationProps = Pick<AvatarProps, 'image' | 'icon'>
27
+
28
+ export type AvatarBadgeProps = Pick<AvatarProps, 'badge'> & Omit<BadgeProps, 'badge' | 'style'>
29
+
30
+ export type AvatarOverlayIconProps = Pick<AvatarProps, 'overlayIcon'> & Omit<TouchableProps, 'onPress' | 'style' | 'debugName'>
31
+
32
+ export type AvatarCtxValue = Omit<AvatarProps, 'style' | 'children'> & {
33
+ styles: StyleRecord<AvatarComposition>
34
+ }
@@ -8,6 +8,7 @@ import { GridProps } from './types'
8
8
  import { AnyRecord, IJSX, StyledComponentProps, StyledComponentWithProps, useTheme } from '@codeleap/styles'
9
9
  import { MobileStyleRegistry } from '../../Registry'
10
10
  import { useStylesFor } from '../../hooks'
11
+ import { TypeGuards } from '@codeleap/types'
11
12
 
12
13
  export * from './styles'
13
14
  export * from './types'
@@ -65,7 +66,7 @@ export const Grid = forwardRef<FlatList, GridProps>((flatGridProps, ref) => {
65
66
 
66
67
  const separatorStyles = { height: themeSpacing?.value?.(spacing), ...styles.separator }
67
68
  const separator = props?.separators || (!!spacing ? <RenderSeparator separatorStyles={separatorStyles} /> : null)
68
- const refreshControl = !!onRefresh && <RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps} />
69
+ const refreshControl = TypeGuards.isFunction(onRefresh) ? <RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps} /> : null
69
70
 
70
71
  return (
71
72
  <List
@@ -80,13 +80,13 @@ export const List = forwardRef<FlatList, FlatListProps>((flatListProps, ref) =>
80
80
  return (
81
81
  <FlatList
82
82
  ItemSeparatorComponent={separator as unknown as React.ComponentType}
83
- refreshControl={!!onRefresh && (
83
+ refreshControl={TypeGuards.isFunction(onRefresh) ? (
84
84
  <RefreshControl
85
85
  refreshing={refreshing}
86
86
  onRefresh={onRefresh}
87
87
  {...refreshControlProps}
88
88
  />
89
- )}
89
+ ) : null}
90
90
  ListEmptyComponent={<EmptyPlaceholder {..._placeholder} />}
91
91
  showsVerticalScrollIndicator={false}
92
92
  showsHorizontalScrollIndicator={false}
@@ -120,13 +120,13 @@ export function Sections<T>(sectionsProps: SectionProps<T>) {
120
120
  return (
121
121
  <SectionList
122
122
  ItemSeparatorComponent={separator}
123
- refreshControl={!!onRefresh && (
123
+ refreshControl={TypeGuards.isFunction(onRefresh) ? (
124
124
  <RefreshControl
125
125
  refreshing={refreshing}
126
126
  onRefresh={onRefresh}
127
127
  {...refreshControlProps}
128
128
  />
129
- )}
129
+ ) : null}
130
130
  ListEmptyComponent={<EmptyPlaceholder {..._placeholder} />}
131
131
  showsVerticalScrollIndicator={false}
132
132
  showsHorizontalScrollIndicator={false}