@codeleap/mobile 5.8.1 → 5.8.3

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 (35) hide show
  1. package/dist/components/EmptyPlaceholder/components/Button.d.ts +3 -0
  2. package/dist/components/EmptyPlaceholder/components/Button.js +14 -0
  3. package/dist/components/EmptyPlaceholder/components/Button.js.map +1 -0
  4. package/dist/components/EmptyPlaceholder/components/Content.d.ts +2 -0
  5. package/dist/components/EmptyPlaceholder/components/Content.js +33 -0
  6. package/dist/components/EmptyPlaceholder/components/Content.js.map +1 -0
  7. package/dist/components/EmptyPlaceholder/components/Illustration.d.ts +3 -0
  8. package/dist/components/EmptyPlaceholder/components/Illustration.js +12 -0
  9. package/dist/components/EmptyPlaceholder/components/Illustration.js.map +1 -0
  10. package/dist/components/EmptyPlaceholder/components/Info.d.ts +3 -0
  11. package/dist/components/EmptyPlaceholder/components/Info.js +12 -0
  12. package/dist/components/EmptyPlaceholder/components/Info.js.map +1 -0
  13. package/dist/components/EmptyPlaceholder/components/Loading.d.ts +2 -0
  14. package/dist/components/EmptyPlaceholder/components/Loading.js +18 -0
  15. package/dist/components/EmptyPlaceholder/components/Loading.js.map +1 -0
  16. package/dist/components/EmptyPlaceholder/context.d.ts +16 -0
  17. package/dist/components/EmptyPlaceholder/context.js +13 -0
  18. package/dist/components/EmptyPlaceholder/context.js.map +1 -0
  19. package/dist/components/EmptyPlaceholder/index.d.ts +4 -1
  20. package/dist/components/EmptyPlaceholder/index.js +17 -39
  21. package/dist/components/EmptyPlaceholder/index.js.map +1 -1
  22. package/dist/components/EmptyPlaceholder/styles.d.ts +2 -1
  23. package/dist/components/EmptyPlaceholder/types.d.ts +17 -11
  24. package/dist/components/Tabs/index.d.ts +1 -1
  25. package/package.json +17 -17
  26. package/package.json.bak +1 -1
  27. package/src/components/EmptyPlaceholder/components/Button.tsx +26 -0
  28. package/src/components/EmptyPlaceholder/components/Content.tsx +42 -0
  29. package/src/components/EmptyPlaceholder/components/Illustration.tsx +15 -0
  30. package/src/components/EmptyPlaceholder/components/Info.tsx +15 -0
  31. package/src/components/EmptyPlaceholder/components/Loading.tsx +23 -0
  32. package/src/components/EmptyPlaceholder/context.ts +19 -0
  33. package/src/components/EmptyPlaceholder/index.tsx +21 -57
  34. package/src/components/EmptyPlaceholder/styles.ts +4 -3
  35. package/src/components/EmptyPlaceholder/types.ts +21 -11
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { EmptyPlaceholderButtonProps } from '../types';
3
+ export declare const EmptyPlaceholderButton: (props: EmptyPlaceholderButtonProps) => JSX.Element;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { useCompositionStyles } from '@codeleap/styles';
3
+ import { useEmptyPlaceholderContext } from '../context';
4
+ import { Button } from '../../Button';
5
+ import { TypeGuards } from '@codeleap/types';
6
+ export const EmptyPlaceholderButton = (props) => {
7
+ const { styles, buttonText, text, onPress, ...buttonProps } = useEmptyPlaceholderContext(props);
8
+ const buttonStyles = useCompositionStyles('button', styles);
9
+ const displayText = text || buttonText;
10
+ if (!TypeGuards.isFunction(onPress))
11
+ return null;
12
+ return (<Button {...buttonProps} onPress={onPress} debugName={`emptyPlaceholderButton:${buttonText}`} style={buttonStyles} text={displayText}/>);
13
+ };
14
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/EmptyPlaceholder/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAkC,EAAE,EAAE;IAC3E,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAA;IAE/F,MAAM,YAAY,GAAG,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAE3D,MAAM,WAAW,GAAG,IAAI,IAAI,UAAU,CAAA;IAEtC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAEhD,OAAO,CACL,CAAC,MAAM,CACL,IAAI,WAAW,CAAC,CAChB,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,SAAS,CAAC,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAClD,KAAK,CAAC,CAAC,YAAY,CAAC,CACpB,IAAI,CAAC,CAAC,WAAW,CAAC,EAClB,CACH,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const EmptyPlaceholderContent: ({ children }: React.PropsWithChildren) => JSX.Element;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { useEmptyPlaceholderContext } from '../context';
3
+ import { View } from '../../View';
4
+ import { logger } from '@codeleap/logger';
5
+ import { EmptyPlaceholderLoading } from './Loading';
6
+ import { EmptyPlaceholderButton } from './Button';
7
+ import { EmptyPlaceholderInfo } from './Info';
8
+ import { EmptyPlaceholderIllustration } from './Illustration';
9
+ const orderMap = {
10
+ illustration: EmptyPlaceholderIllustration,
11
+ info: EmptyPlaceholderInfo,
12
+ button: EmptyPlaceholderButton,
13
+ };
14
+ export const EmptyPlaceholderContent = ({ children }) => {
15
+ const { loading, styles, order } = useEmptyPlaceholderContext();
16
+ if (loading) {
17
+ return <EmptyPlaceholderLoading />;
18
+ }
19
+ if (children) {
20
+ return <View style={styles.wrapper}>{children}</View>;
21
+ }
22
+ return (<View style={styles.wrapper}>
23
+ {order.map(componentKey => {
24
+ const Component = orderMap[componentKey];
25
+ if (!Component) {
26
+ logger.warn(`[EmptyPlaceholder] Component "${componentKey}" not found in orderMap`);
27
+ return null;
28
+ }
29
+ return <Component key={'emptyPlaceholder:' + componentKey}/>;
30
+ })}
31
+ </View>);
32
+ };
33
+ //# sourceMappingURL=Content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.js","sourceRoot":"","sources":["../../../../src/components/EmptyPlaceholder/components/Content.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAG7D,MAAM,QAAQ,GAAmD;IAC/D,YAAY,EAAE,4BAA4B;IAC1C,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE,sBAAsB;CAC/B,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE;IAC/E,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,0BAA0B,EAAE,CAAA;IAE/D,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,uBAAuB,CAAC,AAAD,EAAG,CAAA;KACnC;IAED,IAAI,QAAQ,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAA;KACtD;IAED,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAC1B;MAAA,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACxB,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAA;YAExC,IAAI,CAAC,SAAS,EAAE;gBACd,MAAM,CAAC,IAAI,CAAC,iCAAiC,YAAY,yBAAyB,CAAC,CAAA;gBACnF,OAAO,IAAI,CAAA;aACZ;YAED,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,mBAAmB,GAAG,YAAY,CAAC,EAAG,CAAA;QAC/D,CAAC,CAAC,CACJ;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { EmptyPlaceholderIllustrationProps } from '../types';
3
+ export declare const EmptyPlaceholderIllustration: (props: EmptyPlaceholderIllustrationProps) => JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Icon } from '../../Icon';
3
+ import { Image } from '../../Image';
4
+ import { useEmptyPlaceholderContext } from '../context';
5
+ export const EmptyPlaceholderIllustration = (props) => {
6
+ const { icon, image, styles } = useEmptyPlaceholderContext(props);
7
+ return <>
8
+ {icon ? <Icon name={icon} style={styles.icon}/> : null}
9
+ {image ? <Image source={image} style={styles.image}/> : null}
10
+ </>;
11
+ };
12
+ //# sourceMappingURL=Illustration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Illustration.js","sourceRoot":"","sources":["../../../../src/components/EmptyPlaceholder/components/Illustration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAEvD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,KAAwC,EAAE,EAAE;IACvF,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAA;IAEjE,OAAO,EACL;IAAA,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAe,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAClE;IAAA,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAC/D;EAAA,GAAG,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { EmptyPlaceholderInfoProps } from '../types';
3
+ export declare const EmptyPlaceholderInfo: (props: EmptyPlaceholderInfoProps) => JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Text } from '../../Text';
3
+ import { useEmptyPlaceholderContext } from '../context';
4
+ export const EmptyPlaceholderInfo = (props) => {
5
+ const { title, description, styles, itemName } = useEmptyPlaceholderContext(props);
6
+ const emptyText = title || (itemName && `No ${itemName} found.`);
7
+ return <>
8
+ {title || itemName ? <Text text={emptyText} style={styles.title}/> : null}
9
+ {description ? <Text text={description} style={styles.description}/> : null}
10
+ </>;
11
+ };
12
+ //# sourceMappingURL=Info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Info.js","sourceRoot":"","sources":["../../../../src/components/EmptyPlaceholder/components/Info.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAEvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAgC,EAAE,EAAE;IACvE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAA;IAElF,MAAM,SAAS,GAAG,KAAK,IAAI,CAAC,QAAQ,IAAI,MAAM,QAAQ,SAAS,CAAC,CAAA;IAEhE,OAAO,EACL;IAAA,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAC1E;IAAA,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAC9E;EAAA,GAAG,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const EmptyPlaceholderLoading: () => JSX.Element;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { useCompositionStyles } from '@codeleap/styles';
3
+ import { useEmptyPlaceholderContext } from '../context';
4
+ import { View } from '../../View';
5
+ import { ActivityIndicator } from '../../ActivityIndicator';
6
+ export const EmptyPlaceholderLoading = () => {
7
+ const { styles, loading, LoadingComponent } = useEmptyPlaceholderContext();
8
+ const activityIndicatorStyles = useCompositionStyles('loader', styles);
9
+ if (!loading)
10
+ return null;
11
+ if (React.isValidElement(LoadingComponent)) {
12
+ return <>{LoadingComponent}</>;
13
+ }
14
+ return (<View style={[styles.wrapper, styles['wrapper:loading']]}>
15
+ <ActivityIndicator style={activityIndicatorStyles}/>
16
+ </View>);
17
+ };
18
+ //# sourceMappingURL=Loading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Loading.js","sourceRoot":"","sources":["../../../../src/components/EmptyPlaceholder/components/Loading.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAE3D,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,0BAA0B,EAAE,CAAA;IAE1E,MAAM,uBAAuB,GAAG,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAEtE,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IAEzB,IAAI,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE;QAC1C,OAAO,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAA;KAC/B;IAED,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CACvD;MAAA,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,EACpD;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { EmptyPlaceholderCtxValue } from './types';
3
+ export declare const EmptyPlaceholderContext: import("react").Context<EmptyPlaceholderCtxValue>;
4
+ export declare const useEmptyPlaceholderContext: <T = EmptyPlaceholderCtxValue>(providedProps?: Partial<T>) => {
5
+ description?: string;
6
+ onPress?: import("@codeleap/types").AnyFunction;
7
+ loading?: boolean;
8
+ title?: string;
9
+ image?: number | import("@d11/react-native-fast-image").Source;
10
+ icon?: never;
11
+ order?: ("info" | "button" | "illustration")[];
12
+ buttonText?: string;
13
+ itemName?: string;
14
+ LoadingComponent?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
15
+ styles: import("@codeleap/styles").StyleRecord<import("./styles").EmptyPlaceholderComposition>;
16
+ } & Partial<T>;
@@ -0,0 +1,13 @@
1
+ import { createContext, useContext } from 'react';
2
+ export const EmptyPlaceholderContext = createContext({});
3
+ export const useEmptyPlaceholderContext = (providedProps = {}) => {
4
+ const ctx = useContext(EmptyPlaceholderContext);
5
+ if (!ctx) {
6
+ throw new Error('[EmptyPlaceholder] useEmptyPlaceholderContext must be used within an EmptyPlaceholder 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/EmptyPlaceholder/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC,EAA8B,CAAC,CAAA;AAEpF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAA+B,gBAA4B,EAAE,EAAE,EAAE;IACzG,MAAM,GAAG,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAA;IAE/C,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CACb,kGAAkG,CACnG,CAAA;KACF;IAED,OAAO;QACL,GAAG,GAAG;QACN,GAAG,aAAa;KACjB,CAAA;AACH,CAAC,CAAA"}
@@ -8,6 +8,9 @@ export declare const EmptyPlaceholder: {
8
8
  styleRegistryName: string;
9
9
  elements: string[];
10
10
  rootElement: string;
11
- withVariantTypes<S extends AnyRecord>(styles: S): (props: StyledComponentProps<EmptyPlaceholderProps, S>) => IJSX;
11
+ Info: (props: import("./types").EmptyPlaceholderInfoProps) => JSX.Element;
12
+ Button: (props: import("./types").EmptyPlaceholderButtonProps) => JSX.Element;
13
+ Illustration: (props: import("./types").EmptyPlaceholderIllustrationProps) => JSX.Element;
14
+ withVariantTypes<S extends AnyRecord>(styles: S): ((props: StyledComponentProps<EmptyPlaceholderProps, S>) => IJSX) & Pick<any, "Button" | "Illustration" | "Info">;
12
15
  defaultProps: Partial<EmptyPlaceholderProps>;
13
16
  };
@@ -1,58 +1,36 @@
1
1
  import React from 'react';
2
- import { Icon } from '../Icon';
3
- import { View } from '../View';
4
- import { Text } from '../Text';
5
- import { ActivityIndicator } from '../ActivityIndicator';
6
- import { Image } from '../Image';
7
- import { useNestedStylesByKey } from '@codeleap/styles';
8
2
  import { MobileStyleRegistry } from '../../Registry';
9
3
  import { useStylesFor } from '../../hooks';
4
+ import { EmptyPlaceholderContext } from './context';
5
+ import { EmptyPlaceholderInfo } from './components/Info';
6
+ import { EmptyPlaceholderButton } from './components/Button';
7
+ import { EmptyPlaceholderIllustration } from './components/Illustration';
8
+ import { EmptyPlaceholderContent } from './components/Content';
10
9
  export * from './styles';
11
10
  export * from './types';
12
11
  export const EmptyPlaceholder = (props) => {
13
- const { itemName, title, loading, description, image, icon = null, renderEmpty, style, } = {
12
+ const { children, style, ...contextValue } = {
14
13
  ...EmptyPlaceholder.defaultProps,
15
14
  ...props,
16
15
  };
17
- const emptyText = title || (itemName && `No ${itemName} found.`) || 'No items.';
18
16
  const styles = useStylesFor(EmptyPlaceholder.styleRegistryName, style);
19
- const activityIndicatorStyles = useNestedStylesByKey('loader', styles);
20
- if (loading) {
21
- return (<View style={[styles.wrapper, styles['wrapper:loading']]}>
22
- <ActivityIndicator style={activityIndicatorStyles}/>
23
- </View>);
24
- }
25
- if (renderEmpty) {
26
- return (<View style={styles.wrapper}>
27
- {renderEmpty({
28
- emptyText,
29
- emptyIconName: icon,
30
- style: styles,
31
- })}
32
- </View>);
33
- }
34
- let _image = null;
35
- if (icon) {
36
- _image = <Icon name={icon} style={styles.icon}/>;
37
- }
38
- else if (image) {
39
- _image = <Image source={image} style={styles.image}/>;
40
- }
41
- return (<View style={styles.wrapper}>
42
- {React.isValidElement(_image) ? (<View style={styles.imageWrapper}>
43
- {_image}
44
- </View>) : null}
45
-
46
- {React.isValidElement(emptyText) ? emptyText : <Text text={emptyText} style={styles.title}/>}
47
- {React.isValidElement(description) ? description : <Text text={description} style={styles.description}/>}
48
- </View>);
17
+ return (<EmptyPlaceholderContext.Provider value={{ ...contextValue, styles }}>
18
+ <EmptyPlaceholderContent>
19
+ {children}
20
+ </EmptyPlaceholderContent>
21
+ </EmptyPlaceholderContext.Provider>);
49
22
  };
50
23
  EmptyPlaceholder.styleRegistryName = 'EmptyPlaceholder';
51
24
  EmptyPlaceholder.elements = ['wrapper', 'loader', 'title', 'description', 'image', 'icon'];
52
25
  EmptyPlaceholder.rootElement = 'wrapper';
26
+ EmptyPlaceholder.Info = EmptyPlaceholderInfo;
27
+ EmptyPlaceholder.Button = EmptyPlaceholderButton;
28
+ EmptyPlaceholder.Illustration = EmptyPlaceholderIllustration;
53
29
  EmptyPlaceholder.withVariantTypes = (styles) => {
54
30
  return EmptyPlaceholder;
55
31
  };
56
- EmptyPlaceholder.defaultProps = {};
32
+ EmptyPlaceholder.defaultProps = {
33
+ order: ['illustration', 'info', 'button']
34
+ };
57
35
  MobileStyleRegistry.registerComponent(EmptyPlaceholder);
58
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/EmptyPlaceholder/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAA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;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,uBAAuB,CAC3B;IAAA,EAAE,uBAAuB,CAAC,QAAQ,CAAC,CACpC,CAAA;AACH,CAAC,CAAA;AAED,gBAAgB,CAAC,iBAAiB,GAAG,kBAAkB,CAAA;AACvD,gBAAgB,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAC1F,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAA;AAExC,gBAAgB,CAAC,IAAI,GAAG,oBAAoB,CAAA;AAC5C,gBAAgB,CAAC,MAAM,GAAG,sBAAsB,CAAA;AAChD,gBAAgB,CAAC,YAAY,GAAG,4BAA4B,CAAA;AAE5D,gBAAgB,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACrE,OAAO,gBAAqK,CAAA;AAC9K,CAAC,CAAA;AAED,gBAAgB,CAAC,YAAY,GAAG;IAC9B,KAAK,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC;CACR,CAAA;AAEnC,mBAAmB,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAA"}
@@ -1,2 +1,3 @@
1
1
  import { ActivityIndicatorComposition } from '../ActivityIndicator';
2
- export type EmptyPlaceholderComposition = 'wrapper:loading' | `loader${Capitalize<ActivityIndicatorComposition>}` | 'wrapper' | 'title' | 'description' | 'image' | 'imageWrapper' | 'icon';
2
+ import { ButtonComposition } from '../Button';
3
+ export type EmptyPlaceholderComposition = 'wrapper' | 'wrapper:loading' | 'title' | 'description' | 'image' | 'icon' | `button${Capitalize<ButtonComposition>}` | `loader${Capitalize<ActivityIndicatorComposition>}`;
@@ -1,20 +1,26 @@
1
- import { AppIcon, StyledProp } from '@codeleap/styles';
2
- import { ReactElement } from 'react';
1
+ import { AppIcon, StyleRecord, StyledProp } from '@codeleap/styles';
3
2
  import { ImageProps } from '../Image';
4
3
  import { EmptyPlaceholderComposition } from './styles';
5
- type RenderEmpty = (props: {
6
- emptyText: string | ReactElement;
7
- emptyIconName?: AppIcon;
8
- style?: StyledProp<EmptyPlaceholderComposition>;
9
- }) => ReactElement;
4
+ import { ReactElement, ReactNode } from 'react';
5
+ import { AnyFunction } from '@codeleap/types';
6
+ import { ButtonProps } from '../Button';
10
7
  export type EmptyPlaceholderProps = {
11
8
  itemName?: string;
12
- title?: ReactElement | string;
13
- description?: ReactElement | string;
9
+ title?: string;
10
+ description?: string;
14
11
  image?: ImageProps['source'];
15
12
  icon?: AppIcon;
16
13
  loading?: boolean;
17
14
  style?: StyledProp<EmptyPlaceholderComposition>;
18
- renderEmpty?: RenderEmpty;
15
+ LoadingComponent?: ReactElement;
16
+ children?: ReactNode;
17
+ onPress?: AnyFunction;
18
+ buttonText?: string;
19
+ order?: Array<'info' | 'illustration' | 'button'>;
20
+ };
21
+ export type EmptyPlaceholderInfoProps = Pick<EmptyPlaceholderProps, 'title' | 'description'>;
22
+ export type EmptyPlaceholderIllustrationProps = Pick<EmptyPlaceholderProps, 'image' | 'icon'>;
23
+ export type EmptyPlaceholderButtonProps = Pick<EmptyPlaceholderProps, 'onPress'> & Omit<ButtonProps, 'style' | 'debugName'>;
24
+ export type EmptyPlaceholderCtxValue = Omit<EmptyPlaceholderProps, 'style' | 'children'> & {
25
+ styles: StyleRecord<EmptyPlaceholderComposition>;
19
26
  };
20
- export {};
@@ -148,7 +148,7 @@ export declare const Tabs: {
148
148
  contentOffset?: import("react-native/types").PointProp;
149
149
  contentInsetAdjustmentBehavior?: "always" | "never" | "automatic" | "scrollableAxes";
150
150
  directionalLockEnabled?: boolean;
151
- indicatorStyle?: "default" | "black" | "white";
151
+ indicatorStyle?: "black" | "white" | "default";
152
152
  maintainVisibleContentPosition?: {
153
153
  autoscrollToTopThreshold?: number;
154
154
  minIndexForVisible: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "5.8.1",
3
+ "version": "5.8.3",
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.1",
13
- "@codeleap/utils": "5.8.1",
14
- "@codeleap/hooks": "5.8.1",
15
- "@codeleap/form": "5.8.1",
16
- "@codeleap/query": "5.8.1",
17
- "@codeleap/logger": "5.8.1",
18
- "@codeleap/config": "5.8.1",
19
- "@codeleap/modals": "5.8.1"
12
+ "@codeleap/types": "5.8.3",
13
+ "@codeleap/utils": "5.8.3",
14
+ "@codeleap/hooks": "5.8.3",
15
+ "@codeleap/form": "5.8.3",
16
+ "@codeleap/query": "5.8.3",
17
+ "@codeleap/logger": "5.8.3",
18
+ "@codeleap/config": "5.8.3",
19
+ "@codeleap/modals": "5.8.3"
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.1",
27
- "@codeleap/utils": "5.8.1",
28
- "@codeleap/hooks": "5.8.1",
29
- "@codeleap/form": "5.8.1",
30
- "@codeleap/query": "5.8.1",
31
- "@codeleap/logger": "5.8.1",
32
- "@codeleap/styles": "5.8.1",
33
- "@codeleap/modals": "5.8.1",
26
+ "@codeleap/types": "5.8.3",
27
+ "@codeleap/utils": "5.8.3",
28
+ "@codeleap/hooks": "5.8.3",
29
+ "@codeleap/form": "5.8.3",
30
+ "@codeleap/query": "5.8.3",
31
+ "@codeleap/logger": "5.8.3",
32
+ "@codeleap/styles": "5.8.3",
33
+ "@codeleap/modals": "5.8.3",
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.1",
3
+ "version": "5.8.3",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import { useCompositionStyles } from '@codeleap/styles'
3
+ import { EmptyPlaceholderButtonProps } from '../types'
4
+ import { useEmptyPlaceholderContext } from '../context'
5
+ import { Button } from '../../Button'
6
+ import { TypeGuards } from '@codeleap/types'
7
+
8
+ export const EmptyPlaceholderButton = (props: EmptyPlaceholderButtonProps) => {
9
+ const { styles, buttonText, text, onPress, ...buttonProps } = useEmptyPlaceholderContext(props)
10
+
11
+ const buttonStyles = useCompositionStyles('button', styles)
12
+
13
+ const displayText = text || buttonText
14
+
15
+ if (!TypeGuards.isFunction(onPress)) return null
16
+
17
+ return (
18
+ <Button
19
+ {...buttonProps}
20
+ onPress={onPress}
21
+ debugName={`emptyPlaceholderButton:${buttonText}`}
22
+ style={buttonStyles}
23
+ text={displayText}
24
+ />
25
+ )
26
+ }
@@ -0,0 +1,42 @@
1
+ import React from 'react'
2
+ import { useEmptyPlaceholderContext } from '../context'
3
+ import { View } from '../../View'
4
+ import { logger } from '@codeleap/logger'
5
+ import { EmptyPlaceholderLoading } from './Loading'
6
+ import { EmptyPlaceholderButton } from './Button'
7
+ import { EmptyPlaceholderInfo } from './Info'
8
+ import { EmptyPlaceholderIllustration } from './Illustration'
9
+ import { EmptyPlaceholderProps } from '../types'
10
+
11
+ const orderMap: Record<EmptyPlaceholderProps['order'][0], any> = {
12
+ illustration: EmptyPlaceholderIllustration,
13
+ info: EmptyPlaceholderInfo,
14
+ button: EmptyPlaceholderButton,
15
+ }
16
+
17
+ export const EmptyPlaceholderContent = ({ children }: React.PropsWithChildren) => {
18
+ const { loading, styles, order } = useEmptyPlaceholderContext()
19
+
20
+ if (loading) {
21
+ return <EmptyPlaceholderLoading />
22
+ }
23
+
24
+ if (children) {
25
+ return <View style={styles.wrapper}>{children}</View>
26
+ }
27
+
28
+ return (
29
+ <View style={styles.wrapper}>
30
+ {order.map(componentKey => {
31
+ const Component = orderMap[componentKey]
32
+
33
+ if (!Component) {
34
+ logger.warn(`[EmptyPlaceholder] Component "${componentKey}" not found in orderMap`)
35
+ return null
36
+ }
37
+
38
+ return <Component key={'emptyPlaceholder:' + componentKey} />
39
+ })}
40
+ </View>
41
+ )
42
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react'
2
+ import { AppIcon } from '@codeleap/styles'
3
+ import { Icon } from '../../Icon'
4
+ import { EmptyPlaceholderIllustrationProps } from '../types'
5
+ import { Image } from '../../Image'
6
+ import { useEmptyPlaceholderContext } from '../context'
7
+
8
+ export const EmptyPlaceholderIllustration = (props: EmptyPlaceholderIllustrationProps) => {
9
+ const { icon, image, styles } = useEmptyPlaceholderContext(props)
10
+
11
+ return <>
12
+ {icon ? <Icon name={icon as AppIcon} style={styles.icon} /> : null}
13
+ {image ? <Image source={image} style={styles.image} /> : null}
14
+ </>
15
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react'
2
+ import { Text } from '../../Text'
3
+ import { EmptyPlaceholderInfoProps } from '../types'
4
+ import { useEmptyPlaceholderContext } from '../context'
5
+
6
+ export const EmptyPlaceholderInfo = (props: EmptyPlaceholderInfoProps) => {
7
+ const { title, description, styles, itemName } = useEmptyPlaceholderContext(props)
8
+
9
+ const emptyText = title || (itemName && `No ${itemName} found.`)
10
+
11
+ return <>
12
+ {title || itemName ? <Text text={emptyText} style={styles.title} /> : null}
13
+ {description ? <Text text={description} style={styles.description} /> : null}
14
+ </>
15
+ }
@@ -0,0 +1,23 @@
1
+ import React from 'react'
2
+ import { useCompositionStyles } from '@codeleap/styles'
3
+ import { useEmptyPlaceholderContext } from '../context'
4
+ import { View } from '../../View'
5
+ import { ActivityIndicator } from '../../ActivityIndicator'
6
+
7
+ export const EmptyPlaceholderLoading = () => {
8
+ const { styles, loading, LoadingComponent } = useEmptyPlaceholderContext()
9
+
10
+ const activityIndicatorStyles = useCompositionStyles('loader', styles)
11
+
12
+ if (!loading) return null
13
+
14
+ if (React.isValidElement(LoadingComponent)) {
15
+ return <>{LoadingComponent}</>
16
+ }
17
+
18
+ return (
19
+ <View style={[styles.wrapper, styles['wrapper:loading']]} >
20
+ <ActivityIndicator style={activityIndicatorStyles} />
21
+ </View>
22
+ )
23
+ }
@@ -0,0 +1,19 @@
1
+ import { createContext, useContext } from 'react'
2
+ import { EmptyPlaceholderCtxValue } from './types'
3
+
4
+ export const EmptyPlaceholderContext = createContext({} as EmptyPlaceholderCtxValue)
5
+
6
+ export const useEmptyPlaceholderContext = <T = EmptyPlaceholderCtxValue>(providedProps: Partial<T> = {}) => {
7
+ const ctx = useContext(EmptyPlaceholderContext)
8
+
9
+ if (!ctx) {
10
+ throw new Error(
11
+ '[EmptyPlaceholder] useEmptyPlaceholderContext must be used within an EmptyPlaceholder component.'
12
+ )
13
+ }
14
+
15
+ return {
16
+ ...ctx,
17
+ ...providedProps,
18
+ }
19
+ }
@@ -1,77 +1,35 @@
1
1
  import React from 'react'
2
- import { Icon } from '../Icon'
3
- import { View } from '../View'
4
- import { Text } from '../Text'
5
- import { ActivityIndicator } from '../ActivityIndicator'
6
- import { Image } from '../Image'
7
2
  import { EmptyPlaceholderProps } from './types'
8
- import { AnyRecord, AppIcon, useNestedStylesByKey, IJSX, StyledComponentProps } from '@codeleap/styles'
3
+ import { AnyRecord, IJSX, StyledComponentProps } from '@codeleap/styles'
9
4
  import { MobileStyleRegistry } from '../../Registry'
10
5
  import { useStylesFor } from '../../hooks'
6
+ import { EmptyPlaceholderContext } from './context'
7
+ import { EmptyPlaceholderInfo } from './components/Info'
8
+ import { EmptyPlaceholderButton } from './components/Button'
9
+ import { EmptyPlaceholderIllustration } from './components/Illustration'
10
+ import { EmptyPlaceholderContent } from './components/Content'
11
11
 
12
12
  export * from './styles'
13
13
  export * from './types'
14
14
 
15
15
  export const EmptyPlaceholder = (props: EmptyPlaceholderProps) => {
16
16
  const {
17
- itemName,
18
- title,
19
- loading,
20
- description,
21
- image,
22
- icon = null,
23
- renderEmpty,
17
+ children,
24
18
  style,
19
+ ...contextValue
25
20
  } = {
26
21
  ...EmptyPlaceholder.defaultProps,
27
22
  ...props,
28
23
  }
29
24
 
30
- const emptyText = title || (itemName && `No ${itemName} found.`) || 'No items.'
31
-
32
25
  const styles = useStylesFor(EmptyPlaceholder.styleRegistryName, style)
33
26
 
34
- const activityIndicatorStyles = useNestedStylesByKey('loader', styles)
35
-
36
- if (loading) {
37
- return (
38
- <View style={[styles.wrapper, styles['wrapper:loading']]} >
39
- <ActivityIndicator style={activityIndicatorStyles} />
40
- </View>
41
- )
42
- }
43
-
44
- if (renderEmpty) {
45
- return (
46
- <View style={styles.wrapper}>
47
- {renderEmpty({
48
- emptyText,
49
- emptyIconName: icon as AppIcon,
50
- style: styles,
51
- })}
52
- </View>
53
- )
54
- }
55
-
56
- let _image = null
57
-
58
- if (icon) {
59
- _image = <Icon name={icon as AppIcon} style={styles.icon} />
60
- } else if (image) {
61
- _image = <Image source={image} style={styles.image} />
62
- }
63
-
64
27
  return (
65
- <View style={styles.wrapper}>
66
- {React.isValidElement(_image) ? (
67
- <View style={styles.imageWrapper}>
68
- {_image}
69
- </View>
70
- ) : null}
71
-
72
- {React.isValidElement(emptyText) ? emptyText : <Text text={emptyText} style={styles.title} />}
73
- {React.isValidElement(description) ? description : <Text text={description} style={styles.description} />}
74
- </View>
28
+ <EmptyPlaceholderContext.Provider value={{ ...contextValue, styles }}>
29
+ <EmptyPlaceholderContent>
30
+ {children}
31
+ </EmptyPlaceholderContent>
32
+ </EmptyPlaceholderContext.Provider>
75
33
  )
76
34
  }
77
35
 
@@ -79,10 +37,16 @@ EmptyPlaceholder.styleRegistryName = 'EmptyPlaceholder'
79
37
  EmptyPlaceholder.elements = ['wrapper', 'loader', 'title', 'description', 'image', 'icon']
80
38
  EmptyPlaceholder.rootElement = 'wrapper'
81
39
 
40
+ EmptyPlaceholder.Info = EmptyPlaceholderInfo
41
+ EmptyPlaceholder.Button = EmptyPlaceholderButton
42
+ EmptyPlaceholder.Illustration = EmptyPlaceholderIllustration
43
+
82
44
  EmptyPlaceholder.withVariantTypes = <S extends AnyRecord>(styles: S) => {
83
- return EmptyPlaceholder as (props: StyledComponentProps<EmptyPlaceholderProps, typeof styles>) => IJSX
45
+ return EmptyPlaceholder as ((props: StyledComponentProps<EmptyPlaceholderProps, typeof styles>) => IJSX) & Pick<typeof EmptyPlaceholder, 'Button' | 'Illustration' | 'Info'>
84
46
  }
85
47
 
86
- EmptyPlaceholder.defaultProps = {} as Partial<EmptyPlaceholderProps>
48
+ EmptyPlaceholder.defaultProps = {
49
+ order: ['illustration', 'info', 'button']
50
+ } as Partial<EmptyPlaceholderProps>
87
51
 
88
52
  MobileStyleRegistry.registerComponent(EmptyPlaceholder)
@@ -1,11 +1,12 @@
1
1
  import { ActivityIndicatorComposition } from '../ActivityIndicator'
2
+ import { ButtonComposition } from '../Button'
2
3
 
3
4
  export type EmptyPlaceholderComposition =
4
- | 'wrapper:loading'
5
- | `loader${Capitalize<ActivityIndicatorComposition>}`
6
5
  | 'wrapper'
6
+ | 'wrapper:loading'
7
7
  | 'title'
8
8
  | 'description'
9
9
  | 'image'
10
- | 'imageWrapper'
11
10
  | 'icon'
11
+ | `button${Capitalize<ButtonComposition>}`
12
+ | `loader${Capitalize<ActivityIndicatorComposition>}`
@@ -1,21 +1,31 @@
1
- import { AppIcon, StyledProp } from '@codeleap/styles'
2
- import { ReactElement } from 'react'
1
+ import { AppIcon, StyleRecord, StyledProp } from '@codeleap/styles'
3
2
  import { ImageProps } from '../Image'
4
3
  import { EmptyPlaceholderComposition } from './styles'
5
-
6
- type RenderEmpty = (props: {
7
- emptyText: string | ReactElement
8
- emptyIconName?: AppIcon
9
- style?: StyledProp<EmptyPlaceholderComposition>
10
- }) => ReactElement
4
+ import { ReactElement, ReactNode } from 'react'
5
+ import { AnyFunction } from '@codeleap/types'
6
+ import { ButtonProps } from '../Button'
11
7
 
12
8
  export type EmptyPlaceholderProps = {
13
9
  itemName?: string
14
- title?: ReactElement | string
15
- description?: ReactElement | string
10
+ title?: string
11
+ description?: string
16
12
  image?: ImageProps['source']
17
13
  icon?: AppIcon
18
14
  loading?: boolean
19
15
  style?: StyledProp<EmptyPlaceholderComposition>
20
- renderEmpty?: RenderEmpty
16
+ LoadingComponent?: ReactElement
17
+ children?: ReactNode
18
+ onPress?: AnyFunction
19
+ buttonText?: string
20
+ order?: Array<'info' | 'illustration' | 'button'>
21
+ }
22
+
23
+ export type EmptyPlaceholderInfoProps = Pick<EmptyPlaceholderProps, 'title' | 'description'>
24
+
25
+ export type EmptyPlaceholderIllustrationProps = Pick<EmptyPlaceholderProps, 'image' | 'icon'>
26
+
27
+ export type EmptyPlaceholderButtonProps = Pick<EmptyPlaceholderProps, 'onPress'> & Omit<ButtonProps, 'style' | 'debugName'>
28
+
29
+ export type EmptyPlaceholderCtxValue = Omit<EmptyPlaceholderProps, 'style' | 'children'> & {
30
+ styles: StyleRecord<EmptyPlaceholderComposition>
21
31
  }