# Specialized Inputs

Masked values, phone numbers, PIN and OTP codes, password strength and file uploads. Exact props: `widgets-get-component-props`.

---

## DInputMask

A text input with a mask. `onChange` receives the value as a string. The mask options (`mask`, `replacement`, …) are forwarded to the mask library, so they are valid even though the catalog lists them under `forwardedProps`:

```tsx
<DInputMask
  label={t('account.rut')}
  value={rut}
  onChange={setRut}
  mask="__.___.___-v"
  replacement={{ _: /\d/, v: /[\dkK]/ }}
/>
```

Each key of `replacement` is a slot in `mask` with its own pattern: here the check digit (`v`) also accepts `K`.

## DInputPhone

A phone input with a country selector. `onChange` receives an object, not a string:

| Field | Meaning |
|-------|---------|
| `phone` | The number in international format |
| `inputValue` | What the user typed |
| `country` | The parsed country |
| `isValid` | Whether the number is valid for that country |

```tsx
<DInputPhone
  label={t('profile.phone')}
  value={phone}
  onChange={({ phone: next, isValid }) => {
    setPhone(next);
    setPhoneValid(isValid);
  }}
/>
```

`defaultCountry` sets the initial country (ISO 3166-1 alpha-2 code, lowercase); `filteredCountries` limits the list.

## DInputPin

A code split into boxes. `characters` sets the length (4 by default), `secret` hides the digits, `onChange` receives the value as a string:

```tsx
<DInputPin label={t('card.pin')} characters={4} secret onChange={setPin} />
```

## DOtp

A complete one-time-code step: the code boxes, the submit action and a resend countdown. `action` runs on submit and may return a promise; `otpSize` sets the length (6 by default); `seconds` sets the resend countdown; `texts` overrides the visible labels (`title`, `submit`, `resend`, `resendText`, `invalidCode`, `contact`).

```tsx
<DOtp action={verifyCode} texts={{ title: t('otp.title'), submit: t('otp.submit') }} />
```

To build your own OTP layout with the same logic, use the `useOtp` hook (`modyo://docs/widgets/components-hooks`).

## DPasswordStrengthMeter

A password field that shows which rules the value meets. `enabledChecks` picks the rules (`number`, `uppercase`, `lowercase`, `specialChar`) and `validationMessages` sets their texts; `onChange` receives the value as a string.

## DBoxFile

A drop zone for files. `accept` (required) maps MIME types to extensions; `onDrop` receives the accepted and rejected files:

```tsx
<DBoxFile
  accept={{ 'application/pdf': ['.pdf'] }}
  maxFiles={1}
  onDrop={(acceptedFiles) => setFile(acceptedFiles[0])}
/>
```

`multiple`, `minSize`, `maxSize` and `maxFiles` limit what is accepted.

---

## Common mistakes

| Wrong | Right |
|-------|-------|
| `onChange={setPhone}` on `DInputPhone` (stores an object) | `onChange={({ phone }) => setPhone(phone)}` |
| `DBoxFile` without `accept` | `accept` is required |
| A custom OTP built from several `DInput` | `DOtp`, or `useOtp` for a custom layout |
