@janiscommerce/ui-native 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/{BaseButton → atoms/BaseButton}/index.js +1 -1
- package/dist/components/atoms/BaseCardList/index.d.ts +8 -0
- package/dist/components/atoms/BaseCardList/index.js +29 -0
- package/dist/components/{BaseToast → atoms/BaseToast}/index.js +1 -1
- package/dist/components/{CheckBox → atoms/CheckBox}/icon/CheckedIcon.js +1 -1
- package/dist/components/{CheckBox → atoms/CheckBox}/index.js +2 -2
- package/dist/components/{Icon → atoms/Icon}/index.js +2 -2
- package/dist/components/{Input → atoms/Input}/index.js +1 -1
- package/dist/components/{Input → atoms/Input}/utils/index.d.ts +1 -1
- package/dist/components/{Input → atoms/Input}/utils/index.js +1 -1
- package/dist/components/{Loading → atoms/Loading}/LoadingSvg/index.js +1 -1
- package/dist/components/{Loading → atoms/Loading}/index.js +2 -2
- package/dist/components/{RadioButton → atoms/RadioButton}/index.js +2 -2
- package/dist/components/{StatusChip → atoms/StatusChip}/index.js +2 -2
- package/dist/components/{Svg → atoms/Svg}/index.d.ts +1 -1
- package/dist/components/{Svg → atoms/Svg}/index.js +2 -2
- package/dist/components/{Svg → atoms/Svg}/svgs/EmptyIllustration/index.d.ts +1 -1
- package/dist/components/{Svg → atoms/Svg}/svgs/EmptyListIllustration/index.d.ts +1 -1
- package/dist/components/{Svg → atoms/Svg}/svgs/JanisLogo/index.d.ts +1 -1
- package/dist/components/{Svg → atoms/Svg}/svgs/JanisLogoColor/index.d.ts +1 -1
- package/dist/components/{Svg → atoms/Svg}/svgs/LoginIllustration/index.d.ts +1 -1
- package/dist/components/{Svg → atoms/Svg}/svgs/NoNotifications/index.d.ts +1 -1
- package/dist/components/{Text → atoms/Text}/index.js +1 -1
- package/dist/components/{Avatar → molecules/Avatar}/index.js +3 -3
- package/dist/components/{Button → molecules/Button}/index.d.ts +2 -2
- package/dist/components/{Button → molecules/Button}/index.js +11 -8
- package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/index.js +2 -2
- package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/styleConfigs/index.d.ts +2 -0
- package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/styleConfigs/index.js +4 -2
- package/dist/components/{Carousel → molecules/Carousel}/utils/index.d.ts +1 -1
- package/dist/components/molecules/ItemSelectionButton/index.d.ts +11 -0
- package/dist/components/molecules/ItemSelectionButton/index.js +66 -0
- package/dist/components/{LayoutWithBottomButtons → molecules/LayoutWithBottomButtons}/index.js +8 -7
- package/dist/components/{LayoutWithBottomButtons → molecules/LayoutWithBottomButtons}/utils/index.d.ts +18 -16
- package/dist/components/{LayoutWithBottomButtons → molecules/LayoutWithBottomButtons}/utils/index.js +21 -8
- package/dist/components/molecules/MainCardList/index.d.ts +14 -0
- package/dist/components/molecules/MainCardList/index.js +60 -0
- package/dist/components/{ProgressBar → molecules/ProgressBar}/index.js +2 -2
- package/dist/components/{ProgressBar → molecules/ProgressBar}/utils/index.js +1 -1
- package/dist/components/{Select → molecules/Select}/Components/Dropdown/index.d.ts +1 -1
- package/dist/components/{Select → molecules/Select}/Components/Modal/index.js +2 -2
- package/dist/components/{Select → molecules/Select}/Components/Options/index.d.ts +1 -1
- package/dist/components/{Select → molecules/Select}/Components/Options/index.js +1 -1
- package/dist/components/{Select → molecules/Select}/Components/SwitcherComponent/index.d.ts +1 -1
- package/dist/components/{Select → molecules/Select}/index.js +3 -3
- package/dist/components/{Select → molecules/Select}/utils/index.d.ts +1 -1
- package/dist/components/molecules/SwipeList/index.d.ts +11 -0
- package/dist/components/molecules/SwipeList/index.js +31 -0
- package/dist/components/{Tabs → molecules/Tabs}/index.js +5 -6
- package/dist/components/{Toast → molecules/Toast}/index.d.ts +1 -1
- package/dist/components/{Toast → molecules/Toast}/index.js +5 -5
- package/dist/components/{Toast → molecules/Toast}/utils/index.js +1 -1
- package/dist/components/{FullScreenMessage → organisms/FullScreenMessage}/index.js +4 -4
- package/dist/components/{LoadingFullScreen → organisms/LoadingFullScreen}/index.d.ts +1 -1
- package/dist/components/{LoadingFullScreen → organisms/LoadingFullScreen}/index.js +4 -4
- package/dist/components/organisms/SwipeItemSelectionList/index.d.ts +14 -0
- package/dist/components/organisms/SwipeItemSelectionList/index.js +37 -0
- package/dist/index.d.ts +28 -25
- package/dist/index.js +32 -25
- package/package.json +11 -9
- /package/dist/components/{BaseButton → atoms/BaseButton}/index.d.ts +0 -0
- /package/dist/components/{BaseToast → atoms/BaseToast}/index.d.ts +0 -0
- /package/dist/components/{BaseToast → atoms/BaseToast}/utils/index.d.ts +0 -0
- /package/dist/components/{BaseToast → atoms/BaseToast}/utils/index.js +0 -0
- /package/dist/components/{CheckBox → atoms/CheckBox}/icon/CheckedIcon.d.ts +0 -0
- /package/dist/components/{CheckBox → atoms/CheckBox}/index.d.ts +0 -0
- /package/dist/components/{Icon → atoms/Icon}/assets/fonts/selection.json +0 -0
- /package/dist/components/{Icon → atoms/Icon}/index.d.ts +0 -0
- /package/dist/components/{Image → atoms/Image}/index.d.ts +0 -0
- /package/dist/components/{Image → atoms/Image}/index.js +0 -0
- /package/dist/components/{Input → atoms/Input}/index.d.ts +0 -0
- /package/dist/components/{List → atoms/List}/index.d.ts +0 -0
- /package/dist/components/{List → atoms/List}/index.js +0 -0
- /package/dist/components/{Loading → atoms/Loading}/LoadingSvg/index.d.ts +0 -0
- /package/dist/components/{Loading → atoms/Loading}/index.d.ts +0 -0
- /package/dist/components/{RadioButton → atoms/RadioButton}/index.d.ts +0 -0
- /package/dist/components/{StatusChip → atoms/StatusChip}/index.d.ts +0 -0
- /package/dist/components/{Svg → atoms/Svg}/svgs/EmptyIllustration/index.js +0 -0
- /package/dist/components/{Svg → atoms/Svg}/svgs/EmptyListIllustration/index.js +0 -0
- /package/dist/components/{Svg → atoms/Svg}/svgs/JanisLogo/index.js +0 -0
- /package/dist/components/{Svg → atoms/Svg}/svgs/JanisLogoColor/index.js +0 -0
- /package/dist/components/{Svg → atoms/Svg}/svgs/LoginIllustration/index.js +0 -0
- /package/dist/components/{Svg → atoms/Svg}/svgs/NoNotifications/index.js +0 -0
- /package/dist/components/{SwipeUp → atoms/SwipeUp}/childComponents/index.d.ts +0 -0
- /package/dist/components/{SwipeUp → atoms/SwipeUp}/childComponents/index.js +0 -0
- /package/dist/components/{SwipeUp → atoms/SwipeUp}/index.d.ts +0 -0
- /package/dist/components/{SwipeUp → atoms/SwipeUp}/index.js +0 -0
- /package/dist/components/{Text → atoms/Text}/index.d.ts +0 -0
- /package/dist/components/{Avatar → molecules/Avatar}/index.d.ts +0 -0
- /package/dist/components/{Avatar → molecules/Avatar}/utils/formatPlaceholder/index.d.ts +0 -0
- /package/dist/components/{Avatar → molecules/Avatar}/utils/formatPlaceholder/index.js +0 -0
- /package/dist/components/{Button → molecules/Button}/types/index.d.ts +0 -0
- /package/dist/components/{Button → molecules/Button}/types/index.js +0 -0
- /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/index.d.ts +0 -0
- /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/constants/index.d.ts +0 -0
- /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/constants/index.js +0 -0
- /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/defaultValues/index.d.ts +0 -0
- /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/defaultValues/index.js +0 -0
- /package/dist/components/{Carousel → molecules/Carousel}/index.d.ts +0 -0
- /package/dist/components/{Carousel → molecules/Carousel}/index.js +0 -0
- /package/dist/components/{Carousel → molecules/Carousel}/utils/index.js +0 -0
- /package/dist/components/{LayoutWithBottomButtons → molecules/LayoutWithBottomButtons}/index.d.ts +0 -0
- /package/dist/components/{ProgressBar → molecules/ProgressBar}/index.d.ts +0 -0
- /package/dist/components/{ProgressBar → molecules/ProgressBar}/utils/index.d.ts +0 -0
- /package/dist/components/{Select → molecules/Select}/Components/Dropdown/index.js +0 -0
- /package/dist/components/{Select → molecules/Select}/Components/Modal/index.d.ts +0 -0
- /package/dist/components/{Select → molecules/Select}/Components/SwitcherComponent/index.js +0 -0
- /package/dist/components/{Select → molecules/Select}/index.d.ts +0 -0
- /package/dist/components/{Select → molecules/Select}/utils/index.js +0 -0
- /package/dist/components/{Tabs → molecules/Tabs}/index.d.ts +0 -0
- /package/dist/components/{Toast → molecules/Toast}/utils/index.d.ts +0 -0
- /package/dist/components/{FullScreenMessage → organisms/FullScreenMessage}/index.d.ts +0 -0
package/dist/components/{LayoutWithBottomButtons → molecules/LayoutWithBottomButtons}/utils/index.js
RENAMED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { moderateScale, scaledForDevice } from '
|
|
2
|
-
import { palette } from '
|
|
1
|
+
import { moderateScale, scaledForDevice } from '../../../../scale';
|
|
2
|
+
import { palette } from '../../../../theme/palette';
|
|
3
3
|
export const validVariants = {
|
|
4
4
|
squared: 'squared',
|
|
5
5
|
rounded: 'rounded',
|
|
6
|
+
roundedOnTop: 'roundedOnTop',
|
|
6
7
|
default: 'squared',
|
|
7
8
|
};
|
|
8
9
|
const buttonVariantStyles = (variant) => ({
|
|
9
|
-
...(variant === 'rounded' && {
|
|
10
|
+
...((variant === 'rounded' || variant === 'roundedOnTop') && {
|
|
10
11
|
borderRadius: scaledForDevice(48, moderateScale),
|
|
11
12
|
height: scaledForDevice(48, moderateScale),
|
|
12
13
|
}),
|
|
@@ -27,6 +28,9 @@ export const buttonWrapperVariantStyles = (variant) => ({
|
|
|
27
28
|
...(variant === 'rounded' && {
|
|
28
29
|
padding: scaledForDevice(16, moderateScale),
|
|
29
30
|
}),
|
|
31
|
+
...(variant === 'roundedOnTop' && {
|
|
32
|
+
padding: scaledForDevice(16, moderateScale),
|
|
33
|
+
}),
|
|
30
34
|
});
|
|
31
35
|
const validWidth = (width) => {
|
|
32
36
|
if (typeof width === 'number' && !Number.isNaN(width)) {
|
|
@@ -43,7 +47,7 @@ export const parseButtonsStyles = (buttons, variant) => {
|
|
|
43
47
|
}
|
|
44
48
|
const currentVariant = validVariants[variant] || validVariants.default;
|
|
45
49
|
const newButtons = [...buttons].slice(0, 3);
|
|
46
|
-
const areButtonsRounded = currentVariant === validVariants.rounded;
|
|
50
|
+
const areButtonsRounded = currentVariant === validVariants.rounded || currentVariant === validVariants.roundedOnTop;
|
|
47
51
|
if (newButtons.length === 3 && areButtonsRounded) {
|
|
48
52
|
const parsedButtons = newButtons.map((btn, idx) => {
|
|
49
53
|
const { backgroundColor, pressedColor } = getBackgroundColor(btn);
|
|
@@ -73,17 +77,26 @@ export const parseButtonsStyles = (buttons, variant) => {
|
|
|
73
77
|
return parsedButtons;
|
|
74
78
|
}
|
|
75
79
|
if (newButtons.length === 2 && areButtonsRounded) {
|
|
80
|
+
let isThereAnOnlyIconBtn = false;
|
|
76
81
|
const parsedButtons = newButtons.map((btn, idx) => {
|
|
77
82
|
const { backgroundColor, pressedColor } = getBackgroundColor(btn);
|
|
78
|
-
if (
|
|
83
|
+
if (!isThereAnOnlyIconBtn) {
|
|
84
|
+
isThereAnOnlyIconBtn = !!btn.icon && !btn.value;
|
|
85
|
+
}
|
|
86
|
+
if (idx === 0) {
|
|
79
87
|
return {
|
|
80
88
|
...btn,
|
|
81
89
|
pressedColor,
|
|
82
90
|
style: {
|
|
83
91
|
...btn?.style,
|
|
84
92
|
backgroundColor,
|
|
85
|
-
width:
|
|
86
|
-
|
|
93
|
+
width: isThereAnOnlyIconBtn
|
|
94
|
+
? 'auto'
|
|
95
|
+
: currentVariant === 'roundedOnTop'
|
|
96
|
+
? '100%'
|
|
97
|
+
: '58%',
|
|
98
|
+
paddingHorizontal: scaledForDevice(24, moderateScale),
|
|
99
|
+
marginBottom: scaledForDevice(currentVariant === 'roundedOnTop' ? 8 : 0, moderateScale),
|
|
87
100
|
...buttonVariantStyles(currentVariant),
|
|
88
101
|
},
|
|
89
102
|
};
|
|
@@ -94,7 +107,7 @@ export const parseButtonsStyles = (buttons, variant) => {
|
|
|
94
107
|
style: {
|
|
95
108
|
...btn?.style,
|
|
96
109
|
backgroundColor,
|
|
97
|
-
width:
|
|
110
|
+
width: currentVariant === 'roundedOnTop' ? '100%' : isThereAnOnlyIconBtn ? '75%' : '40%',
|
|
98
111
|
...buttonVariantStyles(currentVariant),
|
|
99
112
|
},
|
|
100
113
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
export interface Block {
|
|
4
|
+
component: ReactNode;
|
|
5
|
+
hasSeparator?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface MainCardListProps extends ViewProps {
|
|
8
|
+
displayId: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
blocks?: Block[];
|
|
11
|
+
isSelected?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const MainCardList: FC<MainCardListProps>;
|
|
14
|
+
export default MainCardList;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import BaseCardList from '../../atoms/BaseCardList';
|
|
2
|
+
import Text from '../../atoms/Text';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { StyleSheet, View } from 'react-native';
|
|
5
|
+
import { palette } from '../../../theme/palette';
|
|
6
|
+
const MainCardList = ({ displayId, children, blocks, isSelected, style, ...props }) => {
|
|
7
|
+
if (!displayId || typeof displayId !== 'string') {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const styles = StyleSheet.create({
|
|
11
|
+
innerContainer: {},
|
|
12
|
+
blockContainer: {
|
|
13
|
+
marginTop: 12,
|
|
14
|
+
paddingTop: 12,
|
|
15
|
+
},
|
|
16
|
+
blockWithSeparator: {
|
|
17
|
+
borderTopWidth: 1,
|
|
18
|
+
borderTopColor: palette.white.main,
|
|
19
|
+
},
|
|
20
|
+
displayIdText: {
|
|
21
|
+
fontFamily: 'Roboto',
|
|
22
|
+
fontWeight: '700',
|
|
23
|
+
fontSize: 18,
|
|
24
|
+
color: palette.black.main,
|
|
25
|
+
},
|
|
26
|
+
selectedDisplayIdText: {
|
|
27
|
+
color: palette.primary.main,
|
|
28
|
+
},
|
|
29
|
+
childrenContainer: {
|
|
30
|
+
marginTop: 4,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const renderBlocks = () => {
|
|
34
|
+
if (!blocks || !Array.isArray(blocks) || !blocks.length) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return blocks.map((block, idx) => {
|
|
38
|
+
const { component, hasSeparator = true } = block;
|
|
39
|
+
const activeBlockStyles = [
|
|
40
|
+
styles.blockContainer,
|
|
41
|
+
hasSeparator && styles.blockWithSeparator,
|
|
42
|
+
].filter(Boolean);
|
|
43
|
+
return (<View key={idx} style={activeBlockStyles}>
|
|
44
|
+
{component}
|
|
45
|
+
</View>);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const activeDisplayIdStyles = [
|
|
49
|
+
styles.displayIdText,
|
|
50
|
+
isSelected && styles.selectedDisplayIdText,
|
|
51
|
+
].filter(Boolean);
|
|
52
|
+
return (<BaseCardList isSelected={isSelected} style={style && style} {...props}>
|
|
53
|
+
<View>
|
|
54
|
+
<Text style={activeDisplayIdStyles}>{displayId}</Text>
|
|
55
|
+
{children && <View style={styles.childrenContainer}>{children}</View>}
|
|
56
|
+
<View>{renderBlocks()}</View>
|
|
57
|
+
</View>
|
|
58
|
+
</BaseCardList>);
|
|
59
|
+
};
|
|
60
|
+
export default MainCardList;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* istanbul ignore file */
|
|
2
2
|
import React, { useEffect, useRef } from 'react';
|
|
3
3
|
import { View, StyleSheet, Animated, Easing } from 'react-native';
|
|
4
|
-
import { palette } from '
|
|
4
|
+
import { palette } from '../../../theme/palette';
|
|
5
5
|
import { getBarColor, getPercentage } from './utils';
|
|
6
|
-
import { moderateScale, scaledForDevice } from '
|
|
6
|
+
import { moderateScale, scaledForDevice } from '../../../scale';
|
|
7
7
|
const ProgressBar = ({ value, totalValue, isAnimated = false, duration = 300, style, ...props }) => {
|
|
8
8
|
const { white } = palette;
|
|
9
9
|
const widthAnimation = useRef(new Animated.Value(0)).current;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Modal as ModalComponent, StyleSheet, View } from 'react-native';
|
|
3
|
-
import { base } from '
|
|
4
|
-
import { moderateScale, scaledForDevice } from '
|
|
3
|
+
import { base } from '../../../../../theme/palette';
|
|
4
|
+
import { moderateScale, scaledForDevice } from '../../../../../scale';
|
|
5
5
|
import Button from '../../../Button';
|
|
6
6
|
const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
|
|
7
7
|
const validBottom = scaledForDevice(20, moderateScale);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { CustomOptionComponent, DropdownMeasures, Option, VariantOptions } from '
|
|
2
|
+
import { CustomOptionComponent, DropdownMeasures, Option, VariantOptions } from '../../';
|
|
3
3
|
interface OptionsProps {
|
|
4
4
|
variantOptions: VariantOptions;
|
|
5
5
|
dropdownMeasures: DropdownMeasures;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, StyleSheet, TouchableOpacity, ScrollView, Text } from 'react-native';
|
|
3
|
-
import { base, black, grey, primary, white } from '
|
|
3
|
+
import { base, black, grey, primary, white } from '../../../../../theme/palette';
|
|
4
4
|
import SwitcherComponent from '../SwitcherComponent';
|
|
5
5
|
const Options = (props) => {
|
|
6
6
|
const { variantOptions, dropdownMeasures, isShowedOptions, setIsShowedOptions, filteredOptions, callbackOption, selectedOptions, noOptionsMessage, optionStyles, customOptionComponent = null, isMulti, modalAcceptText, } = props;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* istanbul ignore file */
|
|
2
2
|
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
3
|
import { Keyboard, Pressable, StyleSheet, Text, TextInput, View } from 'react-native';
|
|
4
|
-
import { black, grey, primary } from '
|
|
4
|
+
import { black, grey, primary } from '../../../theme/palette';
|
|
5
5
|
import { formatPlaceholderMulti } from './utils';
|
|
6
6
|
import Options from './Components/Options';
|
|
7
|
-
import Icon from '
|
|
8
|
-
import { horizontalScale, moderateScale, scaledForDevice } from '
|
|
7
|
+
import Icon from '../../atoms/Icon';
|
|
8
|
+
import { horizontalScale, moderateScale, scaledForDevice } from '../../../scale';
|
|
9
9
|
var KeyboardTypes;
|
|
10
10
|
(function (KeyboardTypes) {
|
|
11
11
|
KeyboardTypes["Default"] = "default";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Option } from '
|
|
1
|
+
import { Option } from '../';
|
|
2
2
|
export declare const formatPlaceholderMulti: (options: Option[], optionsText: string | null) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC, Ref } from 'react';
|
|
2
|
+
import { SwipeUpProps } from '../../atoms/SwipeUp';
|
|
3
|
+
import { ButtonProps } from '../Button';
|
|
4
|
+
import BottomSheet, { BottomSheetProps } from '@gorhom/bottom-sheet';
|
|
5
|
+
export interface SwipeListProps extends SwipeUpProps, BottomSheetProps {
|
|
6
|
+
ref?: Ref<BottomSheet>;
|
|
7
|
+
renderHeader?: () => void;
|
|
8
|
+
actions?: ButtonProps[];
|
|
9
|
+
}
|
|
10
|
+
declare const SwipeList: FC<SwipeListProps>;
|
|
11
|
+
export default SwipeList;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import SwipeUp from '../../atoms/SwipeUp';
|
|
3
|
+
import Button from '../Button';
|
|
4
|
+
import { SwipeUpScrollView } from '../../atoms/SwipeUp/childComponents';
|
|
5
|
+
import { StyleSheet, View } from 'react-native';
|
|
6
|
+
import { verticalScale } from '../../../scale';
|
|
7
|
+
const styles = StyleSheet.create({
|
|
8
|
+
footerContainer: {
|
|
9
|
+
padding: verticalScale(17),
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
const SwipeList = React.forwardRef(({ renderHeader = () => { }, actions = [], children, ...props }, ref) => {
|
|
13
|
+
if (!children) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const isRenderHeaderValid = typeof renderHeader === 'function';
|
|
17
|
+
const areThereValidActions = Array.isArray(actions) && actions.length > 0;
|
|
18
|
+
const renderActions = () => {
|
|
19
|
+
if (!areThereValidActions) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return (<View style={styles.footerContainer}>
|
|
23
|
+
{actions?.map((action, idx) => (<Button key={idx} {...action}/>))}
|
|
24
|
+
</View>);
|
|
25
|
+
};
|
|
26
|
+
return (<SwipeUp ref={ref} footerComponent={renderActions} {...props}>
|
|
27
|
+
{isRenderHeaderValid && renderHeader()}
|
|
28
|
+
<SwipeUpScrollView>{children}</SwipeUpScrollView>
|
|
29
|
+
</SwipeUp>);
|
|
30
|
+
});
|
|
31
|
+
export default SwipeList;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { StyleSheet, View, ScrollView, FlatList } from 'react-native';
|
|
4
|
-
import { moderateScale, scaledForDevice } from '
|
|
5
|
-
import { base, black, grey, primary } from '
|
|
6
|
-
import BaseButton from '
|
|
7
|
-
import Text from '
|
|
8
|
-
import {
|
|
9
|
-
import { isObject } from '../../utils';
|
|
4
|
+
import { moderateScale, scaledForDevice, viewportWidth } from '../../../scale';
|
|
5
|
+
import { base, black, grey, primary } from '../../../theme/palette';
|
|
6
|
+
import BaseButton from '../../atoms/BaseButton';
|
|
7
|
+
import Text from '../../atoms/Text';
|
|
8
|
+
import { isObject } from '../../../utils';
|
|
10
9
|
export const positions = {
|
|
11
10
|
top: 'top',
|
|
12
11
|
bottom: 'bottom',
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { StyleSheet } from 'react-native';
|
|
4
|
-
import { moderateScale, scaledForDevice } from '
|
|
4
|
+
import { moderateScale, scaledForDevice } from '../../../scale';
|
|
5
5
|
import { defaultIcon } from './utils';
|
|
6
|
-
import { base, black } from '
|
|
7
|
-
import BaseToast from '
|
|
6
|
+
import { base, black } from '../../../theme/palette';
|
|
7
|
+
import BaseToast from '../../atoms/BaseToast';
|
|
8
8
|
import ToastAction from 'react-native-toast-message';
|
|
9
|
-
import Text from '
|
|
10
|
-
import Icon from '
|
|
9
|
+
import Text from '../../atoms/Text';
|
|
10
|
+
import Icon from '../../atoms/Icon';
|
|
11
11
|
const Toast = ({ type, text1, text2, style, props }) => {
|
|
12
12
|
const validType = type && typeof type === 'string';
|
|
13
13
|
const validTitle = text1 && typeof text1 === 'string';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { Modal, StyleSheet, View } from 'react-native';
|
|
3
|
-
import { moderateScale, scaledForDevice } from '
|
|
4
|
-
import { base, primary } from '
|
|
5
|
-
import Icon from '
|
|
6
|
-
import Text from '
|
|
3
|
+
import { moderateScale, scaledForDevice } from '../../../scale';
|
|
4
|
+
import { base, primary } from '../../../theme/palette';
|
|
5
|
+
import Icon from '../../atoms/Icon';
|
|
6
|
+
import Text from '../../atoms/Text';
|
|
7
7
|
export var animationTypes;
|
|
8
8
|
(function (animationTypes) {
|
|
9
9
|
animationTypes["Slide"] = "slide";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ModalProps, ViewStyle } from 'react-native';
|
|
3
|
-
import { Names } from '
|
|
3
|
+
import { Names } from '../../../ts/interfaces/svgs';
|
|
4
4
|
interface ILoadingFullScreen extends ModalProps {
|
|
5
5
|
isLoading: boolean;
|
|
6
6
|
text?: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyleSheet, Modal, Text, View } from 'react-native';
|
|
3
|
-
import Loading from '
|
|
4
|
-
import Svg from '
|
|
5
|
-
import { grey, white } from '
|
|
6
|
-
import { moderateScale, horizontalScale, scaledForDevice } from '
|
|
3
|
+
import Loading from '../../atoms/Loading';
|
|
4
|
+
import Svg from '../../atoms/Svg';
|
|
5
|
+
import { grey, white } from '../../../theme/palette';
|
|
6
|
+
import { moderateScale, horizontalScale, scaledForDevice } from '../../../scale';
|
|
7
7
|
const validFontSize = scaledForDevice(16, moderateScale);
|
|
8
8
|
const validLineHeight = scaledForDevice(24, moderateScale);
|
|
9
9
|
const validMarginTop = scaledForDevice(25, moderateScale);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { Ref } from 'react';
|
|
2
|
+
import { SwipeListProps } from '../../molecules/SwipeList';
|
|
3
|
+
import BottomSheet from '@gorhom/bottom-sheet';
|
|
4
|
+
interface SwipeItemSelectionListProps extends Partial<SwipeListProps> {
|
|
5
|
+
ref?: Ref<BottomSheet>;
|
|
6
|
+
data: any[];
|
|
7
|
+
radioButton?: boolean;
|
|
8
|
+
multiselect?: boolean;
|
|
9
|
+
leftSelection?: boolean;
|
|
10
|
+
rightSelection?: boolean;
|
|
11
|
+
onSelection?: (id: string) => {};
|
|
12
|
+
}
|
|
13
|
+
declare const SwipeItemSelectionList: React.FC<SwipeItemSelectionListProps>;
|
|
14
|
+
export default SwipeItemSelectionList;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import SwipeList from '../../molecules/SwipeList';
|
|
3
|
+
import ItemSelectionButton from '../../molecules/ItemSelectionButton';
|
|
4
|
+
const SwipeItemSelectionList = React.forwardRef(({ data, radioButton = false, multiselect = false, leftSelection = false, rightSelection = false, onSelection = () => { }, ...props }, ref) => {
|
|
5
|
+
const [selectedElementId, setSelectedElementId] = useState('');
|
|
6
|
+
const [selectedElementsIds, setSelectedElementsIds] = useState([]);
|
|
7
|
+
if (!data || !data.length) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const checkIfElementIsSelected = (id, isElementSelected) => {
|
|
11
|
+
if (isElementSelected) {
|
|
12
|
+
return multiselect
|
|
13
|
+
? setSelectedElementsIds((prevState) => prevState.filter((includedId) => includedId !== id)
|
|
14
|
+
// eslint-disable-next-line no-mixed-spaces-and-tabs
|
|
15
|
+
)
|
|
16
|
+
: setSelectedElementId('');
|
|
17
|
+
}
|
|
18
|
+
return multiselect
|
|
19
|
+
? setSelectedElementsIds((prevState) => [...prevState, id])
|
|
20
|
+
: setSelectedElementId(id);
|
|
21
|
+
};
|
|
22
|
+
const renderItem = (element) => {
|
|
23
|
+
const { id, name } = element;
|
|
24
|
+
const isElementSelected = multiselect
|
|
25
|
+
? selectedElementsIds.includes(id)
|
|
26
|
+
: selectedElementId === id;
|
|
27
|
+
const onSelectElement = () => {
|
|
28
|
+
checkIfElementIsSelected(id, isElementSelected);
|
|
29
|
+
return onSelection(id);
|
|
30
|
+
};
|
|
31
|
+
return (<ItemSelectionButton radioButton={radioButton} leftSelection={leftSelection} rightSelection={rightSelection} selected={isElementSelected} onSelection={onSelectElement} name={name}/>);
|
|
32
|
+
};
|
|
33
|
+
return (<SwipeList ref={ref} {...props}>
|
|
34
|
+
{data.map((element) => renderItem(element))}
|
|
35
|
+
</SwipeList>);
|
|
36
|
+
});
|
|
37
|
+
export default SwipeItemSelectionList;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import Image from './components/Image';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import Carousel from './components/Carousel';
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import Button from './components/Button/index';
|
|
21
|
-
import FullScreenMessage from './components/FullScreenMessage';
|
|
22
|
-
import LayoutWithBottomButtons from './components/LayoutWithBottomButtons';
|
|
1
|
+
import BaseButton from './components/atoms/BaseButton';
|
|
2
|
+
import CheckBox from './components/atoms/CheckBox';
|
|
3
|
+
import Icon from './components/atoms/Icon';
|
|
4
|
+
import Image from './components/atoms/Image';
|
|
5
|
+
import Input from './components/atoms/Input';
|
|
6
|
+
import List from './components/atoms/List';
|
|
7
|
+
import Loading from './components/atoms/Loading';
|
|
8
|
+
import RadioButton from './components/atoms/RadioButton';
|
|
9
|
+
import StatusChip from './components/atoms/StatusChip';
|
|
10
|
+
import Svg from './components/atoms/Svg';
|
|
11
|
+
import SwipeUp from './components/atoms/SwipeUp';
|
|
12
|
+
import { SwipeUpFlatList, SwipeUpScrollView, SwipeUpView } from './components/atoms/SwipeUp/childComponents';
|
|
13
|
+
import Text from './components/atoms/Text';
|
|
14
|
+
import Avatar from './components/molecules/Avatar';
|
|
15
|
+
import Button from './components/molecules/Button';
|
|
16
|
+
import Carousel from './components/molecules/Carousel';
|
|
17
|
+
import LayoutWithBottomButtons from './components/molecules/LayoutWithBottomButtons';
|
|
18
|
+
import ProgressBar from './components/molecules/ProgressBar';
|
|
19
|
+
import Select from './components/molecules/Select';
|
|
23
20
|
import Toast from 'react-native-toast-message';
|
|
24
|
-
import { configToast } from './components/Toast/utils';
|
|
25
|
-
import
|
|
21
|
+
import { configToast } from './components/molecules/Toast/utils';
|
|
22
|
+
import SwipeList from './components/molecules/SwipeList';
|
|
23
|
+
import ItemSelectionButton from './components/molecules/ItemSelectionButton';
|
|
24
|
+
import MainCardList from './components/molecules/MainCardList';
|
|
25
|
+
import LoadingFullScreen from './components/organisms/LoadingFullScreen';
|
|
26
|
+
import FullScreenMessage from './components/organisms/FullScreenMessage';
|
|
27
|
+
import SwipeItemSelectionList from './components/organisms/SwipeItemSelectionList';
|
|
28
|
+
import { palette } from './theme/palette';
|
|
26
29
|
import * as getScale from './scale';
|
|
27
|
-
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, Toast, configToast,
|
|
30
|
+
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, Toast, configToast, SwipeList, ItemSelectionButton, SwipeItemSelectionList, MainCardList, };
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import CheckBox from './components/CheckBox';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import LayoutWithBottomButtons from './components/LayoutWithBottomButtons';
|
|
1
|
+
// Atoms
|
|
2
|
+
import BaseButton from './components/atoms/BaseButton';
|
|
3
|
+
import CheckBox from './components/atoms/CheckBox';
|
|
4
|
+
import Icon from './components/atoms/Icon';
|
|
5
|
+
import Image from './components/atoms/Image';
|
|
6
|
+
import Input from './components/atoms/Input';
|
|
7
|
+
import List from './components/atoms/List';
|
|
8
|
+
import Loading from './components/atoms/Loading';
|
|
9
|
+
import RadioButton from './components/atoms/RadioButton';
|
|
10
|
+
import StatusChip from './components/atoms/StatusChip';
|
|
11
|
+
import Svg from './components/atoms/Svg';
|
|
12
|
+
import SwipeUp from './components/atoms/SwipeUp';
|
|
13
|
+
import { SwipeUpFlatList, SwipeUpScrollView, SwipeUpView } from './components/atoms/SwipeUp/childComponents';
|
|
14
|
+
import Text from './components/atoms/Text';
|
|
15
|
+
// Molecules
|
|
16
|
+
import Avatar from './components/molecules/Avatar';
|
|
17
|
+
import Button from './components/molecules/Button';
|
|
18
|
+
import Carousel from './components/molecules/Carousel';
|
|
19
|
+
import LayoutWithBottomButtons from './components/molecules/LayoutWithBottomButtons';
|
|
20
|
+
import ProgressBar from './components/molecules/ProgressBar';
|
|
21
|
+
import Select from './components/molecules/Select';
|
|
23
22
|
import Toast from 'react-native-toast-message';
|
|
24
|
-
import { configToast } from './components/Toast/utils';
|
|
25
|
-
import
|
|
23
|
+
import { configToast } from './components/molecules/Toast/utils';
|
|
24
|
+
import SwipeList from './components/molecules/SwipeList';
|
|
25
|
+
import ItemSelectionButton from './components/molecules/ItemSelectionButton';
|
|
26
|
+
import MainCardList from './components/molecules/MainCardList';
|
|
27
|
+
// Organisms
|
|
28
|
+
import LoadingFullScreen from './components/organisms/LoadingFullScreen';
|
|
29
|
+
import FullScreenMessage from './components/organisms/FullScreenMessage';
|
|
30
|
+
import SwipeItemSelectionList from './components/organisms/SwipeItemSelectionList';
|
|
31
|
+
// Misc
|
|
32
|
+
import { palette } from './theme/palette';
|
|
26
33
|
import * as getScale from './scale';
|
|
27
|
-
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, Toast, configToast,
|
|
34
|
+
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, Toast, configToast, SwipeList, ItemSelectionButton, SwipeItemSelectionList, MainCardList, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@janiscommerce/ui-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "components library for Janis app",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"test": "jest",
|
|
17
17
|
"lint": "eslint .",
|
|
18
18
|
"prepare": "husky install",
|
|
19
|
-
"validate:code": "npm run lint -- --fix && tsc --noEmit && npm t",
|
|
19
|
+
"validate:code": "npm run lint -- --fix && tsc --project tsconfig.build.json --noEmit && npm t",
|
|
20
20
|
"test:commit": "jest --colors --bail --findRelatedTests",
|
|
21
21
|
"test:coverage": "tsc --noEmit && jest --collectCoverage --detectOpenHandles",
|
|
22
|
-
"build": "rm -rf dist && tsc && cp -r android ios dist",
|
|
22
|
+
"build": "rm -rf dist && tsc --project tsconfig.build.json && cp -r android ios dist && tsc-alias -p tsconfig.aliases.json",
|
|
23
23
|
"storybook-server": "react-native-storybook-server",
|
|
24
24
|
"storybook-watcher": "sb-rn-watcher --config-path .ondevice",
|
|
25
25
|
"update-stories": "sb-rn-get-stories --config-path .ondevice",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"react": ">=17.0.2",
|
|
47
47
|
"react-native": ">=0.67.5",
|
|
48
48
|
"react-native-gesture-handler": ">=2.9.0",
|
|
49
|
-
"react-native-
|
|
50
|
-
"react-native-
|
|
49
|
+
"react-native-reanimated": "2.17.0",
|
|
50
|
+
"react-native-toast-message": ">=1.6.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@babel/core": "^7.12.9",
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
"react-test-renderer": "17.0.2",
|
|
99
99
|
"setup-env": "^2.0.0",
|
|
100
100
|
"storybook": "^6.5.4",
|
|
101
|
+
"tsc-alias": "^1.8.10",
|
|
101
102
|
"typescript": "^5.1.6",
|
|
102
103
|
"webpack": "^5.52.0"
|
|
103
104
|
},
|
|
@@ -117,17 +118,18 @@
|
|
|
117
118
|
]
|
|
118
119
|
},
|
|
119
120
|
"dependencies": {
|
|
120
|
-
"@gorhom/bottom-sheet": "^4.
|
|
121
|
+
"@gorhom/bottom-sheet": "^4.6.3",
|
|
121
122
|
"@react-native-async-storage/async-storage": "^1.19.0",
|
|
122
123
|
"@react-native-community/datetimepicker": "^7.4.0",
|
|
123
124
|
"@react-native-community/slider": "^4.4.2",
|
|
124
125
|
"@storybook/cli": "^6.5.4",
|
|
125
|
-
"
|
|
126
|
-
"react-native-gesture-handler": "
|
|
126
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
127
|
+
"react-native-gesture-handler": ">=2.9.0",
|
|
128
|
+
"react-native-reanimated": "2.17.0",
|
|
127
129
|
"react-native-safe-area-context": "^4.6.4",
|
|
128
130
|
"react-native-svg": "12.1.1",
|
|
129
|
-
"react-native-vector-icons": "^9.2.0",
|
|
130
131
|
"react-native-toast-message": ">=1.6.0",
|
|
132
|
+
"react-native-vector-icons": "^9.2.0",
|
|
131
133
|
"react-native-web": "^0.15.0"
|
|
132
134
|
}
|
|
133
135
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|