@tecsinapse/react-core 1.12.2 → 1.12.6
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/Badge/styled.d.ts +3 -2
- package/dist/components/atoms/Badge/styled.js +5 -3
- package/dist/components/atoms/Badge/styled.js.map +1 -1
- package/dist/components/atoms/Button/styled.js +4 -2
- package/dist/components/atoms/Button/styled.js.map +1 -1
- package/dist/components/atoms/GroupButton/styled.js +4 -2
- package/dist/components/atoms/GroupButton/styled.js.map +1 -1
- package/dist/components/atoms/Input/styled.js +3 -1
- package/dist/components/atoms/Input/styled.js.map +1 -1
- package/dist/components/atoms/ProgressBar/styled.d.ts +15 -3
- package/dist/components/atoms/ProgressBar/styled.js +3 -1
- package/dist/components/atoms/ProgressBar/styled.js.map +1 -1
- package/dist/components/atoms/Switch/Switch.js +30 -22
- package/dist/components/atoms/Switch/Switch.js.map +1 -1
- package/dist/components/atoms/Switch/animation.d.ts +1 -1
- package/dist/components/atoms/Switch/animation.js +24 -16
- package/dist/components/atoms/Switch/animation.js.map +1 -1
- package/dist/components/atoms/Switch/styled.d.ts +16 -2
- package/dist/components/atoms/Switch/styled.js +11 -5
- package/dist/components/atoms/Switch/styled.js.map +1 -1
- package/dist/components/atoms/shared/PaperAndCard.js +0 -1
- package/dist/components/atoms/shared/PaperAndCard.js.map +1 -1
- package/dist/components/molecules/DatePicker/styled.d.ts +25 -4
- package/dist/components/molecules/DatePicker/styled.js +7 -5
- package/dist/components/molecules/DatePicker/styled.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/styled.js +4 -2
- package/dist/components/molecules/DateTimePicker/styled.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/styled.js +3 -1
- package/dist/components/molecules/DateTimeSelector/styled.js.map +1 -1
- package/dist/components/molecules/Grid/Grid.d.ts +6 -1
- package/dist/components/molecules/Grid/Grid.js.map +1 -1
- package/dist/components/molecules/Grid/Item/Item.d.ts +6 -1
- package/dist/components/molecules/Grid/Item/Item.js +12 -1
- package/dist/components/molecules/Grid/Item/Item.js.map +1 -1
- package/dist/components/molecules/Snackbar/styled.js +7 -5
- package/dist/components/molecules/Snackbar/styled.js.map +1 -1
- package/dist/components/molecules/TextArea/styled.d.ts +13 -6
- package/dist/components/molecules/TextArea/styled.js +8 -6
- package/dist/components/molecules/TextArea/styled.js.map +1 -1
- package/dist/styles/definitions.js +44 -41
- package/dist/styles/definitions.js.map +1 -1
- package/dist/utils/IPhoneXHelper.d.ts +4 -0
- package/dist/utils/IPhoneXHelper.js +38 -0
- package/dist/utils/IPhoneXHelper.js.map +1 -0
- package/dist/utils/ResponsiveFontSize.d.ts +3 -0
- package/dist/utils/ResponsiveFontSize.js +57 -0
- package/dist/utils/ResponsiveFontSize.js.map +1 -0
- package/dist/utils/extractNumbersFromString.js +2 -2
- package/dist/utils/extractNumbersFromString.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +33 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/atoms/Badge/styled.ts +5 -4
- package/src/components/atoms/Button/styled.ts +3 -2
- package/src/components/atoms/GroupButton/styled.ts +3 -2
- package/src/components/atoms/Input/styled.ts +2 -1
- package/src/components/atoms/ProgressBar/styled.ts +3 -2
- package/src/components/atoms/Switch/Switch.tsx +29 -32
- package/src/components/atoms/Switch/animation.ts +26 -16
- package/src/components/atoms/Switch/styled.ts +10 -6
- package/src/components/atoms/shared/PaperAndCard.ts +0 -1
- package/src/components/molecules/DatePicker/styled.ts +4 -2
- package/src/components/molecules/DateTimePicker/styled.ts +4 -3
- package/src/components/molecules/DateTimeSelector/styled.ts +2 -1
- package/src/components/molecules/Grid/Grid.tsx +8 -1
- package/src/components/molecules/Grid/Item/Item.tsx +24 -2
- package/src/components/molecules/Snackbar/styled.ts +6 -5
- package/src/components/molecules/TextArea/styled.ts +6 -12
- package/src/styles/definitions.ts +43 -42
- package/src/utils/IPhoneXHelper.ts +34 -0
- package/src/utils/ResponsiveFontSize.ts +52 -0
- package/src/utils/extractNumbersFromString.ts +2 -4
- package/src/utils/index.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/styles/definitions.ts"],"names":["statusColor","error","xlight","light","medium","dark","xdark","warning","success","info","hex2rgba","hex","alpha","r","g","b","match","map","x","parseInt","miscellaneous","shadow","overlay","bodyColor","surfaceColor","spacing","nano","micro","mili","centi","deca","kilo","mega","giga","tera","peta","hexa","iconSize","borderRadius","pill","borderWidth","pico","typography","h5","fontSize","lineHeight","h4","h3","h2","h1","base","sub","label","fontStack","default","mono","fontWeight","regular","bold","black","fontFiles","fontColor","orange","zIndex","absolute","select","input","popover","tooltip","header","backdrop","drawer","sidebar","modal"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/styles/definitions.ts"],"names":["statusColor","error","xlight","light","medium","dark","xdark","warning","success","info","hex2rgba","hex","alpha","r","g","b","match","map","x","parseInt","miscellaneous","shadow","overlay","bodyColor","surfaceColor","spacing","nano","micro","mili","centi","deca","kilo","mega","giga","tera","peta","hexa","iconSize","borderRadius","pill","borderWidth","pico","typography","h5","fontSize","lineHeight","h4","h3","h2","h1","base","sub","label","fontStack","default","mono","fontWeight","regular","bold","black","fontFiles","fontColor","orange","zIndex","absolute","select","input","popover","tooltip","header","backdrop","drawer","sidebar","modal"],"mappings":";;;;;;;AAYA;;AAEO,MAAMA,WAAW,GAAG;AACzBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,MAAM,EAAE,SADH;AAELC,IAAAA,KAAK,EAAE,SAFF;AAGLC,IAAAA,MAAM,EAAE,SAHH;AAILC,IAAAA,IAAI,EAAE,SAJD;AAKLC,IAAAA,KAAK,EAAE;AALF,GADkB;AAQzBC,EAAAA,OAAO,EAAE;AACPL,IAAAA,MAAM,EAAE,SADD;AAEPC,IAAAA,KAAK,EAAE,SAFA;AAGPC,IAAAA,MAAM,EAAE,SA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AA,OAAO,EAAE;AAH0B,CAA9B;;AAMA,MAAMI,SAAoB,GAAG;AAClC1D,EAAAA,KAAK,EAAE,MAD2B;AAElCC,EAAAA,MAAM,EAAE,SAF0B;AAGlCC,EAAAA,IAAI,EAAE,SAH4B;AAIlCyD,EAAAA,MAAM,EAAE;AAJ0B,CAA7B;;AAOA,MAAMC,MAAc,GAAG;AAC5BT,EAAAA,OAAO,EAAE,CADmB;AAE5BU,EAAAA,QAAQ,EAAE,CAFkB;AAG5BC,EAAAA,MAAM,EAAE,EAHoB;AAI5BC,EAAAA,KAAK,EAAE,EAJqB;AAK5BC,EAAAA,OAAO,EAAE,EALmB;AAM5BC,EAAAA,OAAO,EAAE,EANmB;AAO5BC,EAAAA,MAAM,EAAE,GAPoB;AAQ5BC,EAAAA,QAAQ,EAAE,GARkB;AAS5BC,EAAAA,MAAM,EAAE,GAToB;AAU5BC,EAAAA,OAAO,EAAE,GAVmB;AAW5BC,EAAAA,KAAK,EAAE;AAXqB,CAAvB","sourcesContent":["import {\n BorderRadius,\n BorderWidth,\n FontColor,\n FontStack,\n FontWeight,\n IconSize,\n Miscellaneous,\n Spacing,\n TypographyVariation,\n ZIndex\n} from '../types/defaults';\nimport { RFValueStr } from '../utils';\n\nexport const statusColor = {\n error: {\n xlight: '#fdf3f2',\n light: '#ee9891',\n medium: '#e04638',\n dark: '#9b2318',\n xdark: '#58240e',\n },\n warning: {\n xlight: '#fffcf0',\n light: '#ffe380',\n medium: '#ffc700',\n dark: '#cc9f00',\n xdark: '#665000',\n },\n success: {\n xlight: '#f3fcf8',\n light: '#99e6c9',\n medium: '#2db783',\n dark: '#238f67',\n xdark: '#14523b',\n },\n info: {\n xlight: '#f0f8fe',\n light: '#85c7fa',\n medium: '#239bf6',\n dark: '#0873c4',\n xdark: '#043962',\n },\n};\n\nexport const hex2rgba: (hex, alpha?: number) => string = (hex, alpha = 1) => {\n const [r, g, b] = hex.match(/\\w\\w/g).map(x => parseInt(x, 16));\n return `rgba(${r},${g},${b},${alpha})`;\n};\n\nexport const miscellaneous: Miscellaneous = {\n shadow: '#85807a', // rgba(133, 128, 122, 0.08)\n overlay: '#282625', // rgba(40, 38, 37, 0.5)\n bodyColor: '#f8f7f7',\n surfaceColor: '#ffffff', //input, group button, cards\n};\n\nexport const spacing: Spacing = {\n nano: RFValueStr('2px'),\n micro: RFValueStr('4px'),\n mili: RFValueStr('8px'),\n centi: RFValueStr('12px'),\n deca: RFValueStr('16px'),\n kilo: RFValueStr('24px'),\n mega: RFValueStr('32px'),\n giga: RFValueStr('40px'),\n tera: RFValueStr('48px'),\n peta: RFValueStr('56px'),\n hexa: RFValueStr('64px'),\n};\n\nexport const iconSize: IconSize = {\n micro: RFValueStr('12px'),\n mili: RFValueStr('14px'),\n centi: RFValueStr('16px'), // '1rem'\n deca: RFValueStr('18px'), // '1.5rem'\n kilo: RFValueStr('24px'), // '1.6rem'\n mega: RFValueStr('32px'), // '2rem'\n};\n\nexport const borderRadius: BorderRadius = {\n nano: RFValueStr('2px'),\n micro: RFValueStr('4px'),\n mili: RFValueStr('8px'),\n centi: RFValueStr('16px'),\n deca: RFValueStr('24px'),\n pill: RFValueStr('999999px'), // also circle\n};\n\nexport const borderWidth: BorderWidth = {\n pico: RFValueStr('1px'),\n nano: RFValueStr('2px'),\n};\n\nexport const typography: TypographyVariation = {\n h5: {\n fontSize: RFValueStr('16px'), // '1rem'\n lineHeight: RFValueStr('24px'), // '1.5rem'\n },\n h4: {\n fontSize: RFValueStr('18px'), // '1.125rem'\n lineHeight: RFValueStr('27px'), // '1.688rem'\n },\n h3: {\n fontSize: RFValueStr('20px'), // '1.25rem'\n lineHeight: RFValueStr('32px'), // '2rem'\n },\n h2: {\n fontSize: RFValueStr('26px'), // '1.625rem'\n lineHeight: RFValueStr('38px'), // '2.375rem'\n },\n h1: {\n fontSize: RFValueStr('32px'), // '2rem'\n lineHeight: RFValueStr('42px'), // '2.625rem'\n },\n base: {\n fontSize: RFValueStr('14px'), // '0.875rem'\n lineHeight: RFValueStr('21px'), // '1.313rem'\n },\n sub: {\n fontSize: RFValueStr('12px'), // '0.75rem'\n lineHeight: RFValueStr('18px'), // '1.125rem'\n },\n label: {\n fontSize: RFValueStr('10px'),\n lineHeight: RFValueStr('12px'),\n },\n};\n\nexport const fontStack: FontStack = {\n default: 'Lato',\n mono: 'Consolas, monaco, monospace',\n};\n\nexport const fontWeight: FontWeight = {\n regular: '400',\n bold: '700',\n black: '900',\n};\n\nexport const fontFiles: FontWeight = {\n black: '{0}-Black',\n bold: '{0}-Bold',\n regular: '{0}-Regular',\n};\n\nexport const fontColor: FontColor = {\n light: '#fff',\n medium: '#85807a',\n dark: '#353231', // default\n orange: '#f89907',\n};\n\nexport const zIndex: ZIndex = {\n default: 0,\n absolute: 1,\n select: 20,\n input: 20,\n popover: 30,\n tooltip: 40,\n header: 600,\n backdrop: 700,\n drawer: 700,\n sidebar: 800,\n modal: 1000,\n};\n\nexport type IconType =\n | 'material'\n | 'material-community'\n | 'simple-line-icon'\n | 'zocial'\n | 'font-awesome'\n | 'octicon'\n | 'ionicon'\n | 'foundation'\n | 'evilicon'\n | 'entypo'\n | 'antdesign'\n | 'font-awesome-5'\n | string;\n"],"file":"definitions.js"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isIphoneX = isIphoneX;
|
|
7
|
+
exports.ifIphoneX = ifIphoneX;
|
|
8
|
+
exports.getStatusBarHeight = getStatusBarHeight;
|
|
9
|
+
exports.getBottomSpace = getBottomSpace;
|
|
10
|
+
|
|
11
|
+
var _reactNative = require("react-native");
|
|
12
|
+
|
|
13
|
+
function isIphoneX() {
|
|
14
|
+
const dimen = _reactNative.Dimensions.get('window');
|
|
15
|
+
|
|
16
|
+
return _reactNative.Platform.OS === 'ios' && !_reactNative.Platform.isPad && !_reactNative.Platform.isTVOS && (dimen.height === 780 || dimen.width === 780 || dimen.height === 812 || dimen.width === 812 || dimen.height === 844 || dimen.width === 844 || dimen.height === 896 || dimen.width === 896 || dimen.height === 926 || dimen.width === 926);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function ifIphoneX(iphoneXStyle, regularStyle) {
|
|
20
|
+
if (isIphoneX()) {
|
|
21
|
+
return iphoneXStyle;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return regularStyle;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getStatusBarHeight(safe) {
|
|
28
|
+
return _reactNative.Platform.select({
|
|
29
|
+
ios: ifIphoneX(safe ? 44 : 30, 20),
|
|
30
|
+
android: _reactNative.StatusBar.currentHeight,
|
|
31
|
+
default: 0
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getBottomSpace() {
|
|
36
|
+
return isIphoneX() ? 34 : 0;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=IPhoneXHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/IPhoneXHelper.ts"],"names":["isIphoneX","dimen","Dimensions","get","Platform","OS","isPad","isTVOS","height","width","ifIphoneX","iphoneXStyle","regularStyle","getStatusBarHeight","safe","select","ios","android","StatusBar","currentHeight","default","getBottomSpace"],"mappings":";;;;;;;;;;AAAA;;AAEO,SAASA,SAAT,GAAqB;AACxB,QAAMC,KAAK,GAAGC,wBAAWC,GAAX,CAAe,QAAf,CAAd;;AACA,SACIC,sBAASC,EAAT,KAAgB,KAAhB,IACA,CAACD,sBAASE,KADV,IAEA,CAACF,sBAASG,MAFV,KAGEN,KAAK,CAACO,MAAN,KAAiB,GAAjB,IAAwBP,KAAK,CAACQ,KAAN,KAAgB,GAAzC,IACKR,KAAK,CAACO,MAAN,KAAiB,GAAjB,IAAwBP,KAAK,CAACQ,KAAN,KAAgB,GAD7C,IAEKR,KAAK,CAACO,MAAN,KAAiB,GAAjB,IAAwBP,KAAK,CAACQ,KAAN,KAAgB,GAF7C,IAGKR,KAAK,CAACO,MAAN,KAAiB,GAAjB,IAAwBP,KAAK,CAACQ,KAAN,KAAgB,GAH7C,IAIKR,KAAK,CAACO,MAAN,KAAiB,GAAjB,IAAwBP,KAAK,CAACQ,KAAN,KAAgB,GAP9C,CADJ;AAUH;;AAEM,SAASC,SAAT,CAAmBC,YAAnB,EAAiCC,YAAjC,EAA+C;AAClD,MAAIZ,SAAS,EAAb,EAAiB;AACb,WAAOW,YAAP;AACH;;AACD,SAAOC,YAAP;AACH;;AAEM,SAASC,kBAAT,CAA4BC,IAA5B,EAAkC;AACrC,SAAOV,sBAASW,MAAT,CAAgB;AACnBC,IAAAA,GAAG,EAAEN,SAAS,CAACI,IAAI,GAAG,EAAH,GAAQ,EAAb,EAAiB,EAAjB,CADK;AAEnBG,IAAAA,OAAO,EAAEC,uBAAUC,aAFA;AAGnBC,IAAAA,OAAO,EAAE;AAHU,GAAhB,CAAP;AAKH;;AAEM,SAASC,cAAT,GAA0B;AAC7B,SAAOrB,SAAS,KAAK,EAAL,GAAU,CAA1B;AACH","sourcesContent":["import { Dimensions, Platform, StatusBar } from 'react-native';\n\nexport function isIphoneX() {\n const dimen = Dimensions.get('window');\n return (\n Platform.OS === 'ios' &&\n !Platform.isPad &&\n !Platform.isTVOS &&\n ((dimen.height === 780 || dimen.width === 780)\n || (dimen.height === 812 || dimen.width === 812)\n || (dimen.height === 844 || dimen.width === 844)\n || (dimen.height === 896 || dimen.width === 896)\n || (dimen.height === 926 || dimen.width === 926))\n );\n}\n\nexport function ifIphoneX(iphoneXStyle, regularStyle) {\n if (isIphoneX()) {\n return iphoneXStyle;\n }\n return regularStyle;\n}\n\nexport function getStatusBarHeight(safe) {\n return Platform.select({\n ios: ifIphoneX(safe ? 44 : 30, 20),\n android: StatusBar.currentHeight,\n default: 0\n });\n}\n\nexport function getBottomSpace() {\n return isIphoneX() ? 34 : 0;\n}"],"file":"IPhoneXHelper.js"}
|
|
@@ -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
|
|
8
|
+
const extractNumbersFromString = value => Number(extractDigitsFromString(value));
|
|
9
9
|
|
|
10
10
|
exports.extractNumbersFromString = extractNumbersFromString;
|
|
11
11
|
|
|
12
|
-
const extractDigitsFromString = value => value.replace(/[
|
|
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","
|
|
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"}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -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
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
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.
|
|
4
|
+
"version": "1.12.6",
|
|
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": "
|
|
34
|
+
"gitHead": "5005537c38efef79cdd69a324563821e01e81f99"
|
|
35
35
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { View } from 'react-native';
|
|
2
1
|
import styled, { css } from '@emotion/native';
|
|
3
|
-
import {
|
|
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
|
|
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 {
|
|
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
|
|
40
|
-
|
|
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
|
|
43
|
-
.
|
|
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]
|
|
53
|
-
getBackgroundColor(theme.color[activeColor][activeColorTone]
|
|
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
|
-
|
|
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
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
<
|
|
86
|
-
<StyledSwitch
|
|
87
|
-
|
|
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:
|
|
11
|
-
duration:
|
|
12
|
-
|
|
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:
|
|
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<
|
|
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:
|
|
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:
|
|
19
|
-
height: 16px;
|
|
22
|
+
width: ${RFValueStr(SWITCH_PIN_WIDTH)};
|
|
23
|
+
height: ${RFValueStr('16px')};
|
|
20
24
|
`;
|
|
@@ -3,7 +3,6 @@ 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
8
|
overflow: hidden;
|
|
@@ -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
|
: `
|