UNPKG

@dokuhero/react-native-components

Version:

Sets of React Native components that works with dokuhero/react-native-theme and react-i18next

39 lines 1.69 kB
import { withLocale } from '@dokuhero/react-18n-ts-helper'; import { ThemeConsumer } from '@dokuhero/react-native-theme'; import React from 'react'; import { Alert } from 'react-native'; import { CalculatorInput } from 'react-native-calculator'; import { globalStyles } from '../styles'; import { FormField } from './FormField'; export var InputPercent = withLocale('common')(function (_a) { var value = _a.value, label = _a.label, errors = _a.errors, onChange = _a.onChange, t = _a.t, max = _a.max, containerStyle = _a.containerStyle, fieldTextStyle = _a.fieldTextStyle; if (max) { max = 100; } return (<ThemeConsumer> {function (_a) { var color = _a.color; return (<FormField label={label} errors={errors} containerStyle={[containerStyle, { paddingRight: 10 }]}> <CalculatorInput value={value} fieldContainerStyle={{ marginLeft: 20, borderBottomColor: color.grey }} fieldTextStyle={[ globalStyles.inputText, { marginBottom: 6 }, fieldTextStyle ]} borderColor={color.lighter} acceptButtonBackgroundColor={color.primary} calcButtonBackgroundColor={color.secondary} suffix="%" onBeforeChange={function (val) { if (val > max) { Alert.alert('', t('maxPercentIs', { percent: 100 })); return false; } return true; }} onChange={function (val) { if (onChange) { onChange(val); } }} height={300}/> </FormField>); }} </ThemeConsumer>); }); //# sourceMappingURL=InputPercent.js.map