@tecsinapse/react-core 1.9.0 → 1.10.3
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 +47 -0
- package/dist/components/atoms/Avatar/styled.js +0 -3
- package/dist/components/atoms/Avatar/styled.js.map +1 -1
- package/dist/components/atoms/BoxContent/styled.d.ts +10 -1
- package/dist/components/atoms/BoxContent/styled.js.map +1 -1
- package/dist/components/atoms/Button/States/Error.js +2 -2
- package/dist/components/atoms/Button/States/Error.js.map +1 -1
- package/dist/components/atoms/Button/States/Success.js +2 -2
- package/dist/components/atoms/Button/States/Success.js.map +1 -1
- package/dist/components/atoms/GroupButton/GroupButton.d.ts +2 -1
- package/dist/components/atoms/GroupButton/GroupButton.js +3 -2
- package/dist/components/atoms/GroupButton/GroupButton.js.map +1 -1
- package/dist/components/atoms/GroupButton/GroupButtonOption.d.ts +2 -2
- package/dist/components/atoms/GroupButton/GroupButtonOption.js.map +1 -1
- package/dist/components/atoms/GroupButton/styled.d.ts +1 -1
- package/dist/components/atoms/GroupButton/styled.js +8 -0
- package/dist/components/atoms/GroupButton/styled.js.map +1 -1
- package/dist/components/atoms/Input/InputElement/InputElement.d.ts +5 -4
- package/dist/components/atoms/Input/InputElement/InputElement.js +5 -3
- package/dist/components/atoms/Input/InputElement/InputElement.js.map +1 -1
- package/dist/components/atoms/Input/hooks/useCurrencyMask.d.ts +2 -2
- package/dist/components/atoms/Input/hooks/useCurrencyMask.js.map +1 -1
- package/dist/components/atoms/Input/hooks/useMask.d.ts +5 -5
- package/dist/components/atoms/Input/hooks/useMask.js +1 -1
- package/dist/components/atoms/Input/hooks/useMask.js.map +1 -1
- package/dist/components/atoms/Input/masks/index.js +1 -1
- package/dist/components/atoms/Input/masks/index.js.map +1 -1
- package/dist/components/atoms/Switch/Switch.d.ts +1 -0
- package/dist/components/atoms/Switch/Switch.js +10 -4
- package/dist/components/atoms/Switch/Switch.js.map +1 -1
- package/dist/components/atoms/Switch/animation.d.ts +2 -1
- package/dist/components/atoms/Switch/animation.js.map +1 -1
- package/dist/components/atoms/Tag/Tag.js +2 -2
- package/dist/components/atoms/Tag/Tag.js.map +1 -1
- package/dist/components/molecules/Calendar/Calendar.d.ts +1 -1
- package/dist/components/molecules/Calendar/Calendar.js +35 -156
- package/dist/components/molecules/Calendar/Calendar.js.map +1 -1
- package/dist/components/molecules/Calendar/components/MonthWeek.d.ts +13 -0
- package/dist/components/molecules/Calendar/components/MonthWeek.js +152 -0
- package/dist/components/molecules/Calendar/components/MonthWeek.js.map +1 -0
- package/dist/components/molecules/Calendar/components/Weekdays.d.ts +8 -0
- package/dist/components/molecules/Calendar/components/Weekdays.js +41 -0
- package/dist/components/molecules/Calendar/components/Weekdays.js.map +1 -0
- package/dist/components/molecules/Calendar/components/index.d.ts +2 -0
- package/dist/components/molecules/Calendar/components/index.js +24 -0
- package/dist/components/molecules/Calendar/components/index.js.map +1 -0
- package/dist/components/molecules/DatePicker/Modal.js.map +1 -1
- package/dist/components/molecules/DatePicker/styled.d.ts +4 -25
- package/dist/components/molecules/DatePicker/styled.js.map +1 -1
- package/dist/components/molecules/HintInputContainer/HintInputContainer.d.ts +1 -2
- package/dist/components/molecules/HintInputContainer/HintInputContainer.js.map +1 -1
- package/dist/hooks/useTheme.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/extractNumbersFromString.d.ts +1 -0
- package/dist/utils/extractNumbersFromString.js +5 -1
- package/dist/utils/extractNumbersFromString.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lightenDarkenColor.js +5 -5
- package/dist/utils/lightenDarkenColor.js.map +1 -1
- package/package.json +2 -2
- package/src/components/atoms/Avatar/styled.ts +0 -1
- package/src/components/atoms/BoxContent/styled.ts +1 -1
- package/src/components/atoms/Button/States/Error.tsx +1 -1
- package/src/components/atoms/Button/States/Success.tsx +1 -1
- package/src/components/atoms/GroupButton/GroupButton.tsx +6 -4
- package/src/components/atoms/GroupButton/GroupButtonOption.tsx +3 -3
- package/src/components/atoms/GroupButton/styled.ts +13 -1
- package/src/components/atoms/Input/InputElement/InputElement.tsx +36 -27
- package/src/components/atoms/Input/hooks/useCurrencyMask.ts +4 -5
- package/src/components/atoms/Input/hooks/useMask.ts +10 -9
- package/src/components/atoms/Input/masks/index.ts +1 -1
- package/src/components/atoms/Switch/Switch.stories.tsx +2 -1
- package/src/components/atoms/Switch/Switch.tsx +17 -6
- package/src/components/atoms/Switch/animation.ts +5 -1
- package/src/components/atoms/Tag/Tag.tsx +2 -2
- package/src/components/molecules/Calendar/Calendar.tsx +60 -162
- package/src/components/molecules/Calendar/components/MonthWeek.tsx +144 -0
- package/src/components/molecules/Calendar/components/Weekdays.tsx +34 -0
- package/src/components/molecules/Calendar/components/index.ts +2 -0
- package/src/components/molecules/DatePicker/Modal.tsx +1 -1
- package/src/components/molecules/DatePicker/styled.ts +1 -2
- package/src/components/molecules/HintInputContainer/HintInputContainer.tsx +1 -2
- package/src/hooks/useTheme.ts +1 -1
- package/src/index.ts +2 -0
- package/src/utils/extractNumbersFromString.ts +6 -0
- package/src/utils/index.ts +4 -1
- package/src/utils/lightenDarkenColor.ts +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,53 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.10.3](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.10.2...@tecsinapse/react-core@1.10.3) (2021-11-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* added method extractDigitsFromString ([76daa94](https://github.com/tecsinapse/design-system/commit/76daa943cc1be981b587830d0024c4a01c4df6e2))
|
|
12
|
+
* remove cursor css prop from avatar ([2f9ed15](https://github.com/tecsinapse/design-system/commit/2f9ed15bafb6697e2aee883b417574b4ee3275d5))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [1.10.2](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.10.1...@tecsinapse/react-core@1.10.2) (2021-11-16)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* added property disabled in groupButton. ([e6eaf19](https://github.com/tecsinapse/design-system/commit/e6eaf193a0ef75fd1468fb030e8b6e64595d2722))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## [1.10.1](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.10.0...@tecsinapse/react-core@1.10.1) (2021-10-08)
|
|
30
|
+
|
|
31
|
+
**Note:** Version bump only for package @tecsinapse/react-core
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# [1.10.0](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.9.0...@tecsinapse/react-core@1.10.0) (2021-10-01)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* Rename mask interface to avoid mismatch ([589ce1e](https://github.com/tecsinapse/design-system/commit/589ce1e3a63dff4334b48f218d3918dfb2837026))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Performance Improvements
|
|
46
|
+
|
|
47
|
+
* **calendar:** refactoring components for memo ([95d2245](https://github.com/tecsinapse/design-system/commit/95d2245a47c6abd221e673e1dd145f948b83a8e4))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
6
53
|
# [1.9.0](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-core@1.8.0...@tecsinapse/react-core@1.9.0) (2021-09-29)
|
|
7
54
|
|
|
8
55
|
|
|
@@ -22,9 +22,6 @@ const ContainerButtonAvatar = (0, _native.default)(_PressableSurface.PressableSu
|
|
|
22
22
|
theme,
|
|
23
23
|
size = 'mega'
|
|
24
24
|
}) => theme.iconSize[size]};
|
|
25
|
-
cursor: ${({
|
|
26
|
-
onPress
|
|
27
|
-
}) => onPress ? 'pointer' : 'default'};
|
|
28
25
|
`;
|
|
29
26
|
exports.ContainerButtonAvatar = ContainerButtonAvatar;
|
|
30
27
|
const StyledAvatar = (0, _native.default)(_reactNative.Image)`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/atoms/Avatar/styled.ts"],"names":["ContainerButtonAvatar","PressableSurface","theme","size","iconSize","
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/atoms/Avatar/styled.ts"],"names":["ContainerButtonAvatar","PressableSurface","theme","size","iconSize","StyledAvatar","Image","borderRadius","pill","StyledBackground","View","color","secondary","dark","getStyledTextComponent","component"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;;;AAIO,MAAMA,qBAAqB,GAAG,qBAAOC,kCAAP,CAEnC;AACF,WAAW,CAAC;AAAEC,EAAAA,KAAF;AAASC,EAAAA,IAAI,GAAG;AAAhB,CAAD,KACPD,KAAK,CAACE,QAAN,CAAeD,IAAf,CAAqB;AACzB,YAAY,CAAC;AAAED,EAAAA,KAAF;AAASC,EAAAA,IAAI,GAAG;AAAhB,CAAD,KACRD,KAAK,CAACE,QAAN,CAAeD,IAAf,CAAqB;AACzB,CAPO;;AASA,MAAME,YAAY,GAAG,qBAAOC,kBAAP,CAAmC;AAC/D,mBAAmB,CAAC;AAAEJ,EAAAA;AAAF,CAAD,KAA2BA,KAAK,CAACK,YAAN,CAAmBC,IAAK;AACtE;AACA;AACA;AACA,CALO;;AAOA,MAAMC,gBAAgB,GAAG,qBAAOC,iBAAP,CAAkC;AAClE,mBAAmB,CAAC;AAAER,EAAAA;AAAF,CAAD,KAA2BA,KAAK,CAACK,YAAN,CAAmBC,IAAK;AACtE,sBAAsB,CAAC;AAAEN,EAAAA;AAAF,CAAD,KAA2BA,KAAK,CAACS,KAAN,CAAYC,SAAZ,CAAsBC,IAAK;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA,CATO;;;AAWA,MAAMC,sBAAsB,GAAIC,SAAD,IAA8B;AAClE,SAAO,qBAAOA,SAAP,CAAkB;AAC3B;AACA;AACA;AACA;AACA,GALE;AAMD,CAPM","sourcesContent":["import styled from '@emotion/native';\nimport { FC } from 'react';\nimport { Image, View } from 'react-native';\nimport { StyleProps } from '../../../types/defaults';\nimport { PressableSurface } from '../PressableSurface';\nimport { TextProps } from '../Text';\nimport { AvatarProps } from './Avatar';\n\nexport const ContainerButtonAvatar = styled(PressableSurface)<\n Partial<StyleProps & AvatarProps>\n>`\n width: ${({ theme, size = 'mega' }: StyleProps & Partial<AvatarProps>) =>\n theme.iconSize[size]};\n height: ${({ theme, size = 'mega' }: StyleProps & Partial<AvatarProps>) =>\n theme.iconSize[size]};\n`;\n\nexport const StyledAvatar = styled(Image)<Partial<StyleProps>>`\n border-radius: ${({ theme }: StyleProps) => theme.borderRadius.pill};\n overflow: hidden;\n width: 100%;\n height: 100%;\n`;\n\nexport const StyledBackground = styled(View)<Partial<StyleProps>>`\n border-radius: ${({ theme }: StyleProps) => theme.borderRadius.pill};\n background-color: ${({ theme }: StyleProps) => theme.color.secondary.dark};\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: row;\n`;\n\nexport const getStyledTextComponent = (component: FC<TextProps>) => {\n return styled(component)`\n text-transform: uppercase;\n text-align: center;\n align-self: center;\n flex: 1;\n `;\n};\n"],"file":"styled.js"}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
export declare const elevatedStyles: ({ theme }: any) =>
|
|
1
|
+
export declare const elevatedStyles: ({ theme }: any) => {
|
|
2
|
+
shadowColor: any;
|
|
3
|
+
shadowOffset: {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
shadowOpacity: number;
|
|
8
|
+
shadowRadius: number;
|
|
9
|
+
elevation: number;
|
|
10
|
+
}[];
|
|
2
11
|
export declare const StyledBoxContent: import("@emotion/native").StyledComponent<any, {}, {}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/atoms/BoxContent/styled.ts"],"names":["elevatedStyles","theme","shadowColor","miscellaneous","shadow","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","topStyles","variant","borderRadius","deca","bottomStyles","leftStyles","rightStyles","StyledBoxContentBase","View","surfaceColor","spacing","kilo","StyledBoxContent","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAGO,MAAMA,cAAc,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/atoms/BoxContent/styled.ts"],"names":["elevatedStyles","theme","shadowColor","miscellaneous","shadow","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","topStyles","variant","borderRadius","deca","bottomStyles","leftStyles","rightStyles","StyledBoxContentBase","View","surfaceColor","spacing","kilo","StyledBoxContent","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAGO,MAAMA,cAAc,GAAG,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAoC,CAChE,iBAAI;AACFC,EAAAA,WAAW,EAAED,KAAF,aAAEA,KAAF,uBAAEA,KAAK,CAAEE,aAAP,CAAqBC,MADhC;AAEFC,EAAAA,YAAY,EAAE;AAAEC,IAAAA,KAAK,EAAE,CAAT;AAAYC,IAAAA,MAAM,EAAE;AAApB,GAFZ;AAGFC,EAAAA,aAAa,EAAE,IAHb;AAIFC,EAAAA,YAAY,EAAE,IAJZ;AAKFC,EAAAA,SAAS,EAAE;AALT,CAAJ,CADgE,CAA3D;;;;AAUP,MAAMC,SAAS,GAAG,CAAC;AAAEV,EAAAA,KAAF;AAASW,EAAAA;AAAT,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vB,IAAIT,YAAY,CAACS,KAAD,CAAQ;AACxB,IAAIR,UAAU,CAACQ,KAAD,CAAQ;AACtB,IAAIP,WAAW,CAACO,KAAD,CAAQ;AACvB,GAPgC,CAAzB","sourcesContent":["import styled, { css } from '@emotion/native';\nimport { StyleProps } from '@tecsinapse/react-core';\nimport { View } from 'react-native';\nimport { BoxContentProps } from './BoxContent';\n\nexport const elevatedStyles = ({ theme }: Partial<StyleProps>) => [\n css({\n shadowColor: theme?.miscellaneous.shadow,\n shadowOffset: { width: 0, height: 2 },\n shadowOpacity: 0.25,\n shadowRadius: 3.84,\n elevation: 5,\n }),\n];\n\nconst topStyles = ({ theme, variant }: Partial<BoxContentProps> & StyleProps) =>\n variant === 'top' &&\n css`\n border-bottom-left-radius: ${theme.borderRadius.deca};\n border-bottom-right-radius: ${theme.borderRadius.deca};\n `;\n\nconst bottomStyles = ({\n theme,\n variant,\n}: Partial<BoxContentProps> & StyleProps) =>\n variant === 'bottom' &&\n css`\n border-top-left-radius: ${theme.borderRadius.deca};\n border-top-right-radius: ${theme.borderRadius.deca};\n `;\n\nconst leftStyles = ({\n theme,\n variant,\n}: Partial<BoxContentProps> & StyleProps) =>\n variant === 'left' &&\n css`\n border-top-right-radius: ${theme.borderRadius.deca};\n border-bottom-right-radius: ${theme.borderRadius.deca};\n `;\n\nconst rightStyles = ({\n theme,\n variant,\n}: Partial<BoxContentProps> & StyleProps) =>\n variant === 'right' &&\n css`\n border-top-left-radius: ${theme.borderRadius.deca};\n border-bottom-left-radius: ${theme.borderRadius.deca};\n `;\n\nconst StyledBoxContentBase = styled(View)<Partial<StyleProps>>`\n background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};\n min-height: ${({ theme }) => theme.spacing.kilo};\n overflow: hidden;\n`;\n\nexport const StyledBoxContent = styled(StyledBoxContentBase)(\n props => css`\n ${elevatedStyles(props)}\n ${topStyles(props)}\n ${bottomStyles(props)}\n ${leftStyles(props)}\n ${rightStyles(props)}\n `\n);\n"],"file":"styled.js"}
|
|
@@ -7,14 +7,14 @@ exports.default = exports.Error = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
var _BaseState =
|
|
10
|
+
var _BaseState = require("./BaseState");
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
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
15
|
|
|
16
16
|
const Error = props => {
|
|
17
|
-
return _react.default.createElement(_BaseState.
|
|
17
|
+
return _react.default.createElement(_BaseState.BaseState, _extends({}, props, {
|
|
18
18
|
icon: "close-circle-outline"
|
|
19
19
|
}));
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/atoms/Button/States/Error.tsx"],"names":["Error","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAEO,MAAMA,KAA2B,GAAGC,KAAK,IAAI;AAClD,SAAO,6BAAC,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/atoms/Button/States/Error.tsx"],"names":["Error","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAEO,MAAMA,KAA2B,GAAGC,KAAK,IAAI;AAClD,SAAO,6BAAC,oBAAD,eAAeA,KAAf;AAAsB,IAAA,IAAI,EAAC;AAA3B,KAAP;AACD,CAFM;;;eAIQD,K","sourcesContent":["import React, { FC } from 'react';\nimport { ButtonStateProps } from '../Button';\nimport { BaseState } from './BaseState';\n\nexport const Error: FC<ButtonStateProps> = props => {\n return <BaseState {...props} icon=\"close-circle-outline\" />;\n};\n\nexport default Error;\n"],"file":"Error.js"}
|
|
@@ -7,14 +7,14 @@ exports.default = exports.Success = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
var _BaseState =
|
|
10
|
+
var _BaseState = require("./BaseState");
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
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
15
|
|
|
16
16
|
const Success = props => {
|
|
17
|
-
return _react.default.createElement(_BaseState.
|
|
17
|
+
return _react.default.createElement(_BaseState.BaseState, _extends({}, props, {
|
|
18
18
|
icon: "checkmark-circle-outline"
|
|
19
19
|
}));
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/atoms/Button/States/Success.tsx"],"names":["Success","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAEO,MAAMA,OAA6B,GAAGC,KAAK,IAAI;AACpD,SAAO,6BAAC,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/atoms/Button/States/Success.tsx"],"names":["Success","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAEO,MAAMA,OAA6B,GAAGC,KAAK,IAAI;AACpD,SAAO,6BAAC,oBAAD,eAAeA,KAAf;AAAsB,IAAA,IAAI,EAAC;AAA3B,KAAP;AACD,CAFM;;;eAIQD,O","sourcesContent":["import React, { FC } from 'react';\nimport { ButtonStateProps } from '../Button';\nimport { BaseState } from './BaseState';\n\nexport const Success: FC<ButtonStateProps> = props => {\n return <BaseState {...props} icon=\"checkmark-circle-outline\" />;\n};\n\nexport default Success;\n"],"file":"Success.js"}
|
|
@@ -12,6 +12,7 @@ export interface GroupButtonOptions {
|
|
|
12
12
|
inactiveBorderColorTone?: ColorGradationType;
|
|
13
13
|
activeStyle?: StyleProp<ViewStyle>;
|
|
14
14
|
inactiveStyle?: StyleProp<ViewStyle>;
|
|
15
|
+
disabled?: boolean;
|
|
15
16
|
}
|
|
16
17
|
export interface GroupButtonValue<T> {
|
|
17
18
|
value: T;
|
|
@@ -20,7 +21,7 @@ export interface GroupButtonValue<T> {
|
|
|
20
21
|
export interface GroupButtonProps<T> {
|
|
21
22
|
value: T;
|
|
22
23
|
options: GroupButtonValue<T>[];
|
|
23
|
-
renderKey: (option?: T) =>
|
|
24
|
+
renderKey: (option?: T) => string | number | undefined;
|
|
24
25
|
renderOption: (option: T, active: boolean) => JSX.Element;
|
|
25
26
|
onChange: (option: T) => void;
|
|
26
27
|
buttonSize?: ButtonSizeType;
|
|
@@ -42,7 +42,8 @@ const groupOptions = ({
|
|
|
42
42
|
activeBackgroundColor,
|
|
43
43
|
activeBackgroundColorTone,
|
|
44
44
|
inactiveBackgroundColor,
|
|
45
|
-
inactiveBackgroundColorTone
|
|
45
|
+
inactiveBackgroundColorTone,
|
|
46
|
+
disabled
|
|
46
47
|
} = {}
|
|
47
48
|
} = option;
|
|
48
49
|
const key = renderKey === null || renderKey === void 0 ? void 0 : renderKey(optionValue);
|
|
@@ -62,7 +63,7 @@ const groupOptions = ({
|
|
|
62
63
|
return _react2.default.createElement(_styled.StyledOption, {
|
|
63
64
|
key: key
|
|
64
65
|
}, _react2.default.createElement(_styled.StyledPressable, _extends({}, rest, option.options, {
|
|
65
|
-
disabled:
|
|
66
|
+
disabled: disabled,
|
|
66
67
|
isActive: active,
|
|
67
68
|
isFirstOption: isFirst,
|
|
68
69
|
isLastOption: isLast,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/atoms/GroupButton/GroupButton.tsx"],"names":["GroupButton","style","rest","groupOptions","options","renderOption","renderKey","onChange","value","theme","map","option","idx","optionValue","activeStyle","inactiveStyle","activeBackgroundColor","activeBackgroundColorTone","inactiveBackgroundColor","inactiveBackgroundColorTone","key","active","isFirst","isLast","length","colors","miscellaneous","surfaceColor","color"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/atoms/GroupButton/GroupButton.tsx"],"names":["GroupButton","style","rest","groupOptions","options","renderOption","renderKey","onChange","value","theme","map","option","idx","optionValue","activeStyle","inactiveStyle","activeBackgroundColor","activeBackgroundColorTone","inactiveBackgroundColor","inactiveBackgroundColorTone","disabled","key","active","isFirst","isLast","length","colors","miscellaneous","surfaceColor","color"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;;;;;AAoCA,MAAMA,WAAW,GAAG,CAAoB;AACtCC,EAAAA,KADsC;AAEtC,KAAGC;AAFmC,CAApB,KAGO;AACzB,SACE,8BAAC,yBAAD;AAAmB,IAAA,KAAK,EAAED;AAA1B,KAAkCE,YAAY,CAACD,IAAD,CAA9C,CADF;AAGD,CAPD;;AASA,MAAMC,YAAY,GAAG,CAAoB;AACvCC,EAAAA,OADuC;AAEvCC,EAAAA,YAFuC;AAGvCC,EAAAA,SAHuC;AAIvCC,EAAAA,QAJuC;AAKvCC,EAAAA,KALuC;AAMvC,KAAGN;AANoC,CAApB,KAOe;AAClC,QAAMO,KAAK,GAAG,sBAAd;AACA,SAAOL,OAAP,aAAOA,OAAP,uBAAOA,OAAO,CAAEM,GAAT,CAAa,CAACC,MAAD,EAASC,GAAT,KAAiB;AACnC,UAAM;AACJJ,MAAAA,KAAK,EAAEK,WADH;AAEJT,MAAAA,OAAO,EAAE;AACPU,QAAAA,WADO;AAEPC,QAAAA,aAFO;AAGPC,QAAAA,qBAHO;AAIPC,QAAAA,yBAJO;AAKPC,QAAAA,uBALO;AAMPC,QAAAA,2BANO;AAOPC,QAAAA;AAPO,UAQL;AAVA,QAWFT,MAXJ;AAaA,UAAMU,GAAG,GAAGf,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAGO,WAAH,CAArB;AACA,UAAMS,MAAM,GAAGD,GAAG,MAAKf,SAAL,aAAKA,SAAL,uBAAKA,SAAS,CAAGE,KAAH,CAAd,CAAlB;AACA,UAAMe,OAAO,GAAGX,GAAG,KAAK,CAAxB;AACA,UAAMY,MAAM,GAAGZ,GAAG,KAAKR,OAAO,CAACqB,MAAR,GAAiB,CAAxC;AAEA,QAAIC,MAAM,GAAGjB,KAAK,CAACkB,aAAN,CAAoBC,YAAjC;;AACA,QAAIN,MAAJ,EAAY;AACVI,MAAAA,MAAM,GACJjB,KAAK,CAACoB,KAAN,CAAYb,qBAAqB,IAAI,WAArC,EACEC,yBAAyB,IAAI,QAD/B,CADF;AAID;;AAED,QAAI,CAACK,MAAD,KAAYJ,uBAAuB,IAAIC,2BAAvC,CAAJ,EAAyE;AACvEO,MAAAA,MAAM,GACJjB,KAAK,CAACoB,KAAN,CAAYX,uBAAuB,IAAI,WAAvC,EACEC,2BAA2B,IAAI,QADjC,CADF;AAID;;AAED,WACE,8BAAC,oBAAD;AAAc,MAAA,GAAG,EAAEE;AAAnB,OACE,8BAAC,uBAAD,eACMnB,IADN,EAEMS,MAAM,CAACP,OAFb;AAGE,MAAA,QAAQ,EAAEgB,QAHZ;AAIE,MAAA,QAAQ,EAAEE,MAJZ;AAKE,MAAA,aAAa,EAAEC,OALjB;AAME,MAAA,YAAY,EAAEC,MANhB;AAOE,MAAA,OAAO,EAAE,MAAMjB,QAAN,aAAMA,QAAN,uBAAMA,QAAQ,CAAGM,WAAH,CAPzB;AAQE,MAAA,YAAY,EAAEa,MARhB;AASE,MAAA,KAAK,EAAEJ,MAAM,GAAGR,WAAH,GAAiBC;AAThC,QAWGV,YAXH,aAWGA,YAXH,uBAWGA,YAAY,CAAGM,MAAM,CAACH,KAAV,EAAiBc,MAAjB,CAXf,CADF,EAcG,CAACE,MAAD,IAAW,8BAAC,qBAAD,OAdd,CADF;AAkBD,GApDM,CAAP;AAqDD,CA9DD;;eAgEexB,W","sourcesContent":["import { useTheme } from '@emotion/react';\nimport React from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport {\n ColorGradationType,\n ColorType,\n ThemeProp,\n} from '../../../types/defaults';\nimport { ButtonSizeType } from '../Button';\nimport {\n StyledDivider,\n StyledGroupButton,\n StyledOption,\n StyledPressable,\n} from './styled';\n\nexport interface GroupButtonOptions {\n activeBackgroundColor?: ColorType;\n activeBackgroundColorTone?: ColorGradationType;\n activeBorderColor?: ColorType;\n activeBorderColorTone?: ColorGradationType;\n inactiveBackgroundColor?: ColorType;\n inactiveBackgroundColorTone?: ColorGradationType;\n inactiveBorderColor?: ColorType;\n inactiveBorderColorTone?: ColorGradationType;\n activeStyle?: StyleProp<ViewStyle>;\n inactiveStyle?: StyleProp<ViewStyle>;\n disabled?: boolean;\n}\n\nexport interface GroupButtonValue<T> {\n value: T;\n options?: GroupButtonOptions;\n}\n\nexport interface GroupButtonProps<T> {\n value: T;\n options: GroupButtonValue<T>[];\n renderKey: (option?: T) => string | number | undefined;\n renderOption: (option: T, active: boolean) => JSX.Element;\n onChange: (option: T) => void;\n buttonSize?: ButtonSizeType;\n style?: StyleProp<ViewStyle>;\n}\n\nconst GroupButton = <T extends unknown>({\n style,\n ...rest\n}: GroupButtonProps<T>) => {\n return (\n <StyledGroupButton style={style}>{groupOptions(rest)}</StyledGroupButton>\n );\n};\n\nconst groupOptions = <T extends unknown>({\n options,\n renderOption,\n renderKey,\n onChange,\n value,\n ...rest\n}: Partial<GroupButtonProps<T>>) => {\n const theme = useTheme() as ThemeProp;\n return options?.map((option, idx) => {\n const {\n value: optionValue,\n options: {\n activeStyle,\n inactiveStyle,\n activeBackgroundColor,\n activeBackgroundColorTone,\n inactiveBackgroundColor,\n inactiveBackgroundColorTone,\n disabled,\n } = {},\n } = option;\n\n const key = renderKey?.(optionValue);\n const active = key === renderKey?.(value);\n const isFirst = idx === 0;\n const isLast = idx === options.length - 1;\n\n let colors = theme.miscellaneous.surfaceColor;\n if (active) {\n colors =\n theme.color[activeBackgroundColor || 'secondary'][\n activeBackgroundColorTone || 'medium'\n ];\n }\n\n if (!active && (inactiveBackgroundColor || inactiveBackgroundColorTone)) {\n colors =\n theme.color[inactiveBackgroundColor || 'secondary'][\n inactiveBackgroundColorTone || 'medium'\n ];\n }\n\n return (\n <StyledOption key={key}>\n <StyledPressable\n {...rest}\n {...option.options}\n disabled={disabled}\n isActive={active}\n isFirstOption={isFirst}\n isLastOption={isLast}\n onPress={() => onChange?.(optionValue)}\n surfaceColor={colors}\n style={active ? activeStyle : inactiveStyle}\n >\n {renderOption?.(option.value, active)}\n </StyledPressable>\n {!isLast && <StyledDivider />}\n </StyledOption>\n );\n });\n};\n\nexport default GroupButton;\n"],"file":"GroupButton.js"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { TextProps } from '../Text';
|
|
3
|
-
export interface GroupButtonOptionProps
|
|
3
|
+
export interface GroupButtonOptionProps {
|
|
4
4
|
active: boolean;
|
|
5
5
|
description: string;
|
|
6
6
|
TextComponent?: FC<TextProps>;
|
|
7
7
|
}
|
|
8
|
-
declare const GroupButtonOption:
|
|
8
|
+
declare const GroupButtonOption: ({ TextComponent, active, description, }: GroupButtonOptionProps) => JSX.Element;
|
|
9
9
|
export default GroupButtonOption;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/atoms/GroupButton/GroupButtonOption.tsx"],"names":["GroupButtonOption","TextComponent","Text","active","description","StyledText"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAQA,MAAMA,iBAAiB,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/atoms/GroupButton/GroupButtonOption.tsx"],"names":["GroupButtonOption","TextComponent","Text","active","description","StyledText"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAQA,MAAMA,iBAAiB,GAAG,CAAC;AACzBC,EAAAA,aAAa,GAAGC,UADS;AAEzBC,EAAAA,MAFyB;AAGzBC,EAAAA;AAHyB,CAAD,KAIiB;AACzC,QAAMC,UAAU,GAAG,oCAAuBJ,aAAvB,CAAnB;AACA,SACE,6BAAC,UAAD;AAAY,IAAA,UAAU,EAAC,MAAvB;AAA8B,IAAA,UAAU,EAAC,KAAzC;AAA+C,IAAA,MAAM,EAAEE;AAAvD,KACGC,WADH,CADF;AAKD,CAXD;;eAaeJ,iB","sourcesContent":["import React, { FC } from 'react';\nimport { Text, TextProps } from '../Text';\nimport { getStyledGroupItemText } from './styled';\n\nexport interface GroupButtonOptionProps {\n active: boolean;\n description: string;\n TextComponent?: FC<TextProps>;\n}\n\nconst GroupButtonOption = ({\n TextComponent = Text,\n active,\n description,\n}: GroupButtonOptionProps): JSX.Element => {\n const StyledText = getStyledGroupItemText(TextComponent);\n return (\n <StyledText fontWeight=\"bold\" typography=\"sub\" active={active}>\n {description}\n </StyledText>\n );\n};\n\nexport default GroupButtonOption;\n"],"file":"GroupButtonOption.js"}
|
|
@@ -20,7 +20,7 @@ export declare const getStyledGroupItemText: (component: FC<TextProps>) => impor
|
|
|
20
20
|
} & {
|
|
21
21
|
theme?: import("@emotion/react").Theme | undefined;
|
|
22
22
|
as?: import("react").ElementType<any> | undefined;
|
|
23
|
-
} & Partial<GroupButtonOptionProps
|
|
23
|
+
} & Partial<GroupButtonOptionProps> & Partial<import("../../../types/defaults").ThemeProviderProps>, {}, {}>;
|
|
24
24
|
export declare const StyledOption: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
|
|
25
25
|
theme?: import("@emotion/react").Theme | undefined;
|
|
26
26
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -18,6 +18,13 @@ const StyledGroupButton = _native.default.View`
|
|
|
18
18
|
`;
|
|
19
19
|
exports.StyledGroupButton = StyledGroupButton;
|
|
20
20
|
|
|
21
|
+
const disabledStyles = ({
|
|
22
|
+
disabled,
|
|
23
|
+
isActive
|
|
24
|
+
}) => disabled && !isActive && (0, _native.css)`
|
|
25
|
+
background-color: #dcdcdc;
|
|
26
|
+
`;
|
|
27
|
+
|
|
21
28
|
const getStyledGroupItemText = component => {
|
|
22
29
|
return (0, _native.default)(component)`
|
|
23
30
|
color: ${({
|
|
@@ -127,6 +134,7 @@ const StyledPressable = (0, _native.default)(StyledPressableBase)(props => (0, _
|
|
|
127
134
|
${leftStyles(props)}
|
|
128
135
|
${rightStyles(props)}
|
|
129
136
|
${sizeStyles(props)}
|
|
137
|
+
${disabledStyles(props)}
|
|
130
138
|
`);
|
|
131
139
|
exports.StyledPressable = StyledPressable;
|
|
132
140
|
//# sourceMappingURL=styled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/atoms/GroupButton/styled.ts"],"names":["StyledGroupButton","styled","View","getStyledGroupItemText","component","active","theme","miscellaneous","surfaceColor","color","secondary","medium","activeStyles","
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/atoms/GroupButton/styled.ts"],"names":["StyledGroupButton","styled","View","disabledStyles","disabled","isActive","getStyledGroupItemText","component","active","theme","miscellaneous","surfaceColor","color","secondary","medium","activeStyles","activeBorderColor","activeBorderColorTone","inactiveStyles","inactiveBackgroundColor","inactiveBackgroundColorTone","inactiveBorderColor","inactiveBorderColorTone","leftStyles","isFirstOption","borderRadius","mili","borderWidth","pico","rightStyles","isLastOption","sizeStyles","buttonSize","spacing","deca","kilo","StyledPressableBase","PressableSurface","StyledOption","StyledDivider","light","StyledPressable","props"],"mappings":";;;;;;;AAAA;;AAIA;;;;;;AAYO,MAAMA,iBAAiB,GAAGC,gBAAOC,IAA0B;AAClE;AACA,CAFO;;;AAKP,MAAMC,cAAc,GAAG,CAAC;AACtBC,EAAAA,QADsB;AAEtBC,EAAAA;AAFsB,CAAD,KAIrBD,QAAQ,IACR,CAACC,QADD,IAEA,gBAAI;AACN;AACA,GARA;;AAUO,MAAMC,sBAAsB,GAAIC,SAAD,IAA8B;AAClE,SAAO,qBAAOA,SAAP,CAEL;AACJ,aAAa,CAAC;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAD,KACPD,MAAM,GAAGC,KAAK,CAACC,aAAN,CAAoBC,YAA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;AACA,CARA;AAUO,MAAMU,YAAY,GAAGrC,gBAAOC,IAAK;AACxC;AACA;AACA,CAHO;;AAKA,MAAMqC,aAAa,GAAGtC,gBAAOC,IAA0B;AAC9D,WAAW,CAAC;AAAEO,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACkB,WAAN,CAAkBC,IAAK;AACjD,sBAAsB,CAAC;AAAEnB,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACG,KAAN,CAAYC,SAAZ,CAAsB2B,KAAM;AACjE,CAHO;;AAKA,MAAMC,eAAe,GAAG,qBAAOL,mBAAP,EAC5BM,KAAD,IAAmD,gBAAI;AACzD,MAAM3B,YAAY,CAAC2B,KAAD,CAAQ;AAC1B,MAAMxB,cAAc,CAACwB,KAAD,CAAQ;AAC5B,MAAMnB,UAAU,CAACmB,KAAD,CAAQ;AACxB,MAAMb,WAAW,CAACa,KAAD,CAAQ;AACzB,MAAMX,UAAU,CAACW,KAAD,CAAQ;AACxB,MAAMvC,cAAc,CAACuC,KAAD,CAAQ;AAC5B,GAR+B,CAAxB","sourcesContent":["import styled, { css } from '@emotion/native';\nimport { FC } from 'react';\nimport { StyleProps } from '../../../types/defaults';\nimport { ButtonSizeType } from '../Button';\nimport { PressableSurface } from '../PressableSurface';\nimport { TextProps } from '../Text';\nimport { GroupButtonOptions } from './GroupButton';\nimport { GroupButtonOptionProps } from './GroupButtonOption';\n\ninterface PressableOptions extends GroupButtonOptions {\n isActive: boolean;\n isFirstOption: boolean;\n isLastOption: boolean;\n buttonSize?: ButtonSizeType;\n}\n\nexport const StyledGroupButton = styled.View<Partial<StyleProps>>`\n flex-direction: row;\n`;\n\n// TO FIXED: hexa color to theme definitions\nconst disabledStyles = ({\n disabled,\n isActive,\n}: PressableOptions & Partial<StyleProps>) =>\n disabled &&\n !isActive &&\n css`\n background-color: #dcdcdc;\n `;\n\nexport const getStyledGroupItemText = (component: FC<TextProps>) => {\n return styled(component)<\n Partial<GroupButtonOptionProps> & Partial<StyleProps>\n >`\n color: ${({ active, theme }) =>\n active ? theme.miscellaneous.surfaceColor : theme.color.secondary.medium};\n `;\n};\n\nconst activeStyles = ({\n theme,\n isActive,\n activeBorderColor = 'secondary',\n activeBorderColorTone = 'medium',\n}: PressableOptions & Partial<StyleProps>) =>\n isActive &&\n css`\n border-color: ${theme?.color[activeBorderColor][activeBorderColorTone]};\n `;\n\nconst inactiveStyles = ({\n theme,\n isActive,\n inactiveBackgroundColor,\n inactiveBackgroundColorTone,\n inactiveBorderColor = 'secondary',\n inactiveBorderColorTone = 'light',\n}: PressableOptions & Partial<StyleProps>) => {\n if (!isActive && inactiveBackgroundColor && inactiveBackgroundColorTone) {\n return css`\n border-color: ${theme?.color[inactiveBorderColor][\n inactiveBorderColorTone\n ]};\n `;\n }\n\n if (!isActive) {\n return css`\n border-color: ${theme?.color[inactiveBorderColor][\n inactiveBorderColorTone\n ]};\n `;\n }\n};\n\nconst leftStyles = ({\n theme,\n isFirstOption,\n}: PressableOptions & Partial<StyleProps>) =>\n isFirstOption &&\n css`\n border-top-left-radius: ${theme?.borderRadius.mili};\n border-bottom-left-radius: ${theme?.borderRadius.mili};\n border-left-width: ${theme?.borderWidth.pico};\n `;\n\nconst rightStyles = ({\n theme,\n isLastOption,\n}: PressableOptions & Partial<StyleProps>) =>\n isLastOption &&\n css`\n border-top-right-radius: ${theme?.borderRadius.mili};\n border-bottom-right-radius: ${theme?.borderRadius.mili};\n border-right-width: ${theme?.borderWidth.pico};\n `;\n\nconst sizeStyles = ({\n theme,\n buttonSize = 'small',\n}: PressableOptions & Partial<StyleProps>) => {\n switch (buttonSize) {\n case 'small':\n return css`\n padding: ${theme?.spacing.mili} ${theme?.spacing.deca};\n min-height: 34px;\n `;\n default:\n return css`\n padding: ${theme?.spacing.mili} ${theme?.spacing.kilo};\n min-height: 44px;\n `;\n }\n};\n\nconst StyledPressableBase = styled(PressableSurface)<\n PressableOptions & Partial<StyleProps>\n>`\n border-top-width: ${({ theme }) => theme.borderWidth.pico};\n border-bottom-width: ${({ theme }) => theme.borderWidth.pico};\n justify-content: center;\n align-items: center;\n flex: 1;\n`;\n\nexport const StyledOption = styled.View`\n flex-direction: row;\n flex: 1;\n`;\n\nexport const StyledDivider = styled.View<Partial<StyleProps>>`\n width: ${({ theme }) => theme.borderWidth.pico};\n background-color: ${({ theme }) => theme.color.secondary.light}; ;\n`;\n\nexport const StyledPressable = styled(StyledPressableBase)(\n (props: PressableOptions & Partial<StyleProps>) => css`\n ${activeStyles(props)}\n ${inactiveStyles(props)}\n ${leftStyles(props)}\n ${rightStyles(props)}\n ${sizeStyles(props)}\n ${disabledStyles(props)}\n `\n);\n"],"file":"styled.js"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import { StyleProp, TextInputProps, TextStyle } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
export interface InputElementProps extends Omit<TextInputProps, 'onChange' | 'value'> {
|
|
3
|
+
import { IMask } from '../hooks/useMask';
|
|
4
|
+
export interface InputElementProps extends Omit<TextInputProps, 'onChange' | 'value' | 'ref'> {
|
|
5
5
|
style?: StyleProp<TextStyle>;
|
|
6
|
-
value?: string |
|
|
6
|
+
value?: string | IMask;
|
|
7
7
|
placeholder?: string;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
onChange?: (value: string) => void;
|
|
10
10
|
onFocus?: () => void;
|
|
11
11
|
onBlur?: () => void;
|
|
12
|
+
ref?: React.Ref<any>;
|
|
12
13
|
}
|
|
13
14
|
declare const InputElement: FC<InputElementProps>;
|
|
14
15
|
export default InputElement;
|
|
@@ -15,14 +15,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
15
|
|
|
16
16
|
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); }
|
|
17
17
|
|
|
18
|
-
const InputElement = ({
|
|
18
|
+
const InputElement = _react2.default.forwardRef(({
|
|
19
19
|
onChange,
|
|
20
20
|
placeholder,
|
|
21
21
|
value,
|
|
22
22
|
disabled = false,
|
|
23
23
|
placeholderTextColor,
|
|
24
24
|
...rest
|
|
25
|
-
}) => {
|
|
25
|
+
}, ref) => {
|
|
26
26
|
var _value$maskValue;
|
|
27
27
|
|
|
28
28
|
const theme = (0, _react.useTheme)();
|
|
@@ -32,6 +32,7 @@ const InputElement = ({
|
|
|
32
32
|
const _placeholderColor = placeholderTextColor || theme.font.color.dark;
|
|
33
33
|
|
|
34
34
|
return _react2.default.createElement(_styled.StyledInputElement, _extends({}, rest, {
|
|
35
|
+
ref: ref,
|
|
35
36
|
onChangeText: onChange,
|
|
36
37
|
value: _value,
|
|
37
38
|
placeholder: placeholder,
|
|
@@ -39,8 +40,9 @@ const InputElement = ({
|
|
|
39
40
|
disabled: disabled,
|
|
40
41
|
editable: !disabled
|
|
41
42
|
}));
|
|
42
|
-
};
|
|
43
|
+
});
|
|
43
44
|
|
|
45
|
+
InputElement.displayName = 'InputElement';
|
|
44
46
|
var _default = InputElement;
|
|
45
47
|
exports.default = _default;
|
|
46
48
|
//# sourceMappingURL=InputElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/atoms/Input/InputElement/InputElement.tsx"],"names":["InputElement","onChange","placeholder","value","disabled","placeholderTextColor","rest","theme","_value","maskValue","formatted","_placeholderColor","font","color","dark"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/atoms/Input/InputElement/InputElement.tsx"],"names":["InputElement","React","forwardRef","onChange","placeholder","value","disabled","placeholderTextColor","rest","ref","theme","_value","maskValue","formatted","_placeholderColor","font","color","dark","displayName"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;;;;;AAiBA,MAAMA,YAAmC,GAAGC,gBAAMC,UAAN,CAC1C,CACE;AACEC,EAAAA,QADF;AAEEC,EAAAA,WAFF;AAGEC,EAAAA,KAHF;AAIEC,EAAAA,QAAQ,GAAG,KAJb;AAKEC,EAAAA,oBALF;AAME,KAAGC;AANL,CADF,EASEC,GATF,KAUkB;AAAA;;AAChB,QAAMC,KAAK,GAAG,sBAAd;;AACA,QAAMC,MAAM,GACV,OAAON,KAAP,KAAiB,QAAjB,GAA4BA,KAA5B,GAAoCA,KAApC,aAAoCA,KAApC,2CAAoCA,KAAK,CAAEO,SAA3C,qDAAoC,iBAAkBC,SADxD;;AAEA,QAAMC,iBAAiB,GAAGP,oBAAoB,IAAIG,KAAK,CAACK,IAAN,CAAWC,KAAX,CAAiBC,IAAnE;;AAEA,SACE,8BAAC,0BAAD,eACMT,IADN;AAEE,IAAA,GAAG,EAAEC,GAFP;AAGE,IAAA,YAAY,EAAEN,QAHhB;AAIE,IAAA,KAAK,EAAEQ,MAJT;AAKE,IAAA,WAAW,EAAEP,WALf;AAME,IAAA,oBAAoB,EAAEU,iBANxB;AAOE,IAAA,QAAQ,EAAER,QAPZ;AAQE,IAAA,QAAQ,EAAE,CAACA;AARb,KADF;AAYD,CA7ByC,CAA5C;;AAgCAN,YAAY,CAACkB,WAAb,GAA2B,cAA3B;eAEelB,Y","sourcesContent":["import { useTheme } from '@emotion/react';\nimport { ThemeProp } from '@tecsinapse/react-core';\nimport React, { FC } from 'react';\nimport { StyleProp, TextInputProps, TextStyle } from 'react-native';\nimport { IMask } from '../hooks/useMask';\nimport { StyledInputElement } from '../styled';\n\nexport interface InputElementProps\n extends Omit<TextInputProps, 'onChange' | 'value' | 'ref'> {\n style?: StyleProp<TextStyle>;\n /**\n * TODO:\n */\n value?: string | IMask;\n placeholder?: string;\n disabled?: boolean;\n onChange?: (value: string) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n ref?: React.Ref<any>;\n}\n\nconst InputElement: FC<InputElementProps> = React.forwardRef(\n (\n {\n onChange,\n placeholder,\n value,\n disabled = false,\n placeholderTextColor,\n ...rest\n },\n ref: React.Ref<any>\n ): JSX.Element => {\n const theme = useTheme() as ThemeProp;\n const _value =\n typeof value === 'string' ? value : value?.maskValue?.formatted;\n const _placeholderColor = placeholderTextColor || theme.font.color.dark;\n\n return (\n <StyledInputElement\n {...rest}\n ref={ref}\n onChangeText={onChange}\n value={_value}\n placeholder={placeholder}\n placeholderTextColor={_placeholderColor}\n disabled={disabled}\n editable={!disabled}\n />\n );\n }\n);\n\nInputElement.displayName = 'InputElement';\n\nexport default InputElement;\n"],"file":"InputElement.js"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import currency from 'currency.js';
|
|
2
|
-
import {
|
|
3
|
-
export declare const useCurrencyMask: (options?: currency.Options | undefined, defaultValue?: string | undefined) => [
|
|
2
|
+
import { IMask } from './useMask';
|
|
3
|
+
export declare const useCurrencyMask: (options?: currency.Options | undefined, defaultValue?: string | undefined) => [IMask, (value: string) => void];
|
|
@@ -1 +1 @@
|
|
|
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;;
|
|
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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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 +1,9 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface IMaskValue {
|
|
2
2
|
formatted?: string;
|
|
3
3
|
raw?: any;
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
6
|
-
converter?: (raw?: string) =>
|
|
7
|
-
maskValue?:
|
|
5
|
+
export interface IMask {
|
|
6
|
+
converter?: (raw?: string) => IMaskValue;
|
|
7
|
+
maskValue?: IMaskValue;
|
|
8
8
|
}
|
|
9
|
-
export declare const useMask: (mask: string | ((raw: any) => string), defaultValue?: string | undefined) => [
|
|
9
|
+
export declare const useMask: (mask: string | ((raw: any) => string), defaultValue?: string | undefined) => [IMask, (text: string) => void];
|
|
@@ -30,7 +30,7 @@ const getMask = (value = '', mask) => {
|
|
|
30
30
|
|
|
31
31
|
const useMask = (mask, defaultValue) => {
|
|
32
32
|
const applyMask = (0, _react.useCallback)((value = '') => {
|
|
33
|
-
const onlyNumbers =
|
|
33
|
+
const onlyNumbers = value ? (0, _reactCore.extractDigitsFromString)(value) : value;
|
|
34
34
|
const selectedMask = getMask(onlyNumbers, mask);
|
|
35
35
|
const formattedValue = mergeMask(onlyNumbers, selectedMask);
|
|
36
36
|
return {
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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"}
|
|
@@ -12,7 +12,7 @@ const Masks = {
|
|
|
12
12
|
CEP: '99999-999',
|
|
13
13
|
PHONE: '(99) 9999-9999',
|
|
14
14
|
PHONE_EXTENDED: '(99) 99999-9999',
|
|
15
|
-
COMBINED_PHONE: value => value.length <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED
|
|
15
|
+
COMBINED_PHONE: value => (value === null || value === void 0 ? void 0 : value.length) <= 10 ? Masks.PHONE : Masks.PHONE_EXTENDED
|
|
16
16
|
};
|
|
17
17
|
exports.Masks = Masks;
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
|
@@ -33,6 +33,7 @@ const Switch = ({
|
|
|
33
33
|
inactiveColorTone = 'light',
|
|
34
34
|
active,
|
|
35
35
|
dotStyle,
|
|
36
|
+
disabled = false,
|
|
36
37
|
...rest
|
|
37
38
|
}) => {
|
|
38
39
|
const theme = (0, _react.useTheme)();
|
|
@@ -41,9 +42,13 @@ const Switch = ({
|
|
|
41
42
|
|
|
42
43
|
const animatedColor = _react2.default.useRef(new _reactNative.Animated.Value(active ? 1 : 0)).current;
|
|
43
44
|
|
|
45
|
+
const getBackgroundColor = (color, variation) => {
|
|
46
|
+
return disabled ? (0, _utils.lightenDarkenColor)(color, variation) : color;
|
|
47
|
+
};
|
|
48
|
+
|
|
44
49
|
const interpolateColor = animatedColor.interpolate({
|
|
45
50
|
inputRange: [0, 1],
|
|
46
|
-
outputRange: [theme.color[inactiveColor][inactiveColorTone], theme.color[activeColor][activeColorTone]]
|
|
51
|
+
outputRange: [getBackgroundColor(theme.color[inactiveColor][inactiveColorTone], 25), getBackgroundColor(theme.color[activeColor][activeColorTone], 50)]
|
|
47
52
|
});
|
|
48
53
|
const animatedStyle = {
|
|
49
54
|
backgroundColor: interpolateColor
|
|
@@ -52,7 +57,7 @@ const Switch = ({
|
|
|
52
57
|
onChange(!active);
|
|
53
58
|
(0, _animation.transitionSwitch)(active, transitionValue, animatedColor);
|
|
54
59
|
}, [active, onChange]);
|
|
55
|
-
const
|
|
60
|
+
const stylesDefault = {
|
|
56
61
|
borderRadius: (0, _utils.extractNumbersFromString)(theme.borderRadius.pill),
|
|
57
62
|
paddingHorizontal: (0, _utils.extractNumbersFromString)(theme.spacing.micro),
|
|
58
63
|
paddingVertical: 0,
|
|
@@ -62,10 +67,11 @@ const Switch = ({
|
|
|
62
67
|
};
|
|
63
68
|
return _react2.default.createElement(_PressableSurface.PressableSurface, _extends({}, rest, {
|
|
64
69
|
onPress: handleChange,
|
|
65
|
-
effect: "none"
|
|
70
|
+
effect: "none",
|
|
71
|
+
disabled: disabled
|
|
66
72
|
}), _react2.default.createElement(_reactNative.Animated.View, {
|
|
67
73
|
style: { ...animatedStyle,
|
|
68
|
-
...
|
|
74
|
+
...stylesDefault
|
|
69
75
|
}
|
|
70
76
|
}, _react2.default.createElement(_styled.StyledSwitch, {
|
|
71
77
|
style: [dotStyle, {
|