@cscfi/csc-ui 1.3.4 → 1.3.5

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.
@@ -1175,8 +1175,9 @@ const CInput = class {
1175
1175
  _preventNonNumericalInput(event) {
1176
1176
  if (this.type !== 'number')
1177
1177
  return;
1178
- if (!event.key.match(/^[0-9,\.]+$/))
1178
+ if (!event.key.match(/^[0-9,\.-]+$/)) {
1179
1179
  event.preventDefault();
1180
+ }
1180
1181
  }
1181
1182
  _renderBorders() {
1182
1183
  if (this.shadow)
@@ -2445,6 +2446,9 @@ const CTextField = class {
2445
2446
  }
2446
2447
  this._originalType = '';
2447
2448
  this._handleChange = (event) => {
2449
+ if (this.type === 'number' && !event.target.value && event.key === '-') {
2450
+ return;
2451
+ }
2448
2452
  this.value = this.trimWhitespace
2449
2453
  ? event.target.value.trim()
2450
2454
  : event.target.value;
@@ -2475,14 +2479,13 @@ const CTextField = class {
2475
2479
  this.max = null;
2476
2480
  this.min = null;
2477
2481
  this.name = undefined;
2478
- this.number = false;
2479
2482
  this.placeholder = undefined;
2480
2483
  this.readonly = false;
2481
2484
  this.required = false;
2482
2485
  this.rows = 1;
2483
2486
  this.shadow = false;
2484
2487
  this.step = null;
2485
- this.type = undefined;
2488
+ this.type = 'text';
2486
2489
  this.valid = true;
2487
2490
  this.validate = false;
2488
2491
  this.validateOnBlur = false;
@@ -2524,11 +2527,11 @@ const CTextField = class {
2524
2527
  disabled: this.disabled,
2525
2528
  readonly: this.readonly,
2526
2529
  value: this.value,
2527
- onInput: this._handleChange,
2530
+ onkeyup: this._handleChange,
2528
2531
  onChange: this._handleChange,
2529
2532
  onBlur: this._handleBlur,
2530
2533
  },
2531
- 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 })),
2534
+ 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 })),
2532
2535
  textArea: {
2533
2536
  rows: this.rows,
2534
2537
  },