Quellcode durchsuchen

add datetime-local input type

robinken vor 3 Jahren
Ursprung
Commit
238aa0e255
2 geänderte Dateien mit 6 neuen und 5 gelöschten Zeilen
  1. 5 4
      pywebio/input.py
  2. 1 1
      webiojs/src/models/input/input.ts

+ 5 - 4
pywebio/input.py

@@ -92,13 +92,14 @@ URL = "url"
 DATE = "date"
 DATE = "date"
 TIME = "time"
 TIME = "time"
 COLOR = "color"
 COLOR = "color"
+DATETIME_LOCAL = "datetime-local"
 
 
 CHECKBOX = 'checkbox'
 CHECKBOX = 'checkbox'
 RADIO = 'radio'
 RADIO = 'radio'
 SELECT = 'select'
 SELECT = 'select'
 TEXTAREA = 'textarea'
 TEXTAREA = 'textarea'
 
 
-__all__ = ['TEXT', 'NUMBER', 'FLOAT', 'PASSWORD', 'URL', 'DATE', 'TIME', 'COLOR', 'input', 'textarea', 'select',
+__all__ = ['TEXT', 'NUMBER', 'FLOAT', 'PASSWORD', 'URL', 'DATE', 'TIME', 'COLOR', 'DATETIME_LOCAL', 'input', 'textarea', 'select',
            'checkbox', 'radio', 'actions', 'file_upload', 'slider', 'input_group', 'input_update']
            'checkbox', 'radio', 'actions', 'file_upload', 'slider', 'input_group', 'input_update']
 
 
 
 
@@ -134,7 +135,7 @@ def input(label='', type=TEXT, *, validate=None, name=None, value=None, action=N
     r"""Text input
     r"""Text input
 
 
     :param str label: Label of input field.
     :param str label: Label of input field.
-    :param str type: Input type. Currently, supported types are:`TEXT` , `NUMBER` , `FLOAT` , `PASSWORD` , `URL` , `DATE` , `TIME`, `COLOR`
+    :param str type: Input type. Currently, supported types are:`TEXT` , `NUMBER` , `FLOAT` , `PASSWORD` , `URL` , `DATE` , `TIME`, `COLOR`, `DATETIME_LOCAL`
 
 
        Note that `DATE` and `TIME` type are not supported on some browsers,
        Note that `DATE` and `TIME` type are not supported on some browsers,
        for details see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Browser_compatibility
        for details see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Browser_compatibility
@@ -223,7 +224,7 @@ def input(label='', type=TEXT, *, validate=None, name=None, value=None, action=N
     item_spec, valid_func, onchange_func = _parse_args(locals(), excludes=('action',))
     item_spec, valid_func, onchange_func = _parse_args(locals(), excludes=('action',))
 
 
     # check input type
     # check input type
-    allowed_type = {TEXT, NUMBER, FLOAT, PASSWORD, URL, DATE, TIME, COLOR}
+    allowed_type = {TEXT, NUMBER, FLOAT, PASSWORD, URL, DATE, TIME, COLOR, DATETIME_LOCAL}
     assert type in allowed_type, 'Input type not allowed.'
     assert type in allowed_type, 'Input type not allowed.'
 
 
     value_setter = None
     value_setter = None
@@ -722,7 +723,7 @@ def input_group(label='', inputs=None, validate=None, cancelable=False):
 
 
     if all('auto_focus' not in i for i in spec_inputs):  # No `auto_focus` parameter is set for each input item
     if all('auto_focus' not in i for i in spec_inputs):  # No `auto_focus` parameter is set for each input item
         for i in spec_inputs:
         for i in spec_inputs:
-            text_inputs = {TEXT, NUMBER, PASSWORD, SELECT, URL, FLOAT, DATE, TIME}
+            text_inputs = {TEXT, NUMBER, PASSWORD, SELECT, URL, FLOAT, DATE, TIME, DATETIME_LOCAL}
             if i.get('type') in text_inputs:
             if i.get('type') in text_inputs:
                 i['auto_focus'] = True
                 i['auto_focus'] = True
                 break
                 break

+ 1 - 1
webiojs/src/models/input/input.ts

@@ -28,7 +28,7 @@ const common_input_tpl = `
 
 
 
 
 export class Input extends InputItem {
 export class Input extends InputItem {
-    static accept_input_types: string[] = ["text", "password", "number", "float", "color", "date", "range", "time", "email", "url"];
+    static accept_input_types: string[] = ["text", "password", "number", "float", "color", "date", "range", "time", "email", "url", "datetime-local"];
     previous_value = '';
     previous_value = '';
 
 
     constructor(spec: any, task_id: string, on_input_event: (event_name: string, input_item: InputItem) => void) {
     constructor(spec: any, task_id: string, on_input_event: (event_name: string, input_item: InputItem) => void) {