@dile/ui 2.5.6 → 2.6.1

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.
@@ -0,0 +1,3 @@
1
+ import { DileInputContact } from "./src/DileInputContact.js";
2
+
3
+ window.customElements.define("dile-input-contact", DileInputContact);
@@ -0,0 +1,130 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { DileInput } from '../../input/index.js';
3
+
4
+ export class DileInputContact extends DileInput {
5
+
6
+ static get properties() {
7
+ return {
8
+ value: { type: String },
9
+ phone: { type: Boolean },
10
+ mobile: { type: Boolean },
11
+ fax: { type: Boolean },
12
+ email: { type: Boolean },
13
+ messageError: { type: String }
14
+ };
15
+ }
16
+
17
+ constructor() {
18
+ super();
19
+ this.valid = true;
20
+ }
21
+
22
+ firstUpdated() {
23
+ super.firstUpdated();
24
+ if(this.value !== '' && this.value !== undefined) {
25
+ this._isValidInput();
26
+ }
27
+ }
28
+
29
+ render() {
30
+ return html`
31
+ <div>
32
+ ${this.label ? this.renderLabel : ''}
33
+ ${this.renderInput}
34
+ ${this.errored && this.messageError != '' ? this.renderMsgError : ''}
35
+ </div>
36
+ `;
37
+ }
38
+
39
+ get renderLabel() {
40
+ return html`
41
+ <label for="textField">${this.label}</label>
42
+ `;
43
+ }
44
+
45
+ get renderInput() {
46
+ return html`
47
+ <input
48
+ type="${this.availableType(this.type)}"
49
+ id="textField"
50
+ name="${this.name}"
51
+ placeholder="${this.placeholder}"
52
+ ?disabled="${this.disabled}"
53
+ ?readonly="${this.readonly}"
54
+ autocomplete="${this.disableAutocomplete ? "off" : "on"}"
55
+ .value="${this.computeValue(this.value)}"
56
+ class="${this.errored ? 'errored' : ''}"
57
+ @keypress="${this._lookForEnter}"
58
+ @input="${this._input}"
59
+ @blur="${this._isValidInput}"
60
+ @focus="${this.doFocus}"
61
+ >
62
+ </input>
63
+ `;
64
+ }
65
+
66
+ get renderMsgError() {
67
+ return html`
68
+ <div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.messageError}</span></div>
69
+ `;
70
+ }
71
+
72
+ _input(ev) {
73
+ this.value = ev.target.value;
74
+ this.dispatchEvent(new CustomEvent('dile-input-contact-input', {
75
+ bubbles: true,
76
+ composed: true,
77
+ detail: {
78
+ value: this.value
79
+ }
80
+ }));
81
+ }
82
+
83
+ _isValidInput() {
84
+ const rePhone = /^(\+34|0034|34)?[89]\d{8}$/;
85
+ const reMobile = /^(\+34|0034|34)?[67]\d{8}$/;
86
+ const reMail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
87
+ if(this.value === '') {
88
+ this.valid = true;
89
+ } else {
90
+ if (this.phone || this.fax) {
91
+ if (rePhone.test(this.value) || this.value === "") {
92
+ this._isPhone = this.phone;
93
+ this._isFax = this.fax;
94
+ this.valid = true;
95
+ } else {
96
+ this.valid = false;
97
+ }
98
+ } else if (this.mobile) {
99
+ this._isMobile = true;
100
+ if (reMobile.test(this.value) || this.value === "") {
101
+ this.valid = true;
102
+ } else {
103
+ this.valid = false;
104
+ }
105
+ } else if(this.email) {
106
+ if(reMail.test(this.value) || this.value === ""){
107
+ this.valid = true;
108
+ }else{
109
+ this.valid = false;
110
+     }
111
+ }
112
+ }
113
+ this.errored = !this.valid;
114
+ console.log("Válido: " + this.valid);
115
+ this.dispatchEvent(
116
+ new CustomEvent('dile-input-contact-blur', {
117
+ bubbles: true,
118
+ composed: true,
119
+ detail: {
120
+ value: this.value,
121
+ isValid: this.valid,
122
+ isMobile: this._isMobile,
123
+ isPhone: this._isPhone,
124
+ isFax: this._isFax,
125
+ isMail: this._isMail
126
+ }
127
+   }),
128
+     );
129
+ }
130
+ }
@@ -115,6 +115,7 @@ export class DileSelectAjax extends DileEmmitChange(LitElement) {
115
115
  updated(changedProperties) {
116
116
  if(changedProperties.has("value")) {
117
117
  this.emmitChange();
118
+ this.dispatchSelectedTextChanged();
118
119
  this.internals.setFormValue(this.value);
119
120
  }
120
121
  }
@@ -398,4 +399,14 @@ export class DileSelectAjax extends DileEmmitChange(LitElement) {
398
399
  this.searchValueInitial();
399
400
  }
400
401
  }
402
+
403
+ dispatchSelectedTextChanged() {
404
+ this.dispatchEvent(new CustomEvent('dile-select-ajax-selected-text-changed',
405
+ {
406
+ bubbles: true,
407
+ composed: true,
408
+ detail: { selectedText: this.selectedText }
409
+ }
410
+ ));
411
+ }
401
412
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "2.5.6",
3
+ "version": "2.6.1",
4
4
  "description": "UI Core components from dile-components.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,11 +20,11 @@
20
20
  },
21
21
  "homepage": "https://dile-components.com/",
22
22
  "dependencies": {
23
- "@dile/icons": "^2.1.2",
23
+ "@dile/icons": "^2.1.3",
24
24
  "lit": "^2.7.0 || ^3.0.0"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "0ca8a028f7d8e60a7e1b83ad5a6a90dfc97ddac4"
29
+ "gitHead": "916ed6faee1f05e718fba83e7f0f646992d4018e"
30
30
  }