@progressive-development/pd-forms 0.1.39 → 0.1.41

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent pd-forms following open-wc recommendations",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "PD Progressive Development",
6
- "version": "0.1.39",
6
+ "version": "0.1.41",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
package/src/PdCheckbox.js CHANGED
@@ -242,7 +242,7 @@ export class PdCheckbox extends PdBaseUIInput {
242
242
  ${this._renderLabel(inputId)}
243
243
  <div @click="${this.onClick}" class="${classMap(classMapVal)}">
244
244
  <a href="#" @click="${this.linkClick}" @keypress="${this.onKeyPress}" class="${classMap(aClassMap)}">
245
- <pd-icon icon="checkBox" class="small" ?activeIcon="${checked}"></pd-icon>
245
+ <pd-icon icon="${this.isSwitch ? "checkBox" : "checkBoxOnlyCheck"}" class="small" ?activeIcon="${checked}"></pd-icon>
246
246
  </a>
247
247
  ${this._hasInner ? html`
248
248
  <span class="label">
package/src/PdInput.js CHANGED
@@ -9,6 +9,7 @@ import '@progressive-development/pd-icon/pd-icon.js';
9
9
  import { INPUT_TYPE_TEXT } from './PdBaseUiInput.js';
10
10
  import { PdBaseInputElement } from './PdBaseInputElement.js';
11
11
 
12
+ const onlyContainsNumbers = (str) => /^\d+$/.test(str);
12
13
 
13
14
  // https://github.com/Victor-Bernabe/lit-input
14
15
  // https://levelup.gitconnected.com/build-a-material-like-input-web-component-using-litelement-20e9e0d203b6
@@ -69,7 +70,8 @@ export class PdInput extends PdBaseInputElement {
69
70
  icon: { type: String },
70
71
  secret: { type: Boolean }, // True for type password
71
72
  minlength: { type: String },
72
- maxlength: { type: String }, // max length for field
73
+ maxlength: { type: String }, // max length for field,
74
+ onlyNumbers: { type: Boolean }, // if only numbers allowed
73
75
  };
74
76
  }
75
77
 
@@ -104,6 +106,14 @@ export class PdInput extends PdBaseInputElement {
104
106
  `;
105
107
  }
106
108
 
109
+ _onKeyUp() {
110
+ if (this.onlyNumbers && !onlyContainsNumbers(this._input.value)) {
111
+ this._input.value = this._input.value.replace(/\D/g, '')
112
+ } else {
113
+ super.onkeyup();
114
+ }
115
+ }
116
+
107
117
  }
108
118
 
109
119
 
@@ -66,6 +66,13 @@ function Template({
66
66
  placeHolder="Placeholder Text"
67
67
  ></pd-input>
68
68
 
69
+ <h3>Default Input only Numbers</h3>
70
+ <pd-input
71
+ id="test2Id"
72
+ onlyNumbers
73
+ placeHolder="Placeholder Text"
74
+ ></pd-input>
75
+
69
76
  <h3>Default Input with value</h3>
70
77
  <pd-input
71
78
  id="test3Id"