@tecsinapse/react-core 1.12.3 → 1.12.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/components/atoms/Badge/styled.d.ts +3 -2
  3. package/dist/components/atoms/Badge/styled.js +5 -3
  4. package/dist/components/atoms/Badge/styled.js.map +1 -1
  5. package/dist/components/atoms/Button/styled.js +4 -2
  6. package/dist/components/atoms/Button/styled.js.map +1 -1
  7. package/dist/components/atoms/GroupButton/styled.js +4 -2
  8. package/dist/components/atoms/GroupButton/styled.js.map +1 -1
  9. package/dist/components/atoms/Input/styled.js +3 -1
  10. package/dist/components/atoms/Input/styled.js.map +1 -1
  11. package/dist/components/atoms/ProgressBar/styled.d.ts +15 -3
  12. package/dist/components/atoms/ProgressBar/styled.js +3 -1
  13. package/dist/components/atoms/ProgressBar/styled.js.map +1 -1
  14. package/dist/components/atoms/Switch/Switch.js +30 -22
  15. package/dist/components/atoms/Switch/Switch.js.map +1 -1
  16. package/dist/components/atoms/Switch/animation.d.ts +1 -1
  17. package/dist/components/atoms/Switch/animation.js +24 -16
  18. package/dist/components/atoms/Switch/animation.js.map +1 -1
  19. package/dist/components/atoms/Switch/styled.d.ts +16 -2
  20. package/dist/components/atoms/Switch/styled.js +11 -5
  21. package/dist/components/atoms/Switch/styled.js.map +1 -1
  22. package/dist/components/atoms/shared/PaperAndCard.js +3 -5
  23. package/dist/components/atoms/shared/PaperAndCard.js.map +1 -1
  24. package/dist/components/molecules/DatePicker/styled.d.ts +25 -4
  25. package/dist/components/molecules/DatePicker/styled.js +7 -5
  26. package/dist/components/molecules/DatePicker/styled.js.map +1 -1
  27. package/dist/components/molecules/DateTimePicker/styled.js +4 -2
  28. package/dist/components/molecules/DateTimePicker/styled.js.map +1 -1
  29. package/dist/components/molecules/DateTimeSelector/styled.js +3 -1
  30. package/dist/components/molecules/DateTimeSelector/styled.js.map +1 -1
  31. package/dist/components/molecules/Snackbar/styled.js +7 -5
  32. package/dist/components/molecules/Snackbar/styled.js.map +1 -1
  33. package/dist/components/molecules/TextArea/styled.d.ts +13 -6
  34. package/dist/components/molecules/TextArea/styled.js +8 -6
  35. package/dist/components/molecules/TextArea/styled.js.map +1 -1
  36. package/dist/styles/definitions.js +45 -42
  37. package/dist/styles/definitions.js.map +1 -1
  38. package/dist/utils/IPhoneXHelper.d.ts +4 -0
  39. package/dist/utils/IPhoneXHelper.js +38 -0
  40. package/dist/utils/IPhoneXHelper.js.map +1 -0
  41. package/dist/utils/ResponsiveFontSize.d.ts +3 -0
  42. package/dist/utils/ResponsiveFontSize.js +57 -0
  43. package/dist/utils/ResponsiveFontSize.js.map +1 -0
  44. package/dist/utils/extractNumbersFromString.js +2 -2
  45. package/dist/utils/extractNumbersFromString.js.map +1 -1
  46. package/dist/utils/index.d.ts +2 -0
  47. package/dist/utils/index.js +33 -0
  48. package/dist/utils/index.js.map +1 -1
  49. package/package.json +2 -2
  50. package/src/components/atoms/Badge/styled.ts +5 -4
  51. package/src/components/atoms/Button/styled.ts +3 -2
  52. package/src/components/atoms/GroupButton/styled.ts +3 -2
  53. package/src/components/atoms/Input/styled.ts +2 -1
  54. package/src/components/atoms/ProgressBar/styled.ts +3 -2
  55. package/src/components/atoms/Switch/Switch.tsx +29 -32
  56. package/src/components/atoms/Switch/animation.ts +26 -16
  57. package/src/components/atoms/Switch/styled.ts +10 -6
  58. package/src/components/atoms/shared/PaperAndCard.ts +4 -6
  59. package/src/components/molecules/DatePicker/styled.ts +4 -2
  60. package/src/components/molecules/DateTimePicker/styled.ts +4 -3
  61. package/src/components/molecules/DateTimeSelector/styled.ts +2 -1
  62. package/src/components/molecules/Snackbar/styled.ts +6 -5
  63. package/src/components/molecules/TextArea/styled.ts +6 -12
  64. package/src/styles/definitions.ts +44 -43
  65. package/src/utils/IPhoneXHelper.ts +34 -0
  66. package/src/utils/ResponsiveFontSize.ts +52 -0
  67. package/src/utils/extractNumbersFromString.ts +2 -4
  68. package/src/utils/index.ts +2 -0
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RFValueStr = exports.RFValue = exports.RFPercentage = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ var _extractNumbersFromString = require("./extractNumbersFromString");
11
+
12
+ var _IPhoneXHelper = require("./IPhoneXHelper");
13
+
14
+ const STANDARD_SCREEN_HEIGHT = 640;
15
+
16
+ const RFPercentage = percent => {
17
+ if (_reactNative.Platform.OS === 'web') return percent;
18
+
19
+ const {
20
+ height,
21
+ width
22
+ } = _reactNative.Dimensions.get("window");
23
+
24
+ const standardLength = width > height ? width : height;
25
+ const offset = width > height ? 0 : _reactNative.Platform.OS === "ios" ? 78 : _reactNative.StatusBar.currentHeight || 0;
26
+ const deviceHeight = (0, _IPhoneXHelper.isIphoneX)() || _reactNative.Platform.OS === "android" ? standardLength - offset : standardLength;
27
+ const heightPercent = percent * deviceHeight / 100;
28
+ return Math.round(heightPercent);
29
+ };
30
+
31
+ exports.RFPercentage = RFPercentage;
32
+
33
+ const RFValue = (fontSize, standardScreenHeight = STANDARD_SCREEN_HEIGHT) => {
34
+ if (_reactNative.Platform.OS === 'web') return fontSize;
35
+
36
+ const {
37
+ height,
38
+ width
39
+ } = _reactNative.Dimensions.get("window");
40
+
41
+ const standardLength = width > height ? width : height;
42
+ const offset = width > height ? 0 : _reactNative.Platform.OS === "ios" ? 78 : _reactNative.StatusBar.currentHeight || 0;
43
+ const deviceHeight = (0, _IPhoneXHelper.isIphoneX)() || _reactNative.Platform.OS === "android" ? standardLength - offset : standardLength;
44
+ const heightPercent = fontSize * deviceHeight / standardScreenHeight;
45
+ return Math.round(heightPercent);
46
+ };
47
+
48
+ exports.RFValue = RFValue;
49
+
50
+ const RFValueStr = (fontSize, standardScreenHeight) => {
51
+ const _fontSize = (0, _extractNumbersFromString.extractNumbersFromString)(fontSize);
52
+
53
+ return `${RFValue(_fontSize, standardScreenHeight)}px`;
54
+ };
55
+
56
+ exports.RFValueStr = RFValueStr;
57
+ //# sourceMappingURL=ResponsiveFontSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/ResponsiveFontSize.ts"],"names":["STANDARD_SCREEN_HEIGHT","RFPercentage","percent","Platform","OS","height","width","Dimensions","get","standardLength","offset","StatusBar","currentHeight","deviceHeight","heightPercent","Math","round","RFValue","fontSize","standardScreenHeight","RFValueStr","_fontSize"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA,MAAMA,sBAAsB,GAAG,GAA/B;;AASO,MAAMC,YAAY,GAAIC,OAAD,IAAqB;AAC7C,MAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B,OAAOF,OAAP;;AAC3B,QAAM;AAAEG,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAoBC,wBAAWC,GAAX,CAAe,QAAf,CAA1B;;AACA,QAAMC,cAAc,GAAGH,KAAK,GAAGD,MAAR,GAAiBC,KAAjB,GAAyBD,MAAhD;AACA,QAAMK,MAAM,GAAGJ,KAAK,GAAGD,MAAR,GAAiB,CAAjB,GAAqBF,sBAASC,EAAT,KAAgB,KAAhB,GAAwB,EAAxB,GAA6BO,uBAAUC,aAAV,IAA2B,CAA5F;AACA,QAAMC,YAAY,GAAG,mCAAeV,sBAASC,EAAT,KAAgB,SAA/B,GAA2CK,cAAc,GAAGC,MAA5D,GAAqED,cAA1F;AACA,QAAMK,aAAa,GAAIZ,OAAO,GAAGW,YAAX,GAA2B,GAAjD;AACA,SAAOE,IAAI,CAACC,KAAL,CAAWF,aAAX,CAAP;AACH,CARM;;;;AAkBA,MAAMG,OAAO,GAAG,CAACC,QAAD,EAAmBC,oBAA4B,GAAGnB,sBAAlD,KAA6E;AAChG,MAAIG,sBAASC,EAAT,KAAgB,KAApB,EAA2B,OAAOc,QAAP;;AAC3B,QAAM;AAAEb,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAoBC,wBAAWC,GAAX,CAAe,QAAf,CAA1B;;AACA,QAAMC,cAAc,GAAGH,KAAK,GAAGD,MAAR,GAAiBC,KAAjB,GAAyBD,MAAhD;AACA,QAAMK,MAAM,GAAGJ,KAAK,GAAGD,MAAR,GAAiB,CAAjB,GAAqBF,sBAASC,EAAT,KAAgB,KAAhB,GAAwB,EAAxB,GAA6BO,uBAAUC,aAAV,IAA2B,CAA5F;AACA,QAAMC,YAAY,GAAG,mCAAeV,sBAASC,EAAT,KAAgB,SAA/B,GAA2CK,cAAc,GAAGC,MAA5D,GAAqED,cAA1F;AACA,QAAMK,aAAa,GAAII,QAAQ,GAAGL,YAAZ,GAA4BM,oBAAlD;AACA,SAAOJ,IAAI,CAACC,KAAL,CAAWF,aAAX,CAAP;AACH,CARM;;;;AAiBA,MAAMM,UAAU,GAAG,CAACF,QAAD,EAAmBC,oBAAnB,KAAqD;AAC3E,QAAME,SAAS,GAAG,wDAAyBH,QAAzB,CAAlB;;AACA,SAAQ,GAAED,OAAO,CAACI,SAAD,EAAYF,oBAAZ,CAAkC,IAAnD;AACH,CAHM","sourcesContent":["import { Dimensions, Platform, StatusBar } from \"react-native\";\nimport { extractNumbersFromString } from \"./extractNumbersFromString\";\nimport { isIphoneX } from \"./IPhoneXHelper\";\n\nconst STANDARD_SCREEN_HEIGHT = 640\n\n/**\n * Use this function when you want to scale a percentage number\n * to a reasonable value that will fit better on most of devices.\n * \n * @param percent \n * @returns \n */\nexport const RFPercentage = (percent: number) => {\n if (Platform.OS === 'web') return percent\n const { height, width } = Dimensions.get(\"window\");\n const standardLength = width > height ? width : height;\n const offset = width > height ? 0 : Platform.OS === \"ios\" ? 78 : StatusBar.currentHeight || 0 // iPhone X style SafeAreaView size in portrait\n const deviceHeight = isIphoneX() || Platform.OS === \"android\" ? standardLength - offset : standardLength;\n const heightPercent = (percent * deviceHeight) / 100;\n return Math.round(heightPercent);\n}\n\n/**\n * Use this function when you want to scale a font size based on pixel unit \n * to a reasonable value that will fit better on most of devices.\n * \n * @param fontSize \n * @param standardScreenHeight \n * @returns \n */\nexport const RFValue = (fontSize: number, standardScreenHeight: number = STANDARD_SCREEN_HEIGHT) => {\n if (Platform.OS === 'web') return fontSize\n const { height, width } = Dimensions.get(\"window\");\n const standardLength = width > height ? width : height;\n const offset = width > height ? 0 : Platform.OS === \"ios\" ? 78 : StatusBar.currentHeight || 0 // iPhone X style SafeAreaView size in portrait\n const deviceHeight = isIphoneX() || Platform.OS === \"android\" ? standardLength - offset : standardLength;\n const heightPercent = (fontSize * deviceHeight) / standardScreenHeight;\n return Math.round(heightPercent);\n}\n\n/**\n * Same of RFValue, however you can provide string values. E.g: '10px', '-5px'.\n * \n * @param fontSize \n * @param standardScreenHeight \n * @returns \n */\nexport const RFValueStr = (fontSize: string, standardScreenHeight?: number) => {\n const _fontSize = extractNumbersFromString(fontSize)\n return `${RFValue(_fontSize, standardScreenHeight)}px`\n}"],"file":"ResponsiveFontSize.js"}
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.extractDigitsFromString = exports.extractNumbersFromString = void 0;
7
7
 
8
- const extractNumbersFromString = value => Number(value.replace(/[^0-9]/g, ''));
8
+ const extractNumbersFromString = value => Number(extractDigitsFromString(value));
9
9
 
10
10
  exports.extractNumbersFromString = extractNumbersFromString;
11
11
 
12
- const extractDigitsFromString = value => value.replace(/[^0-9]/g, '');
12
+ const extractDigitsFromString = value => value.replace(/[^-0-9]/g, '');
13
13
 
14
14
  exports.extractDigitsFromString = extractDigitsFromString;
15
15
  //# sourceMappingURL=extractNumbersFromString.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/extractNumbersFromString.ts"],"names":["extractNumbersFromString","value","Number","replace","extractDigitsFromString"],"mappings":";;;;;;;AAAO,MAAMA,wBAAwB,GAAIC,KAAD,IACtCC,MAAM,CAACD,KAAK,CAACE,OAAN,CAAc,SAAd,EAAyB,EAAzB,CAAD,CADD;;;;AAMA,MAAMC,uBAAuB,GAAIH,KAAD,IACrCA,KAAK,CAACE,OAAN,CAAc,SAAd,EAAyB,EAAzB,CADK","sourcesContent":["export const extractNumbersFromString = (value: string): number =>\n Number(value.replace(/[^0-9]/g, ''));\n\n/*\n * implemented for the case: string numbers start with 0. Example: 012.345.678-91 Example: 012.345.678-91\n * */\nexport const extractDigitsFromString = (value: string): string =>\n value.replace(/[^0-9]/g, '');\n"],"file":"extractNumbersFromString.js"}
1
+ {"version":3,"sources":["../../src/utils/extractNumbersFromString.ts"],"names":["extractNumbersFromString","value","Number","extractDigitsFromString","replace"],"mappings":";;;;;;;AAAO,MAAMA,wBAAwB,GAAIC,KAAD,IAA2BC,MAAM,CAACC,uBAAuB,CAACF,KAAD,CAAxB,CAAlE;;;;AAKA,MAAME,uBAAuB,GAAIF,KAAD,IAA2BA,KAAK,CAACG,OAAN,CAAc,UAAd,EAA0B,EAA1B,CAA3D","sourcesContent":["export const extractNumbersFromString = (value: string): number => Number(extractDigitsFromString(value));\n\n/*\n * implemented for the case: string numbers start with 0. Example: 012.345.678-91 Example: 012.345.678-91\n * */\nexport const extractDigitsFromString = (value: string): string => value.replace(/[^-0-9]/g, '');\n"],"file":"extractNumbersFromString.js"}
@@ -1,2 +1,4 @@
1
1
  export { lightenDarkenColor } from './lightenDarkenColor';
2
2
  export { extractNumbersFromString, extractDigitsFromString, } from './extractNumbersFromString';
3
+ export * from './IPhoneXHelper';
4
+ export * from './ResponsiveFontSize';
@@ -3,6 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ lightenDarkenColor: true,
8
+ extractNumbersFromString: true,
9
+ extractDigitsFromString: true
10
+ };
6
11
  Object.defineProperty(exports, "lightenDarkenColor", {
7
12
  enumerable: true,
8
13
  get: function () {
@@ -25,4 +30,32 @@ Object.defineProperty(exports, "extractDigitsFromString", {
25
30
  var _lightenDarkenColor = require("./lightenDarkenColor");
26
31
 
27
32
  var _extractNumbersFromString = require("./extractNumbersFromString");
33
+
34
+ var _IPhoneXHelper = require("./IPhoneXHelper");
35
+
36
+ Object.keys(_IPhoneXHelper).forEach(function (key) {
37
+ if (key === "default" || key === "__esModule") return;
38
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
39
+ if (key in exports && exports[key] === _IPhoneXHelper[key]) return;
40
+ Object.defineProperty(exports, key, {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _IPhoneXHelper[key];
44
+ }
45
+ });
46
+ });
47
+
48
+ var _ResponsiveFontSize = require("./ResponsiveFontSize");
49
+
50
+ Object.keys(_ResponsiveFontSize).forEach(function (key) {
51
+ if (key === "default" || key === "__esModule") return;
52
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
53
+ if (key in exports && exports[key] === _ResponsiveFontSize[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _ResponsiveFontSize[key];
58
+ }
59
+ });
60
+ });
28
61
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export { lightenDarkenColor } from './lightenDarkenColor';\nexport {\n extractNumbersFromString,\n extractDigitsFromString,\n} from './extractNumbersFromString';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAIA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export { lightenDarkenColor } from './lightenDarkenColor';\nexport {\n extractNumbersFromString,\n extractDigitsFromString,\n} from './extractNumbersFromString';\nexport * from './IPhoneXHelper'\nexport * from './ResponsiveFontSize'"],"file":"index.js"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tecsinapse/react-core",
3
3
  "description": "TecSinapse hybrid React components",
4
- "version": "1.12.3",
4
+ "version": "1.12.7",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -31,5 +31,5 @@
31
31
  "react-native": ">=0.64.0",
32
32
  "react-native-vector-icons": ">=8.1.0"
33
33
  },
34
- "gitHead": "70d4f967e058d9d50acaf752273a9063d64c6074"
34
+ "gitHead": "cdb61cb619e5098670792c47729e0aae373749fc"
35
35
  }
@@ -1,6 +1,7 @@
1
- import { View } from 'react-native';
2
1
  import styled, { css } from '@emotion/native';
3
- import { StyleProps } from '@tecsinapse/react-core';
2
+ import { View } from 'react-native';
3
+ import { StyleProps } from '../../../types/defaults';
4
+ import { RFValueStr } from '../../../utils';
4
5
  import { BadgeProps } from './Badge';
5
6
 
6
7
  const baseStyle = ({
@@ -17,8 +18,8 @@ const baseStyle = ({
17
18
  justify-content: center;
18
19
  height: ${theme.iconSize.centi};
19
20
  width: ${theme.iconSize.centi};
20
- top: -4px;
21
- right: -4px;
21
+ top: ${RFValueStr('-4px')};
22
+ right: ${RFValueStr('-4px')};
22
23
  `;
23
24
  };
24
25
 
@@ -1,5 +1,6 @@
1
1
  import styled, { css } from '@emotion/native';
2
2
  import { StyleProps } from '../../../types/defaults';
3
+ import { RFValueStr } from '../../../utils';
3
4
  import { PressableSurface } from '../PressableSurface';
4
5
  import { ButtonProps } from './Button';
5
6
 
@@ -20,12 +21,12 @@ const sizeStyles = ({ theme, size = 'default' }: StyleProps & ButtonProps) => {
20
21
  case 'small':
21
22
  return css`
22
23
  padding: ${theme.spacing.mili} ${theme.spacing.deca};
23
- min-height: 34px;
24
+ min-height: ${RFValueStr('34px')};
24
25
  `;
25
26
  default:
26
27
  return css`
27
28
  padding: ${theme.spacing.mili} ${theme.spacing.kilo};
28
- min-height: 44px;
29
+ min-height: ${RFValueStr('44px')};
29
30
  `;
30
31
  }
31
32
  };
@@ -1,6 +1,7 @@
1
1
  import styled, { css } from '@emotion/native';
2
2
  import { FC } from 'react';
3
3
  import { StyleProps } from '../../../types/defaults';
4
+ import { RFValueStr } from '../../../utils';
4
5
  import { ButtonSizeType } from '../Button';
5
6
  import { PressableSurface } from '../PressableSurface';
6
7
  import { TextProps } from '../Text';
@@ -104,12 +105,12 @@ const sizeStyles = ({
104
105
  case 'small':
105
106
  return css`
106
107
  padding: ${theme?.spacing.mili} ${theme?.spacing.deca};
107
- min-height: 34px;
108
+ min-height: ${RFValueStr('34px')};
108
109
  `;
109
110
  default:
110
111
  return css`
111
112
  padding: ${theme?.spacing.mili} ${theme?.spacing.kilo};
112
- min-height: 44px;
113
+ min-height: ${RFValueStr('44px')};
113
114
  `;
114
115
  }
115
116
  };
@@ -2,6 +2,7 @@ import styled, { css } from '@emotion/native';
2
2
  import { TextInput } from 'react-native';
3
3
  import { InputElementProps } from '.';
4
4
  import { StyleProps } from '../../../types/defaults';
5
+ import { RFValueStr } from '../../../utils';
5
6
  import { Icon } from '../Icon';
6
7
  import { InputContainerProps } from './InputContainer/InputContainer';
7
8
 
@@ -62,7 +63,7 @@ export const StyledInputContainer = styled.View<
62
63
  >`
63
64
  flex-direction: row;
64
65
  align-items: center;
65
- min-height: 44px;
66
+ min-height: ${RFValueStr('44px')};
66
67
  `;
67
68
 
68
69
  export const StyledInputElementBase = styled(TextInput)<
@@ -1,6 +1,7 @@
1
1
  import styled from '@emotion/native';
2
- import { StyleProps } from '@tecsinapse/react-core';
3
2
  import { Animated } from 'react-native';
3
+ import { StyleProps } from '../../../types/defaults';
4
+ import { RFValueStr } from '../../../utils';
4
5
 
5
6
  export const Container = styled.View<Partial<StyleProps>>`
6
7
  display: flex;
@@ -14,7 +15,7 @@ export const Container = styled.View<Partial<StyleProps>>`
14
15
  export const Segment = styled.View<Partial<StyleProps>>`
15
16
  flex: 1;
16
17
  background-color: ${({ theme }) => theme.color.secondary.light};
17
- border-right-width: 2px;
18
+ border-right-width: ${RFValueStr('2px')};
18
19
  border-color: ${({ theme }) => theme.color.secondary.xlight};
19
20
  `;
20
21
 
@@ -1,15 +1,15 @@
1
1
  import { useTheme } from '@emotion/react';
2
2
  import React, { FC, useCallback, useEffect } from 'react';
3
- import { Animated, StyleProp, ViewStyle, Text } from 'react-native';
3
+ import { Animated, LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';
4
4
  import {
5
5
  ColorGradationType,
6
6
  ColorType,
7
- ThemeProp,
7
+ ThemeProp
8
8
  } from '../../../types/defaults';
9
+ import { extractNumbersFromString, lightenDarkenColor, RFValueStr } from '../../../utils';
9
10
  import { PressableSurface } from '../PressableSurface';
10
- import { StyledSwitch } from './styled';
11
11
  import { transitionSwitch } from './animation';
12
- import { extractNumbersFromString, lightenDarkenColor } from '../../../utils';
12
+ import { StyledSwitch, StyledSwitchContent, SWITCH_PIN_WIDTH } from './styled';
13
13
 
14
14
  export interface SwitchProps {
15
15
  onChange: (active: boolean) => void;
@@ -36,44 +36,43 @@ const Switch: FC<SwitchProps> = ({
36
36
  }): JSX.Element => {
37
37
  const theme = useTheme() as ThemeProp;
38
38
 
39
- const transitionValue = React.useRef(new Animated.Value(active ? 16.5 : 0))
40
- .current;
39
+ const width = React.useRef(0)
40
+ const transitionValue = React.useRef(new Animated.Value(0)).current
41
+ const animatedColor = React.useRef(new Animated.Value(0)).current
42
+
43
+ const calculateTranslate = () => {
44
+ if (width.current > 0) {
45
+ return width.current - (extractNumbersFromString(theme.spacing.micro) * 2) - (extractNumbersFromString(RFValueStr(SWITCH_PIN_WIDTH)))
46
+ }
47
+ return 0
48
+ }
41
49
 
42
- const animatedColor = React.useRef(new Animated.Value(active ? 1 : 0))
43
- .current;
44
-
45
- const getBackgroundColor = (color: string, variation: number) => {
46
- return disabled ? lightenDarkenColor(color, variation) : color;
50
+ const getBackgroundColor = (color: string) => {
51
+ return disabled ? lightenDarkenColor(theme.color[inactiveColor][inactiveColorTone], 20) : color;
47
52
  };
48
53
 
49
54
  const interpolateColor = animatedColor.interpolate({
50
55
  inputRange: [0, 1],
51
56
  outputRange: [
52
- getBackgroundColor(theme.color[inactiveColor][inactiveColorTone], 25),
53
- getBackgroundColor(theme.color[activeColor][activeColorTone], 50),
54
- ],
57
+ getBackgroundColor(theme.color[inactiveColor][inactiveColorTone]),
58
+ getBackgroundColor(theme.color[activeColor][activeColorTone]),
59
+ ]
55
60
  });
56
61
 
57
- const animatedStyle = {
58
- backgroundColor: interpolateColor,
59
- };
60
-
61
62
  useEffect(() => {
62
- transitionSwitch(!active, transitionValue, animatedColor);
63
+ const translate = calculateTranslate()
64
+ transitionSwitch(active, translate, transitionValue, animatedColor);
63
65
  }, [active]);
64
66
 
65
67
  const handleChange = useCallback(() => {
66
68
  onChange(!active);
67
69
  }, [active, onChange]);
68
70
 
69
- const stylesDefault: ViewStyle = {
70
- borderRadius: extractNumbersFromString(theme.borderRadius.pill),
71
- paddingHorizontal: extractNumbersFromString(theme.spacing.micro),
72
- paddingVertical: 0,
73
- justifyContent: 'center',
74
- width: 40,
75
- height: 22,
76
- };
71
+ const handleSwitchLayout = (lce: LayoutChangeEvent) => {
72
+ width.current = lce.nativeEvent.layout.width
73
+ const translate = calculateTranslate()
74
+ transitionSwitch(active, translate, transitionValue, animatedColor);
75
+ }
77
76
 
78
77
  return (
79
78
  <PressableSurface
@@ -82,11 +81,9 @@ const Switch: FC<SwitchProps> = ({
82
81
  effect="none"
83
82
  disabled={disabled}
84
83
  >
85
- <Animated.View style={{ ...animatedStyle, ...stylesDefault }}>
86
- <StyledSwitch
87
- style={[dotStyle, { transform: [{ translateX: transitionValue }] }]}
88
- />
89
- </Animated.View>
84
+ <StyledSwitchContent onLayout={handleSwitchLayout} style={{ backgroundColor: interpolateColor }}>
85
+ <StyledSwitch style={[dotStyle, { transform: [{ translateX: transitionValue }] }]}/>
86
+ </StyledSwitchContent>
90
87
  </PressableSurface>
91
88
  );
92
89
  };
@@ -1,31 +1,41 @@
1
- import { Animated } from 'react-native';
1
+ import { Animated, Easing } from 'react-native';
2
+
3
+ const ANIMATION_SPEED = 140
2
4
 
3
5
  export const transitionSwitch = (
4
6
  active: boolean,
7
+ translate: number,
5
8
  transitionValue: Animated.Value,
6
9
  animatedColor: Animated.Value
7
10
  ): void => {
11
+
12
+ if (translate <= 0) return
13
+
8
14
  if (active) {
9
15
  Animated.timing(transitionValue, {
10
- toValue: 0,
11
- duration: 150,
12
- useNativeDriver: true,
13
- }).start();
14
- Animated.timing(animatedColor, {
15
- toValue: 0,
16
- duration: 150,
17
- useNativeDriver: false,
18
- }).start();
19
- } else {
20
- Animated.timing(transitionValue, {
21
- toValue: 16.5,
22
- duration: 150,
16
+ toValue: translate,
17
+ duration: ANIMATION_SPEED,
18
+ easing: Easing.out(Easing.ease),
23
19
  useNativeDriver: true,
24
20
  }).start();
25
21
  Animated.timing(animatedColor, {
26
22
  toValue: 1,
27
- duration: 150,
23
+ duration: ANIMATION_SPEED,
28
24
  useNativeDriver: false,
29
25
  }).start();
30
- }
26
+ return
27
+ }
28
+
29
+ Animated.timing(transitionValue, {
30
+ toValue: 0,
31
+ duration: ANIMATION_SPEED,
32
+ easing: Easing.out(Easing.ease),
33
+ useNativeDriver: true,
34
+ }).start();
35
+ Animated.timing(animatedColor, {
36
+ toValue: 0,
37
+ duration: ANIMATION_SPEED,
38
+ useNativeDriver: false,
39
+ }).start();
40
+
31
41
  };
@@ -1,20 +1,24 @@
1
1
  import styled from '@emotion/native';
2
- import { StyleProps, SwitchProps } from '@tecsinapse/react-core';
3
2
  import { Animated } from 'react-native';
3
+ import { StyleProps } from '../../../types/defaults';
4
+ import { RFValueStr } from '../../../utils';
5
+
6
+ export const SWITCH_BODY_WIDTH = '40px'
7
+ export const SWITCH_PIN_WIDTH = '16px'
4
8
 
5
9
  export const StyledSwitchContent = styled(Animated.View)<
6
- Partial<SwitchProps> & Partial<StyleProps>
10
+ Partial<StyleProps>
7
11
  >`
8
12
  border-radius: ${({ theme }) => theme.borderRadius.pill};
9
13
  padding: 0 ${({ theme }) => theme.spacing.micro};
10
14
  justify-content: center;
11
- width: 40px;
12
- height: 22px;
15
+ width: ${RFValueStr(SWITCH_BODY_WIDTH)};
16
+ height: ${RFValueStr('22px')};
13
17
  `;
14
18
 
15
19
  export const StyledSwitch = styled(Animated.View)<Partial<StyleProps>>`
16
20
  border-radius: ${({ theme }) => theme.borderRadius.pill};
17
21
  background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};
18
- width: 16px;
19
- height: 16px;
22
+ width: ${RFValueStr(SWITCH_PIN_WIDTH)};
23
+ height: ${RFValueStr('16px')};
20
24
  `;
@@ -3,10 +3,8 @@ import { StyleProps } from '@tecsinapse/react-core';
3
3
 
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
5
  export const baseStyles = ({ theme }: StyleProps): any => css`
6
- padding: ${theme.spacing.deca};
7
6
  border-radius: ${theme.borderRadius.mili};
8
7
  background-color: ${theme.miscellaneous.surfaceColor};
9
- overflow: hidden;
10
8
  `;
11
9
 
12
10
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -17,10 +15,10 @@ export const elevatedStyles = ({
17
15
  elevated && [
18
16
  css({
19
17
  shadowColor: theme.miscellaneous.shadow,
20
- shadowOffset: { width: 0, height: 1 },
21
- shadowOpacity: 0.2,
22
- shadowRadius: 1.4,
23
- elevation: 2,
18
+ shadowOffset: { width: 0, height: 2 },
19
+ shadowOpacity: 0.05,
20
+ shadowRadius: 5,
21
+ elevation: 2
24
22
  }),
25
23
  ];
26
24
  /* eslint-enable @typescript-eslint/no-explicit-any */
@@ -1,11 +1,13 @@
1
1
  import styled, { css } from '@emotion/native';
2
2
  import { FC } from 'react';
3
3
  import { Platform } from 'react-native';
4
+ import { hex2rgba } from '../../../styles/definitions';
5
+ import { StyleProps } from '../../../types/defaults';
6
+ import { RFValue } from '../../../utils';
4
7
  import { Icon } from '../../atoms/Icon';
5
8
  import { disabledInputStyles, InputContainerProps } from '../../atoms/Input';
6
9
  import { PressableSurface } from '../../atoms/PressableSurface';
7
10
  import { TextProps } from '../../atoms/Text';
8
- import { hex2rgba, StyleProps } from '@tecsinapse/react-core';
9
11
 
10
12
  const isWeb = Platform.OS === 'web';
11
13
 
@@ -29,7 +31,7 @@ export const ModalContent = styled.View<
29
31
  { offset: number } & Partial<StyleProps>
30
32
  >`
31
33
  background-color: transparent;
32
- padding-bottom: ${({ offset }) => `${offset}px`};
34
+ padding-bottom: ${({ offset }) => `${RFValue(offset)}px`};
33
35
  ${({ theme: { borderRadius } }) => css`
34
36
  ${isWeb
35
37
  ? `
@@ -2,9 +2,10 @@ import styled, { css } from '@emotion/native';
2
2
  import { FC } from 'react';
3
3
  import { Platform } from 'react-native';
4
4
  import { StyleProps } from '../../../types/defaults';
5
+ import { RFValue, RFValueStr } from '../../../utils';
5
6
  import {
6
7
  PressableSurface,
7
- PressableSurfaceProps,
8
+ PressableSurfaceProps
8
9
  } from '../../atoms/PressableSurface';
9
10
  import { DateTimeSelectorProps } from '../DateTimeSelector';
10
11
 
@@ -35,11 +36,11 @@ export const ModalContent = styled.View<
35
36
  { offset: number } & Partial<StyleProps>
36
37
  >`
37
38
  background-color: transparent;
38
- padding-bottom: ${({ offset }) => `${offset}px`};
39
+ padding-bottom: ${({ offset }) => `${RFValue(offset)}px`};
39
40
  ${({ theme: { borderRadius } }) => css`
40
41
  ${isWeb
41
42
  ? `
42
- width: 375px;
43
+ width: ${RFValueStr('375px')};
43
44
  border-radius: ${borderRadius.micro};
44
45
  `
45
46
  : `
@@ -1,5 +1,6 @@
1
1
  import styled from '@emotion/native';
2
2
  import { StyleProps } from '../../../types/defaults';
3
+ import { RFValueStr } from '../../../utils';
3
4
  import { PressableSurface } from '../../atoms/PressableSurface';
4
5
 
5
6
  export const Root = styled.View<Partial<StyleProps>>`
@@ -14,7 +15,7 @@ export const Content = styled.View<Partial<StyleProps>>`
14
15
  `;
15
16
 
16
17
  export const SelectorRoot = styled.View<Partial<StyleProps>>`
17
- border-width: 1px;
18
+ border-width: ${RFValueStr('1px')};
18
19
  border-color: ${({ theme }) => theme.color.secondary.xlight};
19
20
  border-radius: ${({ theme }) => theme.borderRadius.mili};
20
21
  `;
@@ -1,10 +1,11 @@
1
- import { View } from 'react-native';
2
1
  import styled, { css } from '@emotion/native';
3
- import { SnackbarProps } from './Snackbar';
2
+ import { View } from 'react-native';
4
3
  import { StyleProps } from '../../../types/defaults';
5
- import { ProgressBar } from '../../atoms/ProgressBar';
4
+ import { RFValue } from '../../../utils';
6
5
  import { Paper } from '../../atoms/Paper';
7
6
  import { PressableSurface } from '../../atoms/PressableSurface';
7
+ import { ProgressBar } from '../../atoms/ProgressBar';
8
+ import { SnackbarProps } from './Snackbar';
8
9
 
9
10
  const baseStyles = ({
10
11
  theme,
@@ -31,7 +32,7 @@ const anchorTop = ({
31
32
  return (
32
33
  anchor === 'top' &&
33
34
  css`
34
- top: ${anchorDistance ? `${anchorDistance}px` : theme.spacing.deca};
35
+ top: ${anchorDistance ? `${RFValue(anchorDistance)}px` : theme.spacing.deca};
35
36
  `
36
37
  );
37
38
  };
@@ -44,7 +45,7 @@ const anchorBottom = ({
44
45
  return (
45
46
  anchor === 'bottom' &&
46
47
  css`
47
- bottom: ${anchorDistance ? `${anchorDistance}px` : theme.spacing.deca};
48
+ bottom: ${anchorDistance ? `${RFValue(anchorDistance)}px` : theme.spacing.deca};
48
49
  `
49
50
  );
50
51
  };
@@ -1,25 +1,19 @@
1
1
  import styled from '@emotion/native';
2
- import {
3
- extractNumbersFromString,
4
- InputContainer,
5
- InputElement,
6
- StyleProps,
7
- } from '@tecsinapse/react-core';
2
+ import { StyleProps } from '../../../types/defaults';
3
+ import { extractNumbersFromString, RFValue, RFValueStr } from '../../../utils';
4
+ import { InputContainer, InputElement } from '../../atoms/Input';
8
5
  import { TextAreaProps } from './TextArea';
9
6
 
10
7
  export const StyledInputContainer = styled(InputContainer)<Partial<StyleProps>>`
11
- min-height: 50px;
8
+ min-height: ${RFValueStr('50px')};
12
9
  `;
13
10
 
14
11
  export const TextAreaInputBase = styled(InputElement)<
15
12
  Partial<TextAreaProps> & Partial<StyleProps>
16
13
  >`
17
14
  max-height: ${({ theme, numberOfLines }) =>
18
- `${
19
- extractNumbersFromString(theme.typography.h5.lineHeight) *
20
- (numberOfLines || 1)
21
- }px`};
15
+ `${RFValue(extractNumbersFromString(theme.typography.h5.lineHeight) * (numberOfLines || 1))}px`};
22
16
  width: 100%;
23
17
  padding: 0;
24
- margin: 3px 0;
18
+ margin: ${RFValueStr('3px')} 0;
25
19
  `;