Skip to content

Commit 1033be0

Browse files
committed
rename input.DATETIME_LOCAL -> input.DATETIME
1 parent 457b605 commit 1033be0

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

pywebio/input.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,15 @@
9494
TIME = "time"
9595
COLOR = "color"
9696
DATETIME_LOCAL = "datetime-local"
97+
DATETIME = DATETIME_LOCAL
9798

9899
CHECKBOX = 'checkbox'
99100
RADIO = 'radio'
100101
SELECT = 'select'
101102
TEXTAREA = 'textarea'
102103

103104
__all__ = ['TEXT', 'NUMBER', 'FLOAT', 'PASSWORD', 'URL', 'DATE',
104-
'TIME', 'COLOR', 'DATETIME_LOCAL', 'input', 'textarea',
105+
'TIME', 'COLOR', 'DATETIME_LOCAL', 'DATETIME', 'input', 'textarea',
105106
'select', 'checkbox', 'radio', 'actions', 'file_upload',
106107
'slider', 'input_group', 'input_update']
107108

@@ -133,16 +134,18 @@ def _parse_args(kwargs, excludes=()):
133134
return kwargs, valid_func, onchange_func
134135

135136

136-
def input(label: str = '', type: str = TEXT, *, validate: Callable[[Any], Optional[str]] = None, name: str = None, value: str = None,
137-
action: Tuple[str, Callable[[Callable], None]] = None, onchange: Callable[[Any], None] = None, placeholder: str = None, required: bool = None,
137+
def input(label: str = '', type: str = TEXT, *, validate: Callable[[Any], Optional[str]] = None, name: str = None,
138+
value: str = None,
139+
action: Tuple[str, Callable[[Callable], None]] = None, onchange: Callable[[Any], None] = None,
140+
placeholder: str = None, required: bool = None,
138141
readonly: bool = None, datalist: List[str] = None, help_text: str = None, **other_html_attrs):
139142
r"""Text input
140143
141144
:param str label: Label of input field.
142-
:param str type: Input type. Currently, supported types are:`TEXT` , `NUMBER` , `FLOAT` , `PASSWORD` , `URL` , `DATE` , `TIME`, `COLOR`, `DATETIME_LOCAL`
145+
:param str type: Input type. Currently, supported types are:`TEXT` , `NUMBER` , `FLOAT` , `PASSWORD` , `URL` , `DATE` , `TIME`, `DATETIME`, `COLOR`
143146
144-
Note that `DATE` and `TIME` type are not supported on some browsers,
145-
for details see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Browser_compatibility
147+
The value of `DATE` , `TIME`, `DATETIME` type is a string in the format of `YYYY-MM-DD` , `HH:MM:SS` , `YYYY-MM-DDTHH:MM` respectively
148+
(`%Y-%m-%d`, `%H:%M:%S`, `%Y-%m-%dT%H:%M` in python `strptime() <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior>`_ format).
146149
:param callable validate: Input value validation function. If provided, the validation function will be called when
147150
user completes the input field or submits the form.
148151
@@ -263,9 +266,12 @@ def preprocess_func(d): # Convert the original data submitted by the user
263266
return single_input(item_spec, valid_func, preprocess_func, onchange_func)
264267

265268

266-
def textarea(label: str = '', *, rows: int = 6, code: Union[bool, Dict] = None, maxlength: int = None, minlength: int = None,
267-
validate: Callable[[Any], Optional[str]] = None, name: str = None, value: str = None, onchange: Callable[[Any], None] = None,
268-
placeholder: str = None, required: bool = None, readonly: bool = None, help_text: str = None, **other_html_attrs):
269+
def textarea(label: str = '', *, rows: int = 6, code: Union[bool, Dict] = None, maxlength: int = None,
270+
minlength: int = None,
271+
validate: Callable[[Any], Optional[str]] = None, name: str = None, value: str = None,
272+
onchange: Callable[[Any], None] = None,
273+
placeholder: str = None, required: bool = None, readonly: bool = None, help_text: str = None,
274+
**other_html_attrs):
269275
r"""Text input area (multi-line text input)
270276
271277
:param int rows: The number of visible text lines for the input area. Scroll bar will be used when content exceeds.
@@ -379,7 +385,8 @@ def select(label: str = '', options: List[Union[Dict[str, Any], Tuple, List, str
379385
return single_input(item_spec, valid_func=valid_func, preprocess_func=lambda d: d, onchange_func=onchange_func)
380386

381387

382-
def checkbox(label: str = '', options: List[Union[Dict[str, Any], Tuple, List, str]] = None, *, inline: bool = None, validate: Callable[[Any], Optional[str]] = None,
388+
def checkbox(label: str = '', options: List[Union[Dict[str, Any], Tuple, List, str]] = None, *, inline: bool = None,
389+
validate: Callable[[Any], Optional[str]] = None,
383390
name: str = None, value: List = None, onchange: Callable[[Any], None] = None, help_text: str = None,
384391
**other_html_attrs):
385392
r"""A group of check box that allowing single values to be selected/deselected.
@@ -402,7 +409,8 @@ def checkbox(label: str = '', options: List[Union[Dict[str, Any], Tuple, List, s
402409
return single_input(item_spec, valid_func, lambda d: d, onchange_func)
403410

404411

405-
def radio(label: str = '', options: List[Union[Dict[str, Any], Tuple, List, str]] = None, *, inline: bool = None, validate: Callable[[Any], Optional[str]] = None,
412+
def radio(label: str = '', options: List[Union[Dict[str, Any], Tuple, List, str]] = None, *, inline: bool = None,
413+
validate: Callable[[Any], Optional[str]] = None,
406414
name: str = None, value: str = None, onchange: Callable[[Any], None] = None, required: bool = None,
407415
help_text: str = None, **other_html_attrs):
408416
r"""A group of radio button. Only a single button can be selected.
@@ -467,7 +475,8 @@ def _parse_action_buttons(buttons):
467475
return act_res
468476

469477

470-
def actions(label: str = '', buttons: List[Union[Dict[str, Any], Tuple, List, str]] = None, name: str = None, help_text: str = None):
478+
def actions(label: str = '', buttons: List[Union[Dict[str, Any], Tuple, List, str]] = None, name: str = None,
479+
help_text: str = None):
471480
r"""Actions selection
472481
473482
It is displayed as a group of buttons on the page. After the user clicks the button of it,
@@ -673,7 +682,8 @@ def slider(label: str = '', *, name: str = None, value: Union[int, float] = 0, m
673682
return single_input(item_spec, valid_func, lambda d: d, onchange_func)
674683

675684

676-
def input_group(label: str = '', inputs: List = None, validate: Callable[[Dict], Optional[Tuple[str, str]]] = None, cancelable: bool = False):
685+
def input_group(label: str = '', inputs: List = None, validate: Callable[[Dict], Optional[Tuple[str, str]]] = None,
686+
cancelable: bool = False):
677687
r"""Input group. Request a set of inputs from the user at once.
678688
679689
:param str label: Label of input group.

0 commit comments

Comments
 (0)