@ui5/webcomponents 2.26.0 → 2.27.0-rc.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 (208) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/Avatar.d.ts +7 -0
  4. package/dist/Avatar.js +18 -5
  5. package/dist/Avatar.js.map +1 -1
  6. package/dist/ComboBoxItemGroup.d.ts +2 -0
  7. package/dist/ComboBoxItemGroup.js +2 -0
  8. package/dist/ComboBoxItemGroup.js.map +1 -1
  9. package/dist/DatePicker.d.ts +14 -0
  10. package/dist/DatePicker.js +14 -0
  11. package/dist/DatePicker.js.map +1 -1
  12. package/dist/DayPicker.d.ts +1 -0
  13. package/dist/DayPicker.js +4 -1
  14. package/dist/DayPicker.js.map +1 -1
  15. package/dist/DayPickerTemplate.js +1 -1
  16. package/dist/DayPickerTemplate.js.map +1 -1
  17. package/dist/Icon.js +3 -0
  18. package/dist/Icon.js.map +1 -1
  19. package/dist/List.js +1 -1
  20. package/dist/List.js.map +1 -1
  21. package/dist/ListBoxItemGroupTemplate.js +1 -1
  22. package/dist/ListBoxItemGroupTemplate.js.map +1 -1
  23. package/dist/ListItem.d.ts +4 -2
  24. package/dist/ListItem.js +5 -9
  25. package/dist/ListItem.js.map +1 -1
  26. package/dist/ListItemBaseTemplate.d.ts +2 -0
  27. package/dist/ListItemBaseTemplate.js +1 -1
  28. package/dist/ListItemBaseTemplate.js.map +1 -1
  29. package/dist/ListItemGroup.d.ts +7 -23
  30. package/dist/ListItemGroup.js +4 -21
  31. package/dist/ListItemGroup.js.map +1 -1
  32. package/dist/ListItemGroupBase.d.ts +41 -0
  33. package/dist/ListItemGroupBase.js +54 -0
  34. package/dist/ListItemGroupBase.js.map +1 -0
  35. package/dist/ListItemStandardTemplate.js +1 -1
  36. package/dist/ListItemStandardTemplate.js.map +1 -1
  37. package/dist/MultiComboBoxItemGroup.d.ts +2 -0
  38. package/dist/MultiComboBoxItemGroup.js +2 -0
  39. package/dist/MultiComboBoxItemGroup.js.map +1 -1
  40. package/dist/NumberInput.d.ts +271 -0
  41. package/dist/NumberInput.js +719 -0
  42. package/dist/NumberInput.js.map +1 -0
  43. package/dist/NumberInputTemplate.d.ts +2 -0
  44. package/dist/NumberInputTemplate.js +18 -0
  45. package/dist/NumberInputTemplate.js.map +1 -0
  46. package/dist/Option.d.ts +10 -0
  47. package/dist/Option.js +6 -0
  48. package/dist/Option.js.map +1 -1
  49. package/dist/OptionGroup.d.ts +34 -0
  50. package/dist/OptionGroup.js +61 -0
  51. package/dist/OptionGroup.js.map +1 -0
  52. package/dist/OptionGroupTemplate.d.ts +2 -0
  53. package/dist/OptionGroupTemplate.js +6 -0
  54. package/dist/OptionGroupTemplate.js.map +1 -0
  55. package/dist/OptionTemplate.js +6 -1
  56. package/dist/OptionTemplate.js.map +1 -1
  57. package/dist/Popover.js +5 -3
  58. package/dist/Popover.js.map +1 -1
  59. package/dist/Select.d.ts +19 -2
  60. package/dist/Select.js +79 -28
  61. package/dist/Select.js.map +1 -1
  62. package/dist/SelectPopoverTemplate.js +1 -1
  63. package/dist/SelectPopoverTemplate.js.map +1 -1
  64. package/dist/SelectTemplate.js +2 -1
  65. package/dist/SelectTemplate.js.map +1 -1
  66. package/dist/SplitButton.d.ts +7 -3
  67. package/dist/SplitButton.js +4 -4
  68. package/dist/SplitButton.js.map +1 -1
  69. package/dist/SplitButtonTemplate.js +1 -1
  70. package/dist/SplitButtonTemplate.js.map +1 -1
  71. package/dist/StepInput.d.ts +14 -127
  72. package/dist/StepInput.js +40 -472
  73. package/dist/StepInput.js.map +1 -1
  74. package/dist/StepInputTemplate.js +4 -15
  75. package/dist/StepInputTemplate.js.map +1 -1
  76. package/dist/SuggestionItemGroup.d.ts +2 -0
  77. package/dist/SuggestionItemGroup.js +2 -0
  78. package/dist/SuggestionItemGroup.js.map +1 -1
  79. package/dist/ToolbarButton.d.ts +18 -0
  80. package/dist/ToolbarButton.js +16 -0
  81. package/dist/ToolbarButton.js.map +1 -1
  82. package/dist/ToolbarButtonTemplate.js +1 -1
  83. package/dist/ToolbarButtonTemplate.js.map +1 -1
  84. package/dist/bundle.esm.js +2 -0
  85. package/dist/bundle.esm.js.map +1 -1
  86. package/dist/css/themes/NumberInput.css +1 -0
  87. package/dist/css/themes/OptionGroup.css +1 -0
  88. package/dist/css/themes/StepInput.css +1 -1
  89. package/dist/css/themes/TimePickerClock.css +1 -1
  90. package/dist/css/themes/TimeSelectionClocks.css +1 -1
  91. package/dist/css/themes/sap_fiori_3/parameters-bundle.css +1 -1
  92. package/dist/css/themes/sap_fiori_3_dark/parameters-bundle.css +1 -1
  93. package/dist/css/themes/sap_fiori_3_hcb/parameters-bundle.css +1 -1
  94. package/dist/css/themes/sap_fiori_3_hcw/parameters-bundle.css +1 -1
  95. package/dist/css/themes/sap_horizon/parameters-bundle.css +1 -1
  96. package/dist/css/themes/sap_horizon_auto/parameters-bundle.css +30 -22
  97. package/dist/css/themes/sap_horizon_dark/parameters-bundle.css +1 -1
  98. package/dist/css/themes/sap_horizon_hc_auto/parameters-bundle.css +31 -24
  99. package/dist/css/themes/sap_horizon_hcb/parameters-bundle.css +1 -1
  100. package/dist/css/themes/sap_horizon_hcw/parameters-bundle.css +1 -1
  101. package/dist/custom-elements-internal.json +719 -156
  102. package/dist/custom-elements.json +658 -162
  103. package/dist/generated/assets/i18n/messagebundle_de.json +1 -1
  104. package/dist/generated/assets/i18n/messagebundle_en.json +1 -1
  105. package/dist/generated/assets/i18n/messagebundle_en_US_saprigi.json +1 -1
  106. package/dist/generated/assets/i18n/messagebundle_pl.json +1 -1
  107. package/dist/generated/assets/i18n/messagebundle_ru.json +1 -1
  108. package/dist/generated/assets/themes/sap_fiori_3/parameters-bundle.css.json +1 -1
  109. package/dist/generated/assets/themes/sap_fiori_3_dark/parameters-bundle.css.json +1 -1
  110. package/dist/generated/assets/themes/sap_fiori_3_hcb/parameters-bundle.css.json +1 -1
  111. package/dist/generated/assets/themes/sap_fiori_3_hcw/parameters-bundle.css.json +1 -1
  112. package/dist/generated/assets/themes/sap_horizon/parameters-bundle.css.json +1 -1
  113. package/dist/generated/assets/themes/sap_horizon_auto/parameters-bundle.css.json +1 -1
  114. package/dist/generated/assets/themes/sap_horizon_dark/parameters-bundle.css.json +1 -1
  115. package/dist/generated/assets/themes/sap_horizon_hc_auto/parameters-bundle.css.json +1 -1
  116. package/dist/generated/assets/themes/sap_horizon_hcb/parameters-bundle.css.json +1 -1
  117. package/dist/generated/assets/themes/sap_horizon_hcw/parameters-bundle.css.json +1 -1
  118. package/dist/generated/i18n/i18n-defaults.d.ts +8 -6
  119. package/dist/generated/i18n/i18n-defaults.js +8 -6
  120. package/dist/generated/i18n/i18n-defaults.js.map +1 -1
  121. package/dist/generated/themes/NumberInput.css.d.ts +2 -0
  122. package/dist/generated/themes/NumberInput.css.js +8 -0
  123. package/dist/generated/themes/NumberInput.css.js.map +1 -0
  124. package/dist/generated/themes/OptionGroup.css.d.ts +2 -0
  125. package/dist/generated/themes/OptionGroup.css.js +8 -0
  126. package/dist/generated/themes/OptionGroup.css.js.map +1 -0
  127. package/dist/generated/themes/StepInput.css.d.ts +1 -1
  128. package/dist/generated/themes/StepInput.css.js +1 -1
  129. package/dist/generated/themes/StepInput.css.js.map +1 -1
  130. package/dist/generated/themes/TimePickerClock.css.d.ts +1 -1
  131. package/dist/generated/themes/TimePickerClock.css.js +1 -1
  132. package/dist/generated/themes/TimePickerClock.css.js.map +1 -1
  133. package/dist/generated/themes/TimeSelectionClocks.css.d.ts +1 -1
  134. package/dist/generated/themes/TimeSelectionClocks.css.js +1 -1
  135. package/dist/generated/themes/TimeSelectionClocks.css.js.map +1 -1
  136. package/dist/generated/themes/sap_fiori_3/parameters-bundle.css.d.ts +1 -1
  137. package/dist/generated/themes/sap_fiori_3/parameters-bundle.css.js +1 -1
  138. package/dist/generated/themes/sap_fiori_3/parameters-bundle.css.js.map +1 -1
  139. package/dist/generated/themes/sap_fiori_3_dark/parameters-bundle.css.d.ts +1 -1
  140. package/dist/generated/themes/sap_fiori_3_dark/parameters-bundle.css.js +1 -1
  141. package/dist/generated/themes/sap_fiori_3_dark/parameters-bundle.css.js.map +1 -1
  142. package/dist/generated/themes/sap_fiori_3_hcb/parameters-bundle.css.d.ts +1 -1
  143. package/dist/generated/themes/sap_fiori_3_hcb/parameters-bundle.css.js +1 -1
  144. package/dist/generated/themes/sap_fiori_3_hcb/parameters-bundle.css.js.map +1 -1
  145. package/dist/generated/themes/sap_fiori_3_hcw/parameters-bundle.css.d.ts +1 -1
  146. package/dist/generated/themes/sap_fiori_3_hcw/parameters-bundle.css.js +1 -1
  147. package/dist/generated/themes/sap_fiori_3_hcw/parameters-bundle.css.js.map +1 -1
  148. package/dist/generated/themes/sap_horizon/parameters-bundle.css.d.ts +1 -1
  149. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js +1 -1
  150. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js.map +1 -1
  151. package/dist/generated/themes/sap_horizon_auto/parameters-bundle.css.d.ts +1 -1
  152. package/dist/generated/themes/sap_horizon_auto/parameters-bundle.css.js +30 -22
  153. package/dist/generated/themes/sap_horizon_auto/parameters-bundle.css.js.map +1 -1
  154. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.d.ts +1 -1
  155. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js +1 -1
  156. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js.map +1 -1
  157. package/dist/generated/themes/sap_horizon_hc_auto/parameters-bundle.css.d.ts +1 -1
  158. package/dist/generated/themes/sap_horizon_hc_auto/parameters-bundle.css.js +31 -24
  159. package/dist/generated/themes/sap_horizon_hc_auto/parameters-bundle.css.js.map +1 -1
  160. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.d.ts +1 -1
  161. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js +1 -1
  162. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js.map +1 -1
  163. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.d.ts +1 -1
  164. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js +1 -1
  165. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js.map +1 -1
  166. package/dist/vscode.html-custom-data.json +117 -17
  167. package/dist/web-types.json +266 -34
  168. package/package.json +9 -9
  169. package/src/DayPickerTemplate.tsx +1 -1
  170. package/src/ListBoxItemGroupTemplate.tsx +1 -1
  171. package/src/ListItemBaseTemplate.tsx +4 -0
  172. package/src/ListItemStandardTemplate.tsx +1 -1
  173. package/src/NumberInputTemplate.tsx +95 -0
  174. package/src/OptionGroupTemplate.tsx +20 -0
  175. package/src/OptionTemplate.tsx +6 -1
  176. package/src/SelectPopoverTemplate.tsx +1 -1
  177. package/src/SelectTemplate.tsx +6 -0
  178. package/src/SplitButtonTemplate.tsx +1 -2
  179. package/src/StepInputTemplate.tsx +23 -86
  180. package/src/ToolbarButtonTemplate.tsx +2 -0
  181. package/src/i18n/messagebundle.properties +13 -8
  182. package/src/i18n/messagebundle_de.properties +2 -2
  183. package/src/i18n/messagebundle_en.properties +2 -0
  184. package/src/i18n/messagebundle_en_US_saprigi.properties +7 -6
  185. package/src/i18n/messagebundle_pl.properties +1 -1
  186. package/src/i18n/messagebundle_ru.properties +1 -1
  187. package/src/themes/NumberInput.css +321 -0
  188. package/src/themes/OptionGroup.css +28 -0
  189. package/src/themes/StepInput.css +0 -276
  190. package/src/themes/TimePickerClock.css +1 -1
  191. package/src/themes/TimeSelectionClocks.css +1 -1
  192. package/src/themes/base/NumberInput-parameters.css +31 -0
  193. package/src/themes/base/sizes-parameters.css +3 -3
  194. package/src/themes/sap_fiori_3/parameters-bundle.css +1 -1
  195. package/src/themes/sap_fiori_3_dark/parameters-bundle.css +1 -1
  196. package/src/themes/sap_fiori_3_hcb/parameters-bundle.css +1 -1
  197. package/src/themes/sap_fiori_3_hcw/parameters-bundle.css +1 -1
  198. package/src/themes/sap_horizon/NumberInput-parameters.css +26 -0
  199. package/src/themes/sap_horizon/parameters-bundle.css +1 -1
  200. package/src/themes/sap_horizon_dark/NumberInput-parameters.css +26 -0
  201. package/src/themes/sap_horizon_dark/parameters-bundle.css +1 -1
  202. package/src/themes/sap_horizon_hcb/NumberInput-parameters.css +14 -0
  203. package/src/themes/sap_horizon_hcb/parameters-bundle.css +2 -1
  204. package/src/themes/sap_horizon_hcw/NumberInput-parameters.css +14 -0
  205. package/src/themes/sap_horizon_hcw/parameters-bundle.css +2 -1
  206. package/src/themes/base/StepInput-parameters.css +0 -25
  207. package/src/themes/sap_horizon/StepInput-parameters.css +0 -25
  208. package/src/themes/sap_horizon_dark/StepInput-parameters.css +0 -25
package/dist/StepInput.js CHANGED
@@ -11,27 +11,13 @@ import property from "@ui5/webcomponents-base/dist/decorators/property.js";
11
11
  import slot from "@ui5/webcomponents-base/dist/decorators/slot-strict.js";
12
12
  import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
13
13
  import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
14
- import { isUp, isDown, isUpCtrl, isDownCtrl, isUpShift, isDownShift, isUpShiftCtrl, isDownShiftCtrl, isPageUpShift, isPageDownShift, isEscape, isEnter, isMinus, } from "@ui5/webcomponents-base/dist/Keys.js";
15
- import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js";
16
- import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
17
- import { getEffectiveAriaLabelText, getAssociatedLabelForTexts } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js";
18
14
  import { submitForm } from "@ui5/webcomponents-base/dist/features/InputElementsFormSupport.js";
15
+ import { getAssociatedLabelForTexts } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js";
16
+ import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js";
17
+ import { NUMBERINPUT_PATTERN_MISSMATCH, NUMBERINPUT_RANGEOVERFLOW, NUMBERINPUT_RANGEUNDERFLOW, } from "./generated/i18n/i18n-defaults.js";
19
18
  import StepInputTemplate from "./StepInputTemplate.js";
20
- import { STEPINPUT_DEC_ICON_TITLE, STEPINPUT_INC_ICON_TITLE, STEPINPUT_PATTER_MISSMATCH, STEPINPUT_RANGEOVERFLOW, STEPINPUT_RANGEUNDERFLOW, } from "./generated/i18n/i18n-defaults.js";
21
- import "@ui5/webcomponents-icons/dist/less.js";
22
- import "@ui5/webcomponents-icons/dist/add.js";
23
- import InputType from "./types/InputType.js";
24
- import NumberFormat from "@ui5/webcomponents-localization/dist/NumberFormat.js";
25
19
  // Styles
26
20
  import StepInputCss from "./generated/themes/StepInput.css.js";
27
- import getCachedLocaleDataInstance from "@ui5/webcomponents-localization/dist/getCachedLocaleDataInstance.js";
28
- import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
29
- import { attachLanguageChange, detachLanguageChange } from "@ui5/webcomponents-base/dist/locale/languageChange.js";
30
- // Spin variables
31
- const INITIAL_WAIT_TIMEOUT = 500; // milliseconds
32
- const ACCELERATION = 0.8;
33
- const MIN_WAIT_TIMEOUT = 50; // milliseconds
34
- const INITIAL_SPEED = 120; // milliseconds
35
21
  /**
36
22
  * @class
37
23
  *
@@ -118,14 +104,9 @@ let StepInput = StepInput_1 = class StepInput extends UI5Element {
118
104
  * @public
119
105
  */
120
106
  this.valuePrecision = 0;
121
- this._decIconDisabled = false;
122
- this._incIconDisabled = false;
123
- this.focused = false;
124
- this._inputFocused = false;
125
- this._waitTimeout = INITIAL_WAIT_TIMEOUT;
126
- this._speed = INITIAL_SPEED;
127
- this._spinStarted = false;
128
- this._languageChanged = false;
107
+ }
108
+ get _innerNumberInput() {
109
+ return this.shadowRoot.querySelector("[ui5-number-input]");
129
110
  }
130
111
  async formElementAnchor() {
131
112
  return (await this.getFocusDomRefAsync())?.getFocusDomRefAsync();
@@ -133,454 +114,71 @@ let StepInput = StepInput_1 = class StepInput extends UI5Element {
133
114
  get formValidityMessage() {
134
115
  const validity = this.formValidity;
135
116
  if (validity.patternMismatch) {
136
- return StepInput_1.i18nBundle.getText(STEPINPUT_PATTER_MISSMATCH, this.valuePrecision);
117
+ return StepInput_1.i18nBundle.getText(NUMBERINPUT_PATTERN_MISSMATCH, this.valuePrecision);
137
118
  }
138
119
  if (validity.rangeUnderflow) {
139
- return StepInput_1.i18nBundle.getText(STEPINPUT_RANGEUNDERFLOW, this.min);
120
+ return StepInput_1.i18nBundle.getText(NUMBERINPUT_RANGEUNDERFLOW, this.min);
140
121
  }
141
122
  if (validity.rangeOverflow) {
142
- return StepInput_1.i18nBundle.getText(STEPINPUT_RANGEOVERFLOW, this.max);
123
+ return StepInput_1.i18nBundle.getText(NUMBERINPUT_RANGEOVERFLOW, this.max);
143
124
  }
144
- return ""; // No error
125
+ return "";
145
126
  }
146
127
  get formValidity() {
147
128
  return {
148
- patternMismatch: this.value !== 0 && !this._isValueWithCorrectPrecision,
149
- rangeOverflow: this.max !== undefined && this.value >= this.max,
150
- rangeUnderflow: this.min !== undefined && this.value <= this.min,
129
+ patternMismatch: this.value !== 0 && (this._innerNumberInput?.formValidity.patternMismatch ?? false),
130
+ rangeOverflow: this.max !== undefined && this.value > this.max,
131
+ rangeUnderflow: this.min !== undefined && this.value < this.min,
151
132
  };
152
133
  }
153
134
  get formFormattedValue() {
154
135
  return this.value.toString();
155
136
  }
156
- get type() {
157
- return InputType.Text;
158
- }
159
- // icons-related
160
- get decIconTitle() {
161
- return StepInput_1.i18nBundle.getText(STEPINPUT_DEC_ICON_TITLE);
162
- }
163
- get incIconTitle() {
164
- return StepInput_1.i18nBundle.getText(STEPINPUT_INC_ICON_TITLE);
165
- }
166
- get _decIconClickable() {
167
- return !this._decIconDisabled && !this.readonly && !this.disabled;
168
- }
169
- get _incIconClickable() {
170
- return !this._incIconDisabled && !this.readonly && !this.disabled;
171
- }
172
- get _isFocused() {
173
- return this.focused;
174
- }
175
- get _displayValue() {
176
- if (this._languageChanged) {
177
- this._languageChanged = false;
178
- this.valueState = ValueState.None; // to reset the value state visual
179
- return this._formatNumber(this.value);
180
- }
181
- // For the cases when there is set value precision but the input value is not with correct precision we don't need to format it
182
- const value = this.input?.value && !this._isValueWithCorrectPrecision ? this.input.value : this._formatNumber(this.value);
183
- if ((this.value === 0) || (Number.isInteger(this.value))) {
184
- return value;
185
- }
186
- if (this.input && this.value === this._parseNumber(this.input.value)) { // For the cases where the number is fractional and is ending with 0s.
187
- return this.input.value;
188
- }
189
- return value;
190
- }
191
- get accInfo() {
192
- return {
193
- "ariaRequired": this.required,
194
- "ariaLabel": getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this),
195
- };
196
- }
197
- get inputAttributes() {
198
- return {
199
- min: this.min === undefined ? undefined : this.min,
200
- max: this.max === undefined ? undefined : this.max,
201
- step: this.step,
202
- };
203
- }
204
- onBeforeRendering() {
205
- this._setButtonState();
206
- }
207
- onEnterDOM() {
208
- this._setupLanguageChangeHandler();
209
- }
210
- onExitDOM() {
211
- this._cleanupLanguageChangeHandler();
212
- }
213
- _setupLanguageChangeHandler() {
214
- if (this._languageChangeHandler) {
215
- return;
216
- }
217
- this._languageChangeHandler = () => {
218
- this._formatter = undefined;
219
- this._languageChanged = true;
220
- this._delimiter = undefined;
221
- this._groupSeparator = undefined;
222
- return Promise.resolve();
223
- };
224
- attachLanguageChange(this._languageChangeHandler);
225
- }
226
- _cleanupLanguageChangeHandler() {
227
- if (this._languageChangeHandler) {
228
- detachLanguageChange(this._languageChangeHandler);
229
- this._languageChangeHandler = undefined;
230
- }
231
- }
232
- get formatter() {
233
- if (!this._formatter) {
234
- this._formatter = NumberFormat.getFloatInstance({
235
- decimals: this.valuePrecision,
236
- });
237
- }
238
- return this._formatter;
239
- }
240
- get delimiter() {
241
- if (!this._delimiter) {
242
- const localeData = getCachedLocaleDataInstance(getLocale());
243
- this._delimiter = localeData.getNumberSymbol("decimal") || ".";
244
- }
245
- return this._delimiter;
137
+ getFocusDomRef() {
138
+ return this._innerNumberInput?.getFocusDomRef();
246
139
  }
247
- get groupSeparator() {
248
- if (!this._groupSeparator) {
249
- const localeData = getCachedLocaleDataInstance(getLocale());
250
- this._groupSeparator = localeData.getNumberSymbol("group") || ",";
251
- }
252
- return this._groupSeparator;
140
+ get _associatedLabelText() {
141
+ return getAssociatedLabelForTexts(this) || undefined;
253
142
  }
254
- get input() {
255
- return this.shadowRoot.querySelector("[ui5-input]");
143
+ _onNumberInputChange(e) {
144
+ e.stopPropagation();
145
+ this._syncFromInner();
146
+ this.fireDecoratorEvent("change");
256
147
  }
257
- get innerInput() {
258
- return this.input.shadowRoot.querySelector("input");
259
- }
260
- get inputOuter() {
261
- return this.shadowRoot.querySelector(".ui5-step-input-input");
262
- }
263
- _onButtonFocusOut() {
264
- setTimeout(() => {
265
- if (!this._inputFocused && !this.shadowRoot.activeElement) {
266
- this.inputOuter.removeAttribute("focused");
267
- }
268
- }, 0);
269
- }
270
- _onInput(e) {
148
+ _onNumberInputInput(e) {
149
+ e.stopPropagation();
271
150
  const prevented = !this.fireDecoratorEvent("input", { inputType: e.detail.inputType });
272
151
  if (prevented) {
273
152
  e.preventDefault();
274
153
  }
275
154
  }
276
- _onInputFocusIn() {
277
- this._inputFocused = true;
278
- }
279
- _onInputFocusOut() {
280
- this._inputFocused = false;
281
- this._onInputChange();
282
- }
283
- _onMouseWheel(e) {
284
- if (this.disabled || this.readonly || !this._isFocused) {
285
- return;
286
- }
287
- e.preventDefault();
288
- const isScrollUp = e.deltaY < 0;
289
- const modifier = isScrollUp ? this.step : -this.step;
290
- this._modifyValue(modifier, true);
291
- }
292
- _setButtonState() {
293
- this._decIconDisabled = this.min !== undefined && this.value <= this.min;
294
- this._incIconDisabled = this.max !== undefined && this.value >= this.max;
295
- }
296
- _validate() {
297
- if (this._initialValueState === undefined) {
298
- this._initialValueState = this.valueState;
299
- }
300
- this._updateValueState();
301
- }
302
- _updateValueState() {
303
- const isWithinRange = (this.min === undefined || this._parseNumber(this.input.value) >= this.min)
304
- && (this.max === undefined || this._parseNumber(this.input.value) <= this.max);
305
- const isValueWithCorrectPrecision = this._isValueWithCorrectPrecision;
306
- const previousValueState = this.valueState;
307
- const isValid = isWithinRange && isValueWithCorrectPrecision;
308
- this.valueState = isValid ? ValueState.None : ValueState.Negative;
309
- const eventPrevented = !this.fireDecoratorEvent("value-state-change", {
310
- valueState: this.valueState,
311
- valid: isValid,
155
+ _onNumberInputValueStateChange(e) {
156
+ e.stopPropagation();
157
+ const prevented = !this.fireDecoratorEvent("value-state-change", {
158
+ valueState: e.detail.valueState,
159
+ valid: e.detail.valid,
312
160
  });
313
- if (eventPrevented) {
314
- this.valueState = previousValueState;
315
- }
316
- }
317
- _preciseValue(value) {
318
- const pow = 10 ** this.valuePrecision;
319
- return Math.round(value * pow) / pow;
320
- }
321
- _fireChangeEvent() {
322
- if (this._previousValue !== this.value) {
323
- this._previousValue = this.value;
324
- this.fireDecoratorEvent("change");
325
- }
326
- }
327
- /**
328
- * Value modifier - modifies the value of the component, validates the new value and enables/disables increment and
329
- * decrement buttons according to the value and min/max values (if set). Fires `change` event when requested
330
- * @private
331
- * @param modifier modifies the value of the component with the given modifier (positive or negative)
332
- * @param fireChangeEvent if `true`, fires `change` event when the value is changed
333
- */
334
- _modifyValue(modifier, fireChangeEvent = false) {
335
- let value;
336
- value = this.value + modifier;
337
- if (this.min !== undefined && value < this.min) {
338
- value = this.min;
339
- }
340
- if (this.max !== undefined && value > this.max) {
341
- value = this.max;
342
- }
343
- value = this._preciseValue(value);
344
- if (value !== this.value) {
345
- this.value = value;
346
- this.input.value = this._formatNumber(value);
347
- this._validate();
348
- this._setButtonState();
349
- this.focused = true;
350
- this.inputOuter.setAttribute("focused", "");
351
- if (fireChangeEvent) {
352
- this._fireChangeEvent();
353
- }
354
- else {
355
- this.input.focus();
356
- }
357
- }
358
- }
359
- /**
360
- * Formats a number with thousands separator based on current locale
361
- * @private
362
- */
363
- _formatNumber(value) {
364
- return this.formatter.format(value);
365
- }
366
- /**
367
- * Parses formatted number string back to numeric value
368
- * @private
369
- */
370
- _parseNumber(formattedValue) {
371
- return this.formatter.parse(formattedValue);
372
- }
373
- _incValue() {
374
- if (this._incIconClickable && !this.disabled && !this.readonly) {
375
- this._modifyValue(this.step, true);
376
- this._previousValue = this.value;
377
- }
378
- }
379
- _decValue() {
380
- if (this._decIconClickable && !this.disabled && !this.readonly) {
381
- this._modifyValue(-this.step, true);
382
- this._previousValue = this.value;
383
- }
384
- }
385
- get _isValueWithCorrectPrecision() {
386
- const delimiter = this.delimiter;
387
- // check if the value will be displayed with correct precision
388
- // _displayValue has special formatting logic
389
- if (this.valuePrecision === 0 && !this.input?.value.includes(delimiter) && ((this.value === 0) || (Number.isInteger(this.value)))) {
390
- // integers and zero will be formatted with toFixed, so thex y're always valid
391
- return true;
161
+ if (prevented) {
162
+ // Inner already applied the new valueState revert it back to the outer's current value
163
+ this._innerNumberInput.valueState = this.valueState;
392
164
  }
393
- const numberParts = this.input?.value?.split(delimiter);
394
- const decimalPartLength = numberParts?.length > 1 ? numberParts[1].length : 0;
395
- return decimalPartLength === this.valuePrecision;
396
- }
397
- _onInputChange() {
398
- this._setDefaultInputValueIfNeeded();
399
- const updatedValue = this._removeGroupSeparators(this.input.value);
400
- const inputValue = this._parseNumber(updatedValue);
401
- if (this._isValueChanged(inputValue)) {
402
- this._updateValueAndValidate(Number.isNaN(inputValue) ? this.min || 0 : inputValue);
403
- this.innerInput.value = this.input.value;
165
+ else {
166
+ this.valueState = e.detail.valueState;
404
167
  }
405
168
  }
406
- _setDefaultInputValueIfNeeded() {
407
- if (this.input.value === "") {
408
- const defaultValue = this._formatNumber(this.min || 0);
409
- this.input.value = defaultValue;
410
- this.innerInput.value = defaultValue; // we need to update inner input value as well, to avoid empty input scenario
169
+ _syncFromInner() {
170
+ const ni = this._innerNumberInput;
171
+ if (!ni) {
172
+ return;
411
173
  }
174
+ this.value = ni.value;
175
+ this.valueState = ni.valueState;
412
176
  }
413
- _isValueChanged(inputValue) {
414
- const isValueWithCorrectPrecision = this._isValueWithCorrectPrecision;
415
- // Treat values as distinct when modified to match a specific precision (e.g., from 3.4000 to 3.40),
416
- // even if JavaScript sees them as equal, to correctly update valueState based on expected valuePrecision.
417
- const isPrecisionCorrectButValueStateError = isValueWithCorrectPrecision && this.valueState === ValueState.Negative;
418
- return this.value !== this._previousValue
419
- || this.value !== inputValue
420
- || inputValue === 0
421
- || !isValueWithCorrectPrecision
422
- || isPrecisionCorrectButValueStateError
423
- || Number.isNaN(inputValue);
424
- }
425
- _updateValueAndValidate(inputValue) {
426
- this.value = inputValue;
427
- this._validate();
428
- this._setButtonState();
429
- this._fireChangeEvent();
430
- }
431
- _onfocusin() {
432
- this.focused = true;
433
- this._previousValue = this.value;
434
- }
435
- _onfocusout() {
436
- this.focused = false;
437
- this._previousValue = undefined;
438
- }
439
- _onInputRequestSubmit() {
177
+ _onRequestSubmit() {
440
178
  if (this._internals.form) {
441
179
  submitForm(this);
442
180
  }
443
181
  }
444
- _onkeydown(e) {
445
- let preventDefault = true;
446
- if (this.disabled || this.readonly) {
447
- return;
448
- }
449
- if (isEnter(e)) {
450
- this._onInputChange();
451
- return;
452
- }
453
- if (isUp(e)) {
454
- // step up
455
- this._modifyValue(this.step);
456
- }
457
- else if (isDown(e)) {
458
- // step down
459
- this._modifyValue(-this.step);
460
- }
461
- else if (isEscape(e)) {
462
- // return previous value
463
- if (this._previousValue === undefined) {
464
- this._previousValue = this.value;
465
- }
466
- this.value = this._previousValue;
467
- this.input.value = this.value.toFixed(this.valuePrecision);
468
- }
469
- else if (this.max !== undefined && (isPageUpShift(e) || isUpShiftCtrl(e))) {
470
- // step to max
471
- this._modifyValue(this.max - this.value);
472
- }
473
- else if (this.min !== undefined && (isPageDownShift(e) || isDownShiftCtrl(e))) {
474
- // step to min
475
- this._modifyValue(this.min - this.value);
476
- }
477
- else if (!isUpCtrl(e) && !isDownCtrl(e) && !isUpShift(e) && !isDownShift(e)) {
478
- preventDefault = false;
479
- }
480
- if (e.key && e.key.length !== 1) {
481
- return;
482
- }
483
- const caretPosition = this._getCaretPosition();
484
- const inputValue = this.innerInput.value;
485
- const typedValue = this._getValueOnkeyDown(e, inputValue, caretPosition);
486
- const parsedValue = this._parseNumber(typedValue);
487
- const isValidTypedValue = this._isInputValueValid(typedValue, parsedValue);
488
- if (preventDefault || !isValidTypedValue) {
489
- e.preventDefault();
490
- }
491
- if (caretPosition === 0 && isMinus(e)) {
492
- this._updateValueAndValidate(parsedValue);
493
- }
494
- }
495
- _getCaretPosition() {
496
- return this.input.getDomRef().querySelector("input").selectionStart;
497
- }
498
- _getValueOnkeyDown(e, inputValue, cursorPosition) {
499
- const typedValue = `${inputValue.substring(0, cursorPosition)}${e.key}${inputValue.substring(cursorPosition)}`;
500
- const updatedValue = this._removeGroupSeparators(typedValue);
501
- return updatedValue;
502
- }
503
- _removeGroupSeparators(value) {
504
- const groupSeparator = this.groupSeparator;
505
- return value.replaceAll(groupSeparator, "");
506
- }
507
- _isInputValueValid(typedValue, parsedValue) {
508
- return !Number.isNaN(parsedValue) && !/, {2,}/.test(typedValue);
509
- }
510
- _decSpin(e) {
511
- if (this._isFocused || this._decIconDisabled) {
512
- e.preventDefault();
513
- }
514
- if (!this._decIconDisabled) {
515
- this._spinValue(false, true);
516
- }
517
- else {
518
- this.input.focus();
519
- }
520
- }
521
- _incSpin(e) {
522
- if (this._isFocused || this._incIconDisabled) {
523
- e.preventDefault();
524
- }
525
- if (!this._incIconDisabled) {
526
- this._spinValue(true, true);
527
- }
528
- else {
529
- this.input.focus();
530
- }
531
- }
532
- /**
533
- * Calculates the time which should be waited until _spinValue function is called.
534
- */
535
- _calcWaitTimeout() {
536
- this._speed *= ACCELERATION;
537
- this._waitTimeout = ((this._waitTimeout - this._speed) < MIN_WAIT_TIMEOUT ? MIN_WAIT_TIMEOUT : (this._waitTimeout - this._speed));
538
- return this._waitTimeout;
539
- }
540
- /**
541
- * Called when the increment or decrement button is pressed and held to set new value.
542
- * @private
543
- * @param increment - is this the increment button or not so the values should be spin accordingly up or down
544
- * @param resetVariables - whether to reset the spin-related variables or not
545
- */
546
- _spinValue(increment, resetVariables = false) {
547
- if (resetVariables) {
548
- this._waitTimeout = INITIAL_WAIT_TIMEOUT;
549
- this._speed = INITIAL_SPEED;
550
- this._btnDown = true;
551
- }
552
- this._spinTimeoutId = setTimeout(() => {
553
- if (this._btnDown) {
554
- this._spinStarted = true;
555
- this._modifyValue(increment ? this.step : -this.step);
556
- this._setButtonState();
557
- if ((!this._incIconDisabled && increment) || (!this._decIconDisabled && !increment)) {
558
- this._spinValue(increment);
559
- }
560
- else {
561
- this._resetSpin();
562
- this._fireChangeEvent();
563
- }
564
- }
565
- }, this._calcWaitTimeout());
566
- }
567
- /**
568
- * Resets spin process
569
- */
570
- _resetSpin() {
571
- clearTimeout(this._spinTimeoutId);
572
- this._btnDown = false;
573
- this._spinStarted = false;
574
- }
575
- /**
576
- * Resets spin process when mouse outs + or - buttons
577
- */
578
- _resetSpinOut() {
579
- if (this._btnDown) {
580
- this._resetSpin();
581
- this._fireChangeEvent();
582
- }
583
- }
584
182
  };
585
183
  __decorate([
586
184
  property({ type: Number })
@@ -621,36 +219,6 @@ __decorate([
621
219
  __decorate([
622
220
  property()
623
221
  ], StepInput.prototype, "accessibleNameRef", void 0);
624
- __decorate([
625
- property({ noAttribute: true })
626
- ], StepInput.prototype, "_decIconDisabled", void 0);
627
- __decorate([
628
- property({ noAttribute: true })
629
- ], StepInput.prototype, "_incIconDisabled", void 0);
630
- __decorate([
631
- property({ type: Boolean })
632
- ], StepInput.prototype, "focused", void 0);
633
- __decorate([
634
- property({ noAttribute: true })
635
- ], StepInput.prototype, "_inputFocused", void 0);
636
- __decorate([
637
- property({ noAttribute: true })
638
- ], StepInput.prototype, "_previousValue", void 0);
639
- __decorate([
640
- property({ noAttribute: true })
641
- ], StepInput.prototype, "_waitTimeout", void 0);
642
- __decorate([
643
- property({ noAttribute: true })
644
- ], StepInput.prototype, "_speed", void 0);
645
- __decorate([
646
- property({ noAttribute: true })
647
- ], StepInput.prototype, "_btnDown", void 0);
648
- __decorate([
649
- property({ noAttribute: true })
650
- ], StepInput.prototype, "_spinTimeoutId", void 0);
651
- __decorate([
652
- property({ noAttribute: true })
653
- ], StepInput.prototype, "_spinStarted", void 0);
654
222
  __decorate([
655
223
  slot()
656
224
  ], StepInput.prototype, "valueStateMessage", void 0);