From ab6ea54528bf717b469be71d7fc05a72f6fca59e Mon Sep 17 00:00:00 2001 From: bordun Date: Wed, 5 May 2021 17:33:52 +0200 Subject: [PATCH 1/2] package: 1.9.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 805764a4..a9e0b399 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.9.4", + "version": "1.9.5", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" From 99cd75c83f87fb51823c38032271a9984f5056ee Mon Sep 17 00:00:00 2001 From: bordun Date: Wed, 5 May 2021 18:01:33 +0200 Subject: [PATCH 2/2] input: add `numeric` property (allows numeric values only and displays numeric keyboard on mobile devices) --- CHANGELOG.md | 5 +++++ src/client/widgets/basics/input.js | 10 +++++++--- src/scss/widgets/basics.scss | 10 ++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfc3177a..47f75fb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.9.6 (unrelease) + +- widgets + - input: add `numeric` property (allows numeric values only and displays numeric keyboard on mobile devices) + ## 1.9.5 - bug fixes diff --git a/src/client/widgets/basics/input.js b/src/client/widgets/basics/input.js index 8d171499..57186173 100644 --- a/src/client/widgets/basics/input.js +++ b/src/client/widgets/basics/input.js @@ -20,14 +20,15 @@ class Input extends Canvas { }, class_specific: { asYouType: {type: 'boolean', value: false, help: 'Set to `true` to make the input send its value at each keystroke'}, + numeric: {type: 'boolean', value: false, help: ['Set to `true` to allow numeric values only and display a numeric keyboard on mobile devices']}, validation: {type: 'string', value: '', help: [ 'Regular expression: if the submitted value doesn\'t match the regular expression, it will be reset to the last valid value.', 'If leading and trailing slashes are omitted, they will be added automatically and the flag will be set to "gm"', 'Examples:', '- `^[0-9]*$` accepts digits only, any number of them', '- `/^[a-z\s]{0,10}$/i` accept between 0 and 10 alphabetic characters and spaces (case insensitive)', - ]} - } + ]}, + }, }) } @@ -58,6 +59,9 @@ class Input extends Canvas { this.input.addEventListener('blur', (e)=>{ this.blur(true) }) + + if (this.getProp('numeric')) this.input.type = 'number' + var asYouType = this.getProp('asYouType') if (this.getProp('validation') !== '') { @@ -93,7 +97,7 @@ class Input extends Canvas { this.input.value = this.stringValue this.widget.insertBefore(this.input, this.canvas) this.input.focus() - this.input.setSelectionRange(0, this.input.value.length) + if (!this.getProp('numeric')) this.input.setSelectionRange(0, this.input.value.length) } diff --git a/src/scss/widgets/basics.scss b/src/scss/widgets/basics.scss index a7099ed2..05c797df 100644 --- a/src/scss/widgets/basics.scss +++ b/src/scss/widgets/basics.scss @@ -597,6 +597,16 @@ color: var(--color-text); } + &::-webkit-outer-spin-button, + &::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + + &[type="number"] { + -moz-appearance: textfield; + } + } }