@mauur/components
v0.1.0
Published
Style-agnostic React Native contact input and pure contact helpers, shared across mauurda projects (pergy, takehub).
Readme
@mauur/components
Style-agnostic React Native contact input and pure contact helpers, shared across mauurda projects (pergy, takehub).
Install
npm install @mauur/componentsreact and react-native are peer dependencies.
API
Pure helpers (no React):
detectInputType(text)→"email" | "phone" | "undetermined"formatPhoneNumber(text, country?, previousText?)— as-you-type formatting (default country"US")validatePhone(phone, country?)toE164(phone, country?)→ E.164 string ornullvalidateEmail(email)formatPhoneForDisplay(phone)— national format for displaynormalizeToE164(phone)— server-friendly E.164 normalizer with naive fallback
Component:
<ContactField />— aTextInputthat formats phone numbers as you type and reports the detected input type. Styling is the caller's.
import { ContactField } from "@mauur/components";
<ContactField
value={value}
onChangeText={setValue}
onDetectType={(type) => console.log(type)}
placeholder="Phone or email"
/>;