Add default debounce argument for forms
@@ -22,10 +22,7 @@ TEMPLATE_DIR = path.join(
path.abspath(path.dirname(path.dirname(__file__))), "templates"
)
-LABEL_STYLE = {
- "fontSize": "0.875rem",
- "marginBottom": "0.3333em"
-}
+LABEL_STYLE = {"fontSize": "0.875rem", "marginBottom": "0.3333em"}
HEADER_STYLE = {
"fontSize": "1rem",
@@ -33,6 +30,7 @@ HEADER_STYLE = {
"margin": "2rem 0 1rem",
}
+
def read_localization_yml(file: str, language: str) -> Dict[str, Any]:
"""Reads localization template.
@@ -119,7 +117,11 @@ def df_to_html_table(
def create_number_input(
- idx: str, data: Dict[str, Any], content: Dict[str, str], defaults: Parameters
+ idx: str,
+ data: Dict[str, Any],
+ content: Dict[str, str],
+ defaults: Parameters,
+ debounce: bool = True,
):
"""Returns number formgroup for given form data.
@@ -128,6 +130,7 @@ def create_number_input(
data: Input form kwargs.
content: Localization text
defaults: Parameters to infer defaults
+ debounce: Trigger callback on enter or unfocus
"""
input_kwargs = data.copy()
input_kwargs.pop("percent", None)
@@ -139,7 +142,7 @@ def create_number_input(
return FormGroup(
children=[
Label(html_for=idx, children=content[idx], style=LABEL_STYLE),
- Input(id=idx, **input_kwargs),
+ Input(id=idx, debounce=debounce, **input_kwargs),
]
)
@@ -175,10 +178,7 @@ def create_date_input(
children=[
Label(html_for=idx, children=content[idx], style=LABEL_STYLE),
DatePickerSingle(
- className="form-control",
- day_size=32,
- id=idx,
- **input_kwargs
+ className="form-control", day_size=32, id=idx, **input_kwargs
),
]
)
