Skip to content

Commit 3aa0bbc

Browse files
committed
feat(#310): add color input type
1 parent 943442f commit 3aa0bbc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pywebio/input.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
URL = "url"
9292
DATE = "date"
9393
TIME = "time"
94+
COLOR = "color"
9495

9596
CHECKBOX = 'checkbox'
9697
RADIO = 'radio'
@@ -133,7 +134,7 @@ def input(label='', type=TEXT, *, validate=None, name=None, value=None, action=N
133134
r"""Text input
134135
135136
:param str label: Label of input field.
136-
:param str type: Input type. Currently supported types are:`TEXT` , `NUMBER` , `FLOAT` , `PASSWORD` , `URL` , `DATE` , `TIME`
137+
:param str type: Input type. Currently, supported types are:`TEXT` , `NUMBER` , `FLOAT` , `PASSWORD` , `URL` , `DATE` , `TIME`, `COLOR`
137138
138139
Note that `DATE` and `TIME` type are not supported on some browsers,
139140
for details see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Browser_compatibility
@@ -222,7 +223,7 @@ def select_date(set_value):
222223
item_spec, valid_func, onchange_func = _parse_args(locals(), excludes=('action',))
223224

224225
# check input type
225-
allowed_type = {TEXT, NUMBER, FLOAT, PASSWORD, URL, DATE, TIME}
226+
allowed_type = {TEXT, NUMBER, FLOAT, PASSWORD, URL, DATE, TIME, COLOR}
226227
assert type in allowed_type, 'Input type not allowed.'
227228

228229
value_setter = None

webiojs/src/models/input/input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const common_input_tpl = `
1111
<div class="form-group">
1212
{{#label}}<label for="{{id_name}}">{{label}}</label>{{/label}}
1313
{{#action}}<div class="input-group">{{/action}}
14-
<input type="{{type}}" id="{{id_name}}" aria-describedby="{{id_name}}_action_btn" list="{{id_name}}-list" class="form-control" >
14+
<input type="{{type}}" id="{{id_name}}" aria-describedby="{{id_name}}_action_btn" {{#datalist}}list="{{id_name}}-list"{{/datalist}} class="form-control" >
1515
<datalist id="{{id_name}}-list">
1616
${datalist_tpl}
1717
</datalist>

0 commit comments

Comments
 (0)