@tecsinapse/react-core 1.17.3 → 1.19.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/CHANGELOG.md +39 -0
- package/dist/components/atoms/Avatar/Avatar.js.map +1 -1
- package/dist/components/atoms/Avatar/helpers.js.map +1 -1
- package/dist/components/atoms/Avatar/index.js.map +1 -1
- package/dist/components/atoms/Avatar/styled.js.map +1 -1
- package/dist/components/atoms/Badge/Badge.js.map +1 -1
- package/dist/components/atoms/Badge/index.js.map +1 -1
- package/dist/components/atoms/Badge/styled.js.map +1 -1
- package/dist/components/atoms/BoxContent/BoxContent.js.map +1 -1
- package/dist/components/atoms/BoxContent/index.js.map +1 -1
- package/dist/components/atoms/BoxContent/styled.js +1 -1
- package/dist/components/atoms/BoxContent/styled.js.map +1 -1
- package/dist/components/atoms/Button/Button.js +1 -1
- package/dist/components/atoms/Button/Button.js.map +1 -1
- package/dist/components/atoms/Button/States/BaseState.js.map +1 -1
- package/dist/components/atoms/Button/States/Error.js +1 -1
- package/dist/components/atoms/Button/States/Error.js.map +1 -1
- package/dist/components/atoms/Button/States/Loading.js.map +1 -1
- package/dist/components/atoms/Button/States/Success.js +1 -1
- package/dist/components/atoms/Button/States/Success.js.map +1 -1
- package/dist/components/atoms/Button/States/index.js.map +1 -1
- package/dist/components/atoms/Button/States/styled.js +1 -1
- package/dist/components/atoms/Button/States/styled.js.map +1 -1
- package/dist/components/atoms/Button/index.js +1 -1
- package/dist/components/atoms/Button/index.js.map +1 -1
- package/dist/components/atoms/Button/styled.js.map +1 -1
- package/dist/components/atoms/Card/Card.js +1 -1
- package/dist/components/atoms/Card/Card.js.map +1 -1
- package/dist/components/atoms/Card/Footer/Footer.js.map +1 -1
- package/dist/components/atoms/Card/Footer/index.js.map +1 -1
- package/dist/components/atoms/Card/Header/Header.js.map +1 -1
- package/dist/components/atoms/Card/Header/index.js.map +1 -1
- package/dist/components/atoms/Card/index.js.map +1 -1
- package/dist/components/atoms/Card/styled.js.map +1 -1
- package/dist/components/atoms/Checkbox/Checkbox.js +1 -1
- package/dist/components/atoms/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/components/atoms/Checkbox/styled.js +1 -1
- package/dist/components/atoms/Checkbox/styled.js.map +1 -1
- package/dist/components/atoms/Divider/Divider.js.map +1 -1
- package/dist/components/atoms/Divider/index.js.map +1 -1
- package/dist/components/atoms/Divider/styled.js.map +1 -1
- package/dist/components/atoms/GroupButton/GroupButton.d.ts +1 -1
- package/dist/components/atoms/GroupButton/GroupButton.js +1 -1
- package/dist/components/atoms/GroupButton/GroupButton.js.map +1 -1
- package/dist/components/atoms/GroupButton/GroupButtonOption.js.map +1 -1
- package/dist/components/atoms/GroupButton/index.js +1 -1
- package/dist/components/atoms/GroupButton/index.js.map +1 -1
- package/dist/components/atoms/GroupButton/styled.js +1 -1
- package/dist/components/atoms/GroupButton/styled.js.map +1 -1
- package/dist/components/atoms/Icon/Icon.js +1 -1
- package/dist/components/atoms/Icon/Icon.js.map +1 -1
- package/dist/components/atoms/Icon/helpers.js +1 -1
- package/dist/components/atoms/Icon/helpers.js.map +1 -1
- package/dist/components/atoms/Icon/index.js.map +1 -1
- package/dist/components/atoms/Input/Hint.js.map +1 -1
- package/dist/components/atoms/Input/InputContainer/InputContainer.d.ts +1 -1
- package/dist/components/atoms/Input/InputContainer/InputContainer.js +1 -1
- package/dist/components/atoms/Input/InputContainer/InputContainer.js.map +1 -1
- package/dist/components/atoms/Input/InputElement/InputElement.d.ts +3 -4
- package/dist/components/atoms/Input/InputElement/InputElement.js +1 -1
- package/dist/components/atoms/Input/InputElement/InputElement.js.map +1 -1
- package/dist/components/atoms/Input/InputMaskElement/InputMaskElement.d.ts +3 -4
- package/dist/components/atoms/Input/InputMaskElement/InputMaskElement.js +1 -1
- package/dist/components/atoms/Input/InputMaskElement/InputMaskElement.js.map +1 -1
- package/dist/components/atoms/Input/PressableInputContainer/PressableInputContainer.js +1 -1
- package/dist/components/atoms/Input/PressableInputContainer/PressableInputContainer.js.map +1 -1
- package/dist/components/atoms/Input/PressableInputContainer/index.js.map +1 -1
- package/dist/components/atoms/Input/PressableInputContainer/styled.js.map +1 -1
- package/dist/components/atoms/Input/hooks/useInputFocus.js.map +1 -1
- package/dist/components/atoms/Input/hooks/useNumberMask.js.map +1 -1
- package/dist/components/atoms/Input/hooks/useStringMask.js +1 -1
- package/dist/components/atoms/Input/hooks/useStringMask.js.map +1 -1
- package/dist/components/atoms/Input/index.js +1 -1
- package/dist/components/atoms/Input/index.js.map +1 -1
- package/dist/components/atoms/Input/styled.js +1 -1
- package/dist/components/atoms/Input/styled.js.map +1 -1
- package/dist/components/atoms/Paper/Paper.js +1 -1
- package/dist/components/atoms/Paper/Paper.js.map +1 -1
- package/dist/components/atoms/Paper/index.js.map +1 -1
- package/dist/components/atoms/Paper/styled.js.map +1 -1
- package/dist/components/atoms/PressableSurface/PressableSurface.js +1 -1
- package/dist/components/atoms/PressableSurface/PressableSurface.js.map +1 -1
- package/dist/components/atoms/PressableSurface/index.js.map +1 -1
- package/dist/components/atoms/ProgressBar/ProgressBar.d.ts +1 -1
- package/dist/components/atoms/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/atoms/ProgressBar/index.js.map +1 -1
- package/dist/components/atoms/ProgressBar/styled.js +1 -1
- package/dist/components/atoms/ProgressBar/styled.js.map +1 -1
- package/dist/components/atoms/RadioButton/RadioButton.js +1 -1
- package/dist/components/atoms/RadioButton/RadioButton.js.map +1 -1
- package/dist/components/atoms/RadioButton/index.js.map +1 -1
- package/dist/components/atoms/RadioButton/styled.js +1 -1
- package/dist/components/atoms/RadioButton/styled.js.map +1 -1
- package/dist/components/atoms/Switch/Switch.d.ts +1 -1
- package/dist/components/atoms/Switch/Switch.js +1 -1
- package/dist/components/atoms/Switch/Switch.js.map +1 -1
- package/dist/components/atoms/Switch/animation.js.map +1 -1
- package/dist/components/atoms/Switch/index.js.map +1 -1
- package/dist/components/atoms/Switch/styled.d.ts +2 -14
- package/dist/components/atoms/Switch/styled.js +1 -1
- package/dist/components/atoms/Switch/styled.js.map +1 -1
- package/dist/components/atoms/Tag/Tag.js +1 -1
- package/dist/components/atoms/Tag/Tag.js.map +1 -1
- package/dist/components/atoms/Tag/index.js.map +1 -1
- package/dist/components/atoms/Tag/styled.js +1 -1
- package/dist/components/atoms/Tag/styled.js.map +1 -1
- package/dist/components/atoms/Text/Text.js +1 -1
- package/dist/components/atoms/Text/Text.js.map +1 -1
- package/dist/components/atoms/Text/functions.js.map +1 -1
- package/dist/components/atoms/Text/index.js.map +1 -1
- package/dist/components/atoms/Text/styled.js +1 -1
- package/dist/components/atoms/Text/styled.js.map +1 -1
- package/dist/components/atoms/shared/PaperAndCard.js.map +1 -1
- package/dist/components/molecules/Calendar/Calendar.js.map +1 -1
- package/dist/components/molecules/Calendar/components/MonthWeek.js.map +1 -1
- package/dist/components/molecules/Calendar/components/Weekdays.js.map +1 -1
- package/dist/components/molecules/Calendar/components/index.js +1 -1
- package/dist/components/molecules/Calendar/components/index.js.map +1 -1
- package/dist/components/molecules/Calendar/index.d.ts +1 -1
- package/dist/components/molecules/Calendar/index.js +1 -1
- package/dist/components/molecules/Calendar/index.js.map +1 -1
- package/dist/components/molecules/Calendar/styled.js +1 -1
- package/dist/components/molecules/Calendar/styled.js.map +1 -1
- package/dist/components/molecules/DatePicker/DatePicker.js +1 -1
- package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/molecules/DatePicker/index.js.map +1 -1
- package/dist/components/molecules/DatePicker/styled.js +1 -1
- package/dist/components/molecules/DatePicker/styled.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/DateTimePicker.js +1 -1
- package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/index.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/styled.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js +2 -1
- package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/Selector.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/index.js +1 -1
- package/dist/components/molecules/DateTimeSelector/index.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/styled.js +1 -1
- package/dist/components/molecules/DateTimeSelector/styled.js.map +1 -1
- package/dist/components/molecules/Grid/functions.d.ts +3 -0
- package/dist/components/molecules/Grid/functions.js +21 -0
- package/dist/components/molecules/Grid/functions.js.map +1 -0
- package/dist/components/molecules/Grid/index.d.ts +42 -2
- package/dist/components/molecules/Grid/index.js +4 -13
- package/dist/components/molecules/Grid/index.js.map +1 -1
- package/dist/components/molecules/HintInputContainer/HintInputContainer.js +1 -1
- package/dist/components/molecules/HintInputContainer/HintInputContainer.js.map +1 -1
- package/dist/components/molecules/HintInputContainer/index.js.map +1 -1
- package/dist/components/molecules/HintInputContainer/styled.js.map +1 -1
- package/dist/components/molecules/IconTextButton/IconComponent.d.ts +9 -0
- package/dist/components/molecules/IconTextButton/IconComponent.js +28 -0
- package/dist/components/molecules/IconTextButton/IconComponent.js.map +1 -0
- package/dist/components/molecules/IconTextButton/IconTextButton.d.ts +8 -0
- package/dist/components/molecules/IconTextButton/IconTextButton.js +4 -0
- package/dist/components/molecules/IconTextButton/IconTextButton.js.map +1 -0
- package/dist/components/molecules/IconTextButton/index.d.ts +2 -0
- package/dist/components/molecules/IconTextButton/index.js +16 -0
- package/dist/components/molecules/IconTextButton/index.js.map +1 -0
- package/dist/components/molecules/IconTextButton/styled.d.ts +4 -0
- package/dist/components/molecules/{Grid/Item/index.js → IconTextButton/styled.js} +19 -5
- package/dist/components/molecules/IconTextButton/styled.js.map +1 -0
- package/dist/components/molecules/InputPassword/InputPasswordIcon.js +1 -1
- package/dist/components/molecules/InputPassword/InputPasswordIcon.js.map +1 -1
- package/dist/components/molecules/InputPassword/index.js.map +1 -1
- package/dist/components/molecules/InputPassword/styled.js.map +1 -1
- package/dist/components/molecules/LabeledSwitch/LabeledSwitch.d.ts +7 -0
- package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js +4 -0
- package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js.map +1 -0
- package/dist/components/molecules/LabeledSwitch/index.d.ts +1 -0
- package/dist/components/molecules/LabeledSwitch/index.js +10 -0
- package/dist/components/molecules/LabeledSwitch/index.js.map +1 -0
- package/dist/components/molecules/Snackbar/Snackbar.js +1 -1
- package/dist/components/molecules/Snackbar/Snackbar.js.map +1 -1
- package/dist/components/molecules/Snackbar/index.js.map +1 -1
- package/dist/components/molecules/Snackbar/styled.js +1 -1
- package/dist/components/molecules/Snackbar/styled.js.map +1 -1
- package/dist/components/molecules/TextArea/TextArea.d.ts +1 -1
- package/dist/components/molecules/TextArea/TextArea.js.map +1 -1
- package/dist/components/molecules/TextArea/index.js +1 -1
- package/dist/components/molecules/TextArea/index.js.map +1 -1
- package/dist/components/molecules/TextArea/styled.d.ts +2 -14
- package/dist/components/molecules/TextArea/styled.js.map +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useDebouncedState.js +1 -1
- package/dist/hooks/useDebouncedState.js.map +1 -1
- package/dist/hooks/useTheme.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +58 -30
- package/dist/index.js.map +1 -1
- package/dist/styles/ThemeProvider.js.map +1 -1
- package/dist/styles/definitions.d.ts +2 -1
- package/dist/styles/definitions.js +7 -1
- package/dist/styles/definitions.js.map +1 -1
- package/dist/styles/light.js +2 -1
- package/dist/styles/light.js.map +1 -1
- package/dist/types/defaults.d.ts +8 -2
- package/dist/types/defaults.js.map +1 -1
- package/dist/utils/IPhoneXHelper.js +3 -3
- package/dist/utils/IPhoneXHelper.js.map +1 -1
- package/dist/utils/ResponsiveFontSize.js +6 -6
- package/dist/utils/ResponsiveFontSize.js.map +1 -1
- package/dist/utils/extractNumbersFromString.js +1 -1
- package/dist/utils/extractNumbersFromString.js.map +1 -1
- package/dist/utils/formatWithMask.js.map +1 -1
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +28 -19
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lightenDarkenColor.js.map +1 -1
- package/dist/utils/masks.js.map +1 -1
- package/dist/utils/variantComplement.d.ts +6 -0
- package/dist/utils/variantComplement.js +35 -0
- package/dist/utils/variantComplement.js.map +1 -0
- package/package.json +5 -5
- package/src/components/atoms/Badge/styled.ts +2 -3
- package/src/components/atoms/GroupButton/GroupButton.tsx +2 -5
- package/src/components/atoms/Input/InputContainer/InputContainer.tsx +3 -3
- package/src/components/atoms/Input/InputElement/InputElement.tsx +4 -5
- package/src/components/atoms/Input/InputMaskElement/InputMaskElement.tsx +4 -5
- package/src/components/atoms/ProgressBar/ProgressBar.tsx +2 -4
- package/src/components/atoms/Switch/Switch.tsx +39 -19
- package/src/components/atoms/Switch/animation.ts +4 -6
- package/src/components/atoms/Switch/styled.ts +4 -6
- package/src/components/atoms/Tag/Tag.tsx +1 -1
- package/src/components/atoms/shared/PaperAndCard.ts +1 -1
- package/src/components/molecules/Calendar/index.ts +1 -1
- package/src/components/molecules/DatePicker/DatePicker.tsx +12 -8
- package/src/components/molecules/DateTimePicker/DateTimePicker.tsx +19 -11
- package/src/components/molecules/DateTimeSelector/DateTimeSelector.tsx +0 -1
- package/src/components/molecules/Grid/functions.ts +29 -0
- package/src/components/molecules/Grid/index.ts +66 -2
- package/src/components/molecules/HintInputContainer/HintInputContainer.tsx +6 -1
- package/src/components/molecules/IconTextButton/IconComponent.tsx +31 -0
- package/src/components/molecules/IconTextButton/IconTextButton.tsx +10 -0
- package/src/components/molecules/IconTextButton/index.ts +2 -0
- package/src/components/molecules/IconTextButton/styled.ts +20 -0
- package/src/components/molecules/LabeledSwitch/LabeledSwitch.tsx +9 -0
- package/src/components/molecules/LabeledSwitch/index.ts +1 -0
- package/src/components/molecules/Snackbar/Snackbar.tsx +1 -1
- package/src/components/molecules/Snackbar/styled.ts +6 -2
- package/src/components/molecules/TextArea/TextArea.tsx +6 -2
- package/src/components/molecules/TextArea/styled.ts +5 -2
- package/src/hooks/useDebouncedState.ts +1 -1
- package/src/index.ts +26 -6
- package/src/styles/definitions.ts +8 -1
- package/src/styles/light.ts +2 -0
- package/src/types/defaults.ts +11 -1
- package/src/utils/IPhoneXHelper.ts +27 -22
- package/src/utils/ResponsiveFontSize.ts +55 -36
- package/src/utils/index.ts +5 -4
- package/src/utils/variantComplement.ts +36 -0
- package/dist/components/molecules/Grid/Grid.d.ts +0 -15
- package/dist/components/molecules/Grid/Grid.js +0 -55
- package/dist/components/molecules/Grid/Grid.js.map +0 -1
- package/dist/components/molecules/Grid/Item/Item.d.ts +0 -30
- package/dist/components/molecules/Grid/Item/Item.js +0 -68
- package/dist/components/molecules/Grid/Item/Item.js.map +0 -1
- package/dist/components/molecules/Grid/Item/index.d.ts +0 -1
- package/dist/components/molecules/Grid/Item/index.js.map +0 -1
- package/src/components/molecules/Grid/Grid.stories.tsx +0 -132
- package/src/components/molecules/Grid/Grid.tsx +0 -87
- package/src/components/molecules/Grid/Item/Item.tsx +0 -93
- package/src/components/molecules/Grid/Item/index.ts +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonSizeType,
|
|
3
|
+
FontColor,
|
|
4
|
+
Icon,
|
|
5
|
+
IconProps,
|
|
6
|
+
} from '@tecsinapse/react-core';
|
|
7
|
+
import React, { FC } from 'react';
|
|
8
|
+
|
|
9
|
+
interface IconComponentProps {
|
|
10
|
+
iconProps?: IconProps;
|
|
11
|
+
size?: ButtonSizeType;
|
|
12
|
+
defaultFontColor: keyof FontColor;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const IconComponent: FC<IconComponentProps> = ({
|
|
16
|
+
iconProps,
|
|
17
|
+
size = 'default',
|
|
18
|
+
defaultFontColor,
|
|
19
|
+
}) => {
|
|
20
|
+
return iconProps ? (
|
|
21
|
+
<Icon
|
|
22
|
+
size={iconProps.size ?? size === 'small' ? 'deca' : 'kilo'}
|
|
23
|
+
fontColor={iconProps.fontColor ?? defaultFontColor}
|
|
24
|
+
{...iconProps}
|
|
25
|
+
/>
|
|
26
|
+
) : (
|
|
27
|
+
<></>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default React.memo(IconComponent);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ButtonProps, IconProps, TextProps } from '@tecsinapse/react-core';
|
|
2
|
+
|
|
3
|
+
export type IconPositionOptions = 'left' | 'right';
|
|
4
|
+
|
|
5
|
+
export interface IconTextButtonProps extends ButtonProps {
|
|
6
|
+
iconProps?: IconProps;
|
|
7
|
+
iconPosition?: IconPositionOptions;
|
|
8
|
+
textProps?: TextProps;
|
|
9
|
+
label?: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import styled, { css } from '@emotion/native';
|
|
2
|
+
import { IconPositionOptions, StyleProps, Text } from '@tecsinapse/react-core';
|
|
3
|
+
|
|
4
|
+
export const StyledText = styled(Text)<
|
|
5
|
+
Partial<StyleProps> & {
|
|
6
|
+
iconPosition: IconPositionOptions;
|
|
7
|
+
hasIcon?: boolean;
|
|
8
|
+
}
|
|
9
|
+
>`
|
|
10
|
+
${({ theme, iconPosition, hasIcon = false }) => {
|
|
11
|
+
if (hasIcon && iconPosition === 'left')
|
|
12
|
+
return css`
|
|
13
|
+
margin-left: ${theme?.spacing.mili};
|
|
14
|
+
`;
|
|
15
|
+
else if (hasIcon && iconPosition === 'right')
|
|
16
|
+
return css`
|
|
17
|
+
margin-right: ${theme?.spacing.mili};
|
|
18
|
+
`;
|
|
19
|
+
}}
|
|
20
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LabeledSwitchProps, LabelPositionOptions } from './LabeledSwitch';
|
|
@@ -84,7 +84,7 @@ export const Snackbar: React.FC<SnackbarProps> = ({
|
|
|
84
84
|
anchor={anchor}
|
|
85
85
|
anchorDistance={anchorDistance}
|
|
86
86
|
visible={open}
|
|
87
|
-
style={[{ opacity:
|
|
87
|
+
style={[{ opacity: fadeAnim as unknown as number }, style]}
|
|
88
88
|
timeout={timeout}
|
|
89
89
|
>
|
|
90
90
|
<StyledContainerFlexRow>
|
|
@@ -32,7 +32,9 @@ const anchorTop = ({
|
|
|
32
32
|
return (
|
|
33
33
|
anchor === 'top' &&
|
|
34
34
|
css`
|
|
35
|
-
top: ${anchorDistance
|
|
35
|
+
top: ${anchorDistance
|
|
36
|
+
? `${RFValue(anchorDistance)}px`
|
|
37
|
+
: theme.spacing.deca};
|
|
36
38
|
`
|
|
37
39
|
);
|
|
38
40
|
};
|
|
@@ -45,7 +47,9 @@ const anchorBottom = ({
|
|
|
45
47
|
return (
|
|
46
48
|
anchor === 'bottom' &&
|
|
47
49
|
css`
|
|
48
|
-
bottom: ${anchorDistance
|
|
50
|
+
bottom: ${anchorDistance
|
|
51
|
+
? `${RFValue(anchorDistance)}px`
|
|
52
|
+
: theme.spacing.deca};
|
|
49
53
|
`
|
|
50
54
|
);
|
|
51
55
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import { FontStackType, FontWeightType } from '
|
|
4
|
-
import {
|
|
3
|
+
import { FontStackType, FontWeightType } from '@tecsinapse/react-core';
|
|
4
|
+
import {
|
|
5
|
+
Hint,
|
|
6
|
+
InputContainerProps,
|
|
7
|
+
InputElementProps,
|
|
8
|
+
} from '../../atoms/Input';
|
|
5
9
|
import { Text, TextProps } from '../../atoms/Text';
|
|
6
10
|
import { StyledInputContainer } from './styled';
|
|
7
11
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
|
-
import { StyleProps } from '
|
|
2
|
+
import { StyleProps } from '@tecsinapse/react-core';
|
|
3
3
|
import { extractNumbersFromString, RFValue, RFValueStr } from '../../../utils';
|
|
4
4
|
import { InputContainer, InputElement } from '../../atoms/Input';
|
|
5
5
|
import { TextAreaProps } from './TextArea';
|
|
@@ -12,7 +12,10 @@ export const TextAreaInputBase = styled(InputElement)<
|
|
|
12
12
|
Partial<TextAreaProps> & Partial<StyleProps>
|
|
13
13
|
>`
|
|
14
14
|
max-height: ${({ theme, numberOfLines }) =>
|
|
15
|
-
`${RFValue(
|
|
15
|
+
`${RFValue(
|
|
16
|
+
extractNumbersFromString(theme.typography.h5.lineHeight) *
|
|
17
|
+
(numberOfLines || 1)
|
|
18
|
+
)}px`};
|
|
16
19
|
width: 100%;
|
|
17
20
|
padding: 0;
|
|
18
21
|
margin: ${RFValueStr('3px')} 0;
|
|
@@ -18,7 +18,7 @@ export function useDebouncedState<S>(
|
|
|
18
18
|
if (timeoutId.current) clearTimeout(timeoutId.current);
|
|
19
19
|
if (timeoutCallback)
|
|
20
20
|
timeoutId.current = setTimeout(() => timeoutCallback(state), timeoutMs);
|
|
21
|
-
}, [state
|
|
21
|
+
}, [state]);
|
|
22
22
|
|
|
23
23
|
return [state, setState];
|
|
24
24
|
}
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ export {
|
|
|
25
25
|
} from './components/atoms/GroupButton';
|
|
26
26
|
export { Icon, IconProps } from './components/atoms/Icon';
|
|
27
27
|
export {
|
|
28
|
+
disabledInputStyles,
|
|
28
29
|
Hint,
|
|
29
30
|
InputContainer,
|
|
30
31
|
InputContainerProps,
|
|
@@ -39,7 +40,6 @@ export {
|
|
|
39
40
|
useInputFocus,
|
|
40
41
|
useNumberMask,
|
|
41
42
|
useStringMask,
|
|
42
|
-
disabledInputStyles,
|
|
43
43
|
} from './components/atoms/Input';
|
|
44
44
|
export { Paper, PaperProps } from './components/atoms/Paper';
|
|
45
45
|
export {
|
|
@@ -68,21 +68,41 @@ export {
|
|
|
68
68
|
DateTimeSelectorMode,
|
|
69
69
|
DateTimeSelectorProps,
|
|
70
70
|
} from './components/molecules/DateTimeSelector';
|
|
71
|
-
export {
|
|
72
|
-
|
|
71
|
+
export {
|
|
72
|
+
GridSpacing,
|
|
73
|
+
IGridItem,
|
|
74
|
+
getGridItemPadding,
|
|
75
|
+
getGridItemColumSpan,
|
|
76
|
+
IGrid,
|
|
77
|
+
FlexAlignBase,
|
|
78
|
+
FlexAlignType,
|
|
79
|
+
FlexPositioning,
|
|
80
|
+
FlexSpacing,
|
|
81
|
+
PaddingPosition,
|
|
82
|
+
} from './components/molecules/Grid';
|
|
73
83
|
export {
|
|
74
84
|
HintInputContainer,
|
|
75
85
|
HintInputContainerProps,
|
|
76
86
|
} from './components/molecules/HintInputContainer';
|
|
87
|
+
export {
|
|
88
|
+
IconComponent,
|
|
89
|
+
IconPositionOptions,
|
|
90
|
+
IconTextButtonProps,
|
|
91
|
+
} from './components/molecules/IconTextButton';
|
|
92
|
+
export { InputPasswordIcon } from './components/molecules/InputPassword';
|
|
93
|
+
export {
|
|
94
|
+
LabeledSwitchProps,
|
|
95
|
+
LabelPositionOptions,
|
|
96
|
+
} from './components/molecules/LabeledSwitch';
|
|
97
|
+
export { Snackbar, SnackbarProps } from './components/molecules/Snackbar';
|
|
77
98
|
export {
|
|
78
99
|
TextArea,
|
|
79
|
-
TextAreaProps,
|
|
80
100
|
TextAreaInputBase,
|
|
101
|
+
TextAreaProps,
|
|
81
102
|
} from './components/molecules/TextArea';
|
|
82
|
-
export
|
|
103
|
+
export * from './hooks';
|
|
83
104
|
export * from './styles/definitions';
|
|
84
105
|
export * from './styles/light';
|
|
85
106
|
export { default as ThemeProvider } from './styles/ThemeProvider';
|
|
86
107
|
export * from './types/defaults';
|
|
87
108
|
export * from './utils';
|
|
88
|
-
export * from './hooks';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BorderRadius,
|
|
3
3
|
BorderWidth,
|
|
4
|
+
Breakpoints,
|
|
4
5
|
FontColor,
|
|
5
6
|
FontStack,
|
|
6
7
|
FontWeight,
|
|
@@ -8,7 +9,7 @@ import {
|
|
|
8
9
|
Miscellaneous,
|
|
9
10
|
Spacing,
|
|
10
11
|
TypographyVariation,
|
|
11
|
-
ZIndex
|
|
12
|
+
ZIndex,
|
|
12
13
|
} from '../types/defaults';
|
|
13
14
|
import { RFValueStr } from '../utils';
|
|
14
15
|
|
|
@@ -179,3 +180,9 @@ export type IconType =
|
|
|
179
180
|
| 'antdesign'
|
|
180
181
|
| 'font-awesome-5'
|
|
181
182
|
| string;
|
|
183
|
+
|
|
184
|
+
export const breakpoints: Breakpoints = {
|
|
185
|
+
sm: 480,
|
|
186
|
+
md: 768,
|
|
187
|
+
lg: 1366,
|
|
188
|
+
};
|
package/src/styles/light.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ThemeProp } from '../types/defaults';
|
|
|
2
2
|
import {
|
|
3
3
|
borderRadius,
|
|
4
4
|
borderWidth,
|
|
5
|
+
breakpoints,
|
|
5
6
|
fontColor,
|
|
6
7
|
fontFiles,
|
|
7
8
|
fontStack,
|
|
@@ -51,4 +52,5 @@ export const lightTheme: ThemeProp = {
|
|
|
51
52
|
files: fontFiles,
|
|
52
53
|
},
|
|
53
54
|
zIndex,
|
|
55
|
+
breakpoints,
|
|
54
56
|
};
|
package/src/types/defaults.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
1
3
|
export type Color = {
|
|
2
4
|
primary: ColorGradation;
|
|
3
5
|
secondary: ColorGradation;
|
|
@@ -107,6 +109,12 @@ export type FontWeight = {
|
|
|
107
109
|
black: string;
|
|
108
110
|
};
|
|
109
111
|
|
|
112
|
+
export type Breakpoints = {
|
|
113
|
+
sm: number;
|
|
114
|
+
md: number;
|
|
115
|
+
lg: number;
|
|
116
|
+
};
|
|
117
|
+
|
|
110
118
|
export type ThemeProp = {
|
|
111
119
|
color: Color;
|
|
112
120
|
miscellaneous: Miscellaneous;
|
|
@@ -122,10 +130,12 @@ export type ThemeProp = {
|
|
|
122
130
|
files: FontWeight;
|
|
123
131
|
};
|
|
124
132
|
zIndex: ZIndex;
|
|
133
|
+
/** Designed to web */
|
|
134
|
+
breakpoints: Breakpoints;
|
|
125
135
|
};
|
|
126
136
|
|
|
127
137
|
export interface ThemeProviderProps {
|
|
128
|
-
children?:
|
|
138
|
+
children?: ReactNode;
|
|
129
139
|
theme: ThemeProp;
|
|
130
140
|
}
|
|
131
141
|
|
|
@@ -1,34 +1,39 @@
|
|
|
1
1
|
import { Dimensions, Platform, StatusBar } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export function isIphoneX() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
const dimen = Dimensions.get('window');
|
|
5
|
+
return (
|
|
6
|
+
Platform.OS === 'ios' &&
|
|
7
|
+
!Platform.isPad &&
|
|
8
|
+
!Platform.isTVOS &&
|
|
9
|
+
(dimen.height === 780 ||
|
|
10
|
+
dimen.width === 780 ||
|
|
11
|
+
dimen.height === 812 ||
|
|
12
|
+
dimen.width === 812 ||
|
|
13
|
+
dimen.height === 844 ||
|
|
14
|
+
dimen.width === 844 ||
|
|
15
|
+
dimen.height === 896 ||
|
|
16
|
+
dimen.width === 896 ||
|
|
17
|
+
dimen.height === 926 ||
|
|
18
|
+
dimen.width === 926)
|
|
19
|
+
);
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export function ifIphoneX(iphoneXStyle, regularStyle) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
if (isIphoneX()) {
|
|
24
|
+
return iphoneXStyle;
|
|
25
|
+
}
|
|
26
|
+
return regularStyle;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
export function getStatusBarHeight(safe) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
return Platform.select({
|
|
31
|
+
ios: ifIphoneX(safe ? 44 : 30, 20),
|
|
32
|
+
android: StatusBar.currentHeight,
|
|
33
|
+
default: 0,
|
|
34
|
+
});
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
export function getBottomSpace() {
|
|
33
|
-
|
|
34
|
-
}
|
|
38
|
+
return isIphoneX() ? 34 : 0;
|
|
39
|
+
}
|
|
@@ -1,52 +1,71 @@
|
|
|
1
|
-
import { Dimensions, Platform, StatusBar } from
|
|
2
|
-
import { extractNumbersFromString } from
|
|
3
|
-
import { isIphoneX } from
|
|
1
|
+
import { Dimensions, Platform, StatusBar } from 'react-native';
|
|
2
|
+
import { extractNumbersFromString } from './extractNumbersFromString';
|
|
3
|
+
import { isIphoneX } from './IPhoneXHelper';
|
|
4
4
|
|
|
5
|
-
const STANDARD_SCREEN_HEIGHT = 680
|
|
5
|
+
const STANDARD_SCREEN_HEIGHT = 680;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Use this function when you want to scale a percentage number
|
|
9
9
|
* to a reasonable value that will fit better on most of devices.
|
|
10
|
-
*
|
|
11
|
-
* @param percent
|
|
12
|
-
* @returns
|
|
10
|
+
*
|
|
11
|
+
* @param percent
|
|
12
|
+
* @returns
|
|
13
13
|
*/
|
|
14
14
|
export const RFPercentage = (percent: number) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
if (Platform.OS === 'web') return percent;
|
|
16
|
+
const { height, width } = Dimensions.get('window');
|
|
17
|
+
const standardLength = width > height ? width : height;
|
|
18
|
+
const offset =
|
|
19
|
+
width > height
|
|
20
|
+
? 0
|
|
21
|
+
: Platform.OS === 'ios'
|
|
22
|
+
? 78
|
|
23
|
+
: StatusBar.currentHeight || 0; // iPhone X style SafeAreaView size in portrait
|
|
24
|
+
const deviceHeight =
|
|
25
|
+
isIphoneX() || Platform.OS === 'android'
|
|
26
|
+
? standardLength - offset
|
|
27
|
+
: standardLength;
|
|
28
|
+
const heightPercent = (percent * deviceHeight) / 100;
|
|
29
|
+
return Math.round(heightPercent);
|
|
30
|
+
};
|
|
23
31
|
|
|
24
32
|
/**
|
|
25
|
-
* Use this function when you want to scale a font size based on pixel unit
|
|
33
|
+
* Use this function when you want to scale a font size based on pixel unit
|
|
26
34
|
* to a reasonable value that will fit better on most of devices.
|
|
27
|
-
*
|
|
28
|
-
* @param fontSize
|
|
29
|
-
* @param standardScreenHeight
|
|
30
|
-
* @returns
|
|
35
|
+
*
|
|
36
|
+
* @param fontSize
|
|
37
|
+
* @param standardScreenHeight
|
|
38
|
+
* @returns
|
|
31
39
|
*/
|
|
32
|
-
export const RFValue = (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
export const RFValue = (
|
|
41
|
+
fontSize: number,
|
|
42
|
+
standardScreenHeight: number = STANDARD_SCREEN_HEIGHT
|
|
43
|
+
) => {
|
|
44
|
+
if (Platform.OS === 'web') return fontSize;
|
|
45
|
+
const { height, width } = Dimensions.get('window');
|
|
46
|
+
const standardLength = width > height ? width : height;
|
|
47
|
+
const offset =
|
|
48
|
+
width > height
|
|
49
|
+
? 0
|
|
50
|
+
: Platform.OS === 'ios'
|
|
51
|
+
? 78
|
|
52
|
+
: StatusBar.currentHeight || 0; // iPhone X style SafeAreaView size in portrait
|
|
53
|
+
const deviceHeight =
|
|
54
|
+
isIphoneX() || Platform.OS === 'android'
|
|
55
|
+
? standardLength - offset
|
|
56
|
+
: standardLength;
|
|
57
|
+
const heightPercent = (fontSize * deviceHeight) / standardScreenHeight;
|
|
58
|
+
return Math.round(heightPercent);
|
|
59
|
+
};
|
|
41
60
|
|
|
42
61
|
/**
|
|
43
62
|
* Same as RFValue, however you can provide string values. E.g: '10px', '-5px'.
|
|
44
|
-
*
|
|
45
|
-
* @param fontSize
|
|
46
|
-
* @param standardScreenHeight
|
|
47
|
-
* @returns
|
|
63
|
+
*
|
|
64
|
+
* @param fontSize
|
|
65
|
+
* @param standardScreenHeight
|
|
66
|
+
* @returns
|
|
48
67
|
*/
|
|
49
68
|
export const RFValueStr = (fontSize: string, standardScreenHeight?: number) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
69
|
+
const _fontSize = extractNumbersFromString(fontSize);
|
|
70
|
+
return `${RFValue(_fontSize, standardScreenHeight)}px`;
|
|
71
|
+
};
|
package/src/utils/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { lightenDarkenColor } from './lightenDarkenColor';
|
|
2
1
|
export {
|
|
3
|
-
extractNumbersFromString,
|
|
4
2
|
extractDigitsFromString,
|
|
3
|
+
extractNumbersFromString,
|
|
5
4
|
} from './extractNumbersFromString';
|
|
5
|
+
export * from './formatWithMask';
|
|
6
6
|
export * from './IPhoneXHelper';
|
|
7
|
-
export
|
|
7
|
+
export { lightenDarkenColor } from './lightenDarkenColor';
|
|
8
8
|
export * from './masks';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './ResponsiveFontSize';
|
|
10
|
+
export * from './variantComplement';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ColorGradationType,
|
|
3
|
+
ColorType,
|
|
4
|
+
FontColorType,
|
|
5
|
+
VariantType,
|
|
6
|
+
} from '../types/defaults';
|
|
7
|
+
|
|
8
|
+
export const fontColorVC: Record<VariantType, FontColorType> = {
|
|
9
|
+
filled: 'light',
|
|
10
|
+
outlined: 'orange',
|
|
11
|
+
text: 'orange',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const colorVC: Record<VariantType, ColorType> = {
|
|
15
|
+
filled: 'primary',
|
|
16
|
+
outlined: 'primary',
|
|
17
|
+
text: 'primary',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const colorGradationVC: Record<VariantType, ColorGradationType> = {
|
|
21
|
+
filled: 'dark',
|
|
22
|
+
outlined: 'dark',
|
|
23
|
+
text: 'dark',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const borderColorVC: Record<VariantType, ColorType> = {
|
|
27
|
+
filled: 'primary',
|
|
28
|
+
outlined: 'primary',
|
|
29
|
+
text: 'primary',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const borderColorGradationVC: Record<VariantType, ColorGradationType> = {
|
|
33
|
+
filled: 'dark',
|
|
34
|
+
outlined: 'dark',
|
|
35
|
+
text: 'dark',
|
|
36
|
+
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ViewProps } from 'react-native';
|
|
2
|
-
import { SpacingType } from '@tecsinapse/react-core';
|
|
3
|
-
export interface IGrid extends ViewProps {
|
|
4
|
-
children: JSX.Element[];
|
|
5
|
-
layout?: number[][];
|
|
6
|
-
columns?: number;
|
|
7
|
-
spacing?: SpacingType | {
|
|
8
|
-
top?: SpacingType;
|
|
9
|
-
right?: SpacingType;
|
|
10
|
-
bottom?: SpacingType;
|
|
11
|
-
left?: SpacingType;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
declare const Grid: ({ children, columns, layout, style, spacing, ...rest }: IGrid) => JSX.Element;
|
|
15
|
-
export default Grid;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
|
|
6
|
-
var _react = _interopRequireDefault(require("react"));
|
|
7
|
-
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
|
|
10
|
-
var _Item = require("./Item");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
-
|
|
16
|
-
const Grid = ({
|
|
17
|
-
children,
|
|
18
|
-
columns = 12,
|
|
19
|
-
layout,
|
|
20
|
-
style,
|
|
21
|
-
spacing,
|
|
22
|
-
...rest
|
|
23
|
-
}) => {
|
|
24
|
-
if (layout) {
|
|
25
|
-
const flatLayout = layout.flat();
|
|
26
|
-
return _react.default.createElement(_reactNative.View, _extends({
|
|
27
|
-
style: [style, {
|
|
28
|
-
display: 'flex',
|
|
29
|
-
flexDirection: 'row',
|
|
30
|
-
flexWrap: 'wrap'
|
|
31
|
-
}]
|
|
32
|
-
}, rest), _react.default.Children.map(children, (child, index) => _react.default.createElement(_Item.GridItem, {
|
|
33
|
-
columns: columns,
|
|
34
|
-
span: flatLayout[index],
|
|
35
|
-
spacing: spacing
|
|
36
|
-
}, child)));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return _react.default.createElement(_reactNative.View, _extends({
|
|
40
|
-
style: [style, {
|
|
41
|
-
display: 'flex',
|
|
42
|
-
flexDirection: 'row',
|
|
43
|
-
flexWrap: 'wrap'
|
|
44
|
-
}]
|
|
45
|
-
}, rest), _react.default.Children.map(children, child => {
|
|
46
|
-
return _react.default.cloneElement(child, { ...(child == null ? void 0 : child.props),
|
|
47
|
-
columns,
|
|
48
|
-
spacing: (child == null ? void 0 : child.props.spacing) ?? spacing
|
|
49
|
-
});
|
|
50
|
-
}));
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
var _default = Grid;
|
|
54
|
-
exports.default = _default;
|
|
55
|
-
//# sourceMappingURL=Grid.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/molecules/Grid/Grid.tsx"],"names":["Grid","children","columns","layout","style","spacing","rest","flatLayout","flat","display","flexDirection","flexWrap","React","Children","map","child","index","cloneElement","props"],"mappings":";;;;;AAAA;;AACA;;AACA;;;;;;AA0BA,MAAMA,IAAI,GAAG,CAAC;AACZC,EAAAA,QADY;AAEZC,EAAAA,OAAO,GAAG,EAFE;AAGZC,EAAAA,MAHY;AAIZC,EAAAA,KAJY;AAKZC,EAAAA,OALY;AAMZ,KAAGC;AANS,CAAD,KAOA;AACX,MAAIH,MAAJ,EAAY;AACV,UAAMI,UAAU,GAAGJ,MAAM,CAACK,IAAP,EAAnB;AACA,WACE,6BAAC,iBAAD;AACE,MAAA,KAAK,EAAE,CACLJ,KADK,EAEL;AACEK,QAAAA,OAAO,EAAE,MADX;AAEEC,QAAAA,aAAa,EAAE,KAFjB;AAGEC,QAAAA,QAAQ,EAAE;AAHZ,OAFK;AADT,OASML,IATN,GAWGM,eAAMC,QAAN,CAAeC,GAAf,CAAmBb,QAAnB,EAA6B,CAACc,KAAD,EAAQC,KAAR,KAC5B,6BAAC,cAAD;AACE,MAAA,OAAO,EAAEd,OADX;AAEE,MAAA,IAAI,EAAEK,UAAU,CAACS,KAAD,CAFlB;AAGE,MAAA,OAAO,EAAEX;AAHX,OAKGU,KALH,CADD,CAXH,CADF;AAuBD;;AAED,SACE,6BAAC,iBAAD;AACE,IAAA,KAAK,EAAE,CACLX,KADK,EAEL;AACEK,MAAAA,OAAO,EAAE,MADX;AAEEC,MAAAA,aAAa,EAAE,KAFjB;AAGEC,MAAAA,QAAQ,EAAE;AAHZ,KAFK;AADT,KASML,IATN,GAWGM,eAAMC,QAAN,CAAeC,GAAf,CAAmBb,QAAnB,EAA6Bc,KAAK,IAAI;AACrC,WAAOH,eAAMK,YAAN,CAAmBF,KAAnB,EAA0B,EAC/B,IAAGA,KAAH,oBAAGA,KAAK,CAAEG,KAAV,CAD+B;AAE/BhB,MAAAA,OAF+B;AAG/BG,MAAAA,OAAO,EAAE,CAAAU,KAAK,QAAL,YAAAA,KAAK,CAAEG,KAAP,CAAab,OAAb,KAAwBA;AAHF,KAA1B,CAAP;AAKD,GANA,CAXH,CADF;AAqBD,CAxDD;;eA0DeL,I","sourcesContent":["import React from 'react';\nimport { View, ViewProps } from 'react-native';\nimport { GridItem } from './Item';\nimport { SpacingType } from '@tecsinapse/react-core';\n\nexport interface IGrid extends ViewProps {\n children: JSX.Element[];\n /** Layout should represent the multiplier of columns to fill the rows properly.\n * Example:\n * const layout = [\n * [6, 6], // Two elements on row\n * [4, 4, 4], // Three elements on row\n * [12], // One element on row\n * ];\n * */\n layout?: number[][];\n /** Number of grid columns to be considered (not the number of elements per row) */\n columns?: number;\n spacing?:\n | SpacingType\n | {\n top?: SpacingType;\n right?: SpacingType;\n bottom?: SpacingType;\n left?: SpacingType;\n };\n}\n\nconst Grid = ({\n children,\n columns = 12,\n layout,\n style,\n spacing,\n ...rest\n}: IGrid) => {\n if (layout) {\n const flatLayout = layout.flat();\n return (\n <View\n style={[\n style,\n {\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n ]}\n {...rest}\n >\n {React.Children.map(children, (child, index) => (\n <GridItem\n columns={columns}\n span={flatLayout[index]}\n spacing={spacing}\n >\n {child}\n </GridItem>\n ))}\n </View>\n );\n }\n\n return (\n <View\n style={[\n style,\n {\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n ]}\n {...rest}\n >\n {React.Children.map(children, child => {\n return React.cloneElement(child, {\n ...child?.props,\n columns,\n spacing: child?.props.spacing ?? spacing,\n });\n })}\n </View>\n );\n};\n\nexport default Grid;\n"],"file":"Grid.js"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SpacingType } from '../../../../types/defaults';
|
|
3
|
-
declare type FlexPositioning = 'flex-start' | 'flex-end' | 'center';
|
|
4
|
-
declare type FlexAlignBase = FlexPositioning | 'stretch';
|
|
5
|
-
declare type FlexAlignType = FlexAlignBase | 'baseline';
|
|
6
|
-
declare type FlexSpacing = 'space-between' | 'space-around';
|
|
7
|
-
export interface IGridItem {
|
|
8
|
-
children: React.ReactElement;
|
|
9
|
-
span: number;
|
|
10
|
-
columns?: number;
|
|
11
|
-
loading?: boolean;
|
|
12
|
-
loadingComponent?: React.ReactElement;
|
|
13
|
-
alignContent?: FlexAlignBase | FlexSpacing;
|
|
14
|
-
alignItems?: FlexAlignType;
|
|
15
|
-
alignSelf?: 'auto' | FlexAlignType;
|
|
16
|
-
flex?: number;
|
|
17
|
-
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
18
|
-
flexGrow?: number;
|
|
19
|
-
flexShrink?: number;
|
|
20
|
-
justifyContent?: FlexPositioning | FlexSpacing | 'space-evenly';
|
|
21
|
-
spacing?: SpacingType | {
|
|
22
|
-
top?: SpacingType;
|
|
23
|
-
right?: SpacingType;
|
|
24
|
-
bottom?: SpacingType;
|
|
25
|
-
left?: SpacingType;
|
|
26
|
-
};
|
|
27
|
-
wrapper?: boolean;
|
|
28
|
-
}
|
|
29
|
-
declare const GridItem: ({ children, span, columns, loadingComponent, loading, spacing: _spacing, wrapper, ...rest }: IGridItem) => JSX.Element;
|
|
30
|
-
export default GridItem;
|