NepaliDateTextField

fun NepaliDateTextField(value: SimpleDate?, onValueChange: (SimpleDate?) -> Unit, modifier: Modifier = Modifier, dateFormat: NepaliDateFormatter.Pattern = Pattern.YYYY_SLASH_MM_SLASH_DD, yearRange: IntRange = NepaliCalendarDefaults.NepaliYearRange, selectableDates: NepaliSelectableDates = NepaliDatePickerDefaults.AllDates, locale: NepaliDateLocale = NepaliDatePickerDefaults.DefaultLocale, label: @Composable () -> Unit? = null, placeholder: @Composable () -> Unit? = { androidx.compose.material3.Text(dateFormat.literal) }, supportingText: @Composable () -> Unit? = null, leadingIcon: @Composable () -> Unit? = null, trailingIcon: @Composable () -> Unit? = null, isError: Boolean = false, enabled: Boolean = true, readOnly: Boolean = false, keyboardOptions: KeyboardOptions = KeyboardOptions( autoCorrectEnabled = false, keyboardType = KeyboardType.Number, imeAction = ImeAction.Done ), keyboardActions: KeyboardActions = KeyboardActions.Default, textStyle: TextStyle = LocalTextStyle.current, prefix: @Composable () -> Unit? = null, suffix: @Composable () -> Unit? = null, shape: Shape = OutlinedTextFieldDefaults.shape, interactionSource: MutableInteractionSource? = null, colors: TextFieldColors = OutlinedTextFieldDefaults.colors())(source)

Standalone outlined text field that edits a Nepali (Bikram Sambat) SimpleDate.

The field accepts both Latin (2082/02/14) and Devanagari (२०८२/०२/१४) digit input regardless of locale; output digit script always follows NepaliDateLocale.resolvedDigitScript. Users type digits only - separators are inserted by a VisualTransformation, so the underlying state holds 8 ASCII digits.

Validation pipeline (runs on every keystroke):

  1. Length < 8 digits → emit null, isError stays as the caller passed it.

  2. Length == 8 → parse with dev.shivathapaa.nepalidatepickerkmp.data.NepaliDateFormatter. Parse failure → emit null with a non-empty error surfaced to the caller via the supplied isError.

  3. Year outside yearRange → emit null, error surfaced.

  4. selectableDates.isSelectableYear or isSelectableDate rejects → emit null, error surfaced.

  5. All checks pass → emit the SimpleDate; no error.

The composable does NOT paint its own error indicator - pass isError to control the field's error state; consult the onValueChange callback for the resolved SimpleDate?. When the caller wants to display per-rule error messages, wire supportingText yourself based on the surface API exposed by your form layer.

Parameters

value

externally-controlled selection. null means "no date".

onValueChange

invoked on every keystroke with the parsed-and-validated SimpleDate?. null indicates "input is incomplete or invalid".

dateFormat

input/display pattern. See Pattern for the supported set.

yearRange

BS year range the field will accept. Out-of-range parses emit null.

selectableDates

predicate that further restricts which dates the field accepts.

locale

localization for output digits + label conventions. Digit script in locale only affects display - input is always tolerant of both Latin and Devanagari.

textStyle

the TextStyle applied to the input text.

prefix

optional content shown before the input, inside the field.

suffix

optional content shown after the input, inside the field.

shape

the Shape of the field's outline.

interactionSource

the MutableInteractionSource for observing interactions, or null to create one.

See also

for a combo that pairs this field with a picker dialog.