@cscfi/csc-ui 1.3.4 → 1.3.6

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.
@@ -1171,8 +1171,9 @@ const CInput = class {
1171
1171
  _preventNonNumericalInput(event) {
1172
1172
  if (this.type !== 'number')
1173
1173
  return;
1174
- if (!event.key.match(/^[0-9,\.]+$/))
1174
+ if (!event.key.match(/^[0-9,\.-]+$/)) {
1175
1175
  event.preventDefault();
1176
+ }
1176
1177
  }
1177
1178
  _renderBorders() {
1178
1179
  if (this.shadow)
@@ -2441,6 +2442,9 @@ const CTextField = class {
2441
2442
  }
2442
2443
  this._originalType = '';
2443
2444
  this._handleChange = (event) => {
2445
+ if (this.type === 'number' && !event.target.value && event.key === '-') {
2446
+ return;
2447
+ }
2444
2448
  this.value = this.trimWhitespace
2445
2449
  ? event.target.value.trim()
2446
2450
  : event.target.value;
@@ -2471,14 +2475,13 @@ const CTextField = class {
2471
2475
  this.max = null;
2472
2476
  this.min = null;
2473
2477
  this.name = undefined;
2474
- this.number = false;
2475
2478
  this.placeholder = undefined;
2476
2479
  this.readonly = false;
2477
2480
  this.required = false;
2478
2481
  this.rows = 1;
2479
2482
  this.shadow = false;
2480
2483
  this.step = null;
2481
- this.type = undefined;
2484
+ this.type = 'text';
2482
2485
  this.valid = true;
2483
2486
  this.validate = false;
2484
2487
  this.validateOnBlur = false;
@@ -2524,7 +2527,7 @@ const CTextField = class {
2524
2527
  onChange: this._handleChange,
2525
2528
  onBlur: this._handleBlur,
2526
2529
  },
2527
- input: Object.assign(Object.assign(Object.assign({ type: this.number ? 'number' : this.type || 'text', min: this.min, max: this.max, step: this.step }, (!!this.autocomplete && { autocomplete: this.autocomplete })), (!!this.autocapitalize && { autocapitalize: this.autocapitalize })), (!!this.autocorrect && { autocorrect: this.autocorrect })),
2530
+ input: Object.assign(Object.assign(Object.assign({ type: this.type, min: this.min, max: this.max, step: this.step }, (!!this.autocomplete && { autocomplete: this.autocomplete })), (!!this.autocapitalize && { autocapitalize: this.autocapitalize })), (!!this.autocorrect && { autocorrect: this.autocorrect })),
2528
2531
  textArea: {
2529
2532
  rows: this.rows,
2530
2533
  },