@dile/ui 3.21.2 → 3.21.3
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
|
-
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
3
|
+
import { DileEmmitChange, DileFieldMessage } from '../../../mixins/form/index.js';
|
|
4
4
|
import { labelStyles } from './label-styles.js';
|
|
5
5
|
import { messageStyles } from './message-styles.js';
|
|
6
6
|
|
|
7
|
-
export class DileInput extends DileEmmitChange(LitElement) {
|
|
7
|
+
export class DileInput extends DileFieldMessage(DileEmmitChange(LitElement)) {
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Fired when user press enter key.
|
|
@@ -41,9 +41,6 @@ export class DileInput extends DileEmmitChange(LitElement) {
|
|
|
41
41
|
/** Name for this input field */
|
|
42
42
|
name: { type: String, reflect: true },
|
|
43
43
|
|
|
44
|
-
/** Has error on this input field */
|
|
45
|
-
errored: { type: Boolean },
|
|
46
|
-
|
|
47
44
|
/** Disable the autocomplete of the input field */
|
|
48
45
|
disableAutocomplete: { type: Boolean },
|
|
49
46
|
|
|
@@ -53,9 +50,6 @@ export class DileInput extends DileEmmitChange(LitElement) {
|
|
|
53
50
|
/** Select all content on focus */
|
|
54
51
|
selectOnFocus: { type: Boolean },
|
|
55
52
|
|
|
56
|
-
/** Message Displayed */
|
|
57
|
-
message: { type: String },
|
|
58
|
-
|
|
59
53
|
/** Text placed on the right side of the input */
|
|
60
54
|
labelRight: { type: String },
|
|
61
55
|
|
|
@@ -197,15 +191,6 @@ export class DileInput extends DileEmmitChange(LitElement) {
|
|
|
197
191
|
return !this.label && this.accessibleLabel ? this.accessibleLabel : undefined;
|
|
198
192
|
}
|
|
199
193
|
|
|
200
|
-
get messageTemplate() {
|
|
201
|
-
return html`
|
|
202
|
-
${this.message
|
|
203
|
-
? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
204
|
-
: ''
|
|
205
|
-
}
|
|
206
|
-
`
|
|
207
|
-
}
|
|
208
|
-
|
|
209
194
|
/**
|
|
210
195
|
* Private method to dispatch events on enter key pressed
|
|
211
196
|
*/
|
|
@@ -222,11 +207,6 @@ export class DileInput extends DileEmmitChange(LitElement) {
|
|
|
222
207
|
}
|
|
223
208
|
}
|
|
224
209
|
|
|
225
|
-
clearError() {
|
|
226
|
-
this.errored = false;
|
|
227
|
-
this.message = '';
|
|
228
|
-
}
|
|
229
|
-
|
|
230
210
|
availableType(type) {
|
|
231
211
|
if(this.types.includes(type)) {
|
|
232
212
|
return type;
|
|
@@ -1,12 +1,31 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import {
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { DileFieldMessage } from '../../../mixins/form/index.js';
|
|
3
|
+
import { messageStyles } from './message-styles.js';
|
|
4
|
+
|
|
5
|
+
export class DileInputMessage extends DileFieldMessage(LitElement) {
|
|
6
|
+
|
|
7
|
+
static get properties() {
|
|
8
|
+
return {
|
|
9
|
+
/** Name used by DileForm to locate this element and show errors on it */
|
|
10
|
+
name: { type: String, reflect: true },
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static get styles() {
|
|
15
|
+
return [
|
|
16
|
+
messageStyles,
|
|
17
|
+
css`
|
|
18
|
+
:host {
|
|
19
|
+
display: block;
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
];
|
|
23
|
+
}
|
|
3
24
|
|
|
4
|
-
export class DileInputMessage extends DileInput {
|
|
5
|
-
|
|
6
25
|
render() {
|
|
7
26
|
return html`
|
|
8
|
-
${this.messageTemplate}
|
|
27
|
+
${this.messageTemplate}
|
|
9
28
|
`
|
|
10
29
|
}
|
|
11
30
|
|
|
12
|
-
}
|
|
31
|
+
}
|
|
@@ -188,13 +188,14 @@ export class DileSelect extends DileEmmitChange(LitElement) {
|
|
|
188
188
|
|
|
189
189
|
updated(changedProperties) {
|
|
190
190
|
if(changedProperties.has("value")) {
|
|
191
|
-
|
|
191
|
+
// null/undefined would be stringified and leave the select without a selected option
|
|
192
|
+
this.elselect.value = this.value ?? '';
|
|
192
193
|
if (this.quiet) {
|
|
193
194
|
this.quiet = false;
|
|
194
195
|
} else {
|
|
195
196
|
this.emmitChange();
|
|
196
197
|
}
|
|
197
|
-
this.internals.setFormValue(this.value);
|
|
198
|
+
this.internals.setFormValue(this.value ?? '');
|
|
198
199
|
}
|
|
199
200
|
if(changedProperties.has("disabled")) {
|
|
200
201
|
this.elselect.disabled = this.disabled;
|
|
@@ -256,7 +257,7 @@ export class DileSelect extends DileEmmitChange(LitElement) {
|
|
|
256
257
|
}
|
|
257
258
|
|
|
258
259
|
clear() {
|
|
259
|
-
this.value =
|
|
260
|
+
this.value = '';
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
getOptionByValue(id) {
|
package/mixins/form/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { DileForm } from "./src/DileForm.js";
|
|
2
2
|
export { DileFormChangeDetect } from "./src/DileFormChangeDetect.js";
|
|
3
|
-
export { DileEmmitChange } from "./src/DileEmmitChange.js";
|
|
3
|
+
export { DileEmmitChange } from "./src/DileEmmitChange.js";
|
|
4
|
+
export { DileFieldMessage } from "./src/DileFieldMessage.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* # DileFieldMessage
|
|
6
|
+
*
|
|
7
|
+
* Mixin to display a feedback / validation message in form components.
|
|
8
|
+
* Provides the `message` and `errored` properties, the `messageTemplate`
|
|
9
|
+
* getter and the `clearError()` method.
|
|
10
|
+
*
|
|
11
|
+
* Components using this mixin should include `messageStyles`
|
|
12
|
+
* (from `@dile/ui/components/input`) in their styles.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const DileFieldMessage = (superclass) => class extends superclass {
|
|
17
|
+
|
|
18
|
+
static get properties() {
|
|
19
|
+
return {
|
|
20
|
+
/** Message Displayed */
|
|
21
|
+
message: { type: String },
|
|
22
|
+
|
|
23
|
+
/** Has error on this field */
|
|
24
|
+
errored: { type: Boolean },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get messageTemplate() {
|
|
29
|
+
return html`
|
|
30
|
+
${this.message
|
|
31
|
+
? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
32
|
+
: ''
|
|
33
|
+
}
|
|
34
|
+
`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
clearError() {
|
|
38
|
+
this.errored = false;
|
|
39
|
+
this.message = '';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/ui",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.3",
|
|
4
4
|
"description": "UI Core components from dile-components.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "0d92ba253fe5827739f5d1215360c6763a50d934"
|
|
32
32
|
}
|