@dile/ui 2.6.0 → 2.6.2

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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "2.6.0",
3
+ "version": "2.6.2",
4
4
  "description": "UI Core components from dile-components.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,5 +26,5 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "60b2984016e81117b9da0a5b5fe8dcd5eb8cee98"
29
+ "gitHead": "b82bb554da6a71a9d0ac5eb3abe7b917b5a25217"
30
30
  }
package/styles/colors.css CHANGED
@@ -33,3 +33,47 @@
33
33
  --dile-gray-dark-color: #555555;
34
34
  --dile-on-gray-dark-color: #ffffff;
35
35
  }
36
+
37
+ :root.dark-theme {
38
+ --dile-background-color: #1e1e1e;
39
+ --dile-on-background-color: #ffffff;
40
+
41
+ --dile-primary-color: #e1e181;
42
+ --dile-on-primary-color: #1e1e1e;
43
+
44
+ --dile-secondary-color: #5fd878;
45
+ --dile-on-secondary-color: #1e1e1e;
46
+
47
+ --dile-terciary-color: #50c4e0;
48
+ --dile-on-terciary-color: #1e1e1e;
49
+
50
+ --dile-neutral-color: #2c2c2c;
51
+ --dile-on-neutral-color: #ffffff;
52
+
53
+ --dile-alert-error-color: #ff6a6a;
54
+ --dile-alert-success-color: #33cc55;
55
+ --dile-alert-neutral-color: #58c0da;
56
+ --dile-on-alert-color: #1e1e1e;
57
+
58
+ --dile-danger-color: #ff4b47;
59
+ --dile-on-danger-color: #ffffff;
60
+
61
+ /* Variaciones */
62
+ --dile-primary-light-color: #f3f3ae;
63
+ --dile-on-primary-light-color: #1e1e1e;
64
+ --dile-primary-dark-color: #b5b53e;
65
+ --dile-on-primary-dark-color: #ffffff;
66
+
67
+ --dile-secondary-light-color: #9ff2b1;
68
+ --dile-on-secondary-light-color: #1e1e1e;
69
+ --dile-secondary-dark-color: #2a7038;
70
+ --dile-on-secondary-dark-color: #ffffff;
71
+
72
+ --dile-terciary-light-color: #a5e6f8;
73
+ --dile-on-terciary-light-color: #1e1e1e;
74
+ --dile-terciary-dark-color: #0e3e49;
75
+ --dile-on-terciary-dark-color: #ffffff;
76
+
77
+ --dile-gray-dark-color: #cccccc;
78
+ --dile-on-gray-dark-color: #1e1e1e;
79
+ }