|
@@ -17,7 +17,8 @@ class Input(ValidationElement, DisableableElement, component='input.js'):
|
|
|
password_toggle_button: bool = False,
|
|
|
on_change: Optional[Callable[..., Any]] = None,
|
|
|
autocomplete: Optional[List[str]] = None,
|
|
|
- validation: Optional[Union[Callable[..., Optional[str]], Dict[str, Callable[..., bool]]]] = None) -> None:
|
|
|
+ validation: Optional[Union[Callable[..., Optional[str]], Dict[str, Callable[..., bool]]]] = None,
|
|
|
+ ) -> None:
|
|
|
"""Text Input
|
|
|
|
|
|
This element is based on Quasar's `QInput <https://quasar.dev/vue-components/input>`_ component.
|
|
@@ -26,8 +27,10 @@ class Input(ValidationElement, DisableableElement, component='input.js'):
|
|
|
If you want to wait until the user confirms the input, you can register a custom event callback, e.g.
|
|
|
`ui.input(...).on('keydown.enter', ...)` or `ui.input(...).on('blur', ...)`.
|
|
|
|
|
|
- You can use the `validation` parameter to define a dictionary of validation rules.
|
|
|
+ You can use the `validation` parameter to define a dictionary of validation rules,
|
|
|
+ e.g. ``{'Too long!': lambda value: len(value) < 3}``.
|
|
|
The key of the first rule that fails will be displayed as an error message.
|
|
|
+ Alternatively, you can pass a callable that returns an optional error message.
|
|
|
|
|
|
Note about styling the input:
|
|
|
Quasar's `QInput` component is a wrapper around a native `input` element.
|
|
@@ -42,7 +45,7 @@ class Input(ValidationElement, DisableableElement, component='input.js'):
|
|
|
:param password_toggle_button: whether to show a button to toggle the password visibility (default: False)
|
|
|
:param on_change: callback to execute when the value changes
|
|
|
:param autocomplete: optional list of strings for autocompletion
|
|
|
- :param validation: dictionary of validation rules, e.g. ``{'Too long!': lambda value: len(value) < 3}``
|
|
|
+ :param validation: dictionary of validation rules or a callable that returns an optional error message
|
|
|
"""
|
|
|
super().__init__(value=value, on_value_change=on_change, validation=validation)
|
|
|
if label is not None:
|