@janiscommerce/ui-native 1.8.1 → 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.
Files changed (114) hide show
  1. package/dist/components/{BaseButton → atoms/BaseButton}/index.js +1 -1
  2. package/dist/components/atoms/BaseCardList/index.d.ts +8 -0
  3. package/dist/components/atoms/BaseCardList/index.js +29 -0
  4. package/dist/components/{BaseToast → atoms/BaseToast}/index.js +1 -1
  5. package/dist/components/{CheckBox → atoms/CheckBox}/icon/CheckedIcon.js +1 -1
  6. package/dist/components/{CheckBox → atoms/CheckBox}/index.js +2 -2
  7. package/dist/components/{Icon → atoms/Icon}/index.js +2 -2
  8. package/dist/components/{Input → atoms/Input}/index.js +1 -1
  9. package/dist/components/{Input → atoms/Input}/utils/index.d.ts +1 -1
  10. package/dist/components/{Input → atoms/Input}/utils/index.js +1 -1
  11. package/dist/components/{Loading → atoms/Loading}/LoadingSvg/index.js +1 -1
  12. package/dist/components/{Loading → atoms/Loading}/index.js +2 -2
  13. package/dist/components/{RadioButton → atoms/RadioButton}/index.js +2 -2
  14. package/dist/components/{StatusChip → atoms/StatusChip}/index.js +2 -2
  15. package/dist/components/{Svg → atoms/Svg}/index.d.ts +1 -1
  16. package/dist/components/{Svg → atoms/Svg}/index.js +2 -2
  17. package/dist/components/{Svg → atoms/Svg}/svgs/EmptyIllustration/index.d.ts +1 -1
  18. package/dist/components/{Svg → atoms/Svg}/svgs/EmptyListIllustration/index.d.ts +1 -1
  19. package/dist/components/{Svg → atoms/Svg}/svgs/JanisLogo/index.d.ts +1 -1
  20. package/dist/components/{Svg → atoms/Svg}/svgs/JanisLogoColor/index.d.ts +1 -1
  21. package/dist/components/{Svg → atoms/Svg}/svgs/LoginIllustration/index.d.ts +1 -1
  22. package/dist/components/{Svg → atoms/Svg}/svgs/NoNotifications/index.d.ts +1 -1
  23. package/dist/components/{Text → atoms/Text}/index.js +1 -1
  24. package/dist/components/{Avatar → molecules/Avatar}/index.js +3 -3
  25. package/dist/components/{Button → molecules/Button}/index.d.ts +2 -2
  26. package/dist/components/{Button → molecules/Button}/index.js +11 -8
  27. package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/index.js +2 -2
  28. package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/styleConfigs/index.d.ts +2 -0
  29. package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/styleConfigs/index.js +4 -2
  30. package/dist/components/{Carousel → molecules/Carousel}/utils/index.d.ts +1 -1
  31. package/dist/components/molecules/ItemSelectionButton/index.d.ts +11 -0
  32. package/dist/components/molecules/ItemSelectionButton/index.js +66 -0
  33. package/dist/components/{LayoutWithBottomButtons → molecules/LayoutWithBottomButtons}/index.js +8 -7
  34. package/dist/components/{LayoutWithBottomButtons → molecules/LayoutWithBottomButtons}/utils/index.d.ts +18 -16
  35. package/dist/components/{LayoutWithBottomButtons → molecules/LayoutWithBottomButtons}/utils/index.js +21 -8
  36. package/dist/components/molecules/MainCardList/index.d.ts +14 -0
  37. package/dist/components/molecules/MainCardList/index.js +60 -0
  38. package/dist/components/{ProgressBar → molecules/ProgressBar}/index.js +2 -2
  39. package/dist/components/{ProgressBar → molecules/ProgressBar}/utils/index.js +1 -1
  40. package/dist/components/{Select → molecules/Select}/Components/Dropdown/index.d.ts +1 -1
  41. package/dist/components/{Select → molecules/Select}/Components/Modal/index.js +2 -2
  42. package/dist/components/{Select → molecules/Select}/Components/Options/index.d.ts +1 -1
  43. package/dist/components/{Select → molecules/Select}/Components/Options/index.js +1 -1
  44. package/dist/components/{Select → molecules/Select}/Components/SwitcherComponent/index.d.ts +1 -1
  45. package/dist/components/{Select → molecules/Select}/index.js +3 -3
  46. package/dist/components/{Select → molecules/Select}/utils/index.d.ts +1 -1
  47. package/dist/components/molecules/SwipeList/index.d.ts +11 -0
  48. package/dist/components/molecules/SwipeList/index.js +31 -0
  49. package/dist/components/molecules/Tabs/index.d.ts +23 -0
  50. package/dist/components/molecules/Tabs/index.js +112 -0
  51. package/dist/components/{Toast → molecules/Toast}/index.d.ts +1 -1
  52. package/dist/components/{Toast → molecules/Toast}/index.js +5 -5
  53. package/dist/components/{Toast → molecules/Toast}/utils/index.js +1 -1
  54. package/dist/components/{FullScreenMessage → organisms/FullScreenMessage}/index.js +4 -4
  55. package/dist/components/{LoadingFullScreen → organisms/LoadingFullScreen}/index.d.ts +1 -1
  56. package/dist/components/{LoadingFullScreen → organisms/LoadingFullScreen}/index.js +4 -4
  57. package/dist/components/organisms/SwipeItemSelectionList/index.d.ts +14 -0
  58. package/dist/components/organisms/SwipeItemSelectionList/index.js +37 -0
  59. package/dist/index.d.ts +28 -24
  60. package/dist/index.js +32 -24
  61. package/dist/utils/index.d.ts +1 -0
  62. package/dist/utils/index.js +1 -0
  63. package/package.json +11 -9
  64. /package/dist/components/{BaseButton → atoms/BaseButton}/index.d.ts +0 -0
  65. /package/dist/components/{BaseToast → atoms/BaseToast}/index.d.ts +0 -0
  66. /package/dist/components/{BaseToast → atoms/BaseToast}/utils/index.d.ts +0 -0
  67. /package/dist/components/{BaseToast → atoms/BaseToast}/utils/index.js +0 -0
  68. /package/dist/components/{CheckBox → atoms/CheckBox}/icon/CheckedIcon.d.ts +0 -0
  69. /package/dist/components/{CheckBox → atoms/CheckBox}/index.d.ts +0 -0
  70. /package/dist/components/{Icon → atoms/Icon}/assets/fonts/selection.json +0 -0
  71. /package/dist/components/{Icon → atoms/Icon}/index.d.ts +0 -0
  72. /package/dist/components/{Image → atoms/Image}/index.d.ts +0 -0
  73. /package/dist/components/{Image → atoms/Image}/index.js +0 -0
  74. /package/dist/components/{Input → atoms/Input}/index.d.ts +0 -0
  75. /package/dist/components/{List → atoms/List}/index.d.ts +0 -0
  76. /package/dist/components/{List → atoms/List}/index.js +0 -0
  77. /package/dist/components/{Loading → atoms/Loading}/LoadingSvg/index.d.ts +0 -0
  78. /package/dist/components/{Loading → atoms/Loading}/index.d.ts +0 -0
  79. /package/dist/components/{RadioButton → atoms/RadioButton}/index.d.ts +0 -0
  80. /package/dist/components/{StatusChip → atoms/StatusChip}/index.d.ts +0 -0
  81. /package/dist/components/{Svg → atoms/Svg}/svgs/EmptyIllustration/index.js +0 -0
  82. /package/dist/components/{Svg → atoms/Svg}/svgs/EmptyListIllustration/index.js +0 -0
  83. /package/dist/components/{Svg → atoms/Svg}/svgs/JanisLogo/index.js +0 -0
  84. /package/dist/components/{Svg → atoms/Svg}/svgs/JanisLogoColor/index.js +0 -0
  85. /package/dist/components/{Svg → atoms/Svg}/svgs/LoginIllustration/index.js +0 -0
  86. /package/dist/components/{Svg → atoms/Svg}/svgs/NoNotifications/index.js +0 -0
  87. /package/dist/components/{SwipeUp → atoms/SwipeUp}/childComponents/index.d.ts +0 -0
  88. /package/dist/components/{SwipeUp → atoms/SwipeUp}/childComponents/index.js +0 -0
  89. /package/dist/components/{SwipeUp → atoms/SwipeUp}/index.d.ts +0 -0
  90. /package/dist/components/{SwipeUp → atoms/SwipeUp}/index.js +0 -0
  91. /package/dist/components/{Text → atoms/Text}/index.d.ts +0 -0
  92. /package/dist/components/{Avatar → molecules/Avatar}/index.d.ts +0 -0
  93. /package/dist/components/{Avatar → molecules/Avatar}/utils/formatPlaceholder/index.d.ts +0 -0
  94. /package/dist/components/{Avatar → molecules/Avatar}/utils/formatPlaceholder/index.js +0 -0
  95. /package/dist/components/{Button → molecules/Button}/types/index.d.ts +0 -0
  96. /package/dist/components/{Button → molecules/Button}/types/index.js +0 -0
  97. /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/index.d.ts +0 -0
  98. /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/constants/index.d.ts +0 -0
  99. /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/constants/index.js +0 -0
  100. /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/defaultValues/index.d.ts +0 -0
  101. /package/dist/components/{Button → molecules/Button}/utils/getButtonStyles/utils/defaultValues/index.js +0 -0
  102. /package/dist/components/{Carousel → molecules/Carousel}/index.d.ts +0 -0
  103. /package/dist/components/{Carousel → molecules/Carousel}/index.js +0 -0
  104. /package/dist/components/{Carousel → molecules/Carousel}/utils/index.js +0 -0
  105. /package/dist/components/{LayoutWithBottomButtons → molecules/LayoutWithBottomButtons}/index.d.ts +0 -0
  106. /package/dist/components/{ProgressBar → molecules/ProgressBar}/index.d.ts +0 -0
  107. /package/dist/components/{ProgressBar → molecules/ProgressBar}/utils/index.d.ts +0 -0
  108. /package/dist/components/{Select → molecules/Select}/Components/Dropdown/index.js +0 -0
  109. /package/dist/components/{Select → molecules/Select}/Components/Modal/index.d.ts +0 -0
  110. /package/dist/components/{Select → molecules/Select}/Components/SwitcherComponent/index.js +0 -0
  111. /package/dist/components/{Select → molecules/Select}/index.d.ts +0 -0
  112. /package/dist/components/{Select → molecules/Select}/utils/index.js +0 -0
  113. /package/dist/components/{Toast → molecules/Toast}/utils/index.d.ts +0 -0
  114. /package/dist/components/{FullScreenMessage → organisms/FullScreenMessage}/index.d.ts +0 -0
@@ -1,12 +1,13 @@
1
- import { moderateScale, scaledForDevice } from '../../../scale';
2
- import { palette } from '../../../theme/palette';
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 (idx === 0 && btn.width === '100%') {
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: btn.width,
86
- marginBottom: scaledForDevice(10, moderateScale),
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: validWidth(btn.width) ?? '49%',
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 '../../theme/palette';
4
+ import { palette } from '../../../theme/palette';
5
5
  import { getBarColor, getPercentage } from './utils';
6
- import { moderateScale, scaledForDevice } from '../../scale';
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,4 +1,4 @@
1
- import { palette } from '../../../theme/palette';
1
+ import { palette } from '../../../../theme/palette';
2
2
  const THRESHOLD = {
3
3
  warning: 25,
4
4
  alert: 50,
@@ -1,5 +1,5 @@
1
1
  import React, { FC } from 'react';
2
- import { DropdownMeasures } from '../..';
2
+ import { DropdownMeasures } from '../../';
3
3
  export interface DropdownProps {
4
4
  show: boolean;
5
5
  setShow: (isShowed: boolean) => void;
@@ -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 '../../../../theme/palette';
4
- import { moderateScale, scaledForDevice } from '../../../../scale';
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 '../../../../theme/palette';
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,5 +1,5 @@
1
1
  import React, { FC } from 'react';
2
- import { DropdownMeasures, VariantOptions } from '../..';
2
+ import { DropdownMeasures, VariantOptions } from '../../';
3
3
  interface SwitcherProps {
4
4
  show: boolean;
5
5
  isMulti: boolean;
@@ -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 '../../theme/palette';
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 '../Icon';
8
- import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
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;
@@ -0,0 +1,23 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { ViewStyle } from 'react-native';
3
+ interface Scene {
4
+ title: string;
5
+ scene: ReactNode;
6
+ disabled?: boolean;
7
+ }
8
+ export declare const positions: {
9
+ top: string;
10
+ bottom: string;
11
+ };
12
+ export type positionsType = typeof positions;
13
+ export type keyPosition = keyof positionsType;
14
+ interface TabsProps {
15
+ scenes: Scene[];
16
+ initialTab?: number | null;
17
+ position?: keyPosition;
18
+ onPressTabCb?: (activeTab: number) => void;
19
+ scrollContentStyle?: ViewStyle;
20
+ style?: ViewStyle;
21
+ }
22
+ declare const Tabs: FC<TabsProps>;
23
+ export default Tabs;
@@ -0,0 +1,112 @@
1
+ /* eslint-disable react-hooks/rules-of-hooks */
2
+ import React, { useEffect, useRef, useState } from 'react';
3
+ import { StyleSheet, View, ScrollView, FlatList } from 'react-native';
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';
9
+ export const positions = {
10
+ top: 'top',
11
+ bottom: 'bottom',
12
+ };
13
+ const Tabs = ({ scenes, initialTab = null, position = positions.top, onPressTabCb = () => { }, scrollContentStyle = {}, style = {}, ...props }) => {
14
+ if (!scenes || !Array.isArray(scenes) || !scenes.length) {
15
+ return null;
16
+ }
17
+ const [activeTab, setActiveTab] = useState(0);
18
+ const scrollViewRef = useRef(null);
19
+ const validScenes = scenes.filter(({ scene, title }) => scene && title);
20
+ const areScenesValid = !!validScenes && Array.isArray(validScenes) && !!validScenes.length;
21
+ const isValidCurrentScene = !!validScenes[activeTab] &&
22
+ isObject(validScenes[activeTab]) &&
23
+ !!Object.keys(validScenes[activeTab]).length;
24
+ const contentDirection = position === positions.bottom ? 'column-reverse' : 'column';
25
+ const quantityScenes = scenes?.length;
26
+ const isScrollViewTab = quantityScenes && quantityScenes > 3;
27
+ const calculateTabs = isScrollViewTab ? { width: viewportWidth / 3 } : { flex: 1 };
28
+ const contentMargin = position === positions.bottom ? { marginBottom: 45 } : { marginTop: 45 };
29
+ const styles = StyleSheet.create({
30
+ wrapper: {
31
+ flex: 1,
32
+ position: 'relative',
33
+ flexDirection: contentDirection,
34
+ },
35
+ wrapperTab: {
36
+ position: 'absolute',
37
+ width: '100%',
38
+ height: scaledForDevice(48, moderateScale),
39
+ flexDirection: 'row',
40
+ backgroundColor: base.white,
41
+ zIndex: 1,
42
+ elevation: scaledForDevice(5, moderateScale),
43
+ },
44
+ tabButton: {
45
+ ...calculateTabs,
46
+ justifyContent: 'center',
47
+ alignItems: 'center',
48
+ borderBottomWidth: scaledForDevice(2, moderateScale),
49
+ },
50
+ title: {
51
+ textTransform: 'uppercase',
52
+ fontFamily: 'Roboto-Medium',
53
+ },
54
+ content: {
55
+ ...contentMargin,
56
+ },
57
+ });
58
+ useEffect(() => {
59
+ if (typeof initialTab === 'number') {
60
+ setActiveTab(initialTab);
61
+ }
62
+ }, [initialTab]);
63
+ useEffect(() => {
64
+ if (isScrollViewTab) {
65
+ scrollViewRef?.current?.scrollToIndex({
66
+ index: activeTab,
67
+ animated: true,
68
+ });
69
+ }
70
+ }, [activeTab, isScrollViewTab]);
71
+ const getItemLayout = (data, index) => ({
72
+ length: viewportWidth / 3,
73
+ offset: (viewportWidth / 3) * index,
74
+ index,
75
+ });
76
+ const handleScrollToIndexFailed = (info) => {
77
+ setTimeout(() => {
78
+ scrollViewRef?.current?.scrollToIndex({
79
+ index: info.index,
80
+ animated: true,
81
+ });
82
+ }, 300);
83
+ };
84
+ const TitleTab = ({ title, disabled, index }) => {
85
+ const borderBottomColor = index === activeTab ? primary.main : base.white;
86
+ const inactiveText = disabled ? grey[400] : black.main;
87
+ const textColor = index === activeTab ? primary.main : inactiveText;
88
+ const handleOnPress = (idx) => {
89
+ setActiveTab(idx);
90
+ return onPressTabCb(idx);
91
+ };
92
+ return (<BaseButton key={title + index} style={{ ...styles.tabButton, borderBottomColor }} disabled={disabled} onPress={() => handleOnPress(index)}>
93
+ <Text style={{ ...styles.title, color: textColor }} selectable={false} numberOfLines={1}>
94
+ {title}
95
+ </Text>
96
+ </BaseButton>);
97
+ };
98
+ const renderItem = ({ item, index }) => (<TitleTab title={item.title} disabled={item.disabled} index={index}/>);
99
+ return (<View style={[styles.wrapper, style]} {...props}>
100
+ {!isScrollViewTab && (<View style={styles.wrapperTab}>
101
+ {areScenesValid &&
102
+ validScenes.map((scene, idx) => (<TitleTab key={scene.title} title={scene.title} disabled={scene.disabled} index={idx}/>))}
103
+ </View>)}
104
+
105
+ {isScrollViewTab && (<FlatList style={styles.wrapperTab} data={scenes} renderItem={renderItem} ref={scrollViewRef} horizontal pagingEnabled={true} showsHorizontalScrollIndicator={false} keyExtractor={(item, index) => item.title + index} getItemLayout={getItemLayout} onScrollToIndexFailed={handleScrollToIndexFailed} initialNumToRender={quantityScenes}/>)}
106
+
107
+ {isValidCurrentScene && (<ScrollView contentContainerStyle={scrollContentStyle} style={styles.content}>
108
+ {validScenes[activeTab].scene}
109
+ </ScrollView>)}
110
+ </View>);
111
+ };
112
+ export default Tabs;
@@ -1,6 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { TextStyle } from 'react-native';
3
- import { BaseToastProps } from '../BaseToast';
3
+ import { BaseToastProps } from '../../atoms/BaseToast';
4
4
  export interface ToastProps extends BaseToastProps {
5
5
  props?: {
6
6
  showIcon?: boolean;
@@ -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 '../../scale';
4
+ import { moderateScale, scaledForDevice } from '../../../scale';
5
5
  import { defaultIcon } from './utils';
6
- import { base, black } from '../../theme/palette';
7
- import BaseToast from '../BaseToast';
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 '../Text';
10
- import Icon from '../Icon';
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,5 +1,5 @@
1
1
  import React from 'react';
2
- import Toast from '..';
2
+ import Toast from '../';
3
3
  export const configToast = {
4
4
  success: (props) => <Toast {...props}/>,
5
5
  notice: (props) => <Toast {...props}/>,
@@ -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 '../../scale';
4
- import { base, primary } from '../../theme/palette';
5
- import Icon from '../Icon';
6
- import Text from '../Text';
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 '../../ts/interfaces/svgs';
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 '../Loading';
4
- import Svg from '../Svg';
5
- import { grey, white } from '../../theme/palette';
6
- import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
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,26 +1,30 @@
1
- import Text from './components/Text';
2
- import Avatar from './components/Avatar';
3
- import CheckBox from './components/CheckBox';
4
- import Image from './components/Image';
5
- import Svg from './components/Svg';
6
- import Loading from './components/Loading';
7
- import StatusChip from './components/StatusChip';
8
- import Input from './components/Input';
9
- import LoadingFullScreen from './components/LoadingFullScreen';
10
- import Icon from './components/Icon';
11
- import Select from './components/Select';
12
- import { palette } from './theme/palette';
13
- import RadioButton from './components/RadioButton';
14
- import SwipeUp from './components/SwipeUp';
15
- import { SwipeUpFlatList, SwipeUpScrollView, SwipeUpView } from './components/SwipeUp/childComponents';
16
- import Carousel from './components/Carousel';
17
- import ProgressBar from './components/ProgressBar';
18
- import List from './components/List';
19
- import BaseButton from './components/BaseButton';
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';
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';
25
29
  import * as getScale from './scale';
26
- 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, };