neo.mjs 5.7.1 → 5.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/apps/ServiceWorker.mjs
CHANGED
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -236,12 +236,12 @@ const DefaultConfig = {
|
|
236
236
|
useVdomWorker: true,
|
237
237
|
/**
|
238
238
|
* buildScripts/injectPackageVersion.mjs will update this value
|
239
|
-
* @default '5.7.
|
239
|
+
* @default '5.7.3'
|
240
240
|
* @memberOf! module:Neo
|
241
241
|
* @name config.version
|
242
242
|
* @type String
|
243
243
|
*/
|
244
|
-
version: '5.7.
|
244
|
+
version: '5.7.3'
|
245
245
|
};
|
246
246
|
|
247
247
|
Object.assign(DefaultConfig, {
|
@@ -32,6 +32,11 @@ class Number extends Text {
|
|
32
32
|
* @member {String[]} baseCls=['neo-numberfield','neo-textfield']
|
33
33
|
*/
|
34
34
|
baseCls: ['neo-numberfield', 'neo-textfield'],
|
35
|
+
/**
|
36
|
+
* Prevent users from typing specific characters.
|
37
|
+
* @member {String[]|null} disabledChars=['e','E']
|
38
|
+
*/
|
39
|
+
disabledChars: ['e', 'E'],
|
35
40
|
/**
|
36
41
|
* data passes maxLength, minLength & valueLength properties
|
37
42
|
* @member {Function} errorTextMaxValue=data=>`Max value violation: ${data.value} / ${data.maxValue}`
|
@@ -254,7 +259,7 @@ class Number extends Text {
|
|
254
259
|
return false;
|
255
260
|
}
|
256
261
|
|
257
|
-
if (value
|
262
|
+
if ((value / me.stepSize) % 1 !== 0) {
|
258
263
|
return false;
|
259
264
|
}
|
260
265
|
|
@@ -275,13 +280,11 @@ class Number extends Text {
|
|
275
280
|
* @protected
|
276
281
|
*/
|
277
282
|
onFocusLeave(data) {
|
278
|
-
let me
|
279
|
-
|
280
|
-
value = me.value;
|
283
|
+
let me = this,
|
284
|
+
value = me.value;
|
281
285
|
|
282
286
|
if (value !== null) {
|
283
287
|
value = me.stepSizeDigits > 0 ? parseFloat(value) : parseInt(value);
|
284
|
-
value = value - Math.round((value % me.stepSize) * stepSizePow) / stepSizePow;
|
285
288
|
value = Math.max(me.minValue, value);
|
286
289
|
value = Math.min(me.maxValue, value);
|
287
290
|
|
@@ -378,7 +381,6 @@ class Number extends Text {
|
|
378
381
|
maxValue = me.maxValue,
|
379
382
|
minValue = me.minValue,
|
380
383
|
stepSize = me.stepSize,
|
381
|
-
stepSizePow = Math.pow(10, me.stepSizeDigits),
|
382
384
|
returnValue = super.validate(silent),
|
383
385
|
errorParam = {maxValue, minValue, stepSize, value};
|
384
386
|
|
@@ -389,7 +391,7 @@ class Number extends Text {
|
|
389
391
|
} else if (Neo.isNumber(minValue) && isNumber && value < minValue) {
|
390
392
|
me._error = me.errorTextMinValue(errorParam);
|
391
393
|
returnValue = false;
|
392
|
-
} else if ((
|
394
|
+
} else if ((value / me.stepSize) % 1 !== 0) {
|
393
395
|
me._error = me.errorTextStepSize(errorParam);
|
394
396
|
returnValue = false;
|
395
397
|
}
|
package/src/form/field/Text.mjs
CHANGED
@@ -69,6 +69,12 @@ class Text extends Base {
|
|
69
69
|
* @member {Boolean} clearToOriginalValue_=false
|
70
70
|
*/
|
71
71
|
clearToOriginalValue_: false,
|
72
|
+
/**
|
73
|
+
* Prevent users from typing specific characters.
|
74
|
+
* E.g. disabling +-e for NumberFields
|
75
|
+
* @member {String[]|null} disabledChars_=null
|
76
|
+
*/
|
77
|
+
disabledChars_: null,
|
72
78
|
/**
|
73
79
|
* @member {String|null} error_=null
|
74
80
|
*/
|
@@ -299,6 +305,24 @@ class Text extends Base {
|
|
299
305
|
})
|
300
306
|
}
|
301
307
|
|
308
|
+
/**
|
309
|
+
* Triggered after the disabledChars config got changed
|
310
|
+
* @param {String[]|null} value
|
311
|
+
* @param {String[]|null} oldValue
|
312
|
+
* @protected
|
313
|
+
*/
|
314
|
+
afterSetDisabledChars(value, oldValue) {
|
315
|
+
if (value) {
|
316
|
+
let me = this;
|
317
|
+
|
318
|
+
Neo.main.DomEvents.registerDisabledInputChars({
|
319
|
+
appName: me.appName,
|
320
|
+
chars : value,
|
321
|
+
id : me.getInputEl().id
|
322
|
+
})
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
302
326
|
/**
|
303
327
|
* Triggered after the error config got changed
|
304
328
|
* @param {String|null} value
|
@@ -936,6 +960,23 @@ class Text extends Base {
|
|
936
960
|
me.fire('clear')
|
937
961
|
}
|
938
962
|
|
963
|
+
/**
|
964
|
+
*
|
965
|
+
* @param args
|
966
|
+
*/
|
967
|
+
destroy(...args) {
|
968
|
+
let me = this;
|
969
|
+
|
970
|
+
if (me.disabledChars) {
|
971
|
+
Neo.main.DomEvents.unregisterDisabledInputChars({
|
972
|
+
appName: me.appName,
|
973
|
+
id : me.getInputEl().id
|
974
|
+
})
|
975
|
+
}
|
976
|
+
|
977
|
+
super.destroy(...args);
|
978
|
+
}
|
979
|
+
|
939
980
|
/**
|
940
981
|
* Calls focus() on the inputEl node instead
|
941
982
|
* @param {String} id=this.id
|
package/src/main/DomEvents.mjs
CHANGED
@@ -60,7 +60,8 @@ const lastWheelEvent = {
|
|
60
60
|
target: null
|
61
61
|
};
|
62
62
|
|
63
|
-
const
|
63
|
+
const disabledInputKeys = {},
|
64
|
+
preventClickTargets = [],
|
64
65
|
preventContextmenuTargets = [];
|
65
66
|
|
66
67
|
/**
|
@@ -100,7 +101,9 @@ class DomEvents extends Base {
|
|
100
101
|
remote: {
|
101
102
|
app: [
|
102
103
|
'addDomListener',
|
103
|
-
'
|
104
|
+
'registerDisabledInputChars',
|
105
|
+
'registerPreventDefaultTargets',
|
106
|
+
'unregisterDisabledInputChars'
|
104
107
|
]
|
105
108
|
}
|
106
109
|
}
|
@@ -507,11 +510,18 @@ class DomEvents extends Base {
|
|
507
510
|
* @param {Object} event
|
508
511
|
*/
|
509
512
|
onKeyDown(event) {
|
510
|
-
|
513
|
+
let target = event.target,
|
514
|
+
isInput = target.nodeName === 'INPUT';
|
511
515
|
|
512
|
-
if (event.
|
513
|
-
|
514
|
-
|
516
|
+
if (isInput && disabledInputKeys[target.id]?.includes(event.key)) {
|
517
|
+
event.preventDefault();
|
518
|
+
} else {
|
519
|
+
this.sendMessageToApp(this.getKeyboardEventData(event));
|
520
|
+
|
521
|
+
if (!isInput) { // see: https://github.com/neomjs/neo/issues/1729
|
522
|
+
if (['ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp'].includes(event.key)) {
|
523
|
+
event.preventDefault();
|
524
|
+
}
|
515
525
|
}
|
516
526
|
}
|
517
527
|
}
|
@@ -659,7 +669,16 @@ class DomEvents extends Base {
|
|
659
669
|
value = true;
|
660
670
|
}
|
661
671
|
|
662
|
-
return value
|
672
|
+
return value
|
673
|
+
}
|
674
|
+
|
675
|
+
/**
|
676
|
+
* @param {Object} data
|
677
|
+
* @param {String[]} data.chars
|
678
|
+
* @param {String} data.id
|
679
|
+
*/
|
680
|
+
registerDisabledInputChars(data) {
|
681
|
+
disabledInputKeys[data.id] = data.chars
|
663
682
|
}
|
664
683
|
|
665
684
|
/**
|
@@ -726,7 +745,15 @@ class DomEvents extends Base {
|
|
726
745
|
}
|
727
746
|
}
|
728
747
|
|
729
|
-
return false
|
748
|
+
return false
|
749
|
+
}
|
750
|
+
|
751
|
+
/**
|
752
|
+
* @param {Object} data
|
753
|
+
* @param {String} data.id
|
754
|
+
*/
|
755
|
+
unregisterDisabledInputChars(data) {
|
756
|
+
delete disabledInputKeys[data.id]
|
730
757
|
}
|
731
758
|
}
|
732
759
|
|