Skip to content

Commit

Permalink
feat: Add in additional HTML5 inputs time, datetime-local and range […
Browse files Browse the repository at this point in the history
…supported by all major browsers]. For BC reasons time and datetime-local implemented as a subtype of date.
  • Loading branch information
lucasnetau committed Oct 9, 2023
1 parent 281d7df commit 0a1c141
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/js/control/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ export default class controlText extends control {
// register this control for the following types & text subtypes
control.register(['text', 'file', 'date', 'number'], controlText)
control.register(['text', 'password', 'email', 'color', 'tel'], controlText, 'text')
control.register(['date', 'time', 'datetime-local'], controlText, 'date')
control.register(['number', 'range'], controlText, 'number')
9 changes: 5 additions & 4 deletions src/js/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,12 @@ function FormBuilder(opts, element, $) {
'options',
],
text: defaultAttrs.concat(['subtype', 'maxlength']),
date: defaultAttrs,
date: defaultAttrs.concat(['subtype','min', 'max', 'step']),
file: defaultAttrs.concat(['subtype', 'multiple']),
header: ['label', 'subtype', 'className', 'access'],
hidden: ['name', 'value', 'access'],
paragraph: ['label', 'subtype', 'className', 'access'],
number: defaultAttrs.concat(['min', 'max', 'step']),
number: defaultAttrs.concat(['subtype','min', 'max', 'step']),
select: defaultAttrs.concat(['multiple', 'options']),
textarea: defaultAttrs.concat(['subtype', 'maxlength', 'rows']),
}
Expand Down Expand Up @@ -600,10 +600,11 @@ function FormBuilder(opts, element, $) {
}
let key
const roles = values.role !== undefined ? values.role.split(',') : []

const numAttrs = ['min', 'max', 'step']

numAttrs.forEach(numAttr => {
advFieldMap[numAttr] = () => numberAttribute(numAttr, values)
advFieldMap[numAttr] = type === 'number' ? () => numberAttribute(numAttr, values) : () => textAttribute(numAttr, values)
})

const noDisable = ['name', 'className']
Expand Down Expand Up @@ -967,7 +968,7 @@ function FormBuilder(opts, element, $) {
const textArea = ['paragraph']

let attrVal = values[attribute] || ''
let attrLabel = mi18n.get(attribute)
let attrLabel = mi18n.get(attribute) || attribute

if (attribute === 'label') {
if (textArea.includes(values.type)) {
Expand Down

0 comments on commit 0a1c141

Please sign in to comment.