@ds-autonomie/web-components 2.1.0 → 2.2.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/CHANGELOG.md +13 -0
- package/cdn/chunks/{chunk.ZDLDKWEM.js → chunk.2APAO2OW.js} +1 -1
- package/cdn/chunks/{chunk.JTHUYIYP.js → chunk.2DJERWBI.js} +5 -5
- package/cdn/chunks/{chunk.QCSRN6TI.js → chunk.3JMBGIZN.js} +1 -1
- package/cdn/chunks/{chunk.Z2IR3WWE.js → chunk.4NC4QO64.js} +1 -1
- package/cdn/chunks/{chunk.OZEY33RC.js → chunk.5LXQ3RKQ.js} +2 -22
- package/cdn/chunks/{chunk.JSVJ7J76.js → chunk.6QTMZJGH.js} +1 -1
- package/cdn/chunks/{chunk.6E6G25TQ.js → chunk.A33BZOMA.js} +1 -1
- package/cdn/chunks/{chunk.LRMXGBIU.js → chunk.ATHAYO6A.js} +155 -4
- package/cdn/chunks/{chunk.Z6DEWBVS.js → chunk.C62MMBV4.js} +10 -0
- package/cdn/chunks/{chunk.5AFQZ4HE.js → chunk.CYMM2ZAV.js} +6 -0
- package/cdn/chunks/chunk.F7NUIVDV.js +10 -0
- package/cdn/chunks/{chunk.OVD3Q2LV.js → chunk.FHOCNAJ4.js} +5 -2
- package/cdn/chunks/{chunk.KTAPO27T.js → chunk.HYTYRM6S.js} +1 -1
- package/cdn/chunks/{chunk.S4BW7KNM.js → chunk.J73YJOU4.js} +1 -1
- package/cdn/chunks/chunk.KELDA33H.js +198 -0
- package/cdn/chunks/{chunk.R6BGXKHX.js → chunk.LNBAAP45.js} +1 -1
- package/cdn/chunks/{chunk.MEYHIAQ5.js → chunk.M7QHADJH.js} +5 -1
- package/cdn/chunks/chunk.MJLKYERJ.js +348 -0
- package/cdn/chunks/chunk.PWL7QCVG.js +9 -0
- package/cdn/chunks/{chunk.Y5CXRULD.js → chunk.UAQ7MMLI.js} +1 -1
- package/cdn/chunks/{chunk.PMMQ5QVY.js → chunk.XQAKSW3W.js} +12 -1
- package/cdn/chunks/{chunk.NPJ5ZOJ4.js → chunk.YQQNMFZF.js} +20 -85
- package/cdn/chunks/{chunk.E4GNTJPS.js → chunk.YS6XV3LD.js} +1 -1
- package/cdn/components/checkbox/checkbox.d.ts +1 -0
- package/cdn/components/checkbox/checkbox.js +6 -1
- package/cdn/components/checkbox-button/checkbox-button.d.ts +1 -0
- package/cdn/components/checkbox-button/checkbox-button.js +1 -1
- package/cdn/components/checkbox-group/checkbox-group.d.ts +5 -8
- package/cdn/components/checkbox-group/checkbox-group.js +3 -5
- package/cdn/components/checkbox-group/checkbox-group.styles.js +1 -1
- package/cdn/components/combobox/combobox.d.ts +3 -2
- package/cdn/components/combobox/combobox.js +3 -2
- package/cdn/components/file-upload/file-upload.d.ts +3 -2
- package/cdn/components/filter-base/filter-base-stories.js +1 -1
- package/cdn/components/filter-counter/filter-counter.js +5 -4
- package/cdn/components/filter-date/filter-date.js +1 -1
- package/cdn/components/filter-range/filter-range.js +5 -4
- package/cdn/components/filter-select/filter-select.d.ts +5 -3
- package/cdn/components/filter-select/filter-select.js +8 -7
- package/cdn/components/input/input.js +5 -4
- package/cdn/components/input-date/input-date.js +4 -3
- package/cdn/components/input-mask/input-mask.js +3 -2
- package/cdn/components/input-otp/input-otp.d.ts +90 -0
- package/cdn/components/input-otp/input-otp.js +38 -0
- package/cdn/components/input-otp/input-otp.styles.d.ts +2 -0
- package/cdn/components/input-otp/input-otp.styles.js +11 -0
- package/cdn/components/input-otp/input-otp.utils.d.ts +3 -0
- package/cdn/components/input-otp/input-otp.utils.js +11 -0
- package/cdn/components/input-phone/input-phone.js +7 -6
- package/cdn/components/navbar-link/navbar-link.js +1 -1
- package/cdn/components/pagination/pagination.js +8 -7
- package/cdn/components/radio-button/radio-button.js +4 -4
- package/cdn/components/radio-group/radio-group.d.ts +3 -2
- package/cdn/components/radio-group/radio-group.js +3 -3
- package/cdn/components/select/select.d.ts +4 -2
- package/cdn/components/select/select.js +3 -2
- package/cdn/components/step/step.js +2 -1
- package/cdn/components/tab/tab.js +1 -1
- package/cdn/components/table-body/table-body.js +2 -2
- package/cdn/components/table-header-row/table-header-row.js +8 -5
- package/cdn/components/table-row/table-row.js +6 -1
- package/cdn/components/textarea/textarea.js +3 -2
- package/cdn/components/tree/tree.js +8 -3
- package/cdn/components/tree-item/tree-item.js +6 -1
- package/cdn/custom-elements.json +517 -41
- package/cdn/design-system.d.ts +2 -0
- package/cdn/design-system.js +111 -98
- package/cdn/internal/a11y-warning.d.ts +2 -0
- package/cdn/internal/a11y-warning.js +4 -0
- package/cdn/internal/components/date-field/date-field.js +6 -1
- package/cdn/internal/components/form-control/form-control-layout.js +6 -1
- package/cdn/themes/dsa-wc-theme.css +14 -0
- package/cdn/themes/dsa-wc-theme.min.css +1 -1
- package/cdn/themes/dsa-wc-theme.styles.js +14 -0
- package/cdn/utilities/storybook.js +1 -1
- package/cdn/vscode.html-custom-data.json +76 -7
- package/cdn/web-types.json +314 -35
- package/dist/chunks/chunk.5P2EEOC5.js +196 -0
- package/dist/chunks/{chunk.VOOE2BQV.js → chunk.6HR34L7E.js} +2 -22
- package/dist/chunks/{chunk.Y72CHU6D.js → chunk.6JHM36KH.js} +5 -1
- package/dist/chunks/{chunk.LKCPAJMF.js → chunk.B6LMEZTV.js} +5 -2
- package/dist/chunks/{chunk.OHPSPLZO.js → chunk.DDDHV2NU.js} +5 -5
- package/dist/chunks/{chunk.P4HRQ2D7.js → chunk.DHDRABMZ.js} +1 -1
- package/dist/chunks/chunk.F7NUIVDV.js +10 -0
- package/dist/chunks/{chunk.D3SHMAJT.js → chunk.H3FSR35C.js} +1 -1
- package/dist/chunks/{chunk.T4BUHP4L.js → chunk.I5HR7JYK.js} +10 -1
- package/dist/chunks/{chunk.NCECJWN7.js → chunk.KN6RQWYN.js} +1 -1
- package/dist/chunks/{chunk.JX7OISYA.js → chunk.KUYI27GJ.js} +186 -30
- package/dist/chunks/{chunk.ZGQUBAEK.js → chunk.L3LZ4MKX.js} +1 -1
- package/dist/chunks/{chunk.BXOGG3JO.js → chunk.LTCZARVI.js} +1 -1
- package/dist/chunks/{chunk.AF5WMYR2.js → chunk.MYSJOWY5.js} +1 -1
- package/dist/chunks/chunk.PWL7QCVG.js +9 -0
- package/dist/chunks/chunk.UDJJFUZ3.js +335 -0
- package/dist/chunks/{chunk.YXXLXJPE.js → chunk.UEWG3G4R.js} +6 -0
- package/dist/chunks/{chunk.WWANVBI5.js → chunk.UWGAOHHQ.js} +1 -1
- package/dist/chunks/{chunk.EGH3AVD7.js → chunk.VBW5RZBM.js} +1 -1
- package/dist/chunks/{chunk.XXHMFUD7.js → chunk.WRPRKCVY.js} +1 -1
- package/dist/chunks/{chunk.G422H4DZ.js → chunk.WUOMKASN.js} +10 -0
- package/dist/chunks/{chunk.ZYTDWH4E.js → chunk.XJMGXWLM.js} +20 -85
- package/dist/chunks/{chunk.6GN2WDDT.js → chunk.Y52TCF24.js} +1 -1
- package/dist/components/checkbox/checkbox.d.ts +1 -0
- package/dist/components/checkbox/checkbox.js +6 -1
- package/dist/components/checkbox-button/checkbox-button.d.ts +1 -0
- package/dist/components/checkbox-button/checkbox-button.js +1 -1
- package/dist/components/checkbox-group/checkbox-group.d.ts +5 -8
- package/dist/components/checkbox-group/checkbox-group.js +3 -4
- package/dist/components/checkbox-group/checkbox-group.styles.js +1 -1
- package/dist/components/combobox/combobox.d.ts +3 -2
- package/dist/components/combobox/combobox.js +3 -2
- package/dist/components/file-upload/file-upload.d.ts +3 -2
- package/dist/components/filter-base/filter-base-stories.js +1 -1
- package/dist/components/filter-counter/filter-counter.js +5 -4
- package/dist/components/filter-date/filter-date.js +1 -1
- package/dist/components/filter-range/filter-range.js +5 -4
- package/dist/components/filter-select/filter-select.d.ts +5 -3
- package/dist/components/filter-select/filter-select.js +8 -7
- package/dist/components/input/input.js +5 -4
- package/dist/components/input-date/input-date.js +4 -3
- package/dist/components/input-mask/input-mask.js +3 -2
- package/dist/components/input-otp/input-otp.d.ts +90 -0
- package/dist/components/input-otp/input-otp.js +31 -0
- package/dist/components/input-otp/input-otp.styles.d.ts +2 -0
- package/dist/components/input-otp/input-otp.styles.js +9 -0
- package/dist/components/input-otp/input-otp.utils.d.ts +3 -0
- package/dist/components/input-otp/input-otp.utils.js +11 -0
- package/dist/components/input-phone/input-phone.js +7 -6
- package/dist/components/navbar-link/navbar-link.js +1 -1
- package/dist/components/pagination/pagination.js +8 -7
- package/dist/components/radio-button/radio-button.js +4 -4
- package/dist/components/radio-group/radio-group.d.ts +3 -2
- package/dist/components/radio-group/radio-group.js +3 -3
- package/dist/components/select/select.d.ts +4 -2
- package/dist/components/select/select.js +3 -2
- package/dist/components/step/step.js +2 -1
- package/dist/components/tab/tab.js +1 -1
- package/dist/components/table-body/table-body.js +2 -2
- package/dist/components/table-header-row/table-header-row.js +7 -4
- package/dist/components/table-row/table-row.js +6 -1
- package/dist/components/textarea/textarea.js +3 -2
- package/dist/components/tree/tree.js +8 -3
- package/dist/components/tree-item/tree-item.js +6 -1
- package/dist/custom-elements.json +517 -41
- package/dist/design-system.d.ts +2 -0
- package/dist/design-system.js +111 -98
- package/dist/internal/a11y-warning.d.ts +2 -0
- package/dist/internal/a11y-warning.js +4 -0
- package/dist/internal/components/date-field/date-field.js +6 -1
- package/dist/internal/components/form-control/form-control-layout.js +6 -1
- package/dist/themes/dsa-wc-theme.css +14 -0
- package/dist/themes/dsa-wc-theme.min.css +1 -1
- package/dist/themes/dsa-wc-theme.styles.js +14 -0
- package/dist/utilities/storybook.js +1 -1
- package/dist/vscode.html-custom-data.json +76 -7
- package/dist/web-types.json +314 -35
- package/package.json +1 -1
- package/cdn/chunks/chunk.PS4PM6DJ.js +0 -164
- package/cdn/internal/test/disable-a11y-warnings.d.ts +0 -2
- package/cdn/internal/test/disable-a11y-warnings.js +0 -10
- package/dist/chunks/chunk.AYDVF4T3.js +0 -157
- package/dist/internal/test/disable-a11y-warnings.d.ts +0 -2
- package/dist/internal/test/disable-a11y-warnings.js +0 -10
- package/cdn/chunks/{chunk.PGT2WHXR.js → chunk.BCLU5KXE.js} +3 -3
- package/cdn/chunks/{chunk.COR7P3QG.js → chunk.NSE76EM5.js} +3 -3
- package/cdn/chunks/{chunk.P33HFS7T.js → chunk.V2UYRTUC.js} +3 -3
- package/dist/chunks/{chunk.WOV5QN3O.js → chunk.3OHVWJYG.js} +3 -3
- package/dist/chunks/{chunk.7BFH35RV.js → chunk.63MNXWSY.js} +3 -3
- package/dist/chunks/{chunk.MEPTPSE5.js → chunk.DUTPVTUZ.js} +3 -3
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import {
|
|
2
|
+
input_otp_styles_default
|
|
3
|
+
} from "./chunk.5P2EEOC5.js";
|
|
4
|
+
import {
|
|
5
|
+
FormControlLayout
|
|
6
|
+
} from "./chunk.I5HR7JYK.js";
|
|
7
|
+
import {
|
|
8
|
+
defaultValue
|
|
9
|
+
} from "./chunk.CMJ2SRTL.js";
|
|
10
|
+
import {
|
|
11
|
+
FormControlController
|
|
12
|
+
} from "./chunk.JA7YFGLI.js";
|
|
13
|
+
import {
|
|
14
|
+
watch
|
|
15
|
+
} from "./chunk.NOMN6DGD.js";
|
|
16
|
+
import {
|
|
17
|
+
ifDefinedAndNotEmpty
|
|
18
|
+
} from "./chunk.ZQJVCRB2.js";
|
|
19
|
+
import {
|
|
20
|
+
__decorateClass
|
|
21
|
+
} from "./chunk.S3NI7NKU.js";
|
|
22
|
+
|
|
23
|
+
// src/components/input-otp/input-otp.ts
|
|
24
|
+
import { html } from "lit";
|
|
25
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
|
26
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
27
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
28
|
+
import { live } from "lit/directives/live.js";
|
|
29
|
+
var DSAInputOTP = class extends FormControlLayout {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.formControlController = new FormControlController(this, {
|
|
33
|
+
assumeInteractionOn: ["dsa-blur", "dsa-input"]
|
|
34
|
+
});
|
|
35
|
+
this.hasFocus = false;
|
|
36
|
+
this.currentIndex = 0;
|
|
37
|
+
this.value = "";
|
|
38
|
+
this.defaultValue = "";
|
|
39
|
+
this.length = 6;
|
|
40
|
+
}
|
|
41
|
+
/** Gets the validity state object */
|
|
42
|
+
get validity() {
|
|
43
|
+
return this.input.validity;
|
|
44
|
+
}
|
|
45
|
+
/** Gets the validation message */
|
|
46
|
+
get validationMessage() {
|
|
47
|
+
return this.input.validationMessage;
|
|
48
|
+
}
|
|
49
|
+
async firstUpdated() {
|
|
50
|
+
await this.updateComplete;
|
|
51
|
+
this.formControlController.updateValidity();
|
|
52
|
+
}
|
|
53
|
+
handleBlur() {
|
|
54
|
+
this.hasFocus = false;
|
|
55
|
+
this.emit("dsa-blur");
|
|
56
|
+
}
|
|
57
|
+
handleChange() {
|
|
58
|
+
this.value = this.input.value;
|
|
59
|
+
this.emit("dsa-change");
|
|
60
|
+
}
|
|
61
|
+
handleFocus() {
|
|
62
|
+
this.currentIndex = this.value ? -1 : 0;
|
|
63
|
+
this.hasFocus = true;
|
|
64
|
+
this.emit("dsa-focus");
|
|
65
|
+
}
|
|
66
|
+
handleInput(event) {
|
|
67
|
+
var _a;
|
|
68
|
+
if (this.patternRegexp && !this.patternRegexp.test(this.input.value)) {
|
|
69
|
+
this.input.value = this.value;
|
|
70
|
+
this.handleCurrentIndexChange();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (this.input.value.length > this.length) {
|
|
74
|
+
this.input.value = this.input.value.slice(0, this.length);
|
|
75
|
+
} else {
|
|
76
|
+
this.value = this.input.value;
|
|
77
|
+
if (!event.data) {
|
|
78
|
+
if (this.currentIndex === 0) {
|
|
79
|
+
this.handleCurrentIndexChange();
|
|
80
|
+
} else if (this.currentIndex === -1) {
|
|
81
|
+
this.currentIndex = 0;
|
|
82
|
+
} else {
|
|
83
|
+
this.currentIndex -= 1;
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
if (((_a = event.data) == null ? void 0 : _a.length) === 1) {
|
|
87
|
+
this.currentIndex = this.currentIndex < this.length ? this.currentIndex + 1 : this.length - 1;
|
|
88
|
+
} else {
|
|
89
|
+
this.currentIndex = this.getLastIndex();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
this.formControlController.updateValidity();
|
|
93
|
+
this.emit("dsa-input");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
handleSelect() {
|
|
97
|
+
if (this.input.value.length > 1 && this.input.selectionStart === 0 && this.input.selectionEnd === this.input.value.length) {
|
|
98
|
+
this.currentIndex = -1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
handleInvalid(event) {
|
|
102
|
+
this.formControlController.setValidity(false);
|
|
103
|
+
this.formControlController.emitInvalidEvent(event);
|
|
104
|
+
}
|
|
105
|
+
handleKeyDown(event) {
|
|
106
|
+
const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
107
|
+
if (event.key === "Enter" && !hasModifier) {
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
if (!event.defaultPrevented && !event.isComposing) {
|
|
110
|
+
this.formControlController.submit();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
switch (event.key) {
|
|
117
|
+
case "ArrowLeft":
|
|
118
|
+
this.currentIndex = this.currentIndex > 0 ? this.currentIndex - 1 : 0;
|
|
119
|
+
break;
|
|
120
|
+
case "ArrowRight":
|
|
121
|
+
if (this.currentIndex === -1) {
|
|
122
|
+
this.currentIndex = this.getLastIndex();
|
|
123
|
+
} else if (this.currentIndex < this.value.length && this.currentIndex < this.length - 1) {
|
|
124
|
+
this.currentIndex += 1;
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case "ArrowUp":
|
|
128
|
+
this.currentIndex = 0;
|
|
129
|
+
break;
|
|
130
|
+
case "ArrowDown":
|
|
131
|
+
this.currentIndex = this.getLastIndex();
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
handleSingleFieldClick(event) {
|
|
137
|
+
this.focus();
|
|
138
|
+
if (event.currentTarget instanceof HTMLElement) {
|
|
139
|
+
const clickedIndex = Number(event.currentTarget.dataset.fieldIndex);
|
|
140
|
+
this.currentIndex = clickedIndex < this.value.length ? clickedIndex : this.getLastIndex();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
getLastIndex() {
|
|
144
|
+
return this.value.length > 0 ? Math.min(this.value.length, this.length - 1) : 0;
|
|
145
|
+
}
|
|
146
|
+
getDescriptionIds() {
|
|
147
|
+
const ids = [...this.error ? ["error-text"] : [], "help-text"];
|
|
148
|
+
return ids.join(" ");
|
|
149
|
+
}
|
|
150
|
+
handleCurrentIndexChange() {
|
|
151
|
+
if (this.currentIndex === -1) {
|
|
152
|
+
this.input.setSelectionRange(0, this.input.value.length);
|
|
153
|
+
} else {
|
|
154
|
+
this.input.setSelectionRange(this.currentIndex, this.currentIndex + 1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
handleDisabledChange() {
|
|
158
|
+
this.formControlController.setValidity(this.disabled);
|
|
159
|
+
}
|
|
160
|
+
async handleValueChange() {
|
|
161
|
+
await this.updateComplete;
|
|
162
|
+
this.formControlController.updateValidity();
|
|
163
|
+
}
|
|
164
|
+
handlePatterChange() {
|
|
165
|
+
this.patternRegexp = new RegExp(this.pattern);
|
|
166
|
+
}
|
|
167
|
+
/** Removes focus from the input. */
|
|
168
|
+
blur() {
|
|
169
|
+
this.input.blur();
|
|
170
|
+
}
|
|
171
|
+
/** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
|
|
172
|
+
checkValidity() {
|
|
173
|
+
return this.input.checkValidity();
|
|
174
|
+
}
|
|
175
|
+
/** Sets focus on the input. */
|
|
176
|
+
focus(options) {
|
|
177
|
+
this.input.focus(options);
|
|
178
|
+
}
|
|
179
|
+
/** Gets the associated form, if one exists. */
|
|
180
|
+
getForm() {
|
|
181
|
+
return this.formControlController.getForm();
|
|
182
|
+
}
|
|
183
|
+
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
184
|
+
reportValidity() {
|
|
185
|
+
return this.input.reportValidity();
|
|
186
|
+
}
|
|
187
|
+
/** Selects all the text in the input. */
|
|
188
|
+
select() {
|
|
189
|
+
if (this.input instanceof HTMLInputElement) {
|
|
190
|
+
this.input.select();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Sets a custom validation message. Pass an empty string to restore validity. */
|
|
194
|
+
setCustomValidity(message) {
|
|
195
|
+
this.input.setCustomValidity(message);
|
|
196
|
+
this.formControlController.updateValidity();
|
|
197
|
+
}
|
|
198
|
+
async getUpdateComplete() {
|
|
199
|
+
const result = await super.getUpdateComplete();
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
renderSingleField(index) {
|
|
203
|
+
const charValue = this.value.split("")[index];
|
|
204
|
+
const isCurrentField = this.currentIndex === index || this.currentIndex === -1 && charValue;
|
|
205
|
+
const inputClasses = classMap({
|
|
206
|
+
"single-field": true,
|
|
207
|
+
"single-field--active": this.hasFocus && isCurrentField
|
|
208
|
+
});
|
|
209
|
+
return html`
|
|
210
|
+
<div
|
|
211
|
+
class=${inputClasses}
|
|
212
|
+
data-field-index=${index}
|
|
213
|
+
aria-hidden="true"
|
|
214
|
+
@click=${this.handleSingleFieldClick}
|
|
215
|
+
>
|
|
216
|
+
${charValue || this.hasFocus && isCurrentField ? html`<span class="single-field__value">${charValue}</span>` : html`
|
|
217
|
+
<span class="single-field__placeholder"
|
|
218
|
+
>${this.placeholder.charAt(0)}</span
|
|
219
|
+
>
|
|
220
|
+
`}
|
|
221
|
+
${this.hasFocus && isCurrentField && !charValue ? html` <div class="fake-caret"></div> ` : ""}
|
|
222
|
+
</div>
|
|
223
|
+
`;
|
|
224
|
+
}
|
|
225
|
+
renderInput() {
|
|
226
|
+
const hasLabelSlot = this.hasSlotController.test("label");
|
|
227
|
+
const hasLabel = this.label ? true : !!hasLabelSlot;
|
|
228
|
+
return html`
|
|
229
|
+
<div part="base" class="input__wrapper">
|
|
230
|
+
<div
|
|
231
|
+
class=${classMap({
|
|
232
|
+
"visible-input": true,
|
|
233
|
+
"input--focused": this.hasFocus,
|
|
234
|
+
// Sizes
|
|
235
|
+
"input--small": this.size === "small",
|
|
236
|
+
"input--medium": this.size === "medium",
|
|
237
|
+
"input--large": this.size === "large",
|
|
238
|
+
// States
|
|
239
|
+
"input--error": this.error,
|
|
240
|
+
"input--on-layer": this.variant === "layer",
|
|
241
|
+
"input--on-base": this.variant === "base",
|
|
242
|
+
"input--disabled": this.disabled
|
|
243
|
+
})}
|
|
244
|
+
>
|
|
245
|
+
${Array.from(Array(this.length)).map(
|
|
246
|
+
(_, index) => this.renderSingleField(index)
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
249
|
+
<input
|
|
250
|
+
part="input"
|
|
251
|
+
id="input"
|
|
252
|
+
class="hidden-input"
|
|
253
|
+
type="text"
|
|
254
|
+
name=${ifDefinedAndNotEmpty(this.name)}
|
|
255
|
+
?disabled=${this.disabled}
|
|
256
|
+
?required=${this.required}
|
|
257
|
+
minlength=${this.length}
|
|
258
|
+
maxlength=${this.length}
|
|
259
|
+
.value=${live(this.value)}
|
|
260
|
+
autocomplete="one-time-code"
|
|
261
|
+
?autofocus=${this.autofocus}
|
|
262
|
+
pattern=${ifDefined(this.pattern)}
|
|
263
|
+
enterkeyhint=${ifDefined(this.enterkeyhint)}
|
|
264
|
+
inputmode=${ifDefined(this.inputmode)}
|
|
265
|
+
aria-label=${ifDefinedAndNotEmpty(hasLabel ? void 0 : this.title)}
|
|
266
|
+
aria-describedby=${this.getDescriptionIds()}
|
|
267
|
+
aria-invalid=${ifDefined(this.error ? "true" : void 0)}
|
|
268
|
+
@change=${this.handleChange}
|
|
269
|
+
@input=${this.handleInput}
|
|
270
|
+
@invalid=${this.handleInvalid}
|
|
271
|
+
@keydown=${this.handleKeyDown}
|
|
272
|
+
@focus=${this.handleFocus}
|
|
273
|
+
@blur=${this.handleBlur}
|
|
274
|
+
@select=${this.handleSelect}
|
|
275
|
+
/>
|
|
276
|
+
</div>
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
DSAInputOTP.styles = input_otp_styles_default;
|
|
281
|
+
__decorateClass([
|
|
282
|
+
query("input")
|
|
283
|
+
], DSAInputOTP.prototype, "input", 2);
|
|
284
|
+
__decorateClass([
|
|
285
|
+
state()
|
|
286
|
+
], DSAInputOTP.prototype, "hasFocus", 2);
|
|
287
|
+
__decorateClass([
|
|
288
|
+
state()
|
|
289
|
+
], DSAInputOTP.prototype, "currentIndex", 2);
|
|
290
|
+
__decorateClass([
|
|
291
|
+
state()
|
|
292
|
+
], DSAInputOTP.prototype, "patternRegexp", 2);
|
|
293
|
+
__decorateClass([
|
|
294
|
+
property()
|
|
295
|
+
], DSAInputOTP.prototype, "value", 2);
|
|
296
|
+
__decorateClass([
|
|
297
|
+
defaultValue()
|
|
298
|
+
], DSAInputOTP.prototype, "defaultValue", 2);
|
|
299
|
+
__decorateClass([
|
|
300
|
+
property()
|
|
301
|
+
], DSAInputOTP.prototype, "pattern", 2);
|
|
302
|
+
__decorateClass([
|
|
303
|
+
property({ type: Number })
|
|
304
|
+
], DSAInputOTP.prototype, "length", 2);
|
|
305
|
+
__decorateClass([
|
|
306
|
+
property()
|
|
307
|
+
], DSAInputOTP.prototype, "autocapitalize", 2);
|
|
308
|
+
__decorateClass([
|
|
309
|
+
property({ type: Boolean })
|
|
310
|
+
], DSAInputOTP.prototype, "autofocus", 2);
|
|
311
|
+
__decorateClass([
|
|
312
|
+
property()
|
|
313
|
+
], DSAInputOTP.prototype, "enterkeyhint", 2);
|
|
314
|
+
__decorateClass([
|
|
315
|
+
property()
|
|
316
|
+
], DSAInputOTP.prototype, "inputmode", 2);
|
|
317
|
+
__decorateClass([
|
|
318
|
+
watch("currentIndex", { waitUntilFirstUpdate: true })
|
|
319
|
+
], DSAInputOTP.prototype, "handleCurrentIndexChange", 1);
|
|
320
|
+
__decorateClass([
|
|
321
|
+
watch("disabled", { waitUntilFirstUpdate: true })
|
|
322
|
+
], DSAInputOTP.prototype, "handleDisabledChange", 1);
|
|
323
|
+
__decorateClass([
|
|
324
|
+
watch("value", { waitUntilFirstUpdate: true })
|
|
325
|
+
], DSAInputOTP.prototype, "handleValueChange", 1);
|
|
326
|
+
__decorateClass([
|
|
327
|
+
watch("pattern")
|
|
328
|
+
], DSAInputOTP.prototype, "handlePatterChange", 1);
|
|
329
|
+
DSAInputOTP = __decorateClass([
|
|
330
|
+
customElement("dsa-input-otp")
|
|
331
|
+
], DSAInputOTP);
|
|
332
|
+
|
|
333
|
+
export {
|
|
334
|
+
DSAInputOTP
|
|
335
|
+
};
|
|
@@ -15,6 +15,12 @@ var DSACheckboxButton = class extends FormToggleButton {
|
|
|
15
15
|
super(...arguments);
|
|
16
16
|
this.type = "checkbox";
|
|
17
17
|
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
if (!this.hasAttribute("role")) {
|
|
21
|
+
this.setAttribute("role", "listitem");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
18
24
|
handleClick() {
|
|
19
25
|
this.checked = !this.checked;
|
|
20
26
|
}
|
|
@@ -81,7 +81,7 @@ var DSATab = class extends ShoelaceElement {
|
|
|
81
81
|
part="close-button"
|
|
82
82
|
exportparts="base:close-button__base"
|
|
83
83
|
name="close"
|
|
84
|
-
label=${this.closeButtonLabel !== "" ? this.closeButtonLabel : this.localize.term("close")}
|
|
84
|
+
label=${this.closeButtonLabel && this.closeButtonLabel !== "" ? this.closeButtonLabel : this.localize.term("close")}
|
|
85
85
|
class="tab__close-button"
|
|
86
86
|
@click=${this.handleCloseClick}
|
|
87
87
|
library="system"
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DSACheckboxGroup
|
|
3
|
+
} from "./chunk.XJMGXWLM.js";
|
|
1
4
|
import {
|
|
2
5
|
defaultValue
|
|
3
6
|
} from "./chunk.CMJ2SRTL.js";
|
|
@@ -63,6 +66,13 @@ var DSACheckbox = class extends ShoelaceElement {
|
|
|
63
66
|
get validationMessage() {
|
|
64
67
|
return this.input.validationMessage;
|
|
65
68
|
}
|
|
69
|
+
connectedCallback() {
|
|
70
|
+
super.connectedCallback();
|
|
71
|
+
const parent = this.parentElement;
|
|
72
|
+
if (!this.hasAttribute("role") && parent instanceof DSACheckboxGroup) {
|
|
73
|
+
this.setAttribute("role", "listitem");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
66
76
|
firstUpdated() {
|
|
67
77
|
this.formControlController.updateValidity();
|
|
68
78
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checkbox_group_styles_default
|
|
3
|
-
} from "./chunk.
|
|
3
|
+
} from "./chunk.6HR34L7E.js";
|
|
4
|
+
import {
|
|
5
|
+
a11yWarning
|
|
6
|
+
} from "./chunk.PWL7QCVG.js";
|
|
4
7
|
import {
|
|
5
8
|
renderFormElementErrors
|
|
6
9
|
} from "./chunk.IZBHR7GP.js";
|
|
@@ -39,7 +42,6 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
39
42
|
this.customValidityMessage = "";
|
|
40
43
|
this.hasCheckboxButtons = false;
|
|
41
44
|
this.defaultValue = [];
|
|
42
|
-
this.allCheckboxes = [];
|
|
43
45
|
this.label = "";
|
|
44
46
|
this.helpText = "";
|
|
45
47
|
this.name = "option";
|
|
@@ -81,45 +83,9 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
81
83
|
}
|
|
82
84
|
firstUpdated() {
|
|
83
85
|
this.formControlController.updateValidity();
|
|
84
|
-
this.allCheckboxes = this.getAllCheckboxes();
|
|
85
|
-
this.observeSlottedElements();
|
|
86
|
-
}
|
|
87
|
-
// A change of attributes on the slotted elements does not trigger the "slotchange" event, so we add an observer
|
|
88
|
-
observeSlottedElements() {
|
|
89
|
-
this.slottedElementsObserver = new MutationObserver((mutationsList) => {
|
|
90
|
-
let needsUpdate = false;
|
|
91
|
-
mutationsList.forEach((mutation) => {
|
|
92
|
-
if (mutation.type === "attributes" || mutation.type === "childList") {
|
|
93
|
-
needsUpdate = true;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
if (needsUpdate) {
|
|
97
|
-
this.handleSlottedElementChange();
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
[...this.defaultSlot.assignedElements({ flatten: true })].forEach(
|
|
101
|
-
(element) => {
|
|
102
|
-
this.slottedElementsObserver.observe(element, {
|
|
103
|
-
attributes: true,
|
|
104
|
-
childList: true
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
86
|
}
|
|
109
87
|
getAllCheckboxes() {
|
|
110
|
-
|
|
111
|
-
const allCheckboxes = [];
|
|
112
|
-
checboxNodeList.forEach((checkbox) => {
|
|
113
|
-
const clonedCheckbox = checkbox.cloneNode(true);
|
|
114
|
-
if (this.disabled) {
|
|
115
|
-
clonedCheckbox.disabled = true;
|
|
116
|
-
}
|
|
117
|
-
if (this.readonly) {
|
|
118
|
-
clonedCheckbox.readonly = true;
|
|
119
|
-
}
|
|
120
|
-
allCheckboxes.push(clonedCheckbox);
|
|
121
|
-
});
|
|
122
|
-
return allCheckboxes;
|
|
88
|
+
return [...this.defaultSlot.assignedElements({ flatten: true })];
|
|
123
89
|
}
|
|
124
90
|
handleCheckboxClick(event) {
|
|
125
91
|
if (event.target.tagName.toLowerCase() === "a") {
|
|
@@ -142,11 +108,11 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
142
108
|
(checkboxValue) => checkboxValue !== target.value
|
|
143
109
|
);
|
|
144
110
|
}
|
|
145
|
-
this.
|
|
111
|
+
this.getAllCheckboxes().forEach((checkbox) => {
|
|
146
112
|
checkbox.checked = this.value.includes(checkbox.value);
|
|
147
113
|
});
|
|
148
|
-
this.emit("dsa-input");
|
|
149
114
|
this.emit("dsa-change");
|
|
115
|
+
this.emit("dsa-input");
|
|
150
116
|
}
|
|
151
117
|
handleKeyDown(event) {
|
|
152
118
|
if (event.target.tagName.toLowerCase() === "a") {
|
|
@@ -159,7 +125,7 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
159
125
|
return;
|
|
160
126
|
}
|
|
161
127
|
target.checked = !target.checked;
|
|
162
|
-
const checkedCheckboxes = this.
|
|
128
|
+
const checkedCheckboxes = this.getAllCheckboxes().filter(
|
|
163
129
|
(checkbox) => checkbox.checked
|
|
164
130
|
);
|
|
165
131
|
this.value = checkedCheckboxes.map((checkbox) => checkbox.value);
|
|
@@ -168,7 +134,7 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
168
134
|
}
|
|
169
135
|
}
|
|
170
136
|
handleLabelClick() {
|
|
171
|
-
const availableCheckboxes = this.
|
|
137
|
+
const availableCheckboxes = this.getAllCheckboxes().filter(
|
|
172
138
|
(checkbox) => !checkbox.disabled && !checkbox.readonly
|
|
173
139
|
);
|
|
174
140
|
const checkboxToFocus = availableCheckboxes.find((checkbox) => checkbox.checked) || availableCheckboxes[0];
|
|
@@ -177,9 +143,8 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
177
143
|
}
|
|
178
144
|
}
|
|
179
145
|
handleSlottedElementChange() {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.allCheckboxes.forEach((checkbox) => {
|
|
146
|
+
const allCheckboxes = this.getAllCheckboxes();
|
|
147
|
+
allCheckboxes.forEach((checkbox) => {
|
|
183
148
|
if (this.disabled) {
|
|
184
149
|
checkbox.disabled = true;
|
|
185
150
|
}
|
|
@@ -188,22 +153,13 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
188
153
|
}
|
|
189
154
|
checkbox.checked = this.value.includes(checkbox.value);
|
|
190
155
|
});
|
|
191
|
-
this.hasCheckboxButtons =
|
|
156
|
+
this.hasCheckboxButtons = allCheckboxes.some(
|
|
192
157
|
(checkbox) => checkbox.tagName.toLowerCase() === "dsa-checkbox-button"
|
|
193
158
|
);
|
|
194
|
-
if (this.hasCheckboxButtons) {
|
|
195
|
-
const buttonGroup = (_a = this.shadowRoot) == null ? void 0 : _a.querySelector(
|
|
196
|
-
"dsa-internal-button-group"
|
|
197
|
-
);
|
|
198
|
-
if (buttonGroup) {
|
|
199
|
-
buttonGroup.disableRole = true;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
159
|
}
|
|
203
160
|
handleSlotChange() {
|
|
204
161
|
if (customElements.get("dsa-checkbox") || customElements.get("dsa-checkbox-button")) {
|
|
205
162
|
this.handleSlottedElementChange();
|
|
206
|
-
this.observeSlottedElements();
|
|
207
163
|
} else {
|
|
208
164
|
customElements.whenDefined("dsa-checkbox").then(() => this.handleSlotChange());
|
|
209
165
|
customElements.whenDefined("dsa-checkbox-button").then(() => this.handleSlotChange());
|
|
@@ -213,17 +169,12 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
213
169
|
this.formControlController.setValidity(false);
|
|
214
170
|
this.formControlController.emitInvalidEvent(event);
|
|
215
171
|
}
|
|
216
|
-
|
|
217
|
-
this.
|
|
172
|
+
handleValueChange() {
|
|
173
|
+
this.getAllCheckboxes().forEach(
|
|
218
174
|
(checkbox) => checkbox.checked = this.value.includes(checkbox.value)
|
|
219
175
|
);
|
|
220
176
|
this.formControlController.setValidity(this.validity.valid);
|
|
221
177
|
}
|
|
222
|
-
handleValueChange() {
|
|
223
|
-
if (this.hasUpdated) {
|
|
224
|
-
this.updateCheckedCheckbox();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
178
|
handleErrorChange() {
|
|
228
179
|
if (this.error) {
|
|
229
180
|
this.setAttribute("aria-invalid", "true");
|
|
@@ -273,8 +224,8 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
273
224
|
const hasLabel = this.label ? true : !!hasLabelSlot;
|
|
274
225
|
const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
|
|
275
226
|
if (!hasLabel) {
|
|
276
|
-
|
|
277
|
-
"
|
|
227
|
+
a11yWarning(
|
|
228
|
+
"<dsa-checkbox-group> requires a label attribute or a label slot for accessibility"
|
|
278
229
|
);
|
|
279
230
|
}
|
|
280
231
|
return html`
|
|
@@ -315,7 +266,7 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
315
266
|
part="form-control-input"
|
|
316
267
|
class="form-control-input form-control__field"
|
|
317
268
|
>
|
|
318
|
-
<
|
|
269
|
+
<dsa-visually-hidden>
|
|
319
270
|
<label class="checkbox-group__validation">
|
|
320
271
|
<input
|
|
321
272
|
class="checkbox-group__validation-input"
|
|
@@ -326,7 +277,7 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
326
277
|
@invalid=${this.handleInvalid}
|
|
327
278
|
/>
|
|
328
279
|
</label>
|
|
329
|
-
</
|
|
280
|
+
</dsa-visually-hidden>
|
|
330
281
|
|
|
331
282
|
<div class="checkbox-group__list-container">
|
|
332
283
|
<div
|
|
@@ -338,22 +289,9 @@ var DSACheckboxGroup = class extends ShoelaceElement {
|
|
|
338
289
|
@click=${this.handleCheckboxClick}
|
|
339
290
|
@keydown=${this.handleKeyDown}
|
|
340
291
|
>
|
|
341
|
-
|
|
342
|
-
(checkbox) => html` <div
|
|
343
|
-
part="form-control-options"
|
|
344
|
-
class="checkbox-group__listitem"
|
|
345
|
-
role="listitem"
|
|
346
|
-
>
|
|
347
|
-
${checkbox}
|
|
348
|
-
</div>`
|
|
349
|
-
)}
|
|
292
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
350
293
|
</div>
|
|
351
294
|
</div>
|
|
352
|
-
<slot
|
|
353
|
-
@click=${this.handleCheckboxClick}
|
|
354
|
-
@slotchange=${this.handleSlotChange}
|
|
355
|
-
class="checkbox-group__default-slot"
|
|
356
|
-
></slot>
|
|
357
295
|
</div>
|
|
358
296
|
<slot
|
|
359
297
|
name="help-text"
|
|
@@ -383,9 +321,6 @@ __decorateClass([
|
|
|
383
321
|
__decorateClass([
|
|
384
322
|
state()
|
|
385
323
|
], DSACheckboxGroup.prototype, "defaultValue", 2);
|
|
386
|
-
__decorateClass([
|
|
387
|
-
state()
|
|
388
|
-
], DSACheckboxGroup.prototype, "allCheckboxes", 2);
|
|
389
324
|
__decorateClass([
|
|
390
325
|
property()
|
|
391
326
|
], DSACheckboxGroup.prototype, "label", 2);
|
|
@@ -446,7 +381,7 @@ __decorateClass([
|
|
|
446
381
|
property({ type: Boolean, attribute: "hide-label" })
|
|
447
382
|
], DSACheckboxGroup.prototype, "hideLabel", 2);
|
|
448
383
|
__decorateClass([
|
|
449
|
-
watch("value")
|
|
384
|
+
watch("value", { waitUntilFirstUpdate: true })
|
|
450
385
|
], DSACheckboxGroup.prototype, "handleValueChange", 1);
|
|
451
386
|
__decorateClass([
|
|
452
387
|
watch("error")
|
|
@@ -67,6 +67,7 @@ export default class DSACheckbox extends ShoelaceElement implements ShoelaceForm
|
|
|
67
67
|
get validity(): ValidityState;
|
|
68
68
|
/** Gets the validation message */
|
|
69
69
|
get validationMessage(): string;
|
|
70
|
+
connectedCallback(): void;
|
|
70
71
|
firstUpdated(): void;
|
|
71
72
|
private handleClick;
|
|
72
73
|
private handleBlur;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DSACheckbox
|
|
3
|
-
} from "../../chunks/chunk.
|
|
3
|
+
} from "../../chunks/chunk.WUOMKASN.js";
|
|
4
|
+
import "../../chunks/chunk.XJMGXWLM.js";
|
|
5
|
+
import "../../chunks/chunk.DCHXTN27.js";
|
|
6
|
+
import "../../chunks/chunk.IOFPPNUO.js";
|
|
7
|
+
import "../../chunks/chunk.6HR34L7E.js";
|
|
4
8
|
import "../../chunks/chunk.CMJ2SRTL.js";
|
|
9
|
+
import "../../chunks/chunk.PWL7QCVG.js";
|
|
5
10
|
import "../../chunks/chunk.KFXWL3NW.js";
|
|
6
11
|
import "../../chunks/chunk.EYZGEU3G.js";
|
|
7
12
|
import "../../chunks/chunk.IZBHR7GP.js";
|
|
@@ -12,6 +12,7 @@ import { FormToggleButton } from '../../internal/components/form-toggle-button/f
|
|
|
12
12
|
*/
|
|
13
13
|
export default class DSACheckboxButton extends FormToggleButton {
|
|
14
14
|
protected type: "checkbox";
|
|
15
|
+
connectedCallback(): void;
|
|
15
16
|
protected handleClick(): void;
|
|
16
17
|
handleErrorChange(): void;
|
|
17
18
|
}
|