@tecsinapse/react-core 1.12.8 → 1.14.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 +35 -0
- package/dist/components/atoms/Input/InputElement/InputElement.d.ts +5 -3
- package/dist/components/atoms/Input/InputElement/InputElement.js +22 -8
- package/dist/components/atoms/Input/InputElement/InputElement.js.map +1 -1
- package/dist/components/atoms/Input/hooks/useNumberMask.d.ts +8 -0
- package/dist/components/atoms/Input/hooks/useNumberMask.js +98 -0
- package/dist/components/atoms/Input/hooks/useNumberMask.js.map +1 -0
- package/dist/components/atoms/Input/hooks/useStringMask.d.ts +8 -0
- package/dist/components/atoms/Input/hooks/useStringMask.js +109 -0
- package/dist/components/atoms/Input/hooks/useStringMask.js.map +1 -0
- package/dist/components/atoms/Input/index.d.ts +2 -3
- package/dist/components/atoms/Input/index.js +12 -26
- package/dist/components/atoms/Input/index.js.map +1 -1
- package/dist/components/atoms/ProgressBar/ProgressBar.d.ts +1 -1
- package/dist/components/atoms/ProgressBar/ProgressBar.js +6 -6
- package/dist/components/atoms/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/molecules/Calendar/components/MonthWeek.js +5 -10
- package/dist/components/molecules/Calendar/components/MonthWeek.js.map +1 -1
- package/dist/components/molecules/Calendar/index.d.ts +1 -1
- package/dist/components/molecules/Calendar/index.js +6 -0
- package/dist/components/molecules/Calendar/index.js.map +1 -1
- package/dist/components/molecules/Calendar/styled.js +0 -17
- package/dist/components/molecules/Calendar/styled.js.map +1 -1
- package/dist/components/molecules/DatePicker/DatePicker.d.ts +6 -5
- package/dist/components/molecules/DatePicker/DatePicker.js +22 -32
- package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/molecules/DatePicker/styled.d.ts +0 -14
- package/dist/components/molecules/DatePicker/styled.js +1 -46
- package/dist/components/molecules/DatePicker/styled.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/DateTimePicker.d.ts +5 -4
- package/dist/components/molecules/DateTimePicker/DateTimePicker.js +35 -37
- package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/styled.d.ts +0 -21
- package/dist/components/molecules/DateTimePicker/styled.js +3 -51
- package/dist/components/molecules/DateTimePicker/styled.js.map +1 -1
- package/dist/components/molecules/Grid/Item/Item.d.ts +1 -1
- package/dist/components/molecules/Grid/Item/Item.js +7 -5
- package/dist/components/molecules/Grid/Item/Item.js.map +1 -1
- package/dist/components/molecules/HintInputContainer/HintInputContainer.d.ts +3 -2
- package/dist/components/molecules/HintInputContainer/HintInputContainer.js +4 -4
- package/dist/components/molecules/HintInputContainer/HintInputContainer.js.map +1 -1
- package/dist/components/molecules/TextArea/TextArea.d.ts +3 -1
- package/dist/components/molecules/TextArea/TextArea.js +4 -4
- package/dist/components/molecules/TextArea/TextArea.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -29
- package/dist/index.js.map +1 -1
- package/dist/utils/ResponsiveFontSize.js +1 -1
- package/dist/utils/ResponsiveFontSize.js.map +1 -1
- package/dist/utils/formatWithMask.d.ts +3 -0
- package/dist/utils/formatWithMask.js +31 -0
- package/dist/utils/formatWithMask.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +28 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/masks.d.ts +10 -0
- package/dist/utils/masks.js +18 -0
- package/dist/utils/masks.js.map +1 -0
- package/package.json +2 -2
- package/src/components/atoms/Input/InputElement/InputElement.tsx +37 -11
- package/src/components/atoms/Input/hooks/useNumberMask.ts +99 -0
- package/src/components/atoms/Input/hooks/useStringMask.ts +126 -0
- package/src/components/atoms/Input/index.ts +2 -3
- package/src/components/atoms/ProgressBar/ProgressBar.tsx +5 -5
- package/src/components/molecules/Calendar/components/MonthWeek.tsx +5 -10
- package/src/components/molecules/Calendar/index.ts +1 -0
- package/src/components/molecules/Calendar/styled.ts +0 -22
- package/src/components/molecules/DatePicker/DatePicker.tsx +32 -41
- package/src/components/molecules/DatePicker/styled.ts +0 -40
- package/src/components/molecules/DateTimePicker/DateTimePicker.tsx +46 -52
- package/src/components/molecules/DateTimePicker/styled.ts +1 -49
- package/src/components/molecules/Grid/Item/Item.tsx +3 -5
- package/src/components/molecules/HintInputContainer/HintInputContainer.tsx +3 -8
- package/src/components/molecules/TextArea/TextArea.tsx +3 -9
- package/src/index.ts +3 -5
- package/src/utils/ResponsiveFontSize.ts +2 -2
- package/src/utils/formatWithMask.ts +25 -0
- package/src/utils/index.ts +4 -2
- package/src/utils/masks.ts +13 -0
- package/dist/components/atoms/Input/hooks/useCurrencyMask.d.ts +0 -3
- package/dist/components/atoms/Input/hooks/useCurrencyMask.js +0 -69
- package/dist/components/atoms/Input/hooks/useCurrencyMask.js.map +0 -1
- package/dist/components/atoms/Input/hooks/useMask.d.ts +0 -9
- package/dist/components/atoms/Input/hooks/useMask.js +0 -61
- package/dist/components/atoms/Input/hooks/useMask.js.map +0 -1
- package/dist/components/atoms/Input/masks/index.d.ts +0 -10
- package/dist/components/atoms/Input/masks/index.js +0 -18
- package/dist/components/atoms/Input/masks/index.js.map +0 -1
- package/dist/components/molecules/DatePicker/Modal.d.ts +0 -8
- package/dist/components/molecules/DatePicker/Modal.js +0 -60
- package/dist/components/molecules/DatePicker/Modal.js.map +0 -1
- package/dist/components/molecules/DateTimePicker/Modal.d.ts +0 -7
- package/dist/components/molecules/DateTimePicker/Modal.js +0 -89
- package/dist/components/molecules/DateTimePicker/Modal.js.map +0 -1
- package/src/components/atoms/Input/hooks/useCurrencyMask.ts +0 -74
- package/src/components/atoms/Input/hooks/useMask.ts +0 -92
- package/src/components/atoms/Input/masks/index.ts +0 -12
- package/src/components/molecules/DatePicker/DatePicker.stories.tsx +0 -44
- package/src/components/molecules/DatePicker/Modal.tsx +0 -51
- package/src/components/molecules/DateTimePicker/DateTimePicker.stories.tsx +0 -26
- package/src/components/molecules/DateTimePicker/Modal.tsx +0 -84
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import { format as formatDate } from 'date-fns';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { ModalBaseProps } from 'react-native';
|
|
4
3
|
import { InputContainerProps, useInputFocus } from '../../atoms/Input';
|
|
5
4
|
import { Text, TextProps } from '../../atoms/Text';
|
|
6
5
|
import { CalendarIcon, getStyledTextComponent } from '../DatePicker/styled';
|
|
7
|
-
import { DateTimeSelectorProps } from '../DateTimeSelector';
|
|
8
|
-
import { DateTimePickerModalProps, Modal } from './Modal';
|
|
6
|
+
import { DateTimeSelector, DateTimeSelectorProps } from '../DateTimeSelector';
|
|
9
7
|
import { HintInputContainer } from '../HintInputContainer';
|
|
8
|
+
import { getStyledDateTimeSelector } from './styled';
|
|
10
9
|
|
|
11
|
-
export interface DateTimePickerProps
|
|
12
|
-
extends InputContainerProps,
|
|
13
|
-
DateTimePickerModalProps,
|
|
14
|
-
Omit<DateTimeSelectorProps, 'style'> {
|
|
10
|
+
export interface DateTimePickerProps extends InputContainerProps, Omit<DateTimeSelectorProps, 'style'> {
|
|
15
11
|
controlComponent?: (
|
|
16
12
|
onPress: () => void,
|
|
17
13
|
displayValue?: string
|
|
18
14
|
) => JSX.Element;
|
|
19
15
|
TextComponent?: React.FC<TextProps>;
|
|
20
|
-
|
|
16
|
+
DateTimeSelectorComponent: React.FC<DateTimeSelectorProps>;
|
|
21
17
|
placeholder?: string;
|
|
22
18
|
onFocus?: () => void | never;
|
|
23
19
|
onBlur?: () => void | never;
|
|
20
|
+
renderSelector: (selector: React.ReactElement, blur?: () => void) => JSX.Element|null
|
|
21
|
+
requestShowSelector: () => void
|
|
22
|
+
requestCloseSelector: () => void
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
@@ -34,7 +33,6 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
|
34
33
|
offsetThreshold,
|
|
35
34
|
upperOffsetThreshold,
|
|
36
35
|
lowerOffsetThreshold,
|
|
37
|
-
|
|
38
36
|
dateModalTitle,
|
|
39
37
|
timeModalTitle,
|
|
40
38
|
dateConfirmButtonText,
|
|
@@ -44,7 +42,6 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
|
44
42
|
yearLabel,
|
|
45
43
|
hourLabel,
|
|
46
44
|
minuteLabel,
|
|
47
|
-
|
|
48
45
|
placeholder,
|
|
49
46
|
onFocus,
|
|
50
47
|
onBlur,
|
|
@@ -54,45 +51,68 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
|
54
51
|
hint,
|
|
55
52
|
variant = 'default',
|
|
56
53
|
TextComponent = Text,
|
|
57
|
-
DateTimeSelectorComponent,
|
|
58
|
-
bottomOffset,
|
|
54
|
+
DateTimeSelectorComponent = DateTimeSelector,
|
|
59
55
|
rightComponent,
|
|
60
|
-
animationType = 'fade',
|
|
61
56
|
style,
|
|
57
|
+
renderSelector,
|
|
58
|
+
requestShowSelector,
|
|
59
|
+
requestCloseSelector,
|
|
62
60
|
...rest
|
|
63
61
|
}) => {
|
|
62
|
+
|
|
64
63
|
const { focused, handleBlur, handleFocus } = useInputFocus(
|
|
65
64
|
onFocus,
|
|
66
65
|
onBlur,
|
|
67
66
|
!disabled
|
|
68
67
|
);
|
|
69
68
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const handlePressInput = () => {
|
|
73
|
-
setModalVisible(true);
|
|
69
|
+
const handleShowSelector = () => {
|
|
70
|
+
requestShowSelector()
|
|
74
71
|
handleFocus();
|
|
75
72
|
};
|
|
76
73
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
const handleChoosing = (value: Date) => {
|
|
75
|
+
onChange?.(value)
|
|
76
|
+
requestCloseSelector()
|
|
80
77
|
};
|
|
81
78
|
|
|
82
79
|
const StyledText = getStyledTextComponent(TextComponent);
|
|
83
|
-
const displayValue =
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
const displayValue = (value ? formatDate(value, format, { locale: locale }) : placeholder) || ' ';
|
|
81
|
+
const StyledDateTimeSelector = getStyledDateTimeSelector(DateTimeSelectorComponent)
|
|
82
|
+
|
|
83
|
+
const dateTimeSelector = (
|
|
84
|
+
<StyledDateTimeSelector
|
|
85
|
+
value={value}
|
|
86
|
+
mode={mode}
|
|
87
|
+
format={format}
|
|
88
|
+
locale={locale}
|
|
89
|
+
upperDateThreshold={upperDateThreshold}
|
|
90
|
+
lowerDateThreshold={lowerDateThreshold}
|
|
91
|
+
offsetThreshold={offsetThreshold}
|
|
92
|
+
upperOffsetThreshold={upperOffsetThreshold}
|
|
93
|
+
lowerOffsetThreshold={lowerOffsetThreshold}
|
|
94
|
+
dateModalTitle={dateModalTitle}
|
|
95
|
+
timeModalTitle={timeModalTitle}
|
|
96
|
+
dateConfirmButtonText={dateConfirmButtonText}
|
|
97
|
+
timeConfirmButtonText={timeConfirmButtonText}
|
|
98
|
+
dayLabel={dayLabel}
|
|
99
|
+
monthLabel={monthLabel}
|
|
100
|
+
yearLabel={yearLabel}
|
|
101
|
+
hourLabel={hourLabel}
|
|
102
|
+
minuteLabel={minuteLabel}
|
|
103
|
+
onChange={handleChoosing}
|
|
104
|
+
/>
|
|
105
|
+
)
|
|
86
106
|
|
|
87
107
|
return (
|
|
88
108
|
<>
|
|
89
109
|
{controlComponent ? (
|
|
90
|
-
controlComponent(
|
|
110
|
+
controlComponent(handleShowSelector, displayValue)
|
|
91
111
|
) : (
|
|
92
112
|
<HintInputContainer
|
|
93
113
|
focused={focused}
|
|
94
114
|
viewStyle={style}
|
|
95
|
-
onPress={
|
|
115
|
+
onPress={handleShowSelector}
|
|
96
116
|
disabled={disabled}
|
|
97
117
|
LabelComponent={TextComponent}
|
|
98
118
|
variant={variant}
|
|
@@ -111,33 +131,7 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
|
111
131
|
</StyledText>
|
|
112
132
|
</HintInputContainer>
|
|
113
133
|
)}
|
|
114
|
-
|
|
115
|
-
DateTimeSelectorComponent={DateTimeSelectorComponent}
|
|
116
|
-
bottomOffset={bottomOffset}
|
|
117
|
-
visible={modalVisible}
|
|
118
|
-
onRequestClose={handleCloseModal}
|
|
119
|
-
animated
|
|
120
|
-
animationType={animationType}
|
|
121
|
-
onChange={onChange}
|
|
122
|
-
value={value}
|
|
123
|
-
mode={mode}
|
|
124
|
-
format={format}
|
|
125
|
-
locale={locale}
|
|
126
|
-
upperDateThreshold={upperDateThreshold}
|
|
127
|
-
lowerDateThreshold={lowerDateThreshold}
|
|
128
|
-
offsetThreshold={offsetThreshold}
|
|
129
|
-
upperOffsetThreshold={upperOffsetThreshold}
|
|
130
|
-
lowerOffsetThreshold={lowerOffsetThreshold}
|
|
131
|
-
dateModalTitle={dateModalTitle}
|
|
132
|
-
timeModalTitle={timeModalTitle}
|
|
133
|
-
dateConfirmButtonText={dateConfirmButtonText}
|
|
134
|
-
timeConfirmButtonText={timeConfirmButtonText}
|
|
135
|
-
dayLabel={dayLabel}
|
|
136
|
-
monthLabel={monthLabel}
|
|
137
|
-
yearLabel={yearLabel}
|
|
138
|
-
hourLabel={hourLabel}
|
|
139
|
-
minuteLabel={minuteLabel}
|
|
140
|
-
/>
|
|
134
|
+
{renderSelector(dateTimeSelector, handleBlur)}
|
|
141
135
|
</>
|
|
142
136
|
);
|
|
143
137
|
};
|
|
@@ -1,56 +1,8 @@
|
|
|
1
|
-
import styled
|
|
1
|
+
import styled from '@emotion/native';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
3
|
import { StyleProps } from '../../../types/defaults';
|
|
5
|
-
import { RFValue, RFValueStr } from '../../../utils';
|
|
6
|
-
import {
|
|
7
|
-
PressableSurface,
|
|
8
|
-
PressableSurfaceProps
|
|
9
|
-
} from '../../atoms/PressableSurface';
|
|
10
4
|
import { DateTimeSelectorProps } from '../DateTimeSelector';
|
|
11
5
|
|
|
12
|
-
const isWeb = Platform.OS === 'web';
|
|
13
|
-
|
|
14
|
-
export const StyledPressableSurface = styled(
|
|
15
|
-
PressableSurface
|
|
16
|
-
)<PressableSurfaceProps>`
|
|
17
|
-
width: 100%;
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
export const Backdrop = styled(PressableSurface)<Partial<StyleProps>>`
|
|
21
|
-
${isWeb
|
|
22
|
-
? css`
|
|
23
|
-
justify-content: center;
|
|
24
|
-
align-items: center;
|
|
25
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
26
|
-
height: 100vh;
|
|
27
|
-
`
|
|
28
|
-
: css`
|
|
29
|
-
justify-content: flex-end;
|
|
30
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
31
|
-
height: 100%;
|
|
32
|
-
`}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
export const ModalContent = styled.View<
|
|
36
|
-
{ offset: number } & Partial<StyleProps>
|
|
37
|
-
>`
|
|
38
|
-
background-color: transparent;
|
|
39
|
-
padding-bottom: ${({ offset }) => `${RFValue(offset)}px`};
|
|
40
|
-
${({ theme: { borderRadius } }) => css`
|
|
41
|
-
${isWeb
|
|
42
|
-
? `
|
|
43
|
-
width: ${RFValueStr('375px')};
|
|
44
|
-
border-radius: ${borderRadius.micro};
|
|
45
|
-
`
|
|
46
|
-
: `
|
|
47
|
-
border-top-left-radius: ${borderRadius.deca};
|
|
48
|
-
border-top-right-radius: ${borderRadius.deca};
|
|
49
|
-
`}
|
|
50
|
-
`}
|
|
51
|
-
overflow: hidden;
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
6
|
export const getStyledDateTimeSelector = (
|
|
55
7
|
component: FC<DateTimeSelectorProps>
|
|
56
8
|
) => {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
extractNumbersFromString,
|
|
4
|
-
SpacingType,
|
|
5
|
-
useTheme,
|
|
6
|
-
} from '@tecsinapse/react-core';
|
|
7
2
|
import { View } from 'react-native';
|
|
3
|
+
import { useTheme } from '../../../../hooks';
|
|
4
|
+
import { SpacingType } from '../../../../types/defaults';
|
|
5
|
+
import { extractNumbersFromString } from '../../../../utils';
|
|
8
6
|
|
|
9
7
|
type FlexPositioning = 'flex-start' | 'flex-end' | 'center';
|
|
10
8
|
type FlexAlignBase = FlexPositioning | 'stretch';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Hint,
|
|
3
|
-
InputVariantType,
|
|
4
|
-
PressableInputContainer,
|
|
5
|
-
PressableInputContainerProps,
|
|
6
|
-
TextProps,
|
|
7
|
-
} from '@tecsinapse/react-core';
|
|
8
|
-
import { StyleProp, View, ViewStyle } from 'react-native';
|
|
9
1
|
import * as React from 'react';
|
|
2
|
+
import { StyleProp, View, ViewStyle } from 'react-native';
|
|
3
|
+
import { Hint, InputVariantType, PressableInputContainer, PressableInputContainerProps } from '../../atoms/Input';
|
|
4
|
+
import { TextProps } from '../../atoms/Text';
|
|
10
5
|
|
|
11
6
|
export interface HintInputContainerProps extends PressableInputContainerProps {
|
|
12
7
|
viewStyle?: StyleProp<ViewStyle>;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
FontStackType,
|
|
4
|
-
FontWeightType,
|
|
5
|
-
Hint,
|
|
6
|
-
InputContainerProps,
|
|
7
|
-
InputElementProps,
|
|
8
|
-
TextProps,
|
|
9
|
-
} from '@tecsinapse/react-core';
|
|
10
2
|
import { View } from 'react-native';
|
|
3
|
+
import { FontStackType, FontWeightType } from '../../../types/defaults';
|
|
4
|
+
import { Hint, InputContainerProps, InputElementProps } from '../../atoms/Input';
|
|
5
|
+
import { Text, TextProps } from '../../atoms/Text';
|
|
11
6
|
import { StyledInputContainer } from './styled';
|
|
12
|
-
import { Text } from '../../atoms/Text';
|
|
13
7
|
|
|
14
8
|
export interface TextAreaProps
|
|
15
9
|
extends Omit<InputElementProps, 'style' | 'multiline' | 'value'>,
|
package/src/index.ts
CHANGED
|
@@ -31,16 +31,13 @@ export {
|
|
|
31
31
|
InputElement,
|
|
32
32
|
InputElementProps,
|
|
33
33
|
InputVariantType,
|
|
34
|
-
Masks,
|
|
35
34
|
PressableInputContainer,
|
|
36
35
|
PressableInputContainerProps,
|
|
37
36
|
StyledBorderKeeper,
|
|
38
|
-
useCurrencyMask,
|
|
39
37
|
useInputFocus,
|
|
40
|
-
|
|
38
|
+
useNumberMask,
|
|
39
|
+
useStringMask,
|
|
41
40
|
disabledInputStyles,
|
|
42
|
-
IMask,
|
|
43
|
-
IMaskValue,
|
|
44
41
|
} from './components/atoms/Input';
|
|
45
42
|
export { Paper, PaperProps } from './components/atoms/Paper';
|
|
46
43
|
export {
|
|
@@ -57,6 +54,7 @@ export {
|
|
|
57
54
|
CalendarProps,
|
|
58
55
|
DateRange,
|
|
59
56
|
SelectionType,
|
|
57
|
+
Value,
|
|
60
58
|
} from './components/molecules/Calendar';
|
|
61
59
|
export { DatePicker, DatePickerProps } from './components/molecules/DatePicker';
|
|
62
60
|
export {
|
|
@@ -2,7 +2,7 @@ import { Dimensions, Platform, StatusBar } from "react-native";
|
|
|
2
2
|
import { extractNumbersFromString } from "./extractNumbersFromString";
|
|
3
3
|
import { isIphoneX } from "./IPhoneXHelper";
|
|
4
4
|
|
|
5
|
-
const STANDARD_SCREEN_HEIGHT =
|
|
5
|
+
const STANDARD_SCREEN_HEIGHT = 680
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Use this function when you want to scale a percentage number
|
|
@@ -40,7 +40,7 @@ export const RFValue = (fontSize: number, standardScreenHeight: number = STANDAR
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* Same
|
|
43
|
+
* Same as RFValue, however you can provide string values. E.g: '10px', '-5px'.
|
|
44
44
|
*
|
|
45
45
|
* @param fontSize
|
|
46
46
|
* @param standardScreenHeight
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MaskType,
|
|
3
|
+
CurrencyOptions,
|
|
4
|
+
getMask,
|
|
5
|
+
mergeMask,
|
|
6
|
+
getInternalNumberAndMask,
|
|
7
|
+
} from '../components/atoms/Input';
|
|
8
|
+
import currency from 'currency.js';
|
|
9
|
+
|
|
10
|
+
export const formatWithMask = (
|
|
11
|
+
mask: (MaskType[] | ((value: string) => MaskType[])) | CurrencyOptions,
|
|
12
|
+
value: string | number
|
|
13
|
+
): string | number => {
|
|
14
|
+
if (Array.isArray(mask) || typeof mask === 'function') {
|
|
15
|
+
const selectedMask = getMask(mask, String(value));
|
|
16
|
+
const { formatted } = mergeMask(String(value), selectedMask);
|
|
17
|
+
return formatted || '';
|
|
18
|
+
} else {
|
|
19
|
+
const { internalNumber, mergedOptions } = getInternalNumberAndMask(
|
|
20
|
+
value,
|
|
21
|
+
mask
|
|
22
|
+
);
|
|
23
|
+
return currency(internalNumber).format(mergedOptions);
|
|
24
|
+
}
|
|
25
|
+
};
|
package/src/utils/index.ts
CHANGED
|
@@ -3,5 +3,7 @@ export {
|
|
|
3
3
|
extractNumbersFromString,
|
|
4
4
|
extractDigitsFromString,
|
|
5
5
|
} from './extractNumbersFromString';
|
|
6
|
-
export * from './IPhoneXHelper'
|
|
7
|
-
export * from './ResponsiveFontSize'
|
|
6
|
+
export * from './IPhoneXHelper';
|
|
7
|
+
export * from './ResponsiveFontSize';
|
|
8
|
+
export * from './masks';
|
|
9
|
+
export * from './formatWithMask';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// NOTE: Add here all individually utils, then you can use it on input components everywhere.
|
|
2
|
+
export const Masks = {
|
|
3
|
+
CPF: ['999.999.999-99'],
|
|
4
|
+
CNPJ: ['99.999.999/9999-99'],
|
|
5
|
+
DATE: ['99/99/9999'],
|
|
6
|
+
MONTH_YEAR: ['99/9999'],
|
|
7
|
+
CEP: ['99999-999'],
|
|
8
|
+
PHONE: ['(99) 9999-9999'],
|
|
9
|
+
PHONE_EXTENDED: ['(99) 99999-9999'],
|
|
10
|
+
COMBINED_PHONE: (value: string) =>
|
|
11
|
+
// Value in formatted mode
|
|
12
|
+
value?.length <= 14 ? Masks.PHONE : Masks.PHONE_EXTENDED,
|
|
13
|
+
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useCurrencyMask = void 0;
|
|
7
|
-
|
|
8
|
-
var _currency = _interopRequireDefault(require("currency.js"));
|
|
9
|
-
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
|
|
12
|
-
var _reactCore = require("@tecsinapse/react-core");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
const DEFAULT_OPTIONS = {
|
|
17
|
-
symbol: 'R$ ',
|
|
18
|
-
separator: '.',
|
|
19
|
-
decimal: ',',
|
|
20
|
-
precision: 2
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const useCurrencyMask = (options, defaultValue) => {
|
|
24
|
-
const getRegex = (0, _react.useCallback)(precision => new RegExp(`\\B(?=(\\d{${precision}})(?!\\d))`, 'g'), [options]);
|
|
25
|
-
const applyMask = (0, _react.useCallback)((value = '') => {
|
|
26
|
-
const mergedOptions = { ...DEFAULT_OPTIONS,
|
|
27
|
-
...options
|
|
28
|
-
};
|
|
29
|
-
const {
|
|
30
|
-
precision = -1
|
|
31
|
-
} = mergedOptions;
|
|
32
|
-
const onlyNumbers = String((0, _reactCore.extractNumbersFromString)(value));
|
|
33
|
-
const padZeros = String(onlyNumbers).padStart(precision + 1, '0');
|
|
34
|
-
let internalNumber = Number(padZeros.replace(getRegex(precision), '.'));
|
|
35
|
-
|
|
36
|
-
if (internalNumber > Number.MAX_SAFE_INTEGER) {
|
|
37
|
-
internalNumber = Number.MAX_SAFE_INTEGER;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (internalNumber < Number.MIN_SAFE_INTEGER) {
|
|
41
|
-
internalNumber = Number.MIN_SAFE_INTEGER;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
raw: internalNumber,
|
|
46
|
-
formatted: (0, _currency.default)(internalNumber).format(mergedOptions)
|
|
47
|
-
};
|
|
48
|
-
}, [options, getRegex]);
|
|
49
|
-
const [value, setValue] = (0, _react.useState)({
|
|
50
|
-
converter: applyMask,
|
|
51
|
-
maskValue: applyMask(defaultValue)
|
|
52
|
-
});
|
|
53
|
-
const handleChangeValue = (0, _react.useCallback)(formattedValue => {
|
|
54
|
-
const {
|
|
55
|
-
raw,
|
|
56
|
-
formatted
|
|
57
|
-
} = applyMask(formattedValue);
|
|
58
|
-
setValue(oldValue => ({ ...oldValue,
|
|
59
|
-
maskValue: {
|
|
60
|
-
raw,
|
|
61
|
-
formatted
|
|
62
|
-
}
|
|
63
|
-
}));
|
|
64
|
-
}, [applyMask, setValue]);
|
|
65
|
-
return [value, handleChangeValue];
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
exports.useCurrencyMask = useCurrencyMask;
|
|
69
|
-
//# sourceMappingURL=useCurrencyMask.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/atoms/Input/hooks/useCurrencyMask.ts"],"names":["DEFAULT_OPTIONS","symbol","separator","decimal","precision","useCurrencyMask","options","defaultValue","getRegex","RegExp","applyMask","value","mergedOptions","onlyNumbers","String","padZeros","padStart","internalNumber","Number","replace","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","raw","formatted","format","setValue","converter","maskValue","handleChangeValue","formattedValue","oldValue"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;AAIA,MAAMA,eAAgC,GAAG;AACvCC,EAAAA,MAAM,EAAE,KAD+B;AAEvCC,EAAAA,SAAS,EAAE,GAF4B;AAGvCC,EAAAA,OAAO,EAAE,GAH8B;AAIvCC,EAAAA,SAAS,EAAE;AAJ4B,CAAzC;;AAaO,MAAMC,eAAe,GAAG,CAC7BC,OAD6B,EAE7BC,YAF6B,KAGQ;AACrC,QAAMC,QAAQ,GAAG,wBACdJ,SAAD,IAAuB,IAAIK,MAAJ,CAAY,cAAaL,SAAU,YAAnC,EAAgD,GAAhD,CADR,EAEf,CAACE,OAAD,CAFe,CAAjB;AAKA,QAAMI,SAAS,GAAG,wBAChB,CAACC,KAAK,GAAG,EAAT,KAA4B;AAC1B,UAAMC,aAAa,GAAG,EAAE,GAAGZ,eAAL;AAAsB,SAAGM;AAAzB,KAAtB;AACA,UAAM;AAAEF,MAAAA,SAAS,GAAG,CAAC;AAAf,QAAqBQ,aAA3B;AACA,UAAMC,WAAW,GAAGC,MAAM,CAAC,yCAAyBH,KAAzB,CAAD,CAA1B;AACA,UAAMI,QAAQ,GAAGD,MAAM,CAACD,WAAD,CAAN,CAAoBG,QAApB,CAA6BZ,SAAS,GAAG,CAAzC,EAA4C,GAA5C,CAAjB;AACA,QAAIa,cAAc,GAAGC,MAAM,CAACH,QAAQ,CAACI,OAAT,CAAiBX,QAAQ,CAACJ,SAAD,CAAzB,EAAsC,GAAtC,CAAD,CAA3B;;AAEA,QAAIa,cAAc,GAAGC,MAAM,CAACE,gBAA5B,EAA8C;AAC5CH,MAAAA,cAAc,GAAGC,MAAM,CAACE,gBAAxB;AACD;;AAED,QAAIH,cAAc,GAAGC,MAAM,CAACG,gBAA5B,EAA8C;AAC5CJ,MAAAA,cAAc,GAAGC,MAAM,CAACG,gBAAxB;AACD;;AAED,WAAO;AACLC,MAAAA,GAAG,EAAEL,cADA;AAELM,MAAAA,SAAS,EAAE,uBAASN,cAAT,EAAyBO,MAAzB,CAAgCZ,aAAhC;AAFN,KAAP;AAID,GApBe,EAqBhB,CAACN,OAAD,EAAUE,QAAV,CArBgB,CAAlB;AAwBA,QAAM,CAACG,KAAD,EAAQc,QAAR,IAAoB,qBAAgB;AACxCC,IAAAA,SAAS,EAAEhB,SAD6B;AAExCiB,IAAAA,SAAS,EAAEjB,SAAS,CAACH,YAAD;AAFoB,GAAhB,CAA1B;AAKA,QAAMqB,iBAAiB,GAAG,wBACvBC,cAAD,IAA4B;AAC1B,UAAM;AAAEP,MAAAA,GAAF;AAAOC,MAAAA;AAAP,QAAqBb,SAAS,CAACmB,cAAD,CAApC;AACAJ,IAAAA,QAAQ,CAACK,QAAQ,KAAK,EACpB,GAAGA,QADiB;AAEpBH,MAAAA,SAAS,EAAE;AACTL,QAAAA,GADS;AAETC,QAAAA;AAFS;AAFS,KAAL,CAAT,CAAR;AAOD,GAVuB,EAWxB,CAACb,SAAD,EAAYe,QAAZ,CAXwB,CAA1B;AAcA,SAAO,CAACd,KAAD,EAAQiB,iBAAR,CAAP;AACD,CArDM","sourcesContent":["import currency from 'currency.js';\nimport { useCallback, useState } from 'react';\nimport { IMaskValue, IMask } from './useMask';\nimport { extractNumbersFromString } from '@tecsinapse/react-core';\n\ntype CurrencyOptions = currency.Options;\n\nconst DEFAULT_OPTIONS: CurrencyOptions = {\n symbol: 'R$ ',\n separator: '.',\n decimal: ',',\n precision: 2,\n};\n\n/**\n * TODO:\n * @param options\n * @param defaultValue\n * @returns\n */\nexport const useCurrencyMask = (\n options?: CurrencyOptions,\n defaultValue?: string\n): [IMask, (value: string) => void] => {\n const getRegex = useCallback(\n (precision: number) => new RegExp(`\\\\B(?=(\\\\d{${precision}})(?!\\\\d))`, 'g'),\n [options]\n );\n\n const applyMask = useCallback(\n (value = ''): IMaskValue => {\n const mergedOptions = { ...DEFAULT_OPTIONS, ...options };\n const { precision = -1 } = mergedOptions;\n const onlyNumbers = String(extractNumbersFromString(value));\n const padZeros = String(onlyNumbers).padStart(precision + 1, '0');\n let internalNumber = Number(padZeros.replace(getRegex(precision), '.'));\n\n if (internalNumber > Number.MAX_SAFE_INTEGER) {\n internalNumber = Number.MAX_SAFE_INTEGER;\n }\n\n if (internalNumber < Number.MIN_SAFE_INTEGER) {\n internalNumber = Number.MIN_SAFE_INTEGER;\n }\n\n return {\n raw: internalNumber,\n formatted: currency(internalNumber).format(mergedOptions),\n };\n },\n [options, getRegex]\n );\n\n const [value, setValue] = useState<IMask>({\n converter: applyMask,\n maskValue: applyMask(defaultValue),\n });\n\n const handleChangeValue = useCallback(\n (formattedValue: string) => {\n const { raw, formatted } = applyMask(formattedValue);\n setValue(oldValue => ({\n ...oldValue,\n maskValue: {\n raw,\n formatted,\n },\n }));\n },\n [applyMask, setValue]\n );\n\n return [value, handleChangeValue];\n};\n"],"file":"useCurrencyMask.js"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface IMaskValue {
|
|
2
|
-
formatted?: string;
|
|
3
|
-
raw?: any;
|
|
4
|
-
}
|
|
5
|
-
export interface IMask {
|
|
6
|
-
converter?: (raw?: string) => IMaskValue;
|
|
7
|
-
maskValue?: IMaskValue;
|
|
8
|
-
}
|
|
9
|
-
export declare const useMask: (mask: string | ((raw: any) => string), defaultValue?: string | undefined) => [IMask, (text: string) => void];
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useMask = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
|
|
10
|
-
var _reactCore = require("@tecsinapse/react-core");
|
|
11
|
-
|
|
12
|
-
const mergeMask = (value = '', mask) => {
|
|
13
|
-
const chars = '' + value;
|
|
14
|
-
let formattedValue = '';
|
|
15
|
-
|
|
16
|
-
for (let iMask = 0, iChars = 0; iMask < mask.length && iChars < chars.length; iMask++) {
|
|
17
|
-
formattedValue += mask.charAt(iMask) === '9' ? chars.charAt(iChars++) : mask.charAt(iMask);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return formattedValue;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const getMask = (value = '', mask) => {
|
|
24
|
-
if (typeof mask === 'function') {
|
|
25
|
-
return mask(value);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return mask;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const useMask = (mask, defaultValue) => {
|
|
32
|
-
const applyMask = (0, _react.useCallback)((value = '') => {
|
|
33
|
-
const onlyNumbers = value ? (0, _reactCore.extractDigitsFromString)(value) : value;
|
|
34
|
-
const selectedMask = getMask(onlyNumbers, mask);
|
|
35
|
-
const formattedValue = mergeMask(onlyNumbers, selectedMask);
|
|
36
|
-
return {
|
|
37
|
-
raw: onlyNumbers,
|
|
38
|
-
formatted: formattedValue
|
|
39
|
-
};
|
|
40
|
-
}, [mask]);
|
|
41
|
-
const [value, setValue] = (0, _react.useState)({
|
|
42
|
-
converter: applyMask,
|
|
43
|
-
maskValue: applyMask(defaultValue)
|
|
44
|
-
});
|
|
45
|
-
const handleChangeValue = (0, _react.useCallback)(value => {
|
|
46
|
-
const {
|
|
47
|
-
raw,
|
|
48
|
-
formatted
|
|
49
|
-
} = applyMask(value);
|
|
50
|
-
setValue(oldValue => ({ ...oldValue,
|
|
51
|
-
maskValue: {
|
|
52
|
-
raw,
|
|
53
|
-
formatted
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
}, [applyMask, setValue]);
|
|
57
|
-
return [value, handleChangeValue];
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
exports.useMask = useMask;
|
|
61
|
-
//# sourceMappingURL=useMask.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/atoms/Input/hooks/useMask.ts"],"names":["mergeMask","value","mask","chars","formattedValue","iMask","iChars","length","charAt","getMask","useMask","defaultValue","applyMask","onlyNumbers","selectedMask","raw","formatted","setValue","converter","maskValue","handleChangeValue","oldValue"],"mappings":";;;;;;;AAAA;;AACA;;AAkBA,MAAMA,SAAS,GAAG,CAACC,KAAK,GAAG,EAAT,EAAaC,IAAb,KAA8B;AAC9C,QAAMC,KAAK,GAAG,KAAKF,KAAnB;AACA,MAAIG,cAAc,GAAG,EAArB;;AAEA,OACE,IAAIC,KAAK,GAAG,CAAZ,EAAeC,MAAM,GAAG,CAD1B,EAEED,KAAK,GAAGH,IAAI,CAACK,MAAb,IAAuBD,MAAM,GAAGH,KAAK,CAACI,MAFxC,EAGEF,KAAK,EAHP,EAIE;AACAD,IAAAA,cAAc,IACZF,IAAI,CAACM,MAAL,CAAYH,KAAZ,MAAuB,GAAvB,GAA6BF,KAAK,CAACK,MAAN,CAAaF,MAAM,EAAnB,CAA7B,GAAsDJ,IAAI,CAACM,MAAL,CAAYH,KAAZ,CADxD;AAED;;AACD,SAAOD,cAAP;AACD,CAbD;;AAqBA,MAAMK,OAAO,GAAG,CAACR,KAAK,GAAG,EAAT,EAAaC,IAAb,KAA+D;AAC7E,MAAI,OAAOA,IAAP,KAAgB,UAApB,EAAgC;AAC9B,WAAOA,IAAI,CAACD,KAAD,CAAX;AACD;;AACD,SAAOC,IAAP;AACD,CALD;;AAaO,MAAMQ,OAAO,GAAG,CACrBR,IADqB,EAErBS,YAFqB,KAGe;AACpC,QAAMC,SAAS,GAAG,wBAChB,CAACX,KAAK,GAAG,EAAT,KAA4B;AAC1B,UAAMY,WAAW,GAAGZ,KAAK,GAAG,wCAAwBA,KAAxB,CAAH,GAAoCA,KAA7D;AACA,UAAMa,YAAY,GAAGL,OAAO,CAACI,WAAD,EAAcX,IAAd,CAA5B;AACA,UAAME,cAAc,GAAGJ,SAAS,CAACa,WAAD,EAAcC,YAAd,CAAhC;AAEA,WAAO;AACLC,MAAAA,GAAG,EAAEF,WADA;AAELG,MAAAA,SAAS,EAAEZ;AAFN,KAAP;AAID,GAVe,EAWhB,CAACF,IAAD,CAXgB,CAAlB;AAcA,QAAM,CAACD,KAAD,EAAQgB,QAAR,IAAoB,qBAAgB;AACxCC,IAAAA,SAAS,EAAEN,SAD6B;AAExCO,IAAAA,SAAS,EAAEP,SAAS,CAACD,YAAD;AAFoB,GAAhB,CAA1B;AAKA,QAAMS,iBAAiB,GAAG,wBACvBnB,KAAD,IAAmB;AACjB,UAAM;AAAEc,MAAAA,GAAF;AAAOC,MAAAA;AAAP,QAAqBJ,SAAS,CAACX,KAAD,CAApC;AACAgB,IAAAA,QAAQ,CAACI,QAAQ,KAAK,EACpB,GAAGA,QADiB;AAEpBF,MAAAA,SAAS,EAAE;AACTJ,QAAAA,GADS;AAETC,QAAAA;AAFS;AAFS,KAAL,CAAT,CAAR;AAOD,GAVuB,EAWxB,CAACJ,SAAD,EAAYK,QAAZ,CAXwB,CAA1B;AAcA,SAAO,CAAChB,KAAD,EAAQmB,iBAAR,CAAP;AACD,CAtCM","sourcesContent":["import { useCallback, useState } from 'react';\nimport { extractDigitsFromString } from '@tecsinapse/react-core';\n\nexport interface IMaskValue {\n formatted?: string;\n raw?: any;\n}\n\nexport interface IMask {\n converter?: (raw?: string) => IMaskValue;\n maskValue?: IMaskValue;\n}\n\n/**\n * TODO:\n * @param value\n * @param mask\n * @returns\n */\nconst mergeMask = (value = '', mask: string) => {\n const chars = '' + value;\n let formattedValue = '';\n\n for (\n let iMask = 0, iChars = 0;\n iMask < mask.length && iChars < chars.length;\n iMask++\n ) {\n formattedValue +=\n mask.charAt(iMask) === '9' ? chars.charAt(iChars++) : mask.charAt(iMask);\n }\n return formattedValue;\n};\n\n/**\n * TODO:\n * @param value\n * @param mask\n * @returns\n */\nconst getMask = (value = '', mask: ((raw: any) => string) | string): string => {\n if (typeof mask === 'function') {\n return mask(value);\n }\n return mask;\n};\n\n/**\n * TODO:\n * @param mask\n * @param defaultValue\n * @returns\n */\nexport const useMask = (\n mask: ((raw: any) => string) | string,\n defaultValue?: string\n): [IMask, (text: string) => void] => {\n const applyMask = useCallback(\n (value = ''): IMaskValue => {\n const onlyNumbers = value ? extractDigitsFromString(value) : value;\n const selectedMask = getMask(onlyNumbers, mask);\n const formattedValue = mergeMask(onlyNumbers, selectedMask);\n\n return {\n raw: onlyNumbers,\n formatted: formattedValue,\n };\n },\n [mask]\n );\n\n const [value, setValue] = useState<IMask>({\n converter: applyMask,\n maskValue: applyMask(defaultValue),\n });\n\n const handleChangeValue = useCallback(\n (value: string) => {\n const { raw, formatted } = applyMask(value);\n setValue(oldValue => ({\n ...oldValue,\n maskValue: {\n raw,\n formatted,\n },\n }));\n },\n [applyMask, setValue]\n );\n\n return [value, handleChangeValue];\n};\n"],"file":"useMask.js"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Masks = void 0;
|
|
7
|
-
const Masks = {
|
|
8
|
-
CPF: '999.999.999-99',
|
|
9
|
-
CNPJ: '99.999.999/9999-99',
|
|
10
|
-
DATE: '99/99/9999',
|
|
11
|
-
MONTH_YEAR: '99/9999',
|
|
12
|
-
CEP: '99999-999',
|
|
13
|
-
PHONE: '(99) 9999-9999',
|
|
14
|
-
PHONE_EXTENDED: '(99) 99999-9999',
|
|
15
|
-
COMBINED_PHONE: value => (value === null || value === void 0 ? void 0 : value.length) <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED
|
|
16
|
-
};
|
|
17
|
-
exports.Masks = Masks;
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/atoms/Input/masks/index.ts"],"names":["Masks","CPF","CNPJ","DATE","MONTH_YEAR","CEP","PHONE","PHONE_EXTENDED","COMBINED_PHONE","value","length"],"mappings":";;;;;;AACO,MAAMA,KAAK,GAAG;AACnBC,EAAAA,GAAG,EAAE,gBADc;AAEnBC,EAAAA,IAAI,EAAE,oBAFa;AAGnBC,EAAAA,IAAI,EAAE,YAHa;AAInBC,EAAAA,UAAU,EAAE,SAJO;AAKnBC,EAAAA,GAAG,EAAE,WALc;AAMnBC,EAAAA,KAAK,EAAE,gBANY;AAOnBC,EAAAA,cAAc,EAAE,iBAPG;AAQnBC,EAAAA,cAAc,EAAGC,KAAD,IACd,CAAAA,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEC,MAAP,KAAiB,EAAjB,GAAsBV,KAAK,CAACM,KAA5B,GAAoCN,KAAK,CAACO;AATzB,CAAd","sourcesContent":["// NOTE: Add here all individually masks, then you can use it on input components everywhere.\nexport const Masks = {\n CPF: '999.999.999-99',\n CNPJ: '99.999.999/9999-99',\n DATE: '99/99/9999',\n MONTH_YEAR: '99/9999',\n CEP: '99999-999',\n PHONE: '(99) 9999-9999',\n PHONE_EXTENDED: '(99) 99999-9999',\n COMBINED_PHONE: (value: string) =>\n value?.length <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED,\n};\n"],"file":"index.js"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ModalProps } from 'react-native';
|
|
3
|
-
import { CalendarProps, SelectionType } from '../Calendar';
|
|
4
|
-
export interface DatePickerModalProps<T extends SelectionType> {
|
|
5
|
-
CalendarComponent?: React.FC<CalendarProps<T>>;
|
|
6
|
-
bottomOffset?: number;
|
|
7
|
-
}
|
|
8
|
-
export declare const Modal: <T extends SelectionType>({ type, value, onRequestClose, month, year, onChange, CalendarComponent, bottomOffset, locale, ...modalProps }: CalendarProps<T> & import("react-native").ModalBaseProps & import("react-native").ModalPropsIOS & import("react-native").ModalPropsAndroid & import("react-native").ViewProps & DatePickerModalProps<T>) => JSX.Element;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Modal = void 0;
|
|
7
|
-
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
|
-
var _Calendar = require("../Calendar");
|
|
13
|
-
|
|
14
|
-
var _styled = require("./styled");
|
|
15
|
-
|
|
16
|
-
var _reactCore = require("@tecsinapse/react-core");
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
|
-
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); }
|
|
23
|
-
|
|
24
|
-
const Component = ({
|
|
25
|
-
type,
|
|
26
|
-
value,
|
|
27
|
-
onRequestClose,
|
|
28
|
-
month,
|
|
29
|
-
year,
|
|
30
|
-
onChange,
|
|
31
|
-
CalendarComponent = _Calendar.Calendar,
|
|
32
|
-
bottomOffset = 0,
|
|
33
|
-
locale,
|
|
34
|
-
...modalProps
|
|
35
|
-
}) => {
|
|
36
|
-
return React.createElement(_reactNative.Modal, _extends({
|
|
37
|
-
transparent: true,
|
|
38
|
-
hardwareAccelerated: true,
|
|
39
|
-
statusBarTranslucent: true
|
|
40
|
-
}, modalProps, {
|
|
41
|
-
onRequestClose: onRequestClose
|
|
42
|
-
}), React.createElement(_styled.Backdrop, {
|
|
43
|
-
onPress: onRequestClose,
|
|
44
|
-
effect: "none"
|
|
45
|
-
}, React.createElement(_reactCore.PressableSurface, null, React.createElement(_styled.ModalContent, {
|
|
46
|
-
offset: bottomOffset
|
|
47
|
-
}, React.createElement(CalendarComponent, {
|
|
48
|
-
pointerEvents: 'box-none',
|
|
49
|
-
type: type,
|
|
50
|
-
value: value,
|
|
51
|
-
month: month,
|
|
52
|
-
year: year,
|
|
53
|
-
onChange: onChange,
|
|
54
|
-
locale: locale
|
|
55
|
-
})))));
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const Modal = Component;
|
|
59
|
-
exports.Modal = Modal;
|
|
60
|
-
//# sourceMappingURL=Modal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/molecules/DatePicker/Modal.tsx"],"names":["Component","type","value","onRequestClose","month","year","onChange","CalendarComponent","Calendar","bottomOffset","locale","modalProps","Modal"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAOA,MAAMA,SAAS,GAAG,CAA0B;AAC1CC,EAAAA,IAD0C;AAE1CC,EAAAA,KAF0C;AAG1CC,EAAAA,cAH0C;AAI1CC,EAAAA,KAJ0C;AAK1CC,EAAAA,IAL0C;AAM1CC,EAAAA,QAN0C;AAO1CC,EAAAA,iBAAiB,GAAGC,kBAPsB;AAQ1CC,EAAAA,YAAY,GAAG,CAR2B;AAS1CC,EAAAA,MAT0C;AAU1C,KAAGC;AAVuC,CAA1B,KAW0D;AAC1E,SACE,oBAAC,kBAAD;AACE,IAAA,WAAW,MADb;AAEE,IAAA,mBAAmB,MAFrB;AAGE,IAAA,oBAAoB;AAHtB,KAIMA,UAJN;AAKE,IAAA,cAAc,EAAER;AALlB,MAOE,oBAAC,gBAAD;AAAU,IAAA,OAAO,EAAEA,cAAnB;AAAmC,IAAA,MAAM,EAAC;AAA1C,KACE,oBAAC,2BAAD,QACE,oBAAC,oBAAD;AAAc,IAAA,MAAM,EAAEM;AAAtB,KACE,oBAAC,iBAAD;AACE,IAAA,aAAa,EAAE,UADjB;AAEE,IAAA,IAAI,EAAER,IAFR;AAGE,IAAA,KAAK,EAAEC,KAHT;AAIE,IAAA,KAAK,EAAEE,KAJT;AAKE,IAAA,IAAI,EAAEC,IALR;AAME,IAAA,QAAQ,EAAEC,QANZ;AAOE,IAAA,MAAM,EAAEI;AAPV,IADF,CADF,CADF,CAPF,CADF;AAyBD,CArCD;;AAuCO,MAAME,KAAK,GAAGZ,SAAd","sourcesContent":["import * as React from 'react';\nimport { Modal as RNModal, ModalProps } from 'react-native';\nimport { Calendar, CalendarProps, SelectionType } from '../Calendar';\nimport { Backdrop, ModalContent } from './styled';\nimport { PressableSurface } from '@tecsinapse/react-core';\n\nexport interface DatePickerModalProps<T extends SelectionType> {\n CalendarComponent?: React.FC<CalendarProps<T>>;\n bottomOffset?: number;\n}\n\nconst Component = <T extends SelectionType>({\n type,\n value,\n onRequestClose,\n month,\n year,\n onChange,\n CalendarComponent = Calendar,\n bottomOffset = 0,\n locale,\n ...modalProps\n}: CalendarProps<T> & ModalProps & DatePickerModalProps<T>): JSX.Element => {\n return (\n <RNModal\n transparent\n hardwareAccelerated\n statusBarTranslucent\n {...modalProps}\n onRequestClose={onRequestClose}\n >\n <Backdrop onPress={onRequestClose} effect=\"none\">\n <PressableSurface>\n <ModalContent offset={bottomOffset}>\n <CalendarComponent\n pointerEvents={'box-none'}\n type={type}\n value={value}\n month={month}\n year={year}\n onChange={onChange}\n locale={locale}\n />\n </ModalContent>\n </PressableSurface>\n </Backdrop>\n </RNModal>\n );\n};\n\nexport const Modal = Component;\n"],"file":"Modal.js"}
|