@codeleap/mobile 5.7.1 → 5.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EmptyPlaceholder/Components.d.ts +7 -0
- package/dist/components/EmptyPlaceholder/Components.js +60 -0
- package/dist/components/EmptyPlaceholder/Components.js.map +1 -0
- package/dist/components/EmptyPlaceholder/context.d.ts +15 -0
- package/dist/components/EmptyPlaceholder/context.js +13 -0
- package/dist/components/EmptyPlaceholder/context.js.map +1 -0
- package/dist/components/EmptyPlaceholder/index.d.ts +4 -1
- package/dist/components/EmptyPlaceholder/index.js +11 -38
- package/dist/components/EmptyPlaceholder/index.js.map +1 -1
- package/dist/components/EmptyPlaceholder/styles.d.ts +2 -1
- package/dist/components/EmptyPlaceholder/types.d.ts +16 -11
- package/dist/components/InputBase/index.d.ts +2 -6
- package/dist/components/InputBase/index.js +4 -4
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +2 -2
- package/package.json +17 -17
- package/package.json.bak +1 -1
- package/src/components/EmptyPlaceholder/Components.tsx +89 -0
- package/src/components/EmptyPlaceholder/context.ts +19 -0
- package/src/components/EmptyPlaceholder/index.tsx +15 -56
- package/src/components/EmptyPlaceholder/styles.ts +4 -3
- package/src/components/EmptyPlaceholder/types.ts +20 -11
- package/src/components/InputBase/index.tsx +5 -4
- package/src/components/InputBase/types.ts +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EmptyPlaceholderButtonProps, EmptyPlaceholderIllustrationProps, EmptyPlaceholderInfoProps } from './types';
|
|
3
|
+
export declare const EmptyPlaceholderInfo: (props: EmptyPlaceholderInfoProps) => JSX.Element;
|
|
4
|
+
export declare const EmptyPlaceholderIllustration: (props: EmptyPlaceholderIllustrationProps) => JSX.Element;
|
|
5
|
+
export declare const EmptyPlaceholderButton: (props: EmptyPlaceholderButtonProps) => JSX.Element;
|
|
6
|
+
export declare const EmptyPlaceholderLoading: () => JSX.Element;
|
|
7
|
+
export declare const EmptyPlaceholderContent: ({ children }: React.PropsWithChildren) => JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useCompositionStyles } from '@codeleap/styles';
|
|
3
|
+
import { Icon } from '../Icon';
|
|
4
|
+
import { Text } from '../Text';
|
|
5
|
+
import { Image } from '../Image';
|
|
6
|
+
import { useEmptyPlaceholderContext } from './context';
|
|
7
|
+
import { Button } from '../Button';
|
|
8
|
+
import { View } from '../View';
|
|
9
|
+
import { ActivityIndicator } from '../ActivityIndicator';
|
|
10
|
+
import { TypeGuards } from '@codeleap/types';
|
|
11
|
+
export const EmptyPlaceholderInfo = (props) => {
|
|
12
|
+
const { title, description, styles, itemName } = useEmptyPlaceholderContext(props);
|
|
13
|
+
const emptyText = title || (itemName && `No ${itemName} found.`);
|
|
14
|
+
return <>
|
|
15
|
+
{title || itemName ? <Text text={emptyText} style={styles.title}/> : null}
|
|
16
|
+
{description ? <Text text={description} style={styles.description}/> : null}
|
|
17
|
+
</>;
|
|
18
|
+
};
|
|
19
|
+
export const EmptyPlaceholderIllustration = (props) => {
|
|
20
|
+
const { icon, image, styles } = useEmptyPlaceholderContext(props);
|
|
21
|
+
return <>
|
|
22
|
+
{icon ? <Icon name={icon} style={styles.icon}/> : null}
|
|
23
|
+
{image ? <Image source={image} style={styles.image}/> : null}
|
|
24
|
+
</>;
|
|
25
|
+
};
|
|
26
|
+
export const EmptyPlaceholderButton = (props) => {
|
|
27
|
+
const { styles, buttonText, text, onPress, ...buttonProps } = useEmptyPlaceholderContext(props);
|
|
28
|
+
const buttonStyles = useCompositionStyles('button', styles);
|
|
29
|
+
const displayText = text || buttonText;
|
|
30
|
+
if (!TypeGuards.isFunction(onPress))
|
|
31
|
+
return null;
|
|
32
|
+
return (<Button {...buttonProps} onPress={onPress} debugName={`emptyPlaceholderButton:${buttonText}`} style={buttonStyles} text={displayText}/>);
|
|
33
|
+
};
|
|
34
|
+
export const EmptyPlaceholderLoading = () => {
|
|
35
|
+
const { styles, loading, LoadingComponent } = useEmptyPlaceholderContext();
|
|
36
|
+
const activityIndicatorStyles = useCompositionStyles('loader', styles);
|
|
37
|
+
if (!loading)
|
|
38
|
+
return null;
|
|
39
|
+
if (React.isValidElement(LoadingComponent)) {
|
|
40
|
+
return <>{LoadingComponent}</>;
|
|
41
|
+
}
|
|
42
|
+
return (<View style={[styles.wrapper, styles['wrapper:loading']]}>
|
|
43
|
+
<ActivityIndicator style={activityIndicatorStyles}/>
|
|
44
|
+
</View>);
|
|
45
|
+
};
|
|
46
|
+
export const EmptyPlaceholderContent = ({ children }) => {
|
|
47
|
+
const { loading, styles } = useEmptyPlaceholderContext();
|
|
48
|
+
if (loading) {
|
|
49
|
+
return <EmptyPlaceholderLoading />;
|
|
50
|
+
}
|
|
51
|
+
if (children) {
|
|
52
|
+
return <View style={styles.wrapper}>{children}</View>;
|
|
53
|
+
}
|
|
54
|
+
return (<View style={styles.wrapper}>
|
|
55
|
+
<EmptyPlaceholderIllustration />
|
|
56
|
+
<EmptyPlaceholderInfo />
|
|
57
|
+
<EmptyPlaceholderButton />
|
|
58
|
+
</View>);
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=Components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Components.js","sourceRoot":"","sources":["../../../src/components/EmptyPlaceholder/Components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAW,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE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AE,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;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE;IAC/E,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,0BAA0B,EAAE,CAAA;IAExD,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,4BAA4B,CAAC,AAAD,EAC7B;MAAA,CAAC,oBAAoB,CAAC,AAAD,EACrB;MAAA,CAAC,sBAAsB,CAAC,AAAD,EACzB;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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>(args?: 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
|
+
buttonText?: string;
|
|
12
|
+
itemName?: string;
|
|
13
|
+
LoadingComponent?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
14
|
+
styles: import("@codeleap/styles").StyleRecord<import("./styles").EmptyPlaceholderComposition>;
|
|
15
|
+
} & Partial<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
export const EmptyPlaceholderContext = createContext({});
|
|
3
|
+
export const useEmptyPlaceholderContext = (args = {}) => {
|
|
4
|
+
const ctx = useContext(EmptyPlaceholderContext);
|
|
5
|
+
if (!ctx) {
|
|
6
|
+
throw new Error('useEmptyPlaceholderContext must be used within an EmptyPlaceholder component.');
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
...ctx,
|
|
10
|
+
...args,
|
|
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,OAAmB,EAAE,EAAE,EAAE;IAChG,MAAM,GAAG,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAA;IAE/C,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAA;KACF;IAED,OAAO;QACL,GAAG,GAAG;QACN,GAAG,IAAI;KACR,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
|
-
|
|
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,55 +1,28 @@
|
|
|
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 { EmptyPlaceholderContent, EmptyPlaceholderButton, EmptyPlaceholderIllustration, EmptyPlaceholderInfo } from './Components';
|
|
10
6
|
export * from './styles';
|
|
11
7
|
export * from './types';
|
|
12
8
|
export const EmptyPlaceholder = (props) => {
|
|
13
|
-
const {
|
|
9
|
+
const { children, style, ...contextValue } = {
|
|
14
10
|
...EmptyPlaceholder.defaultProps,
|
|
15
11
|
...props,
|
|
16
12
|
};
|
|
17
|
-
const emptyText = title || (itemName && `No ${itemName} found.`) || 'No items.';
|
|
18
13
|
const styles = useStylesFor(EmptyPlaceholder.styleRegistryName, style);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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>);
|
|
14
|
+
return (<EmptyPlaceholderContext.Provider value={{ ...contextValue, styles }}>
|
|
15
|
+
<EmptyPlaceholderContent>
|
|
16
|
+
{children}
|
|
17
|
+
</EmptyPlaceholderContent>
|
|
18
|
+
</EmptyPlaceholderContext.Provider>);
|
|
49
19
|
};
|
|
50
20
|
EmptyPlaceholder.styleRegistryName = 'EmptyPlaceholder';
|
|
51
21
|
EmptyPlaceholder.elements = ['wrapper', 'loader', 'title', 'description', 'image', 'icon'];
|
|
52
22
|
EmptyPlaceholder.rootElement = 'wrapper';
|
|
23
|
+
EmptyPlaceholder.Info = EmptyPlaceholderInfo;
|
|
24
|
+
EmptyPlaceholder.Button = EmptyPlaceholderButton;
|
|
25
|
+
EmptyPlaceholder.Illustration = EmptyPlaceholderIllustration;
|
|
53
26
|
EmptyPlaceholder.withVariantTypes = (styles) => {
|
|
54
27
|
return EmptyPlaceholder;
|
|
55
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/EmptyPlaceholder/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"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sB,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,EAAoC,CAAA;AAEpE,mBAAmB,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAA"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ActivityIndicatorComposition } from '../ActivityIndicator';
|
|
2
|
-
|
|
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,25 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
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?:
|
|
13
|
-
description?:
|
|
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
|
-
|
|
15
|
+
LoadingComponent?: ReactElement;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
onPress?: AnyFunction;
|
|
18
|
+
buttonText?: string;
|
|
19
|
+
};
|
|
20
|
+
export type EmptyPlaceholderInfoProps = Pick<EmptyPlaceholderProps, 'title' | 'description'>;
|
|
21
|
+
export type EmptyPlaceholderIllustrationProps = Pick<EmptyPlaceholderProps, 'image' | 'icon'>;
|
|
22
|
+
export type EmptyPlaceholderButtonProps = Pick<EmptyPlaceholderProps, 'onPress'> & Omit<ButtonProps, 'style' | 'debugName'>;
|
|
23
|
+
export type EmptyPlaceholderCtxValue = Omit<EmptyPlaceholderProps, 'style' | 'children'> & {
|
|
24
|
+
styles: StyleRecord<EmptyPlaceholderComposition>;
|
|
19
25
|
};
|
|
20
|
-
export {};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { InputBaseProps } from './types';
|
|
2
|
+
import { StyledComponentWithProps } from '@codeleap/styles';
|
|
3
3
|
export { useInputBase } from './useInputBase';
|
|
4
4
|
export * from './styles';
|
|
5
5
|
export * from './utils';
|
|
6
6
|
export * from './types';
|
|
7
7
|
export declare const InputBaseDefaultOrder: InputBaseProps['order'];
|
|
8
|
-
export declare const InputBase:
|
|
9
|
-
(props: InputBaseProps): JSX.Element;
|
|
10
|
-
elements: string[];
|
|
11
|
-
defaultProps: Partial<InputBaseProps>;
|
|
12
|
-
};
|
|
8
|
+
export declare const InputBase: StyledComponentWithProps<InputBaseProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { TypeGuards } from '@codeleap/types';
|
|
3
3
|
import { getRenderedComponent } from '@codeleap/utils';
|
|
4
4
|
import { ActionIcon } from '../ActionIcon';
|
|
@@ -16,8 +16,8 @@ export const InputBaseDefaultOrder = [
|
|
|
16
16
|
'innerWrapper',
|
|
17
17
|
'error',
|
|
18
18
|
];
|
|
19
|
-
export const InputBase = (props) => {
|
|
20
|
-
const { children, error = null, label, description = null, leftIcon = null, rightIcon = null, wrapper, debugName, innerWrapper, focused, innerWrapperProps = {}, wrapperProps = {}, disabled, order = InputBaseDefaultOrder, style, labelAsRow, hideErrorMessage,
|
|
19
|
+
export const InputBase = forwardRef((props, ref) => {
|
|
20
|
+
const { children, error = null, label, description = null, leftIcon = null, rightIcon = null, wrapper, debugName, innerWrapper, focused, innerWrapperProps = {}, wrapperProps = {}, disabled, order = InputBaseDefaultOrder, style, labelAsRow, hideErrorMessage, ...otherProps } = {
|
|
21
21
|
...InputBase.defaultProps,
|
|
22
22
|
...props,
|
|
23
23
|
};
|
|
@@ -51,7 +51,7 @@ export const InputBase = (props) => {
|
|
|
51
51
|
{TypeGuards.isString(error) ? <Text text={error} style={styles.errorStyle}/> : error}
|
|
52
52
|
</RNAnimated.View>)}
|
|
53
53
|
</WrapperComponent>;
|
|
54
|
-
};
|
|
54
|
+
});
|
|
55
55
|
InputBase.elements = ['wrapper', 'innerWrapper', 'label', 'errorMessage', 'description', 'icon', 'leftIcon', 'rightIcon'];
|
|
56
56
|
InputBase.defaultProps = {
|
|
57
57
|
disabled: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/InputBase/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/InputBase/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,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,M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CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,EAAG,CAAC,CAAC,CAAC,KAAK,CACvF;MAAA,EAAE,UAAU,CAAC,IAAI,CAAC,CACnB,CACH;EAAA,EAAE,gBAAgB,CAAC,CAAA;AACrB,CAAC,CAA6C,CAAA;AAE9C,SAAS,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAA;AAEzH,SAAS,CAAC,YAAY,GAAG;IACvB,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,KAAK;IACvB,KAAK,EAAE,qBAAqB;IAC5B,OAAO,EAAE,IAAI;IACb,YAAY,EAAE,IAAI;CACQ,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { PropsOf, StylesOf } from '@codeleap/types';
|
|
3
3
|
import { InputBaseComposition } from './styles';
|
|
4
4
|
import { ActionIcon } from '../ActionIcon';
|
|
5
|
-
import {
|
|
5
|
+
import { ViewProps } from 'react-native';
|
|
6
6
|
type ActionIconProps = PropsOf<typeof ActionIcon>;
|
|
7
7
|
type OrderedParts = 'label' | 'description' | 'innerWrapper' | 'error';
|
|
8
8
|
type IconProp = Partial<ActionIconProps> | JSX.Element;
|
|
@@ -24,7 +24,7 @@ export type InputBaseProps = React.PropsWithChildren<{
|
|
|
24
24
|
labelAsRow?: boolean;
|
|
25
25
|
hideErrorMessage?: boolean;
|
|
26
26
|
hasValue?: boolean;
|
|
27
|
-
ref?: React.Ref<View>;
|
|
28
27
|
onLayout?: ViewProps['onLayout'];
|
|
28
|
+
ref?: any;
|
|
29
29
|
}>;
|
|
30
30
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/mobile",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.2",
|
|
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.
|
|
13
|
-
"@codeleap/utils": "5.
|
|
14
|
-
"@codeleap/hooks": "5.
|
|
15
|
-
"@codeleap/form": "5.
|
|
16
|
-
"@codeleap/query": "5.
|
|
17
|
-
"@codeleap/logger": "5.
|
|
18
|
-
"@codeleap/config": "5.
|
|
19
|
-
"@codeleap/modals": "5.
|
|
12
|
+
"@codeleap/types": "5.8.2",
|
|
13
|
+
"@codeleap/utils": "5.8.2",
|
|
14
|
+
"@codeleap/hooks": "5.8.2",
|
|
15
|
+
"@codeleap/form": "5.8.2",
|
|
16
|
+
"@codeleap/query": "5.8.2",
|
|
17
|
+
"@codeleap/logger": "5.8.2",
|
|
18
|
+
"@codeleap/config": "5.8.2",
|
|
19
|
+
"@codeleap/modals": "5.8.2"
|
|
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.
|
|
27
|
-
"@codeleap/utils": "5.
|
|
28
|
-
"@codeleap/hooks": "5.
|
|
29
|
-
"@codeleap/form": "5.
|
|
30
|
-
"@codeleap/query": "5.
|
|
31
|
-
"@codeleap/logger": "5.
|
|
32
|
-
"@codeleap/styles": "5.
|
|
33
|
-
"@codeleap/modals": "5.
|
|
26
|
+
"@codeleap/types": "5.8.2",
|
|
27
|
+
"@codeleap/utils": "5.8.2",
|
|
28
|
+
"@codeleap/hooks": "5.8.2",
|
|
29
|
+
"@codeleap/form": "5.8.2",
|
|
30
|
+
"@codeleap/query": "5.8.2",
|
|
31
|
+
"@codeleap/logger": "5.8.2",
|
|
32
|
+
"@codeleap/styles": "5.8.2",
|
|
33
|
+
"@codeleap/modals": "5.8.2",
|
|
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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { AppIcon, useCompositionStyles } from '@codeleap/styles'
|
|
3
|
+
import { Icon } from '../Icon'
|
|
4
|
+
import { Text } from '../Text'
|
|
5
|
+
import { EmptyPlaceholderButtonProps, EmptyPlaceholderIllustrationProps, EmptyPlaceholderInfoProps } from './types'
|
|
6
|
+
import { Image } from '../Image'
|
|
7
|
+
import { useEmptyPlaceholderContext } from './context'
|
|
8
|
+
import { Button } from '../Button'
|
|
9
|
+
import { View } from '../View'
|
|
10
|
+
import { ActivityIndicator } from '../ActivityIndicator'
|
|
11
|
+
import { TypeGuards } from '@codeleap/types'
|
|
12
|
+
|
|
13
|
+
export const EmptyPlaceholderInfo = (props: EmptyPlaceholderInfoProps) => {
|
|
14
|
+
const { title, description, styles, itemName } = useEmptyPlaceholderContext(props)
|
|
15
|
+
|
|
16
|
+
const emptyText = title || (itemName && `No ${itemName} found.`)
|
|
17
|
+
|
|
18
|
+
return <>
|
|
19
|
+
{title || itemName ? <Text text={emptyText} style={styles.title} /> : null}
|
|
20
|
+
{description ? <Text text={description} style={styles.description} /> : null}
|
|
21
|
+
</>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const EmptyPlaceholderIllustration = (props: EmptyPlaceholderIllustrationProps) => {
|
|
25
|
+
const { icon, image, styles } = useEmptyPlaceholderContext(props)
|
|
26
|
+
|
|
27
|
+
return <>
|
|
28
|
+
{icon ? <Icon name={icon as AppIcon} style={styles.icon} /> : null}
|
|
29
|
+
{image ? <Image source={image} style={styles.image} /> : null}
|
|
30
|
+
</>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const EmptyPlaceholderButton = (props: EmptyPlaceholderButtonProps) => {
|
|
34
|
+
const { styles, buttonText, text, onPress, ...buttonProps } = useEmptyPlaceholderContext(props)
|
|
35
|
+
|
|
36
|
+
const buttonStyles = useCompositionStyles('button', styles)
|
|
37
|
+
|
|
38
|
+
const displayText = text || buttonText
|
|
39
|
+
|
|
40
|
+
if (!TypeGuards.isFunction(onPress)) return null
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Button
|
|
44
|
+
{...buttonProps}
|
|
45
|
+
onPress={onPress}
|
|
46
|
+
debugName={`emptyPlaceholderButton:${buttonText}`}
|
|
47
|
+
style={buttonStyles}
|
|
48
|
+
text={displayText}
|
|
49
|
+
/>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const EmptyPlaceholderLoading = () => {
|
|
54
|
+
const { styles, loading, LoadingComponent } = useEmptyPlaceholderContext()
|
|
55
|
+
|
|
56
|
+
const activityIndicatorStyles = useCompositionStyles('loader', styles)
|
|
57
|
+
|
|
58
|
+
if (!loading) return null
|
|
59
|
+
|
|
60
|
+
if (React.isValidElement(LoadingComponent)) {
|
|
61
|
+
return <>{LoadingComponent}</>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<View style={[styles.wrapper, styles['wrapper:loading']]} >
|
|
66
|
+
<ActivityIndicator style={activityIndicatorStyles} />
|
|
67
|
+
</View>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const EmptyPlaceholderContent = ({ children }: React.PropsWithChildren) => {
|
|
72
|
+
const { loading, styles } = useEmptyPlaceholderContext()
|
|
73
|
+
|
|
74
|
+
if (loading) {
|
|
75
|
+
return <EmptyPlaceholderLoading />
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (children) {
|
|
79
|
+
return <View style={styles.wrapper}>{children}</View>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<View style={styles.wrapper}>
|
|
84
|
+
<EmptyPlaceholderIllustration />
|
|
85
|
+
<EmptyPlaceholderInfo />
|
|
86
|
+
<EmptyPlaceholderButton />
|
|
87
|
+
</View>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
@@ -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>(args: Partial<T> = {}) => {
|
|
7
|
+
const ctx = useContext(EmptyPlaceholderContext)
|
|
8
|
+
|
|
9
|
+
if (!ctx) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
'useEmptyPlaceholderContext must be used within an EmptyPlaceholder component.'
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
...ctx,
|
|
17
|
+
...args,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,77 +1,32 @@
|
|
|
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,
|
|
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 { EmptyPlaceholderContent, EmptyPlaceholderButton, EmptyPlaceholderIllustration, EmptyPlaceholderInfo } from './Components'
|
|
11
8
|
|
|
12
9
|
export * from './styles'
|
|
13
10
|
export * from './types'
|
|
14
11
|
|
|
15
12
|
export const EmptyPlaceholder = (props: EmptyPlaceholderProps) => {
|
|
16
13
|
const {
|
|
17
|
-
|
|
18
|
-
title,
|
|
19
|
-
loading,
|
|
20
|
-
description,
|
|
21
|
-
image,
|
|
22
|
-
icon = null,
|
|
23
|
-
renderEmpty,
|
|
14
|
+
children,
|
|
24
15
|
style,
|
|
16
|
+
...contextValue
|
|
25
17
|
} = {
|
|
26
18
|
...EmptyPlaceholder.defaultProps,
|
|
27
19
|
...props,
|
|
28
20
|
}
|
|
29
21
|
|
|
30
|
-
const emptyText = title || (itemName && `No ${itemName} found.`) || 'No items.'
|
|
31
|
-
|
|
32
22
|
const styles = useStylesFor(EmptyPlaceholder.styleRegistryName, style)
|
|
33
23
|
|
|
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
24
|
return (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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>
|
|
25
|
+
<EmptyPlaceholderContext.Provider value={{ ...contextValue, styles }}>
|
|
26
|
+
<EmptyPlaceholderContent>
|
|
27
|
+
{children}
|
|
28
|
+
</EmptyPlaceholderContent>
|
|
29
|
+
</EmptyPlaceholderContext.Provider>
|
|
75
30
|
)
|
|
76
31
|
}
|
|
77
32
|
|
|
@@ -79,8 +34,12 @@ EmptyPlaceholder.styleRegistryName = 'EmptyPlaceholder'
|
|
|
79
34
|
EmptyPlaceholder.elements = ['wrapper', 'loader', 'title', 'description', 'image', 'icon']
|
|
80
35
|
EmptyPlaceholder.rootElement = 'wrapper'
|
|
81
36
|
|
|
37
|
+
EmptyPlaceholder.Info = EmptyPlaceholderInfo
|
|
38
|
+
EmptyPlaceholder.Button = EmptyPlaceholderButton
|
|
39
|
+
EmptyPlaceholder.Illustration = EmptyPlaceholderIllustration
|
|
40
|
+
|
|
82
41
|
EmptyPlaceholder.withVariantTypes = <S extends AnyRecord>(styles: S) => {
|
|
83
|
-
return EmptyPlaceholder as (props: StyledComponentProps<EmptyPlaceholderProps, typeof styles>) => IJSX
|
|
42
|
+
return EmptyPlaceholder as ((props: StyledComponentProps<EmptyPlaceholderProps, typeof styles>) => IJSX) & Pick<typeof EmptyPlaceholder, 'Button' | 'Illustration' | 'Info'>
|
|
84
43
|
}
|
|
85
44
|
|
|
86
45
|
EmptyPlaceholder.defaultProps = {} as Partial<EmptyPlaceholderProps>
|
|
@@ -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,30 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
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?:
|
|
15
|
-
description?:
|
|
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
|
-
|
|
16
|
+
LoadingComponent?: ReactElement
|
|
17
|
+
children?: ReactNode
|
|
18
|
+
onPress?: AnyFunction
|
|
19
|
+
buttonText?: string
|
|
21
20
|
}
|
|
21
|
+
|
|
22
|
+
export type EmptyPlaceholderInfoProps = Pick<EmptyPlaceholderProps, 'title' | 'description'>
|
|
23
|
+
|
|
24
|
+
export type EmptyPlaceholderIllustrationProps = Pick<EmptyPlaceholderProps, 'image' | 'icon'>
|
|
25
|
+
|
|
26
|
+
export type EmptyPlaceholderButtonProps = Pick<EmptyPlaceholderProps, 'onPress'> & Omit<ButtonProps, 'style' | 'debugName'>
|
|
27
|
+
|
|
28
|
+
export type EmptyPlaceholderCtxValue = Omit<EmptyPlaceholderProps, 'style' | 'children'> & {
|
|
29
|
+
styles: StyleRecord<EmptyPlaceholderComposition>
|
|
30
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
2
|
import { TypeGuards } from '@codeleap/types'
|
|
3
3
|
import { getRenderedComponent } from '@codeleap/utils'
|
|
4
4
|
import { ActionIcon, ActionIconProps } from '../ActionIcon'
|
|
@@ -7,6 +7,8 @@ import { useInputBaseStyles } from './styles'
|
|
|
7
7
|
import { InputBaseProps } from './types'
|
|
8
8
|
import { Text } from '../Text'
|
|
9
9
|
import RNAnimated, { FadeIn, FadeOut } from 'react-native-reanimated'
|
|
10
|
+
import { View as RNView } from 'react-native'
|
|
11
|
+
import { StyledComponentWithProps } from '@codeleap/styles'
|
|
10
12
|
|
|
11
13
|
export { useInputBase } from './useInputBase'
|
|
12
14
|
|
|
@@ -21,7 +23,7 @@ export const InputBaseDefaultOrder: InputBaseProps['order'] = [
|
|
|
21
23
|
'error',
|
|
22
24
|
]
|
|
23
25
|
|
|
24
|
-
export const InputBase = (props: InputBaseProps) => {
|
|
26
|
+
export const InputBase = forwardRef<RNView, InputBaseProps>((props: InputBaseProps, ref) => {
|
|
25
27
|
const {
|
|
26
28
|
children,
|
|
27
29
|
error = null,
|
|
@@ -40,7 +42,6 @@ export const InputBase = (props: InputBaseProps) => {
|
|
|
40
42
|
style,
|
|
41
43
|
labelAsRow,
|
|
42
44
|
hideErrorMessage,
|
|
43
|
-
ref,
|
|
44
45
|
...otherProps
|
|
45
46
|
} = {
|
|
46
47
|
...InputBase.defaultProps,
|
|
@@ -89,7 +90,7 @@ export const InputBase = (props: InputBaseProps) => {
|
|
|
89
90
|
</RNAnimated.View>
|
|
90
91
|
)}
|
|
91
92
|
</WrapperComponent>
|
|
92
|
-
}
|
|
93
|
+
}) as StyledComponentWithProps<InputBaseProps>
|
|
93
94
|
|
|
94
95
|
InputBase.elements = ['wrapper', 'innerWrapper', 'label', 'errorMessage', 'description', 'icon', 'leftIcon', 'rightIcon']
|
|
95
96
|
|