@tecsinapse/react-native-kit 1.18.4 → 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.
Files changed (60) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/components/atoms/Button/Button.d.ts +2 -2
  3. package/dist/components/atoms/Button/Button.js.map +1 -1
  4. package/dist/components/molecules/Grid/Grid.d.ts +5 -0
  5. package/dist/components/molecules/Grid/Grid.js +57 -0
  6. package/dist/components/molecules/Grid/Grid.js.map +1 -0
  7. package/dist/components/molecules/Grid/Item/Item.d.ts +7 -0
  8. package/dist/components/molecules/Grid/Item/Item.js +78 -0
  9. package/dist/components/molecules/Grid/Item/Item.js.map +1 -0
  10. package/dist/components/molecules/Grid/Item/index.d.ts +1 -0
  11. package/dist/components/molecules/Grid/Item/index.js +14 -0
  12. package/dist/components/molecules/Grid/Item/index.js.map +1 -0
  13. package/dist/components/molecules/Grid/index.d.ts +2 -0
  14. package/dist/components/molecules/Grid/index.js +15 -0
  15. package/dist/components/molecules/Grid/index.js.map +1 -0
  16. package/dist/components/molecules/IconTextButton/IconTextButton.d.ts +6 -0
  17. package/dist/components/molecules/IconTextButton/IconTextButton.js +50 -0
  18. package/dist/components/molecules/IconTextButton/IconTextButton.js.map +1 -0
  19. package/dist/components/molecules/IconTextButton/TextComponent.d.ts +12 -0
  20. package/dist/components/molecules/IconTextButton/TextComponent.js +34 -0
  21. package/dist/components/molecules/IconTextButton/TextComponent.js.map +1 -0
  22. package/dist/components/molecules/IconTextButton/index.d.ts +1 -0
  23. package/dist/components/molecules/IconTextButton/index.js +14 -0
  24. package/dist/components/molecules/IconTextButton/index.js.map +1 -0
  25. package/dist/components/molecules/IconTextButton/styled.d.ts +2 -0
  26. package/dist/components/molecules/IconTextButton/styled.js +46 -0
  27. package/dist/components/molecules/IconTextButton/styled.js.map +1 -0
  28. package/dist/components/molecules/LabeledSwitch/LabelComponent.d.ts +13 -0
  29. package/dist/components/molecules/LabeledSwitch/LabelComponent.js +36 -0
  30. package/dist/components/molecules/LabeledSwitch/LabelComponent.js.map +1 -0
  31. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.d.ts +8 -0
  32. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js +53 -0
  33. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js.map +1 -0
  34. package/dist/components/molecules/LabeledSwitch/index.d.ts +1 -0
  35. package/dist/components/molecules/LabeledSwitch/index.js +14 -0
  36. package/dist/components/molecules/LabeledSwitch/index.js.map +1 -0
  37. package/dist/components/molecules/LabeledSwitch/styled.d.ts +9 -0
  38. package/dist/components/molecules/LabeledSwitch/styled.js +35 -0
  39. package/dist/components/molecules/LabeledSwitch/styled.js.map +1 -0
  40. package/dist/components/molecules/Select/Select.js +2 -2
  41. package/dist/components/molecules/Select/Select.js.map +1 -1
  42. package/dist/index.d.ts +17 -14
  43. package/dist/index.js +112 -91
  44. package/dist/index.js.map +1 -1
  45. package/package.json +5 -5
  46. package/src/components/atoms/Button/Button.tsx +19 -13
  47. package/src/components/molecules/Grid/Grid.tsx +68 -0
  48. package/src/components/molecules/Grid/Item/Item.tsx +77 -0
  49. package/src/components/molecules/Grid/Item/index.ts +1 -0
  50. package/src/components/molecules/Grid/index.ts +2 -0
  51. package/src/components/molecules/IconTextButton/IconTextButton.tsx +55 -0
  52. package/src/components/molecules/IconTextButton/TextComponent.tsx +43 -0
  53. package/src/components/molecules/IconTextButton/index.ts +4 -0
  54. package/src/components/molecules/IconTextButton/styled.ts +35 -0
  55. package/src/components/molecules/LabeledSwitch/LabelComponent.tsx +46 -0
  56. package/src/components/molecules/LabeledSwitch/LabeledSwitch.tsx +59 -0
  57. package/src/components/molecules/LabeledSwitch/index.ts +4 -0
  58. package/src/components/molecules/LabeledSwitch/styled.ts +27 -0
  59. package/src/components/molecules/Select/Select.tsx +2 -2
  60. package/src/index.ts +38 -29
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import { View, ViewProps } from 'react-native';
3
+ import {
4
+ IGridItem,
5
+ useTheme,
6
+ getGridItemColumSpan,
7
+ getGridItemPadding,
8
+ } from '@tecsinapse/react-core';
9
+
10
+ export type IGridItemNative = IGridItem &
11
+ ViewProps & {
12
+ /** Only specify this property if the GridItem will be 'dynamic', adjusting itself to content. Use this with `wrapper` for better result. */
13
+ flexBasis?: string | 'auto';
14
+ };
15
+
16
+ const GridItem = ({
17
+ children,
18
+ span,
19
+ columns = 12,
20
+ loadingComponent,
21
+ loading = false,
22
+ spacing: _spacing,
23
+ wrapper = false,
24
+ alignContent,
25
+ alignItems,
26
+ alignSelf,
27
+ flex,
28
+ flexDirection,
29
+ flexGrow,
30
+ flexShrink,
31
+ justifyContent,
32
+ flexBasis,
33
+ style,
34
+ ...rest
35
+ }: IGridItemNative): JSX.Element => {
36
+ const { spacing } = useTheme();
37
+ if (!React.Children.only(children)) {
38
+ throw new Error('The number of children in GridItem should be one');
39
+ }
40
+ if (loadingComponent && loading) {
41
+ return loadingComponent;
42
+ }
43
+
44
+ const _style = {
45
+ alignContent,
46
+ alignItems,
47
+ alignSelf,
48
+ flex,
49
+ flexDirection,
50
+ flexGrow,
51
+ flexShrink,
52
+ justifyContent,
53
+ boxSizing: 'border-box',
54
+ flexBasis: flexBasis ?? `${getGridItemColumSpan(columns, span)}%`,
55
+ paddingTop: getGridItemPadding('top', _spacing, spacing),
56
+ paddingBottom: getGridItemPadding('bottom', _spacing, spacing),
57
+ paddingRight: getGridItemPadding('right', _spacing, spacing),
58
+ paddingLeft: getGridItemPadding('left', _spacing, spacing),
59
+ };
60
+
61
+ const clone = React.cloneElement(children, {
62
+ ...children?.props,
63
+ style: wrapper
64
+ ? children?.props.style
65
+ : { ..._style, ...children?.props.style },
66
+ });
67
+
68
+ return wrapper ? (
69
+ <View {...rest} style={[style, _style]}>
70
+ {clone}
71
+ </View>
72
+ ) : (
73
+ clone
74
+ );
75
+ };
76
+
77
+ export default GridItem;
@@ -0,0 +1 @@
1
+ export { default as GridItem, IGridItemNative } from './Item';
@@ -0,0 +1,2 @@
1
+ export { GridItem } from './Item';
2
+ export { default as Grid } from './Grid';
@@ -0,0 +1,55 @@
1
+ import {
2
+ fontColorVC,
3
+ IconComponent,
4
+ IconTextButtonProps,
5
+ } from '@tecsinapse/react-core';
6
+ import React from 'react';
7
+ import { ButtonNativeProps } from '../../atoms/Button';
8
+ import { StyledIconTextButton } from './styled';
9
+ import TextComponent from './TextComponent';
10
+
11
+ export type NativeIconTextButtonProps = IconTextButtonProps &
12
+ Omit<ButtonNativeProps, 'ButtonProps'>;
13
+
14
+ const IconTextButton: React.FC<NativeIconTextButtonProps> = ({
15
+ iconProps,
16
+ iconPosition = 'left',
17
+ textProps,
18
+ label,
19
+ variant = 'filled',
20
+ size = 'default',
21
+ ...rest
22
+ }) => {
23
+ return (
24
+ <StyledIconTextButton boxed={!label} variant={variant} {...rest}>
25
+ {iconPosition === 'left' ? (
26
+ <IconComponent
27
+ iconProps={iconProps}
28
+ size={size}
29
+ defaultFontColor={fontColorVC[variant]}
30
+ />
31
+ ) : (
32
+ <></>
33
+ )}
34
+ <TextComponent
35
+ label={label}
36
+ defaultFontColor={fontColorVC[variant]}
37
+ hasIcon={!!iconProps}
38
+ iconPosition={iconPosition}
39
+ textProps={textProps}
40
+ size={size}
41
+ />
42
+ {iconPosition === 'right' ? (
43
+ <IconComponent
44
+ iconProps={iconProps}
45
+ size={size}
46
+ defaultFontColor={fontColorVC[variant]}
47
+ />
48
+ ) : (
49
+ <></>
50
+ )}
51
+ </StyledIconTextButton>
52
+ );
53
+ };
54
+
55
+ export default IconTextButton;
@@ -0,0 +1,43 @@
1
+ import {
2
+ ButtonSizeType,
3
+ FontColor,
4
+ IconPositionOptions,
5
+ TextProps,
6
+ } from '@tecsinapse/react-core';
7
+ import React, { FC } from 'react';
8
+ import { StyledText } from './styled';
9
+
10
+ interface TextComponentProps {
11
+ textProps?: TextProps;
12
+ size?: ButtonSizeType;
13
+ defaultFontColor: keyof FontColor;
14
+ label?: string;
15
+ iconPosition?: IconPositionOptions;
16
+ hasIcon?: boolean;
17
+ }
18
+
19
+ const TextComponent: FC<TextComponentProps> = ({
20
+ textProps,
21
+ size = 'default',
22
+ defaultFontColor,
23
+ label,
24
+ iconPosition = 'left',
25
+ hasIcon = false,
26
+ }) => {
27
+ return label ? (
28
+ <StyledText
29
+ typography={textProps?.typography ?? size === 'small' ? 'sub' : 'base'}
30
+ fontWeight={textProps?.fontWeight ?? 'bold'}
31
+ fontColor={textProps?.fontColor ?? defaultFontColor}
32
+ iconPosition={iconPosition}
33
+ hasIcon={hasIcon}
34
+ {...textProps}
35
+ >
36
+ {label}
37
+ </StyledText>
38
+ ) : (
39
+ <></>
40
+ );
41
+ };
42
+
43
+ export default React.memo(TextComponent);
@@ -0,0 +1,4 @@
1
+ export {
2
+ default as IconTextButton,
3
+ NativeIconTextButtonProps,
4
+ } from './IconTextButton';
@@ -0,0 +1,35 @@
1
+ import styled, { css } from '@emotion/native';
2
+ import { IconPositionOptions, StyleProps } from '@tecsinapse/react-core';
3
+ import { Button } from '../../atoms/Button';
4
+ import { Text } from '../../atoms/Text';
5
+
6
+ const boxedStyle = ({ theme }: Partial<StyleProps>) => `
7
+ padding: ${theme?.spacing.centi};
8
+ aspect-ratio: 1;
9
+ `;
10
+
11
+ export const StyledIconTextButton = styled(Button)<
12
+ Partial<StyleProps> & {
13
+ boxed: boolean;
14
+ }
15
+ >`
16
+ ${({ boxed, theme }) => boxed && boxedStyle({ theme })};
17
+ `;
18
+
19
+ export const StyledText = styled(Text)<
20
+ Partial<StyleProps> & {
21
+ iconPosition: IconPositionOptions;
22
+ hasIcon?: boolean;
23
+ }
24
+ >`
25
+ ${({ theme, iconPosition, hasIcon = false }) => {
26
+ if (hasIcon && iconPosition === 'left')
27
+ return css`
28
+ margin-left: ${theme?.spacing.mili};
29
+ `;
30
+ else if (hasIcon && iconPosition === 'right')
31
+ return css`
32
+ margin-right: ${theme?.spacing.mili};
33
+ `;
34
+ }}
35
+ `;
@@ -0,0 +1,46 @@
1
+ import {
2
+ FontColor,
3
+ FontWeight,
4
+ LabelPositionOptions,
5
+ } from '@tecsinapse/react-core';
6
+ import React, { FC } from 'react';
7
+ import { Pressable, PressableProps } from 'react-native';
8
+ import { TextNativeProps } from '../../atoms/Text';
9
+ import { StyledLabel } from './styled';
10
+
11
+ export interface LabelComponentProps extends PressableProps {
12
+ label: string;
13
+ labelPosition: LabelPositionOptions;
14
+ labelProps?: TextNativeProps;
15
+ active: boolean;
16
+ switchDisabled?: boolean;
17
+ }
18
+
19
+ const LabelComponent: FC<LabelComponentProps> = ({
20
+ label,
21
+ labelPosition,
22
+ labelProps,
23
+ active,
24
+ switchDisabled = false,
25
+ ...rest
26
+ }) => {
27
+ const defaultFontColor: keyof FontColor =
28
+ active && !switchDisabled ? 'dark' : 'medium';
29
+ const defaultFontWeight: keyof FontWeight =
30
+ active && !switchDisabled ? 'bold' : 'regular';
31
+
32
+ return (
33
+ <Pressable {...rest}>
34
+ <StyledLabel
35
+ labelPosition={labelPosition}
36
+ fontColor={labelProps?.fontColor ?? defaultFontColor}
37
+ fontWeight={labelProps?.fontWeight ?? defaultFontWeight}
38
+ {...labelProps}
39
+ >
40
+ {label}
41
+ </StyledLabel>
42
+ </Pressable>
43
+ );
44
+ };
45
+
46
+ export default React.memo(LabelComponent);
@@ -0,0 +1,59 @@
1
+ import { LabeledSwitchProps, Switch } from '@tecsinapse/react-core';
2
+ import React, { FC } from 'react';
3
+ import { TextNativeProps } from '../../atoms/Text';
4
+ import LabelComponent from './LabelComponent';
5
+ import { StyledView } from './styled';
6
+
7
+ export type LabeledSwitchNativeProps = LabeledSwitchProps & {
8
+ labelProps?: TextNativeProps;
9
+ };
10
+
11
+ const LabeledSwitch: FC<LabeledSwitchNativeProps> = ({
12
+ label,
13
+ labelPosition = 'right',
14
+ labelProps,
15
+ pressableLabel = false,
16
+ active,
17
+ disabled,
18
+ onChange,
19
+ ...rest
20
+ }) => {
21
+ return (
22
+ <StyledView>
23
+ {labelPosition === 'left' ? (
24
+ <LabelComponent
25
+ active={active}
26
+ label={label}
27
+ labelPosition={'left'}
28
+ labelProps={labelProps}
29
+ disabled={!pressableLabel || disabled}
30
+ switchDisabled={disabled}
31
+ onPress={() => onChange(!active)}
32
+ />
33
+ ) : (
34
+ <></>
35
+ )}
36
+ <Switch
37
+ active={active}
38
+ onChange={onChange}
39
+ disabled={disabled}
40
+ {...rest}
41
+ />
42
+ {labelPosition === 'right' ? (
43
+ <LabelComponent
44
+ active={active}
45
+ label={label}
46
+ labelPosition={'right'}
47
+ labelProps={labelProps}
48
+ disabled={!pressableLabel || disabled}
49
+ switchDisabled={disabled}
50
+ onPress={() => onChange(!active)}
51
+ />
52
+ ) : (
53
+ <></>
54
+ )}
55
+ </StyledView>
56
+ );
57
+ };
58
+
59
+ export default LabeledSwitch;
@@ -0,0 +1,4 @@
1
+ export {
2
+ default as LabeledSwitch,
3
+ LabeledSwitchNativeProps,
4
+ } from './LabeledSwitch';
@@ -0,0 +1,27 @@
1
+ import styled, { css } from '@emotion/native';
2
+ import { LabelPositionOptions, StyleProps } from '@tecsinapse/react-core';
3
+ import { View } from 'react-native';
4
+ import { Text } from '../../atoms/Text';
5
+
6
+ export const StyledView = styled(View)`
7
+ display: flex;
8
+ flex-direction: row;
9
+ align-items: center;
10
+ `;
11
+
12
+ export const StyledLabel = styled(Text)<
13
+ Partial<StyleProps> & {
14
+ labelPosition: LabelPositionOptions;
15
+ }
16
+ >`
17
+ ${({ theme, labelPosition }) => {
18
+ if (labelPosition === 'right')
19
+ return css`
20
+ margin-left: ${theme?.spacing.centi};
21
+ `;
22
+ else if (labelPosition === 'left')
23
+ return css`
24
+ margin-right: ${theme?.spacing.centi};
25
+ `;
26
+ }}
27
+ `;
@@ -165,7 +165,7 @@ function Select<Data, Type extends 'single' | 'multi'>({
165
165
  if (Array.isArray(value)) {
166
166
  if (value.length === 0) return _placeholder;
167
167
  else {
168
- let options =
168
+ const options =
169
169
  selectOptions.length > 0 ? selectOptions : (value as Data[]);
170
170
  return options
171
171
  ?.reduce(
@@ -180,7 +180,7 @@ function Select<Data, Type extends 'single' | 'multi'>({
180
180
  .slice(0, -2);
181
181
  }
182
182
  } else {
183
- if (value === undefined) return _placeholder;
183
+ if (!value) return _placeholder;
184
184
  const selectedOption = selectOptions?.find(
185
185
  (option, index) =>
186
186
  keyExtractor(option, index) == keyExtractor(value as Data, index)
package/src/index.ts CHANGED
@@ -1,33 +1,39 @@
1
1
  export * from '@tecsinapse/react-core';
2
- export { Header, HeaderProps } from './components/atoms/Header';
3
- export { Select, SelectNativeProps } from './components/molecules/Select';
4
- export { Input, InputNativeProps } from './components/atoms/Input';
5
- export { InputMask, InputMaskNativeProps } from './components/atoms/InputMask';
6
- export { TextArea, TextAreaProps } from './components/atoms/TextArea';
7
- export { Text, TextNativeProps } from './components/atoms/Text';
2
+ export { Avatar } from './components/atoms/Avatar';
3
+ export { Badge, BadgeNativeProps } from './components/atoms/Badge';
8
4
  export {
5
+ BottomNavigator,
6
+ BottomNavigatorProps,
7
+ } from './components/atoms/BottomNavigator';
8
+ export {
9
+ Button,
10
+ ButtonNativeProps,
9
11
  Error,
10
12
  Loading,
11
13
  Success,
12
- Button,
13
- ButtonNativeProps,
14
14
  } from './components/atoms/Button';
15
15
  export { GroupButtonOption } from './components/atoms/GroupButton';
16
+ export { Header, HeaderProps } from './components/atoms/Header';
17
+ export { Input, InputNativeProps } from './components/atoms/Input';
18
+ export { InputMask, InputMaskNativeProps } from './components/atoms/InputMask';
16
19
  export {
17
- InputPassword,
18
- InputPasswordNativeProps,
19
- } from './components/molecules/InputPassword';
20
- export {
21
- BottomNavigator,
22
- BottomNavigatorProps,
23
- } from './components/atoms/BottomNavigator';
24
- export { Tag, TagProps } from './components/atoms/Tag';
20
+ IBaseModal,
21
+ ModalGroupManager,
22
+ ModalLifecycleHandler,
23
+ ModalView,
24
+ useLazyModalManager,
25
+ useModalManager,
26
+ useModalRemoteControl,
27
+ } from './components/atoms/Modal';
28
+ export { Skeleton, SkeletonProps } from './components/atoms/Skeleton';
25
29
  export {
26
30
  SnappingSlider,
27
31
  SnappingSliderProps,
28
32
  } from './components/atoms/SnappingSlider';
29
- export { Badge, BadgeNativeProps } from './components/atoms/Badge';
30
- export { Snackbar, SnackbarNativeProps } from './components/molecules/Snackbar';
33
+ export { Tag, TagProps } from './components/atoms/Tag';
34
+ export { Text, TextNativeProps } from './components/atoms/Text';
35
+ export { TextArea, TextAreaProps } from './components/atoms/TextArea';
36
+ export { Calendar } from './components/molecules/Calendar';
31
37
  export {
32
38
  DatePicker,
33
39
  NativeDatePickerProps,
@@ -36,16 +42,19 @@ export {
36
42
  DateTimePicker,
37
43
  NativeDateTimePickerProps,
38
44
  } from './components/molecules/DateTimePicker';
39
- export { Avatar } from './components/atoms/Avatar';
40
- export { Calendar } from './components/molecules/Calendar';
41
45
  export { DateTimeSelector } from './components/molecules/DateTimeSelector';
42
46
  export {
43
- ModalGroupManager,
44
- ModalView,
45
- ModalLifecycleHandler,
46
- useLazyModalManager,
47
- useModalManager,
48
- useModalRemoteControl,
49
- IBaseModal,
50
- } from './components/atoms/Modal';
51
- export { Skeleton, SkeletonProps } from './components/atoms/Skeleton';
47
+ IconTextButton,
48
+ NativeIconTextButtonProps,
49
+ } from './components/molecules/IconTextButton';
50
+ export {
51
+ InputPassword,
52
+ InputPasswordNativeProps,
53
+ } from './components/molecules/InputPassword';
54
+ export {
55
+ LabeledSwitch,
56
+ LabeledSwitchNativeProps,
57
+ } from './components/molecules/LabeledSwitch';
58
+ export { Select, SelectNativeProps } from './components/molecules/Select';
59
+ export { Snackbar, SnackbarNativeProps } from './components/molecules/Snackbar';
60
+ export { Grid, GridItem } from './components/molecules/Grid';