@ds-autonomie/web-components 2.5.0 → 2.5.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.
Files changed (175) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/cdn/chunks/{chunk.J5KWVZHL.js → chunk.2BQQJKFU.js} +19 -111
  3. package/cdn/chunks/{chunk.A5QRPK4Q.js → chunk.3XJTVFZ2.js} +1 -1
  4. package/cdn/chunks/{chunk.3OSWL542.js → chunk.53DHJKYL.js} +0 -6
  5. package/cdn/chunks/{chunk.5BQ2BGS6.js → chunk.6KSC4CRL.js} +1 -0
  6. package/cdn/chunks/{chunk.HG4TPK7J.js → chunk.7CBNLWGC.js} +15 -153
  7. package/cdn/chunks/{chunk.5UVKMYSG.js → chunk.BQX4GGIU.js} +18 -12
  8. package/cdn/chunks/{chunk.H2OEFMQC.js → chunk.BWYI3OOJ.js} +0 -6
  9. package/cdn/chunks/chunk.CAWNJ57J.js +291 -0
  10. package/cdn/chunks/{chunk.URME4YZI.js → chunk.E2ERJT5L.js} +4 -121
  11. package/cdn/chunks/{chunk.CMRQV2SO.js → chunk.EVV7CPIX.js} +3 -3
  12. package/cdn/chunks/{chunk.2N65UIM6.js → chunk.IPKU2NK6.js} +23 -1
  13. package/cdn/chunks/{chunk.UM64ZD3C.js → chunk.JUCW3BPM.js} +1 -1
  14. package/cdn/chunks/{chunk.EF2VOGBL.js → chunk.LYIECKOK.js} +1 -1
  15. package/cdn/chunks/{chunk.WLND36JK.js → chunk.MMT7DZQU.js} +19 -10
  16. package/cdn/chunks/{chunk.BKVL3A5I.js → chunk.MRBMS4RB.js} +6 -2
  17. package/cdn/chunks/{chunk.VRC57YIG.js → chunk.NNXRECFT.js} +1 -1
  18. package/cdn/chunks/chunk.NON7TU3E.js +15 -0
  19. package/cdn/chunks/{chunk.L3ZYNSI3.js → chunk.OCDDQJHV.js} +3 -3
  20. package/cdn/chunks/{chunk.BNLQUWBO.js → chunk.OQUR5UM4.js} +1 -1
  21. package/cdn/chunks/{chunk.LZCR7P7U.js → chunk.PQ4KTIXS.js} +3 -129
  22. package/cdn/chunks/chunk.PT3QFRYN.js +336 -0
  23. package/cdn/chunks/{chunk.AJFNFADL.js → chunk.QUA6RD7E.js} +1 -1
  24. package/cdn/chunks/{chunk.TY7NQYTC.js → chunk.T6APUNAB.js} +21 -113
  25. package/cdn/chunks/{chunk.2YVHHVLG.js → chunk.UORXHDBJ.js} +3 -2
  26. package/cdn/chunks/{chunk.2FF44G4Y.js → chunk.WWI5IYQY.js} +3 -3
  27. package/cdn/chunks/{chunk.JVTWZUNG.js → chunk.XODAGFNB.js} +1 -1
  28. package/cdn/chunks/chunk.YGJ3KERC.js +290 -0
  29. package/cdn/chunks/{chunk.3KJHZGAI.js → chunk.ZHNP2Z3B.js} +1 -1
  30. package/cdn/components/checkbox/checkbox.js +3 -3
  31. package/cdn/components/checkbox-button/checkbox-button.js +2 -2
  32. package/cdn/components/checkbox-card/checkbox-card.js +2 -2
  33. package/cdn/components/checkbox-group/checkbox-group.js +1 -1
  34. package/cdn/components/filter-counter/filter-counter.js +11 -8
  35. package/cdn/components/filter-date/filter-date.js +1 -1
  36. package/cdn/components/filter-range/filter-range.js +11 -8
  37. package/cdn/components/filter-select/filter-select.js +12 -9
  38. package/cdn/components/input/input.d.ts +13 -77
  39. package/cdn/components/input/input.js +11 -8
  40. package/cdn/components/input-date/input-date.d.ts +4 -42
  41. package/cdn/components/input-date/input-date.js +5 -4
  42. package/cdn/components/input-date/input-date.styles.js +2 -2
  43. package/cdn/components/input-mask/input-mask.d.ts +3 -50
  44. package/cdn/components/input-mask/input-mask.js +2 -1
  45. package/cdn/components/input-native/input-native.d.ts +57 -0
  46. package/cdn/components/input-native/input-native.js +43 -0
  47. package/cdn/components/{input/input.styles.js → input-native/input-native.styles.js} +4 -3
  48. package/cdn/components/{input/input.utils.d.ts → input-native/input-native.utils.d.ts} +1 -1
  49. package/cdn/components/{input/input.utils.js → input-native/input-native.utils.js} +1 -1
  50. package/cdn/components/input-otp/input-otp.d.ts +6 -50
  51. package/cdn/components/input-otp/input-otp.js +2 -1
  52. package/cdn/components/input-phone/input-phone.d.ts +5 -36
  53. package/cdn/components/input-phone/input-phone.js +2 -1
  54. package/cdn/components/input-time/input-time.d.ts +5 -54
  55. package/cdn/components/input-time/input-time.js +4 -3
  56. package/cdn/components/input-time/input-time.styles.js +2 -2
  57. package/cdn/components/pagination/pagination.js +11 -8
  58. package/cdn/components/radio/radio.js +1 -1
  59. package/cdn/components/radio-card/radio-card.js +2 -2
  60. package/cdn/components/tab-group/tab-group.d.ts +2 -0
  61. package/cdn/components/tab-group/tab-group.js +1 -1
  62. package/cdn/components/table/table.js +2 -2
  63. package/cdn/components/table/table.styles.js +1 -1
  64. package/cdn/components/table-body/table-body.js +3 -3
  65. package/cdn/components/table-head/table-head.js +3 -3
  66. package/cdn/components/table-header-cell/table-header-cell.js +2 -2
  67. package/cdn/components/table-header-cell/table-header-cell.styles.js +1 -1
  68. package/cdn/components/table-header-row/table-header-row.js +5 -5
  69. package/cdn/components/table-row/table-row.js +3 -3
  70. package/cdn/components/tree/tree.js +5 -5
  71. package/cdn/components/tree-item/tree-item.js +3 -3
  72. package/cdn/custom-elements.json +750 -2288
  73. package/cdn/design-system.js +70 -67
  74. package/cdn/internal/components/checkbox-box/checkbox-box.styles.js +0 -6
  75. package/cdn/internal/components/date-field/date-field.d.ts +11 -0
  76. package/cdn/internal/components/date-field/date-field.js +23 -1
  77. package/cdn/internal/components/input-base/input-base.d.ts +118 -0
  78. package/cdn/internal/components/input-base/input-base.js +313 -0
  79. package/cdn/internal/components/input-base/input-base.styles.js +302 -0
  80. package/cdn/internal/components/input-base/input-base.utils.d.ts +1 -0
  81. package/cdn/internal/components/input-base/input-base.utils.js +1 -0
  82. package/cdn/internal/components/radio-icon/radio-icon.styles.js +0 -6
  83. package/cdn/vscode.html-custom-data.json +15 -320
  84. package/cdn/web-types.json +200 -1244
  85. package/dist/chunks/chunk.3CWUZQRT.js +325 -0
  86. package/dist/chunks/{chunk.OKUA77L4.js → chunk.4S7APMGY.js} +18 -12
  87. package/dist/chunks/{chunk.PWVYG6XN.js → chunk.4ZAABSYS.js} +0 -6
  88. package/dist/chunks/{chunk.IE7IGJZB.js → chunk.63BQQE4G.js} +23 -1
  89. package/dist/chunks/{chunk.OWV6XZFR.js → chunk.7QLR3F26.js} +1 -1
  90. package/dist/chunks/{chunk.XVFPRM26.js → chunk.AHHKOQL3.js} +1 -1
  91. package/dist/chunks/{chunk.P2LEUT2Q.js → chunk.BYB2ODNQ.js} +4 -121
  92. package/dist/chunks/{chunk.3ZF3W6DC.js → chunk.DHCXNXX3.js} +1 -1
  93. package/dist/chunks/chunk.DJNQIAYV.js +283 -0
  94. package/dist/chunks/{chunk.DRFXWCPL.js → chunk.DKIEKIV4.js} +3 -129
  95. package/dist/chunks/{chunk.OHDR6G6J.js → chunk.DMIXIORN.js} +3 -3
  96. package/dist/chunks/{chunk.IICLN6L3.js → chunk.DUPWIWDC.js} +15 -153
  97. package/dist/chunks/{chunk.Z2A5AEMU.js → chunk.DXRDCCL4.js} +1 -1
  98. package/dist/chunks/{chunk.54CFE45F.js → chunk.L2B7WMWE.js} +3 -3
  99. package/dist/chunks/{chunk.62WXVS5Q.js → chunk.NKOMMJMK.js} +6 -2
  100. package/dist/chunks/{chunk.7XUPS5FG.js → chunk.PHSUFADX.js} +1 -0
  101. package/dist/chunks/chunk.QFO2VDJ3.js +286 -0
  102. package/dist/chunks/{chunk.DFBKUH2U.js → chunk.RGHMS6RU.js} +1 -1
  103. package/dist/chunks/{chunk.ORLKMJIV.js → chunk.SFD6GJDA.js} +19 -10
  104. package/dist/chunks/{chunk.ZRW5L2NC.js → chunk.SGKW2DOH.js} +3 -2
  105. package/dist/chunks/{chunk.H7ZLX7SO.js → chunk.TODRUEYV.js} +3 -3
  106. package/dist/chunks/chunk.ULPMZDTP.js +13 -0
  107. package/dist/chunks/{chunk.2BZBH3CX.js → chunk.URDP5HQR.js} +0 -6
  108. package/dist/chunks/{chunk.EY2LRNGD.js → chunk.X6M22EYD.js} +21 -113
  109. package/dist/chunks/{chunk.OMUELARQ.js → chunk.Y4CDJYQO.js} +19 -111
  110. package/dist/chunks/{chunk.RS4S7SAD.js → chunk.Y6XPKQ25.js} +1 -1
  111. package/dist/chunks/{chunk.Y3I7GUNB.js → chunk.Z42XBNIN.js} +1 -1
  112. package/dist/chunks/{chunk.DISFQ7ZU.js → chunk.ZMMQOF24.js} +1 -1
  113. package/dist/components/checkbox/checkbox.js +3 -3
  114. package/dist/components/checkbox-button/checkbox-button.js +2 -2
  115. package/dist/components/checkbox-card/checkbox-card.js +2 -2
  116. package/dist/components/checkbox-group/checkbox-group.js +1 -1
  117. package/dist/components/filter-counter/filter-counter.js +11 -8
  118. package/dist/components/filter-date/filter-date.js +1 -1
  119. package/dist/components/filter-range/filter-range.js +11 -8
  120. package/dist/components/filter-select/filter-select.js +12 -9
  121. package/dist/components/input/input.d.ts +13 -77
  122. package/dist/components/input/input.js +11 -8
  123. package/dist/components/input-date/input-date.d.ts +4 -42
  124. package/dist/components/input-date/input-date.js +5 -4
  125. package/dist/components/input-date/input-date.styles.js +2 -2
  126. package/dist/components/input-mask/input-mask.d.ts +3 -50
  127. package/dist/components/input-mask/input-mask.js +2 -1
  128. package/dist/components/input-native/input-native.d.ts +57 -0
  129. package/dist/components/input-native/input-native.js +35 -0
  130. package/dist/components/input-native/input-native.styles.d.ts +2 -0
  131. package/dist/components/input-native/input-native.styles.js +10 -0
  132. package/dist/components/{input/input.utils.d.ts → input-native/input-native.utils.d.ts} +1 -1
  133. package/dist/components/{input/input.utils.js → input-native/input-native.utils.js} +1 -1
  134. package/dist/components/input-otp/input-otp.d.ts +6 -50
  135. package/dist/components/input-otp/input-otp.js +2 -1
  136. package/dist/components/input-phone/input-phone.d.ts +5 -36
  137. package/dist/components/input-phone/input-phone.js +2 -1
  138. package/dist/components/input-time/input-time.d.ts +5 -54
  139. package/dist/components/input-time/input-time.js +4 -3
  140. package/dist/components/input-time/input-time.styles.js +2 -2
  141. package/dist/components/pagination/pagination.js +11 -8
  142. package/dist/components/radio/radio.js +1 -1
  143. package/dist/components/radio-card/radio-card.js +2 -2
  144. package/dist/components/tab-group/tab-group.d.ts +2 -0
  145. package/dist/components/tab-group/tab-group.js +1 -1
  146. package/dist/components/table/table.js +2 -2
  147. package/dist/components/table/table.styles.js +1 -1
  148. package/dist/components/table-body/table-body.js +3 -3
  149. package/dist/components/table-head/table-head.js +3 -3
  150. package/dist/components/table-header-cell/table-header-cell.js +2 -2
  151. package/dist/components/table-header-cell/table-header-cell.styles.js +1 -1
  152. package/dist/components/table-header-row/table-header-row.js +5 -5
  153. package/dist/components/table-row/table-row.js +3 -3
  154. package/dist/components/tree/tree.js +5 -5
  155. package/dist/components/tree-item/tree-item.js +3 -3
  156. package/dist/custom-elements.json +750 -2288
  157. package/dist/design-system.js +70 -67
  158. package/dist/internal/components/checkbox-box/checkbox-box.styles.js +0 -6
  159. package/dist/internal/components/date-field/date-field.d.ts +11 -0
  160. package/dist/internal/components/date-field/date-field.js +23 -1
  161. package/dist/internal/components/input-base/input-base.d.ts +118 -0
  162. package/dist/internal/components/input-base/input-base.js +313 -0
  163. package/dist/internal/components/input-base/input-base.styles.d.ts +2 -0
  164. package/dist/internal/components/input-base/input-base.styles.js +302 -0
  165. package/dist/internal/components/input-base/input-base.utils.d.ts +1 -0
  166. package/dist/internal/components/input-base/input-base.utils.js +1 -0
  167. package/dist/internal/components/radio-icon/radio-icon.styles.js +0 -6
  168. package/dist/vscode.html-custom-data.json +15 -320
  169. package/dist/web-types.json +200 -1244
  170. package/package.json +17 -17
  171. package/cdn/chunks/chunk.5F7AUS4F.js +0 -703
  172. package/dist/chunks/chunk.JJT6FP7U.js +0 -690
  173. package/dist/components/input/input.styles.js +0 -9
  174. /package/cdn/components/{input/input.styles.d.ts → input-native/input-native.styles.d.ts} +0 -0
  175. /package/{dist/components/input/input.styles.d.ts → cdn/internal/components/input-base/input-base.styles.d.ts} +0 -0
@@ -1,703 +0,0 @@
1
- import {
2
- DSAInputTime
3
- } from "./chunk.HG4TPK7J.js";
4
- import {
5
- big_default,
6
- getOverridenIconDetails,
7
- isInvalidAmountKey,
8
- isPrefixIconOverriden,
9
- numberToFrAmount,
10
- parseFrAmount,
11
- roundToStep
12
- } from "./chunk.EF2VOGBL.js";
13
- import {
14
- DSAInputDate
15
- } from "./chunk.TY7NQYTC.js";
16
- import {
17
- input_styles_default
18
- } from "./chunk.L3ZYNSI3.js";
19
- import {
20
- FormControlLayout
21
- } from "./chunk.E73QKLNL.js";
22
- import {
23
- l
24
- } from "./chunk.7PPSHHT2.js";
25
- import {
26
- defaultValue
27
- } from "./chunk.YY5FKN3H.js";
28
- import {
29
- FormControlController
30
- } from "./chunk.3NWILHZZ.js";
31
- import {
32
- LocalizeController
33
- } from "./chunk.BMQ5WSY7.js";
34
- import {
35
- watch
36
- } from "./chunk.4FQJ3QJK.js";
37
- import {
38
- ifDefinedAndNotEmpty
39
- } from "./chunk.B6GVVW66.js";
40
- import {
41
- o
42
- } from "./chunk.YQLIIKLI.js";
43
- import {
44
- e as e2
45
- } from "./chunk.IKHG7XGO.js";
46
- import {
47
- e,
48
- n,
49
- r,
50
- t
51
- } from "./chunk.DZB6XUZ7.js";
52
- import {
53
- x
54
- } from "./chunk.7HUC6BF3.js";
55
- import {
56
- __decorateClass
57
- } from "./chunk.4ZGVANML.js";
58
-
59
- // src/components/input/input.ts
60
- var DSAInput = class extends FormControlLayout {
61
- constructor() {
62
- super(...arguments);
63
- this.formControlController = new FormControlController(this, {
64
- assumeInteractionOn: ["dsa-blur", "dsa-input"]
65
- });
66
- this.localize = new LocalizeController(this);
67
- this.hasFocus = false;
68
- this.type = "text";
69
- this.value = "";
70
- this.defaultValue = "";
71
- this.clearable = false;
72
- this.passwordVisible = false;
73
- this.counter = false;
74
- this.spellcheck = true;
75
- }
76
- /** Gets or sets the current value as a `Date` object. Returns `null` if the value can't be converted. */
77
- get valueAsDate() {
78
- var _a, _b;
79
- if (this.input instanceof DSAInputTime) {
80
- return null;
81
- }
82
- return (_b = (_a = this.input) == null ? void 0 : _a.valueAsDate) != null ? _b : null;
83
- }
84
- set valueAsDate(newValue) {
85
- const input = document.createElement("input");
86
- input.type = "date";
87
- input.valueAsDate = newValue;
88
- this.value = input.value;
89
- }
90
- /** Gets or sets the current value as a number. Returns `NaN` if the value can't be converted. */
91
- get valueAsNumber() {
92
- var _a, _b;
93
- if (this.type === "amount") {
94
- return parseFloat(this.value.replace(",", "."));
95
- } else {
96
- return (_b = (_a = this.standardInput) == null ? void 0 : _a.valueAsNumber) != null ? _b : parseFloat(this.value);
97
- }
98
- }
99
- set valueAsNumber(newValue) {
100
- const input = document.createElement("input");
101
- input.type = "number";
102
- input.valueAsNumber = newValue;
103
- this.value = input.value;
104
- }
105
- /** Gets the validity state object */
106
- get validity() {
107
- var _a, _b;
108
- return (_b = (_a = this.input) == null ? void 0 : _a.validity) != null ? _b : true;
109
- }
110
- /** Gets the validation message */
111
- get validationMessage() {
112
- return this.input.validationMessage;
113
- }
114
- async firstUpdated() {
115
- await this.updateComplete;
116
- if (this.type === "date") {
117
- this.input = this.dateInput;
118
- } else if (this.type === "time") {
119
- this.input = this.timeInput;
120
- } else {
121
- this.input = this.standardInput;
122
- }
123
- this.formControlController.updateValidity();
124
- }
125
- handleBlur(event) {
126
- if (["date", "time"].includes(this.type)) {
127
- event.stopPropagation();
128
- }
129
- this.hasFocus = false;
130
- this.emit("dsa-blur");
131
- }
132
- handleChange(event) {
133
- if (["date", "time"].includes(this.type)) {
134
- event.stopPropagation();
135
- }
136
- if (this.type === "amount") {
137
- this.handleAmountChange();
138
- this.value = this.input.value.replace(",", ".");
139
- } else {
140
- this.value = this.input.value;
141
- }
142
- this.emit("dsa-change");
143
- }
144
- handleAmountChange() {
145
- if (this.input.value === "" || this.input.value === "-") {
146
- this.input.value = "";
147
- return;
148
- }
149
- const parsedValue = parseFrAmount(this.input.value);
150
- const parsedMin = parseFloat(`${this.min}`);
151
- const parsedMax = parseFloat(`${this.max}`);
152
- this.input.value = numberToFrAmount(
153
- roundToStep(parsedValue, this.getSafeStep())
154
- );
155
- if (!isNaN(parsedMin) && parsedValue < parsedMin) {
156
- this.input.value = numberToFrAmount(this.min);
157
- }
158
- if (!isNaN(parsedMax) && parsedValue > parsedMax) {
159
- this.input.value = numberToFrAmount(this.max);
160
- }
161
- }
162
- handleClearClick(event) {
163
- this.value = "";
164
- this.emit("dsa-clear");
165
- this.emit("dsa-input");
166
- this.emit("dsa-change");
167
- this.input.focus();
168
- event.stopPropagation();
169
- }
170
- handleFocus(event) {
171
- if (["date", "time"].includes(this.type)) {
172
- event.stopPropagation();
173
- }
174
- this.hasFocus = true;
175
- this.emit("dsa-focus");
176
- }
177
- handleInput(event) {
178
- if (["date", "time"].includes(this.type)) {
179
- event.stopPropagation();
180
- }
181
- if (this.type === "amount") {
182
- this.value = this.input.value.replace(",", ".");
183
- } else {
184
- this.value = this.input.value;
185
- }
186
- this.formControlController.updateValidity();
187
- this.emit("dsa-input");
188
- }
189
- handleInvalid(event) {
190
- this.formControlController.setValidity(false);
191
- this.formControlController.emitInvalidEvent(event);
192
- }
193
- handleKeyDown(event) {
194
- const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
195
- if (this.type === "amount") {
196
- this.handleAmountKeydown(event);
197
- }
198
- if (event.key === "Enter" && !hasModifier) {
199
- setTimeout(() => {
200
- if (!event.defaultPrevented && !event.isComposing) {
201
- this.formControlController.submit();
202
- }
203
- });
204
- }
205
- }
206
- handleAmountKeydown(event) {
207
- if (event.key === "Dead") {
208
- this.input.blur();
209
- setTimeout(() => this.input.focus());
210
- }
211
- if (isInvalidAmountKey(event) || event.key === "-" && this.standardInput.selectionStart !== null && this.standardInput.selectionStart > 0 || event.key === "," && this.input.value.includes(",")) {
212
- event.preventDefault();
213
- return;
214
- }
215
- if (event.key === "ArrowDown") {
216
- this.stepDown();
217
- }
218
- if (event.key === "ArrowUp") {
219
- this.stepUp();
220
- }
221
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
222
- const inputEvent = new Event("input", { bubbles: true });
223
- const changeEvent = new Event("change", { bubbles: true });
224
- this.input.dispatchEvent(inputEvent);
225
- this.input.dispatchEvent(changeEvent);
226
- }
227
- }
228
- getSafeStep() {
229
- if (this.step === "any") {
230
- return this.step;
231
- }
232
- const parsedStep = parseFloat(`${this.step}`);
233
- if (isNaN(parsedStep) || parsedStep === 0) {
234
- return 1;
235
- } else {
236
- return parsedStep;
237
- }
238
- }
239
- handlePasswordToggle() {
240
- this.passwordVisible = !this.passwordVisible;
241
- }
242
- getDescriptionIds() {
243
- let ids = ["input__prefix", "input__suffix"];
244
- if (this.error) ids = [...ids, "error-text"];
245
- ids = [...ids, "help-text"];
246
- if (this.maxlength && this.counter) ids = [...ids, "counter"];
247
- ids = [...ids, "description"];
248
- return ids.join(" ");
249
- }
250
- handleDisabledChange() {
251
- this.formControlController.setValidity(this.disabled);
252
- }
253
- handleStepChange() {
254
- if (this.input instanceof DSAInputTime) {
255
- this.input.step = typeof this.step === "number" ? this.step : 60;
256
- } else this.standardInput.step = String(this.step);
257
- this.formControlController.updateValidity();
258
- }
259
- async handleValueChange() {
260
- await this.updateComplete;
261
- this.formControlController.updateValidity();
262
- }
263
- /** Sets focus on the input. */
264
- focus(options) {
265
- this.input.focus(options);
266
- }
267
- /** Removes focus from the input. */
268
- blur() {
269
- this.input.blur();
270
- }
271
- /** Selects all the text in the input. */
272
- select() {
273
- if (this.input instanceof HTMLInputElement) {
274
- this.input.select();
275
- }
276
- }
277
- /** Sets the start and end positions of the text selection (0-based). */
278
- setSelectionRange(selectionStart, selectionEnd, selectionDirection = "none") {
279
- if (this.input instanceof HTMLInputElement) {
280
- this.input.setSelectionRange(
281
- selectionStart,
282
- selectionEnd,
283
- selectionDirection
284
- );
285
- }
286
- }
287
- /** Replaces a range of text with a new string. */
288
- setRangeText(replacement, start, end, selectMode) {
289
- if (this.input instanceof HTMLInputElement) {
290
- this.input.setRangeText(replacement, start, end, selectMode);
291
- if (this.value !== this.input.value) {
292
- this.value = this.input.value;
293
- }
294
- }
295
- }
296
- async showTimePicker() {
297
- if (this.input instanceof DSAInputTime) {
298
- await this.input.showTimePicker();
299
- }
300
- }
301
- async hideTimePicker() {
302
- if (this.input instanceof DSAInputTime) {
303
- await this.input.hideTimePicker();
304
- }
305
- }
306
- async showDatepicker() {
307
- if (this.input instanceof DSAInputDate) {
308
- await this.input.showDatepicker();
309
- }
310
- }
311
- async hideDatepicker() {
312
- await this.dateInput.hideDatepicker();
313
- }
314
- adjustAmountValue(direction) {
315
- const safeStep = this.getSafeStep();
316
- const numberStep = new big_default(safeStep === "any" ? 1 : safeStep);
317
- const parsedValue = new big_default(parseFrAmount(this.input.value));
318
- const newValue = direction === "up" ? parsedValue.plus(numberStep).toNumber() : parsedValue.minus(numberStep).toNumber();
319
- this.input.value = numberToFrAmount(newValue);
320
- this.value = this.input.value.replace(",", ".");
321
- }
322
- /** Increments the value of a numeric or time input type by the value of the step attribute, multiplied by an optional number parameter. */
323
- stepUp(stepNumber) {
324
- switch (this.type) {
325
- case "date":
326
- return;
327
- case "time":
328
- if (!(this.input instanceof DSAInputTime)) return;
329
- this.input.stepUp(stepNumber);
330
- this.value = this.input.value;
331
- return;
332
- case "amount":
333
- this.adjustAmountValue("up");
334
- return;
335
- default:
336
- this.standardInput.stepUp(stepNumber);
337
- if (this.value !== this.standardInput.value) {
338
- this.value = this.standardInput.value;
339
- }
340
- }
341
- }
342
- /** Decrements the value of a numeric or time input type by the value of the step attribute, multiplied by an optional number parameter. */
343
- stepDown(stepNumber) {
344
- switch (this.type) {
345
- case "date":
346
- return;
347
- case "time":
348
- if (!(this.input instanceof DSAInputTime)) return;
349
- this.input.stepDown(stepNumber);
350
- this.value = this.input.value;
351
- return;
352
- case "amount":
353
- this.adjustAmountValue("down");
354
- return;
355
- default:
356
- this.standardInput.stepDown(stepNumber);
357
- if (this.value !== this.standardInput.value) {
358
- this.value = this.standardInput.value;
359
- }
360
- }
361
- }
362
- /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
363
- checkValidity() {
364
- if (this.type === "amount") {
365
- return this.input.checkValidity() && this.checkAmountValidity();
366
- }
367
- return this.input.checkValidity();
368
- }
369
- /** Gets the associated form, if one exists. */
370
- getForm() {
371
- return this.formControlController.getForm();
372
- }
373
- /** Checks for validity and shows the browser's validation message if the control is invalid. */
374
- reportValidity() {
375
- if (this.type === "amount") {
376
- return this.input.reportValidity() && this.checkAmountValidity();
377
- }
378
- return this.input.reportValidity();
379
- }
380
- checkAmountValidity() {
381
- if (this.value === "") {
382
- return true;
383
- }
384
- const parsedValue = parseFloat(this.value);
385
- const parsedMin = parseFloat(`${this.min}`);
386
- const parsedMax = parseFloat(`${this.max}`);
387
- const safeStep = this.getSafeStep();
388
- return !isNaN(parsedValue) && (isNaN(parsedMin) || parsedValue >= parsedMin) && (isNaN(parsedMax) || parsedValue <= parsedMax) && (safeStep === "any" || roundToStep(parsedValue, safeStep) === parsedValue);
389
- }
390
- /** Sets a custom validation message. Pass an empty string to restore validity. */
391
- setCustomValidity(message) {
392
- this.input.setCustomValidity(message);
393
- this.formControlController.updateValidity();
394
- }
395
- async getUpdateComplete() {
396
- let result;
397
- if (this.input instanceof DSAInputDate || this.input instanceof DSAInputTime) {
398
- result = await this.input.updateComplete;
399
- } else {
400
- result = await super.getUpdateComplete();
401
- }
402
- return result;
403
- }
404
- render() {
405
- if (this.type === "date") {
406
- return x`
407
- <dsa-input-date
408
- name=${o(this.name)}
409
- title=${o(this.title)}
410
- value=${this.value}
411
- .defaultValue=${o(this.defaultValue)}
412
- size=${o(this.size)}
413
- variant=${o(this.variant)}
414
- label=${o(this.label)}
415
- help-text=${o(this.helpText)}
416
- ?clearable=${this.clearable}
417
- ?disabled=${this.disabled}
418
- lang=${o(this.lang)}
419
- placeholder=${o(this.placeholder)}
420
- ?readonly=${this.readonly}
421
- ?error=${this.error}
422
- .errorMessage=${o(this.errorMessage)}
423
- form=${o(this.form)}
424
- ?required=${this.required}
425
- min=${o(this.min)}
426
- max=${o(this.max)}
427
- calendar-start-date=${o(this.calendarStartDate)}
428
- ?autofocus=${this.autofocus}
429
- enterkeyhint=${o(this.enterkeyhint)}
430
- @dsa-change=${this.handleChange}
431
- @dsa-input=${this.handleInput}
432
- @dsa-focus=${this.handleFocus}
433
- @dsa-blur=${this.handleBlur}
434
- description=${o(this.description)}
435
- >
436
- ${this.hasSlotController.test("label") ? x` <slot name="label" slot="label"></slot> ` : ""}
437
- ${this.hasSlotController.test("prefix") ? x` <slot name="prefix" slot="prefix"></slot> ` : ""}
438
- ${this.hasSlotController.test("help-text") ? x` <slot name="help-text" slot="help-text"></slot> ` : ""}
439
- ${this.hasSlotController.test("tooltip") ? x` <slot name="tooltip" slot="tooltip"></slot> ` : ""}
440
- </dsa-input-date>
441
- `;
442
- } else if (this.type === "time") {
443
- return x`
444
- <dsa-input-time
445
- name=${o(this.name)}
446
- title=${o(this.title)}
447
- value=${this.value}
448
- .defaultValue=${o(this.defaultValue)}
449
- size=${o(this.size)}
450
- variant=${o(this.variant)}
451
- label=${o(this.label)}
452
- help-text=${o(this.helpText)}
453
- ?clearable=${this.clearable}
454
- ?disabled=${this.disabled}
455
- ?readonly=${this.readonly}
456
- ?error=${this.error}
457
- .errorMessage=${o(this.errorMessage)}
458
- form=${o(this.form)}
459
- ?required=${this.required}
460
- min=${o(this.min)}
461
- max=${o(this.max)}
462
- step=${o(this.step)}
463
- ?autofocus=${this.autofocus}
464
- enterkeyhint=${o(this.enterkeyhint)}
465
- @dsa-change=${this.handleChange}
466
- @dsa-input=${this.handleInput}
467
- @dsa-focus=${this.handleFocus}
468
- @dsa-blur=${this.handleBlur}
469
- description=${o(this.description)}
470
- >
471
- ${this.hasSlotController.test("label") ? x` <slot name="label" slot="label"></slot> ` : ""}
472
- ${this.hasSlotController.test("prefix") ? x` <slot name="prefix" slot="prefix"></slot> ` : ""}
473
- ${this.hasSlotController.test("suffix") ? x` <slot name="suffix" slot="suffix"></slot> ` : ""}
474
- ${this.hasSlotController.test("help-text") ? x` <slot name="help-text" slot="help-text"></slot> ` : ""}
475
- ${this.hasSlotController.test("tooltip") ? x` <slot name="tooltip" slot="tooltip"></slot> ` : ""}
476
- </dsa-input-time>
477
- `;
478
- } else {
479
- return super.render();
480
- }
481
- }
482
- renderInput() {
483
- const hasLabelSlot = this.hasSlotController.test("label");
484
- const overridenPrefixIcon = isPrefixIconOverriden(this.type) ? getOverridenIconDetails(this.type) : void 0;
485
- const hasPrefixIcon = overridenPrefixIcon !== void 0 || this.hasSlotController.test("prefix");
486
- const hasSuffixIcon = this.hasSlotController.test("suffix");
487
- const hasLabel = this.label ? true : !!hasLabelSlot;
488
- const hasClearIcon = this.clearable && !this.disabled && !this.readonly && (typeof this.value === "number" || this.value.length > 0);
489
- const hasHideIcon = this.type === "password" && !this.disabled;
490
- let nativeType;
491
- if (this.type === "password" && this.passwordVisible || this.type === "amount") {
492
- nativeType = "text";
493
- } else {
494
- nativeType = this.type;
495
- }
496
- return x`
497
- <div
498
- part="base"
499
- class=${e2({
500
- input: true,
501
- // Sizes
502
- "input--small": this.size === "small",
503
- "input--medium": this.size === "medium",
504
- "input--large": this.size === "large",
505
- // States
506
- "input--error": this.error,
507
- "input--on-layer": this.variant === "layer",
508
- "input--on-base": this.variant === "base",
509
- "input--disabled": this.disabled,
510
- "input--readonly": this.readonly,
511
- "input--focused": this.hasFocus,
512
- "input--empty": !this.value,
513
- "form-control--has-prefix-icon": hasPrefixIcon
514
- })}
515
- >
516
- ${overridenPrefixIcon ? x`<dsa-icon
517
- name=${overridenPrefixIcon.iconName}
518
- class="input__prefix"
519
- library="system"
520
- ></dsa-icon>` : x` <slot
521
- name="prefix"
522
- part="prefix"
523
- id="input__prefix"
524
- class="input__prefix"
525
- ></slot>`}
526
-
527
- <input
528
- part="input"
529
- id="input"
530
- class="input__control"
531
- type=${nativeType}
532
- title=${ifDefinedAndNotEmpty(hasLabel ? void 0 : this.title)}
533
- name=${ifDefinedAndNotEmpty(this.name)}
534
- ?disabled=${this.disabled}
535
- ?readonly=${this.readonly}
536
- ?required=${this.required}
537
- placeholder=${o(this.placeholder)}
538
- minlength=${o(this.minlength)}
539
- maxlength=${o(this.maxlength)}
540
- min=${o(this.min)}
541
- max=${o(this.max)}
542
- step=${o(this.step)}
543
- .value=${l(
544
- this.type === "amount" ? numberToFrAmount(this.value) : this.value
545
- )}
546
- autocapitalize=${o(this.autocapitalize)}
547
- autocomplete=${o(this.autocomplete)}
548
- autocorrect=${o(this.autocorrect)}
549
- ?autofocus=${this.autofocus}
550
- spellcheck=${this.spellcheck}
551
- pattern=${o(this.pattern)}
552
- enterkeyhint=${o(this.enterkeyhint)}
553
- inputmode=${o(this.inputmode)}
554
- aria-label=${ifDefinedAndNotEmpty(hasLabel ? void 0 : this.title)}
555
- aria-describedby=${this.getDescriptionIds()}
556
- aria-invalid=${o(this.error ? "true" : void 0)}
557
- @change=${this.handleChange}
558
- @input=${this.handleInput}
559
- @invalid=${this.handleInvalid}
560
- @keydown=${this.handleKeyDown}
561
- @focus=${this.handleFocus}
562
- @blur=${this.handleBlur}
563
- />
564
-
565
- ${hasSuffixIcon ? x`<slot
566
- name="suffix"
567
- id="input__suffix"
568
- class="input__suffix"
569
- ></slot>` : ""}
570
- ${hasClearIcon ? x`
571
- <dsa-icon-button
572
- part="clear-button"
573
- class="input__action-button"
574
- name="clear"
575
- label=${this.localize.term("clearEntry")}
576
- @click=${this.handleClearClick}
577
- library="system"
578
- ></dsa-icon-button>
579
- ` : ""}
580
- ${hasHideIcon ? x`<dsa-icon-button
581
- part="password-toggle-button"
582
- class="input__action-button"
583
- label=${this.localize.term(
584
- this.passwordVisible ? "hidePassword" : "showPassword"
585
- )}
586
- name=${this.passwordVisible ? "visibility_off" : "visibility"}
587
- @click=${this.handlePasswordToggle}
588
- library="system"
589
- ></dsa-icon-button>` : ""}
590
- </div>
591
- `;
592
- }
593
- renderCounter() {
594
- const counterText = this.maxlength && this.counter ? `${this.value.length}/${this.maxlength}` : void 0;
595
- return counterText !== void 0 ? x`<span
596
- id="counter"
597
- class=${e2({
598
- "form-control__counter": true,
599
- "form-control__counter--animated": this.value.length === this.maxlength
600
- })}
601
- >${counterText}</span
602
- >` : x``;
603
- }
604
- };
605
- DSAInput.styles = input_styles_default;
606
- __decorateClass([
607
- e("input")
608
- ], DSAInput.prototype, "standardInput", 2);
609
- __decorateClass([
610
- e("dsa-input-date")
611
- ], DSAInput.prototype, "dateInput", 2);
612
- __decorateClass([
613
- e("dsa-input-time")
614
- ], DSAInput.prototype, "timeInput", 2);
615
- __decorateClass([
616
- r()
617
- ], DSAInput.prototype, "hasFocus", 2);
618
- __decorateClass([
619
- n({ reflect: true })
620
- ], DSAInput.prototype, "type", 2);
621
- __decorateClass([
622
- n()
623
- ], DSAInput.prototype, "value", 2);
624
- __decorateClass([
625
- defaultValue()
626
- ], DSAInput.prototype, "defaultValue", 2);
627
- __decorateClass([
628
- n({ type: Boolean })
629
- ], DSAInput.prototype, "clearable", 2);
630
- __decorateClass([
631
- n()
632
- ], DSAInput.prototype, "lang", 2);
633
- __decorateClass([
634
- n({ attribute: "password-visible", type: Boolean })
635
- ], DSAInput.prototype, "passwordVisible", 2);
636
- __decorateClass([
637
- n()
638
- ], DSAInput.prototype, "pattern", 2);
639
- __decorateClass([
640
- n({ type: Number })
641
- ], DSAInput.prototype, "minlength", 2);
642
- __decorateClass([
643
- n({ type: Number })
644
- ], DSAInput.prototype, "maxlength", 2);
645
- __decorateClass([
646
- n({ type: Boolean })
647
- ], DSAInput.prototype, "counter", 2);
648
- __decorateClass([
649
- n()
650
- ], DSAInput.prototype, "min", 2);
651
- __decorateClass([
652
- n()
653
- ], DSAInput.prototype, "max", 2);
654
- __decorateClass([
655
- n({ attribute: "calendar-start-date" })
656
- ], DSAInput.prototype, "calendarStartDate", 2);
657
- __decorateClass([
658
- n()
659
- ], DSAInput.prototype, "step", 2);
660
- __decorateClass([
661
- n()
662
- ], DSAInput.prototype, "autocapitalize", 2);
663
- __decorateClass([
664
- n()
665
- ], DSAInput.prototype, "autocorrect", 2);
666
- __decorateClass([
667
- n()
668
- ], DSAInput.prototype, "autocomplete", 2);
669
- __decorateClass([
670
- n({ type: Boolean })
671
- ], DSAInput.prototype, "autofocus", 2);
672
- __decorateClass([
673
- n()
674
- ], DSAInput.prototype, "enterkeyhint", 2);
675
- __decorateClass([
676
- n({
677
- type: Boolean,
678
- converter: {
679
- // Allow "true|false" attribute values but keep the property boolean
680
- fromAttribute: (value) => !value || value === "false" ? false : true,
681
- toAttribute: (value) => value ? "true" : "false"
682
- }
683
- })
684
- ], DSAInput.prototype, "spellcheck", 2);
685
- __decorateClass([
686
- n()
687
- ], DSAInput.prototype, "inputmode", 2);
688
- __decorateClass([
689
- watch("disabled", { waitUntilFirstUpdate: true })
690
- ], DSAInput.prototype, "handleDisabledChange", 1);
691
- __decorateClass([
692
- watch("step", { waitUntilFirstUpdate: true })
693
- ], DSAInput.prototype, "handleStepChange", 1);
694
- __decorateClass([
695
- watch("value", { waitUntilFirstUpdate: true })
696
- ], DSAInput.prototype, "handleValueChange", 1);
697
- DSAInput = __decorateClass([
698
- t("dsa-input")
699
- ], DSAInput);
700
-
701
- export {
702
- DSAInput
703
- };