@dile/ui 3.22.1 → 3.24.0
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/components/button/src/DileButton.js +3 -0
- package/components/checkbox/src/DileCheckbox.js +14 -5
- package/components/color-picker/src/DileColorPicker.js +6 -2
- package/components/drop-file/src/DileDropFile.js +7 -5
- package/components/form-group/form-group.js +5 -0
- package/components/form-group/index.js +1 -0
- package/components/form-group/src/DileFormGroup.js +188 -0
- package/components/input/index.js +1 -1
- package/components/input/src/DileInput.js +128 -31
- package/components/input/src/DileInputContact.js +38 -40
- package/components/input/src/DileInputIcon.js +7 -43
- package/components/input/src/DileInputInteger.js +8 -22
- package/components/input/src/DileInputMask.js +25 -15
- package/components/input/src/DileInputMoney.js +6 -23
- package/components/input/src/DileInputNumber.js +6 -12
- package/components/input/src/DileInputNumberMask.js +5 -12
- package/components/input/src/DileInputPercentage.js +8 -20
- package/components/input/src/DileInputSearch.js +7 -1
- package/components/input/src/label-styles.js +15 -0
- package/components/input-suggestions/src/DileInputSuggestionsBase.js +6 -3
- package/components/number-picker/src/DileNumberPicker.js +8 -4
- package/components/number-picker/src/DileNumberPickerElement.js +7 -0
- package/components/order-switch/src/DileOrderSwitch.js +18 -2
- package/components/otp-input/src/DileOtpInput.js +10 -4
- package/components/password/src/DilePassword.js +19 -42
- package/components/radio-group/src/DileRadioGroup.js +6 -3
- package/components/rating-scale-question/src/DileRatingScaleQuestion.js +35 -3
- package/components/select/src/DileSelect.js +12 -4
- package/components/select/src/DileSelectAjax.js +12 -5
- package/components/select/src/DileSelectBoolean.js +9 -2
- package/components/select/src/DileSelectOverlay.js +6 -3
- package/components/select/src/DileSelectSearchableBase.js +8 -3
- package/components/switch/src/DileSwitch.js +3 -1
- package/components/textarea/src/DileTextarea.js +7 -3
- package/components/time-picker/src/DileTimePicker.js +680 -123
- package/components/wheel-picker/src/DileWheelPicker.js +17 -2
- package/lib/time/time.js +171 -0
- package/lib/time/time.test.js +63 -0
- package/mixins/form/index.js +3 -2
- package/mixins/form/src/DileFieldMessage.js +4 -1
- package/mixins/form/src/DileForm.js +240 -1
- package/mixins/form/src/DileNativeValidity.js +195 -0
- package/mixins/overlay/src/DileOverlay.js +16 -0
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { html, css, LitElement } from "lit";
|
|
2
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
2
3
|
import { arrowDropUpLargeIcon, arrowDropDownLargeIcon } from '@dile/icons';
|
|
3
4
|
import '../../icon/icon.js'
|
|
4
5
|
|
|
@@ -80,7 +81,10 @@ export class DileNumberPickerElement extends LitElement {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
},
|
|
84
|
+
required: { type: Boolean, reflect: true },
|
|
83
85
|
disabled: { type: Boolean },
|
|
86
|
+
/** Accessible description of the input, applied as aria-description (e.g. the validation message of the parent field) */
|
|
87
|
+
accessibleDescription: { type: String },
|
|
84
88
|
};
|
|
85
89
|
}
|
|
86
90
|
|
|
@@ -118,6 +122,9 @@ export class DileNumberPickerElement extends LitElement {
|
|
|
118
122
|
id="elinput"
|
|
119
123
|
@input=${this._onInput}
|
|
120
124
|
?disabled=${this.disabled}
|
|
125
|
+
aria-invalid=${ifDefined(this.errored ? 'true' : undefined)}
|
|
126
|
+
aria-required=${ifDefined(this.required ? 'true' : undefined)}
|
|
127
|
+
aria-description=${ifDefined(this.accessibleDescription || undefined)}
|
|
121
128
|
>
|
|
122
129
|
<div class="controls">
|
|
123
130
|
<dile-icon .icon=${arrowDropUpLargeIcon} @click=${this.increment}></dile-icon>
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { html, css, LitElement } from "lit";
|
|
2
|
-
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
2
|
+
import { DileEmmitChange, DileNativeValidity } from '../../../mixins/form/index.js';
|
|
3
3
|
import { switchLeftIcon } from '@dile/icons/index.js';
|
|
4
4
|
import '../../button/button-icon.js'
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
export class DileOrderSwitch extends DileEmmitChange(LitElement) {
|
|
7
|
+
export class DileOrderSwitch extends DileNativeValidity(DileEmmitChange(LitElement)) {
|
|
8
|
+
static get formAssociated() {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
static get properties() {
|
|
9
13
|
return {
|
|
10
14
|
value: { type: String },
|
|
@@ -22,6 +26,17 @@ export class DileOrderSwitch extends DileEmmitChange(LitElement) {
|
|
|
22
26
|
super();
|
|
23
27
|
this.value = "asc";
|
|
24
28
|
this.selected = false;
|
|
29
|
+
this.internals = this.attachInternals();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
firstUpdated() {
|
|
33
|
+
this._defaultValue = this.value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Called by the browser when the owner form is reset: restores the initial value */
|
|
37
|
+
formResetCallback() {
|
|
38
|
+
super.formResetCallback?.();
|
|
39
|
+
this.value = this._defaultValue;
|
|
25
40
|
}
|
|
26
41
|
|
|
27
42
|
static get styles() {
|
|
@@ -77,6 +92,7 @@ export class DileOrderSwitch extends DileEmmitChange(LitElement) {
|
|
|
77
92
|
|
|
78
93
|
updated(changedProperties) {
|
|
79
94
|
if(changedProperties.has('value')) {
|
|
95
|
+
this.internals.setFormValue(this.value ?? null);
|
|
80
96
|
if(this.value != "asc" && this.value != "desc") {
|
|
81
97
|
this.value = "asc";
|
|
82
98
|
} else if(changedProperties.get('value')) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
|
-
import {
|
|
2
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
|
+
import { DileNativeValidity, DileEmmitChange, FIELD_MESSAGE_ID } from '../../../mixins/form/index.js';
|
|
3
4
|
import { labelStyles, messageStyles } from '../../input/index.js';
|
|
4
5
|
import { sanitizeOtpValue } from '../../../lib/otp/sanitizeOtpValue.js';
|
|
5
6
|
|
|
6
|
-
export class DileOtpInput extends DileEmmitChange(LitElement) {
|
|
7
|
+
export class DileOtpInput extends DileNativeValidity(DileEmmitChange(LitElement)) {
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Fired when user press enter key.
|
|
@@ -38,6 +39,8 @@ export class DileOtpInput extends DileEmmitChange(LitElement) {
|
|
|
38
39
|
name: { type: String, reflect: true },
|
|
39
40
|
|
|
40
41
|
/** Disable the input field */
|
|
42
|
+
/** Marks the field as required: shows the required indicator in the label and sets aria-required */
|
|
43
|
+
required: { type: Boolean, reflect: true },
|
|
41
44
|
disabled: { type: Boolean },
|
|
42
45
|
|
|
43
46
|
/** ReadOnly attribute */
|
|
@@ -155,7 +158,7 @@ export class DileOtpInput extends DileEmmitChange(LitElement) {
|
|
|
155
158
|
return html`
|
|
156
159
|
<main>
|
|
157
160
|
${this.label
|
|
158
|
-
? html`<label>${this.label}</label>`
|
|
161
|
+
? html`<label class="field-label">${this.label}</label>`
|
|
159
162
|
: ''}
|
|
160
163
|
<section class="for-input">
|
|
161
164
|
${this.boxesChars.map((char, index) => html`
|
|
@@ -169,6 +172,9 @@ export class DileOtpInput extends DileEmmitChange(LitElement) {
|
|
|
169
172
|
?readonly="${this.readonly}"
|
|
170
173
|
.value="${char}"
|
|
171
174
|
class="${this.errored ? 'errored' : ''}"
|
|
175
|
+
aria-invalid="${ifDefined(this.errored ? 'true' : undefined)}"
|
|
176
|
+
aria-required="${ifDefined(this.required ? 'true' : undefined)}"
|
|
177
|
+
aria-describedby="${ifDefined(this.message ? FIELD_MESSAGE_ID : undefined)}"
|
|
172
178
|
@input="${(e) => this._onInput(e, index)}"
|
|
173
179
|
@keydown="${(e) => this._onKeydown(e, index)}"
|
|
174
180
|
@keypress="${this._lookForEnter}"
|
|
@@ -185,7 +191,7 @@ export class DileOtpInput extends DileEmmitChange(LitElement) {
|
|
|
185
191
|
get messageTemplate() {
|
|
186
192
|
return html`
|
|
187
193
|
${this.message
|
|
188
|
-
? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
194
|
+
? html`<div id="${FIELD_MESSAGE_ID}" class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
189
195
|
: ''
|
|
190
196
|
}
|
|
191
197
|
`;
|
|
@@ -59,49 +59,26 @@ export class DilePassword extends DileInput {
|
|
|
59
59
|
this.passwordVisible = false;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.value="${this.value}"
|
|
81
|
-
class="${ this.errored ? 'errored' : '' }"
|
|
82
|
-
>
|
|
83
|
-
${this.showPasswordToggle
|
|
84
|
-
? html`<button
|
|
85
|
-
class="password-toggle-btn"
|
|
86
|
-
type="button"
|
|
87
|
-
@click="${this._togglePasswordVisibility}"
|
|
88
|
-
?disabled="${this.disabled}"
|
|
89
|
-
aria-label="${this.passwordVisible ? 'Hide password' : 'Show password'}"
|
|
90
|
-
>
|
|
91
|
-
${this.passwordVisible
|
|
92
|
-
? html`<dile-lucide-icon-eye></dile-lucide-icon-eye>`
|
|
93
|
-
: html`<dile-lucide-icon-eye-off></dile-lucide-icon-eye-off>`
|
|
94
|
-
}
|
|
95
|
-
</button>`
|
|
96
|
-
: ''
|
|
97
|
-
}
|
|
98
|
-
</section>
|
|
99
|
-
${this.message
|
|
100
|
-
? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
101
|
-
: ''
|
|
62
|
+
get inputType() {
|
|
63
|
+
return this.passwordVisible ? 'text' : 'password';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get fieldEndTemplate() {
|
|
67
|
+
if (!this.showPasswordToggle) {
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
return html`<button
|
|
71
|
+
class="password-toggle-btn"
|
|
72
|
+
type="button"
|
|
73
|
+
@click="${this._togglePasswordVisibility}"
|
|
74
|
+
?disabled="${this.isDisabled}"
|
|
75
|
+
aria-label="${this.passwordVisible ? 'Hide password' : 'Show password'}"
|
|
76
|
+
>
|
|
77
|
+
${this.passwordVisible
|
|
78
|
+
? html`<dile-lucide-icon-eye></dile-lucide-icon-eye>`
|
|
79
|
+
: html`<dile-lucide-icon-eye-off></dile-lucide-icon-eye-off>`
|
|
102
80
|
}
|
|
103
|
-
</
|
|
104
|
-
`;
|
|
81
|
+
</button>`;
|
|
105
82
|
}
|
|
106
83
|
|
|
107
84
|
_togglePasswordVisibility() {
|
|
@@ -1,13 +1,13 @@
|
|
|
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 { DileNativeValidity, DileEmmitChange } from '../../../mixins/form/index.js';
|
|
4
4
|
import '../radio.js';
|
|
5
5
|
import '../../input/input-message.js';
|
|
6
6
|
import { labelStyles } from '../../input/index.js';
|
|
7
7
|
|
|
8
8
|
const NAVIGATION_KEYS = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft', 'Home', 'End'];
|
|
9
9
|
|
|
10
|
-
export class DileRadioGroup extends DileEmmitChange(LitElement) {
|
|
10
|
+
export class DileRadioGroup extends DileNativeValidity(DileEmmitChange(LitElement)) {
|
|
11
11
|
static styles = [
|
|
12
12
|
labelStyles,
|
|
13
13
|
css`
|
|
@@ -33,6 +33,8 @@ export class DileRadioGroup extends DileEmmitChange(LitElement) {
|
|
|
33
33
|
message: { type: String },
|
|
34
34
|
errored: { type: Boolean },
|
|
35
35
|
hideErrorOnInput: { type: Boolean },
|
|
36
|
+
/** Marks the field as required: shows the required indicator in the label and sets aria-required */
|
|
37
|
+
required: { type: Boolean, reflect: true },
|
|
36
38
|
disabled: {
|
|
37
39
|
type: Boolean,
|
|
38
40
|
reflect: true
|
|
@@ -79,12 +81,13 @@ export class DileRadioGroup extends DileEmmitChange(LitElement) {
|
|
|
79
81
|
aria-labelledby="${ifDefined(this.label ? `${this._id}-label` : undefined)}"
|
|
80
82
|
aria-describedby="${ifDefined(this.message ? `${this._id}-message` : undefined)}"
|
|
81
83
|
aria-invalid="${this.errored ? 'true' : 'false'}"
|
|
84
|
+
aria-required="${ifDefined(this.required ? 'true' : undefined)}"
|
|
82
85
|
aria-disabled="${this.disabled ? 'true' : 'false'}"
|
|
83
86
|
@dile-radio-selected=${this.changeValue}
|
|
84
87
|
@keydown=${this.handleKeydown}
|
|
85
88
|
>
|
|
86
89
|
${this.label
|
|
87
|
-
? html`<span class="label" id="${this._id}-label">${this.label}</span>`
|
|
90
|
+
? html`<span class="label field-label" id="${this._id}-label">${this.label}</span>`
|
|
88
91
|
: ""
|
|
89
92
|
}
|
|
90
93
|
<slot></slot>
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
|
-
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
2
|
+
import { DileEmmitChange, DileFieldMessage, DileNativeValidity } from '../../../mixins/form/index.js';
|
|
3
|
+
import { messageStyles } from '../../input/src/message-styles.js';
|
|
4
|
+
import { requiredIndicatorStyles } from '../../input/src/label-styles.js';
|
|
5
|
+
|
|
6
|
+
export class DileRatingScaleQuestion extends DileFieldMessage(DileNativeValidity(DileEmmitChange(LitElement))) {
|
|
7
|
+
static get formAssociated() {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
3
10
|
|
|
4
|
-
export class DileRatingScaleQuestion extends DileEmmitChange(LitElement) {
|
|
5
11
|
static styles = [
|
|
12
|
+
messageStyles,
|
|
13
|
+
requiredIndicatorStyles,
|
|
6
14
|
css`
|
|
7
15
|
:host {
|
|
8
16
|
display: block;
|
|
@@ -130,6 +138,10 @@ export class DileRatingScaleQuestion extends DileEmmitChange(LitElement) {
|
|
|
130
138
|
type: Boolean,
|
|
131
139
|
reflect: true
|
|
132
140
|
},
|
|
141
|
+
/** Marks the field as required: shows the required indicator in the label. In a form, an answer is needed */
|
|
142
|
+
required: { type: Boolean, reflect: true },
|
|
143
|
+
/** Clears the error message when the user selects an option */
|
|
144
|
+
hideErrorOnInput: { type: Boolean },
|
|
133
145
|
};
|
|
134
146
|
}
|
|
135
147
|
|
|
@@ -141,9 +153,13 @@ export class DileRatingScaleQuestion extends DileEmmitChange(LitElement) {
|
|
|
141
153
|
this.scale_neutral_label = "Neutral";
|
|
142
154
|
this.scale_right_label="Disagree";
|
|
143
155
|
this.scale_point=7; //7, 5, 3
|
|
156
|
+
this.internals = this.attachInternals();
|
|
144
157
|
}
|
|
145
158
|
|
|
146
159
|
updated(changedProperties) {
|
|
160
|
+
if (changedProperties.has('value')) {
|
|
161
|
+
this.internals.setFormValue(this.value === undefined || this.value === null ? null : String(this.value));
|
|
162
|
+
}
|
|
147
163
|
if(changedProperties.has('value') && this.init) {
|
|
148
164
|
this.doSelection(this.value);
|
|
149
165
|
this.emmitChange();
|
|
@@ -152,6 +168,7 @@ export class DileRatingScaleQuestion extends DileEmmitChange(LitElement) {
|
|
|
152
168
|
}
|
|
153
169
|
|
|
154
170
|
firstUpdated() {
|
|
171
|
+
this._defaultValue = this.value;
|
|
155
172
|
this.init = true;
|
|
156
173
|
if(this.value !== undefined) {
|
|
157
174
|
setTimeout(() => {
|
|
@@ -163,7 +180,7 @@ export class DileRatingScaleQuestion extends DileEmmitChange(LitElement) {
|
|
|
163
180
|
render() {
|
|
164
181
|
this.getOptions();
|
|
165
182
|
return html`<fieldset @dile-rating-scale-option-selected=${this.changeValue}>
|
|
166
|
-
<legend><span>${this.label}</span></legend>
|
|
183
|
+
<legend><span class="field-label">${this.label}</span></legend>
|
|
167
184
|
<div class="group_options">
|
|
168
185
|
<div class="caption-desktop text-leftColor">${this.scale_left_label}</div>
|
|
169
186
|
<div class="radios">
|
|
@@ -178,6 +195,7 @@ export class DileRatingScaleQuestion extends DileEmmitChange(LitElement) {
|
|
|
178
195
|
</div>
|
|
179
196
|
</div>
|
|
180
197
|
</fieldset>
|
|
198
|
+
${this.messageTemplate}
|
|
181
199
|
`;
|
|
182
200
|
}
|
|
183
201
|
|
|
@@ -226,9 +244,23 @@ export class DileRatingScaleQuestion extends DileEmmitChange(LitElement) {
|
|
|
226
244
|
changeValue(e) {
|
|
227
245
|
if(!this.disabled) {
|
|
228
246
|
this.value = e.detail.value;
|
|
247
|
+
if (this.hideErrorOnInput && this.errored) {
|
|
248
|
+
this.clearError();
|
|
249
|
+
}
|
|
229
250
|
}
|
|
230
251
|
}
|
|
231
252
|
|
|
253
|
+
/** Inner control the browser points to when it reports a validation error */
|
|
254
|
+
get el() {
|
|
255
|
+
return this.shadowRoot?.querySelector('dile-rating-scale-option')?.shadowRoot?.querySelector('input') ?? null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Called by the browser when the owner form is reset: restores the initial value */
|
|
259
|
+
formResetCallback() {
|
|
260
|
+
super.formResetCallback?.();
|
|
261
|
+
this.value = this._defaultValue;
|
|
262
|
+
}
|
|
263
|
+
|
|
232
264
|
doSelection(newValue) {
|
|
233
265
|
this.shadowRoot.querySelectorAll('dile-rating-scale-option').forEach(option => {
|
|
234
266
|
if (option.value === newValue) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { html, css, LitElement } from "lit";
|
|
2
|
-
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
2
|
+
import { DileNativeValidity, DileEmmitChange } from '../../../mixins/form/index.js';
|
|
3
3
|
import { labelStyles, messageStyles } from '../../input/index.js';
|
|
4
4
|
|
|
5
|
-
export class DileSelect extends DileEmmitChange(LitElement) {
|
|
5
|
+
export class DileSelect extends DileNativeValidity(DileEmmitChange(LitElement)) {
|
|
6
6
|
static get styles() {
|
|
7
7
|
return [
|
|
8
8
|
labelStyles,
|
|
@@ -101,6 +101,8 @@ export class DileSelect extends DileEmmitChange(LitElement) {
|
|
|
101
101
|
accessibleLabel: { type: String },
|
|
102
102
|
value: { type: String },
|
|
103
103
|
name: { type: String, reflect: true },
|
|
104
|
+
/** Marks the field as required: shows the required indicator in the label and sets aria-required */
|
|
105
|
+
required: { type: Boolean, reflect: true },
|
|
104
106
|
disabled: { type: Boolean },
|
|
105
107
|
errored: { type: Boolean },
|
|
106
108
|
message: { type: String },
|
|
@@ -116,7 +118,7 @@ export class DileSelect extends DileEmmitChange(LitElement) {
|
|
|
116
118
|
return html`
|
|
117
119
|
<div>
|
|
118
120
|
${this.label
|
|
119
|
-
? html`<label for="${this.selectId}" @click="${this._focusSelect}">${this.label}</label>`
|
|
121
|
+
? html`<label for="${this.selectId}" class="field-label" @click="${this._focusSelect}">${this.label}</label>`
|
|
120
122
|
: ""
|
|
121
123
|
}
|
|
122
124
|
<div class="select-wrapper">
|
|
@@ -202,7 +204,7 @@ export class DileSelect extends DileEmmitChange(LitElement) {
|
|
|
202
204
|
this.elselect.classList.toggle("disabled", this.disabled);
|
|
203
205
|
this.elselect.setAttribute("aria-disabled", this.disabled);
|
|
204
206
|
}
|
|
205
|
-
if(changedProperties.has("errored") || changedProperties.has("message")
|
|
207
|
+
if(changedProperties.has("errored") || changedProperties.has("message") || changedProperties.has("required")
|
|
206
208
|
|| changedProperties.has("label") || changedProperties.has("accessibleLabel")) {
|
|
207
209
|
this.updateSelectA11y();
|
|
208
210
|
}
|
|
@@ -213,6 +215,12 @@ export class DileSelect extends DileEmmitChange(LitElement) {
|
|
|
213
215
|
|
|
214
216
|
// Set aria-invalid when errored
|
|
215
217
|
this.elselect.setAttribute("aria-invalid", this.errored);
|
|
218
|
+
|
|
219
|
+
if (this.required) {
|
|
220
|
+
this.elselect.setAttribute("aria-required", "true");
|
|
221
|
+
} else {
|
|
222
|
+
this.elselect.removeAttribute("aria-required");
|
|
223
|
+
}
|
|
216
224
|
|
|
217
225
|
// The message lives in the shadow DOM and the select in the light DOM, so an
|
|
218
226
|
// aria-describedby id reference cannot cross the boundary: use aria-description.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import '../../input/input-search.js';
|
|
3
3
|
import '../../spinner/spinner-horizontal.js';
|
|
4
|
-
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
4
|
+
import { DileNativeValidity, DileEmmitChange, FIELD_MESSAGE_ID } from '../../../mixins/form/index.js';
|
|
5
5
|
import '../select.js';
|
|
6
6
|
import { labelStyles } from '../../input/src/label-styles.js';
|
|
7
7
|
import { messageStyles } from '../../input/src/message-styles.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
export class DileSelectAjax extends DileEmmitChange(LitElement) {
|
|
10
|
+
export class DileSelectAjax extends DileNativeValidity(DileEmmitChange(LitElement)) {
|
|
11
11
|
|
|
12
12
|
static get styles() {
|
|
13
13
|
return [
|
|
@@ -68,6 +68,8 @@ export class DileSelectAjax extends DileEmmitChange(LitElement) {
|
|
|
68
68
|
label: { type: String },
|
|
69
69
|
value: { type: String },
|
|
70
70
|
name: { type: String, reflect: true },
|
|
71
|
+
/** Marks the field as required: shows the required indicator in the label and sets aria-required */
|
|
72
|
+
required: { type: Boolean, reflect: true },
|
|
71
73
|
disabled: { type: Boolean },
|
|
72
74
|
errored: { type: Boolean },
|
|
73
75
|
data: { type: Array },
|
|
@@ -184,7 +186,7 @@ export class DileSelectAjax extends DileEmmitChange(LitElement) {
|
|
|
184
186
|
return html`
|
|
185
187
|
<div>
|
|
186
188
|
${this.label
|
|
187
|
-
? html`<label for="textField">${this.label}</label>`
|
|
189
|
+
? html`<label for="textField" class="field-label">${this.label}</label>`
|
|
188
190
|
: ""}
|
|
189
191
|
${this.isSelected
|
|
190
192
|
? this.selectedTemplate
|
|
@@ -200,7 +202,9 @@ export class DileSelectAjax extends DileEmmitChange(LitElement) {
|
|
|
200
202
|
<dile-input-search
|
|
201
203
|
id="result"
|
|
202
204
|
?errored=${this.errored}
|
|
205
|
+
?required=${this.required}
|
|
203
206
|
?disabled=${this.disabled}
|
|
207
|
+
.accessibleDescription=${this.message || undefined}
|
|
204
208
|
value="${this.selectedText}"
|
|
205
209
|
readOnly
|
|
206
210
|
@dile-input-search-cleared=${this.onClearSelected}
|
|
@@ -216,7 +220,9 @@ export class DileSelectAjax extends DileEmmitChange(LitElement) {
|
|
|
216
220
|
placeholder="${this.placeholder}"
|
|
217
221
|
label="${this.label}"
|
|
218
222
|
?errored=${this.errored}
|
|
223
|
+
?required=${this.required}
|
|
219
224
|
?disabled=${this.disabled}
|
|
225
|
+
.accessibleDescription=${this.message || undefined}
|
|
220
226
|
@focus=${this.onFocus}
|
|
221
227
|
@dile-input-search=${this.onTextInput}
|
|
222
228
|
delay="${this.delay}"
|
|
@@ -271,8 +277,9 @@ export class DileSelectAjax extends DileEmmitChange(LitElement) {
|
|
|
271
277
|
@element-changed=${this.doSelected}
|
|
272
278
|
name="generated-select-field"
|
|
273
279
|
?errored=${this.errored}
|
|
280
|
+
?required=${this.required}
|
|
274
281
|
>
|
|
275
|
-
<select slot="select">
|
|
282
|
+
<select slot="select" aria-description=${this.message || ''}>
|
|
276
283
|
<option value="">${this.selectDefaultPlaceholder}</option>
|
|
277
284
|
${this.data.map(item => html`
|
|
278
285
|
<option value="${item[this.idProperty]}">${item[this.displayProperty]}</option>
|
|
@@ -285,7 +292,7 @@ export class DileSelectAjax extends DileEmmitChange(LitElement) {
|
|
|
285
292
|
get messageTemplate() {
|
|
286
293
|
return html`
|
|
287
294
|
${this.message
|
|
288
|
-
? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
295
|
+
? html`<div id="${FIELD_MESSAGE_ID}" class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
289
296
|
: ''
|
|
290
297
|
}
|
|
291
298
|
`
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { html, css, LitElement } from "lit";
|
|
2
|
-
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
2
|
+
import { DileNativeValidity, DileEmmitChange } from '../../../mixins/form/index.js';
|
|
3
3
|
import '../select.js';
|
|
4
4
|
|
|
5
|
-
export class DileSelectBoolean extends DileEmmitChange(LitElement) {
|
|
5
|
+
export class DileSelectBoolean extends DileNativeValidity(DileEmmitChange(LitElement)) {
|
|
6
6
|
static get formAssociated() {
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
@@ -20,6 +20,8 @@ export class DileSelectBoolean extends DileEmmitChange(LitElement) {
|
|
|
20
20
|
label: { type: String },
|
|
21
21
|
value: {},
|
|
22
22
|
name: { type: String, reflect: true },
|
|
23
|
+
/** Marks the field as required: shows the required indicator in the label and sets aria-required */
|
|
24
|
+
required: { type: Boolean, reflect: true },
|
|
23
25
|
disabled: { type: Boolean },
|
|
24
26
|
errored: { type: Boolean },
|
|
25
27
|
message: { type: String },
|
|
@@ -46,6 +48,7 @@ export class DileSelectBoolean extends DileEmmitChange(LitElement) {
|
|
|
46
48
|
<dile-select
|
|
47
49
|
label="${this.label || ''}"
|
|
48
50
|
?errored="${this.errored}"
|
|
51
|
+
?required="${this.required}"
|
|
49
52
|
message="${this.message || ''}"
|
|
50
53
|
?disabled="${this.disabled}"
|
|
51
54
|
quietOnStart
|
|
@@ -92,6 +95,10 @@ export class DileSelectBoolean extends DileEmmitChange(LitElement) {
|
|
|
92
95
|
|
|
93
96
|
_onInnerChange(e) {
|
|
94
97
|
e.stopPropagation();
|
|
98
|
+
// The inner select is emptied by clear() or a null value: keep the empty state
|
|
99
|
+
if (e.detail.value !== 'true' && e.detail.value !== 'false') {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
95
102
|
const boolValue = e.detail.value === 'true';
|
|
96
103
|
if (boolValue !== this.value) {
|
|
97
104
|
this.value = boolValue;
|
|
@@ -1,6 +1,6 @@
|
|
|
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 { DileNativeValidity, DileEmmitChange } from '../../../mixins/form/index.js';
|
|
4
4
|
import { DileOverlay } from '../../../mixins/overlay/index.js';
|
|
5
5
|
import { DileCloseDocumentClick } from '../../../mixins/close-document-click/index.js';
|
|
6
6
|
import { labelStyles, messageStyles } from '../../input/index.js';
|
|
@@ -11,7 +11,7 @@ const TYPEAHEAD_RESET_DELAY = 500;
|
|
|
11
11
|
const ICONLIB_FOLDERS = { material: 'material-icons', lucide: 'lucide-icons', fontawesome: 'fontawesome-icons' };
|
|
12
12
|
const warnedIcons = new Set();
|
|
13
13
|
|
|
14
|
-
export class DileSelectOverlay extends DileOverlay(DileCloseDocumentClick(DileEmmitChange(LitElement))) {
|
|
14
|
+
export class DileSelectOverlay extends DileOverlay(DileCloseDocumentClick(DileNativeValidity(DileEmmitChange(LitElement)))) {
|
|
15
15
|
static get styles() {
|
|
16
16
|
return [
|
|
17
17
|
labelStyles,
|
|
@@ -181,6 +181,8 @@ export class DileSelectOverlay extends DileOverlay(DileCloseDocumentClick(DileEm
|
|
|
181
181
|
accessibleLabel: { type: String },
|
|
182
182
|
value: { type: String },
|
|
183
183
|
name: { type: String, reflect: true },
|
|
184
|
+
/** Marks the field as required: shows the required indicator in the label and sets aria-required */
|
|
185
|
+
required: { type: Boolean, reflect: true },
|
|
184
186
|
disabled: { type: Boolean },
|
|
185
187
|
errored: { type: Boolean },
|
|
186
188
|
message: { type: String },
|
|
@@ -340,7 +342,7 @@ export class DileSelectOverlay extends DileOverlay(DileCloseDocumentClick(DileEm
|
|
|
340
342
|
const messageId = this.message ? `${this.selectId}-message` : null;
|
|
341
343
|
return html`
|
|
342
344
|
<div>${this.label
|
|
343
|
-
? html`<label for="trigger">${this.label}</label>`
|
|
345
|
+
? html`<label for="trigger" class="field-label">${this.label}</label>`
|
|
344
346
|
: ""
|
|
345
347
|
}<div class="select-wrapper">
|
|
346
348
|
${this.triggerTemplate}
|
|
@@ -371,6 +373,7 @@ export class DileSelectOverlay extends DileOverlay(DileCloseDocumentClick(DileEm
|
|
|
371
373
|
aria-controls="overlay"
|
|
372
374
|
aria-activedescendant="${ifDefined(this._activeIndex >= 0 ? this._optionId(this._activeIndex) : undefined)}"
|
|
373
375
|
aria-invalid="${this.errored}"
|
|
376
|
+
aria-required="${ifDefined(this.required ? 'true' : undefined)}"
|
|
374
377
|
aria-describedby="${ifDefined(this.message ? `${this.selectId}-message` : undefined)}"
|
|
375
378
|
?disabled="${this.disabled}"
|
|
376
379
|
tabindex="${this.hideTrigger ? '-1' : '0'}"
|
|
@@ -6,7 +6,7 @@ import '../../icon/icon.js';
|
|
|
6
6
|
import '../select-overlay.js';
|
|
7
7
|
import '../../input/input-search.js';
|
|
8
8
|
import { searchIcon, clearIcon } from '@dile/icons/index.js';
|
|
9
|
-
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
9
|
+
import { DileNativeValidity, DileEmmitChange } from '../../../mixins/form/index.js';
|
|
10
10
|
import { labelStyles } from '../../input/src/label-styles.js';
|
|
11
11
|
import { messageStyles } from '../../input/src/message-styles.js';
|
|
12
12
|
|
|
@@ -25,7 +25,7 @@ const OPTION_PARTS = ['option', 'option-highlighted', 'option-selected', 'option
|
|
|
25
25
|
* - resolveSelectedText(): set `selectedText` for the current `value` (initial value or set()).
|
|
26
26
|
* - selectedTextChangedEventName: name of the event fired when the selected text changes.
|
|
27
27
|
*/
|
|
28
|
-
export class DileSelectSearchableBase extends DileEmmitChange(LitElement) {
|
|
28
|
+
export class DileSelectSearchableBase extends DileNativeValidity(DileEmmitChange(LitElement)) {
|
|
29
29
|
|
|
30
30
|
static get styles() {
|
|
31
31
|
return [
|
|
@@ -146,6 +146,8 @@ export class DileSelectSearchableBase extends DileEmmitChange(LitElement) {
|
|
|
146
146
|
label: { type: String },
|
|
147
147
|
value: { type: String },
|
|
148
148
|
name: { type: String, reflect: true },
|
|
149
|
+
/** Marks the field as required: shows the required indicator in the label and sets aria-required */
|
|
150
|
+
required: { type: Boolean, reflect: true },
|
|
149
151
|
disabled: { type: Boolean },
|
|
150
152
|
errored: { type: Boolean },
|
|
151
153
|
data: { type: Array },
|
|
@@ -301,7 +303,7 @@ export class DileSelectSearchableBase extends DileEmmitChange(LitElement) {
|
|
|
301
303
|
return html`
|
|
302
304
|
<div>
|
|
303
305
|
${this.label
|
|
304
|
-
? html`<label for="${this.isSelected ? 'result' : 'search'}">${this.label}</label>`
|
|
306
|
+
? html`<label for="${this.isSelected ? 'result' : 'search'}" class="field-label">${this.label}</label>`
|
|
305
307
|
: ""}
|
|
306
308
|
${this.isSelected
|
|
307
309
|
? this.selectedTemplate
|
|
@@ -317,6 +319,7 @@ export class DileSelectSearchableBase extends DileEmmitChange(LitElement) {
|
|
|
317
319
|
<dile-input-search
|
|
318
320
|
id="result"
|
|
319
321
|
?errored=${this.errored}
|
|
322
|
+
?required=${this.required}
|
|
320
323
|
?disabled=${this.disabled}
|
|
321
324
|
value="${this.selectedText}"
|
|
322
325
|
readOnly
|
|
@@ -341,6 +344,7 @@ export class DileSelectSearchableBase extends DileEmmitChange(LitElement) {
|
|
|
341
344
|
aria-haspopup="listbox"
|
|
342
345
|
aria-expanded="${this.opened}"
|
|
343
346
|
aria-invalid="${this.errored}"
|
|
347
|
+
aria-required="${ifDefined(this.required ? 'true' : undefined)}"
|
|
344
348
|
aria-describedby="${ifDefined(this.message ? `${this.selectId}-message` : undefined)}"
|
|
345
349
|
placeholder="${this.placeholder}"
|
|
346
350
|
.value="${this.keyword}"
|
|
@@ -388,6 +392,7 @@ export class DileSelectSearchableBase extends DileEmmitChange(LitElement) {
|
|
|
388
392
|
<dile-select-overlay
|
|
389
393
|
id="elselect"
|
|
390
394
|
?hideTrigger=${this.hasSearchField}
|
|
395
|
+
?required=${this.required}
|
|
391
396
|
name="generated-select-field"
|
|
392
397
|
placeholder="${this.placeholder}"
|
|
393
398
|
?disabled=${this.disabled}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { DileCheckbox } from '../../checkbox/src/DileCheckbox.js';
|
|
3
|
+
import { requiredIndicatorStyles } from '../../input/src/label-styles.js';
|
|
3
4
|
|
|
4
5
|
export class DileSwitch extends DileCheckbox {
|
|
5
6
|
static styles = [
|
|
7
|
+
requiredIndicatorStyles,
|
|
6
8
|
css`
|
|
7
9
|
:host {
|
|
8
10
|
display: inline-block;
|
|
@@ -76,7 +78,7 @@ export class DileSwitch extends DileCheckbox {
|
|
|
76
78
|
|
|
77
79
|
get reactiveLabelsTemplate() {
|
|
78
80
|
return html`
|
|
79
|
-
<label class="label">
|
|
81
|
+
<label class="label field-label">
|
|
80
82
|
${this.checked
|
|
81
83
|
? this.checkedLabel
|
|
82
84
|
: this.uncheckedLabel
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
2
3
|
import { labelStyles, messageStyles } from '../../input/index.js';
|
|
3
|
-
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
4
|
+
import { DileNativeValidity, DileEmmitChange } from '../../../mixins/form/index.js';
|
|
4
5
|
|
|
5
|
-
export class DileTextarea extends DileEmmitChange(LitElement) {
|
|
6
|
+
export class DileTextarea extends DileNativeValidity(DileEmmitChange(LitElement)) {
|
|
6
7
|
|
|
7
8
|
static get styles() {
|
|
8
9
|
return [
|
|
@@ -71,6 +72,8 @@ export class DileTextarea extends DileEmmitChange(LitElement) {
|
|
|
71
72
|
rows: { type: Number },
|
|
72
73
|
maxRows: { type: Number },
|
|
73
74
|
readonly: { type: Boolean },
|
|
75
|
+
/** Marks the field as required: shows the required indicator in the label and sets aria-required */
|
|
76
|
+
required: { type: Boolean, reflect: true },
|
|
74
77
|
disabled: {
|
|
75
78
|
type: Boolean,
|
|
76
79
|
reflect: true,
|
|
@@ -113,7 +116,7 @@ export class DileTextarea extends DileEmmitChange(LitElement) {
|
|
|
113
116
|
return html`
|
|
114
117
|
<main>
|
|
115
118
|
${this.label
|
|
116
|
-
? html`<label for="textArea">${this.label}</label>`
|
|
119
|
+
? html`<label for="textArea" class="field-label">${this.label}</label>`
|
|
117
120
|
: ""}
|
|
118
121
|
<section class="for-input">
|
|
119
122
|
<textarea
|
|
@@ -123,6 +126,7 @@ export class DileTextarea extends DileEmmitChange(LitElement) {
|
|
|
123
126
|
placeholder="${this.placeholder}"
|
|
124
127
|
?disabled="${this.disabled}"
|
|
125
128
|
?readonly="${this.readonly}"
|
|
129
|
+
aria-required="${ifDefined(this.required ? 'true' : undefined)}"
|
|
126
130
|
autocomplete="${this.disableAutocomplete ? "off" : "on"}"
|
|
127
131
|
.value="${this.value}"
|
|
128
132
|
class="${this.errored ? 'errored' : ''}"
|