@refinitiv-ui/elements 5.7.0 → 5.8.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.
Files changed (161) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/lib/autosuggest/custom-elements.json +14 -4
  3. package/lib/autosuggest/custom-elements.md +21 -14
  4. package/lib/autosuggest/index.d.ts +4 -0
  5. package/lib/autosuggest/index.js +4 -0
  6. package/lib/calendar/custom-elements.json +4 -2
  7. package/lib/calendar/custom-elements.md +2 -2
  8. package/lib/calendar/index.d.ts +2 -0
  9. package/lib/calendar/index.js +2 -0
  10. package/lib/canvas/custom-elements.json +7 -5
  11. package/lib/canvas/custom-elements.md +8 -8
  12. package/lib/canvas/index.d.ts +1 -0
  13. package/lib/canvas/index.js +1 -0
  14. package/lib/card/custom-elements.json +3 -1
  15. package/lib/card/custom-elements.md +5 -5
  16. package/lib/card/index.d.ts +2 -0
  17. package/lib/card/index.js +2 -0
  18. package/lib/chart/custom-elements.json +1 -1
  19. package/lib/chart/custom-elements.md +4 -4
  20. package/lib/checkbox/custom-elements.json +8 -4
  21. package/lib/checkbox/custom-elements.md +2 -2
  22. package/lib/checkbox/index.d.ts +3 -1
  23. package/lib/checkbox/index.js +2 -0
  24. package/lib/clock/custom-elements.json +8 -4
  25. package/lib/clock/custom-elements.md +9 -9
  26. package/lib/clock/index.d.ts +2 -0
  27. package/lib/clock/index.js +2 -0
  28. package/lib/clock/themes/halo/dark/index.js +1 -1
  29. package/lib/clock/themes/halo/light/index.js +1 -1
  30. package/lib/clock/themes/solar/charcoal/index.js +1 -1
  31. package/lib/clock/themes/solar/pearl/index.js +1 -1
  32. package/lib/color-dialog/custom-elements.json +21 -8
  33. package/lib/color-dialog/custom-elements.md +22 -22
  34. package/lib/color-dialog/index.d.ts +8 -8
  35. package/lib/color-dialog/index.js +8 -8
  36. package/lib/combo-box/custom-elements.json +19 -10
  37. package/lib/combo-box/custom-elements.md +20 -20
  38. package/lib/combo-box/index.d.ts +10 -2
  39. package/lib/combo-box/index.js +10 -1
  40. package/lib/combo-box/themes/halo/dark/index.js +1 -1
  41. package/lib/combo-box/themes/halo/light/index.js +1 -1
  42. package/lib/combo-box/themes/solar/charcoal/index.js +1 -1
  43. package/lib/combo-box/themes/solar/pearl/index.js +1 -1
  44. package/lib/counter/custom-elements.json +8 -4
  45. package/lib/counter/custom-elements.md +4 -4
  46. package/lib/counter/index.d.ts +2 -0
  47. package/lib/counter/index.js +2 -0
  48. package/lib/datetime-picker/custom-elements.json +48 -19
  49. package/lib/datetime-picker/custom-elements.md +36 -28
  50. package/lib/datetime-picker/index.d.ts +15 -4
  51. package/lib/datetime-picker/index.js +15 -4
  52. package/lib/dialog/custom-elements.json +30 -8
  53. package/lib/dialog/custom-elements.md +16 -16
  54. package/lib/dialog/index.d.ts +7 -10
  55. package/lib/dialog/index.js +7 -10
  56. package/lib/email-field/custom-elements.json +80 -93
  57. package/lib/email-field/custom-elements.md +22 -20
  58. package/lib/email-field/index.d.ts +43 -115
  59. package/lib/email-field/index.js +44 -244
  60. package/lib/flag/custom-elements.md +4 -4
  61. package/lib/flag/index.d.ts +2 -0
  62. package/lib/flag/index.js +2 -0
  63. package/lib/icon/custom-elements.md +4 -4
  64. package/lib/icon/index.d.ts +2 -0
  65. package/lib/icon/index.js +2 -0
  66. package/lib/interactive-chart/custom-elements.json +6 -10
  67. package/lib/interactive-chart/custom-elements.md +6 -7
  68. package/lib/interactive-chart/index.d.ts +5 -2
  69. package/lib/interactive-chart/index.js +5 -2
  70. package/lib/item/custom-elements.json +8 -6
  71. package/lib/item/custom-elements.md +14 -14
  72. package/lib/item/index.d.ts +2 -1
  73. package/lib/item/index.js +2 -1
  74. package/lib/led-gauge/custom-elements.json +4 -4
  75. package/lib/led-gauge/custom-elements.md +2 -2
  76. package/lib/led-gauge/index.d.ts +1 -0
  77. package/lib/led-gauge/index.js +1 -0
  78. package/lib/list/custom-elements.json +18 -5
  79. package/lib/list/custom-elements.md +12 -10
  80. package/lib/list/helpers/list-renderer.js +2 -0
  81. package/lib/list/index.d.ts +19 -2
  82. package/lib/list/index.js +34 -1
  83. package/lib/multi-input/custom-elements.json +3 -2
  84. package/lib/multi-input/custom-elements.md +16 -16
  85. package/lib/multi-input/index.d.ts +4 -0
  86. package/lib/multi-input/index.js +4 -0
  87. package/lib/number-field/custom-elements.json +97 -52
  88. package/lib/number-field/custom-elements.md +27 -22
  89. package/lib/number-field/index.d.ts +92 -47
  90. package/lib/number-field/index.js +113 -80
  91. package/lib/overlay/custom-elements.json +23 -13
  92. package/lib/overlay/custom-elements.md +29 -29
  93. package/lib/overlay/elements/overlay.d.ts +5 -0
  94. package/lib/overlay-menu/custom-elements.json +66 -14
  95. package/lib/overlay-menu/custom-elements.md +19 -19
  96. package/lib/overlay-menu/index.d.ts +13 -11
  97. package/lib/overlay-menu/index.js +13 -11
  98. package/lib/password-field/custom-elements.json +62 -67
  99. package/lib/password-field/custom-elements.md +19 -11
  100. package/lib/password-field/index.d.ts +42 -94
  101. package/lib/password-field/index.js +48 -194
  102. package/lib/pill/custom-elements.json +4 -2
  103. package/lib/pill/custom-elements.md +1 -1
  104. package/lib/pill/index.d.ts +1 -1
  105. package/lib/pill/index.js +1 -1
  106. package/lib/radio-button/custom-elements.json +8 -6
  107. package/lib/radio-button/custom-elements.md +3 -3
  108. package/lib/radio-button/index.d.ts +6 -5
  109. package/lib/radio-button/index.js +5 -4
  110. package/lib/search-field/custom-elements.json +70 -74
  111. package/lib/search-field/custom-elements.md +24 -16
  112. package/lib/search-field/index.d.ts +43 -100
  113. package/lib/search-field/index.js +46 -215
  114. package/lib/select/custom-elements.json +3 -2
  115. package/lib/select/custom-elements.md +10 -10
  116. package/lib/select/index.d.ts +11 -3
  117. package/lib/select/index.js +65 -26
  118. package/lib/sidebar-layout/custom-elements.json +2 -6
  119. package/lib/sidebar-layout/custom-elements.md +5 -6
  120. package/lib/sidebar-layout/index.d.ts +2 -1
  121. package/lib/slider/custom-elements.json +2 -2
  122. package/lib/slider/custom-elements.md +1 -1
  123. package/lib/slider/index.d.ts +1 -1
  124. package/lib/slider/index.js +1 -1
  125. package/lib/sparkline/custom-elements.json +4 -4
  126. package/lib/sparkline/custom-elements.md +2 -2
  127. package/lib/sparkline/index.d.ts +3 -1
  128. package/lib/sparkline/index.js +2 -0
  129. package/lib/swing-gauge/custom-elements.json +5 -3
  130. package/lib/swing-gauge/custom-elements.md +11 -11
  131. package/lib/swing-gauge/index.d.ts +3 -1
  132. package/lib/swing-gauge/index.js +3 -1
  133. package/lib/text-field/custom-elements.json +76 -87
  134. package/lib/text-field/custom-elements.md +24 -26
  135. package/lib/text-field/index.d.ts +50 -92
  136. package/lib/text-field/index.js +81 -230
  137. package/lib/time-picker/custom-elements.md +3 -3
  138. package/lib/time-picker/index.d.ts +3 -0
  139. package/lib/time-picker/index.js +3 -0
  140. package/lib/toggle/custom-elements.json +4 -2
  141. package/lib/toggle/custom-elements.md +1 -1
  142. package/lib/toggle/index.d.ts +2 -1
  143. package/lib/toggle/index.js +1 -0
  144. package/lib/tree/custom-elements.json +2 -1
  145. package/lib/tree/custom-elements.md +1 -1
  146. package/lib/tree/elements/tree.d.ts +1 -0
  147. package/lib/tree/elements/tree.js +1 -0
  148. package/lib/tree/themes/halo/dark/index.js +1 -1
  149. package/lib/tree/themes/halo/light/index.js +1 -1
  150. package/lib/tree/themes/solar/charcoal/index.js +1 -1
  151. package/lib/tree/themes/solar/pearl/index.js +1 -1
  152. package/lib/tree-select/custom-elements.json +8 -4
  153. package/lib/tree-select/custom-elements.md +3 -3
  154. package/lib/tree-select/index.d.ts +5 -3
  155. package/lib/tree-select/index.js +3 -2
  156. package/lib/tree-select/themes/halo/dark/index.js +1 -1
  157. package/lib/tree-select/themes/halo/light/index.js +1 -1
  158. package/lib/tree-select/themes/solar/charcoal/index.js +1 -1
  159. package/lib/tree-select/themes/solar/pearl/index.js +1 -1
  160. package/lib/version.js +1 -1
  161. package/package.json +10 -10
@@ -1,33 +1,38 @@
1
1
  # ef-number-field
2
2
 
3
- Form control element for numbers
3
+ Form control element for numbers.
4
4
 
5
5
  ## Properties
6
6
 
7
- | Property | Attribute | Modifiers | Type | Default | Description |
8
- |-----------------|---------------|-----------|------------------|---------|--------------------------------------------------|
9
- | `disabled` | `disabled` | | `boolean` | false | Set disabled state |
10
- | `error` | `error` | | `boolean` | false | Set state to error |
11
- | `max` | `max` | | `string \| null` | null | Set maximum value.<br />This value must be greater than or equal to the value of the `min` attribute |
12
- | `min` | `min` | | `string \| null` | null | Set minimum value.<br />This value must be less than or equal to the value of the `max` attribute |
13
- | `noSpinner` | `no-spinner` | | `boolean` | false | Set spinner's visibility |
14
- | `placeholder` | `placeholder` | | `string \| null` | null | Set placeholder text |
15
- | `readonly` | `readonly` | | `boolean` | false | Set readonly state |
16
- | `step` | `step` | | `string \| null` | null | Set step value |
17
- | `transparent` | `transparent` | | `boolean` | false | Set state to transparent |
18
- | `value` | `value` | | `string` | 0 | The value of the number entered into the input. |
19
- | `valueAsNumber` | | readonly | `number` | | Returns the value of the element, interpreted as double number |
20
- | `warning` | `warning` | | `boolean` | false | Set state to warning |
7
+ | Property | Attribute | Type | Default | Description |
8
+ |----------------------------|---------------|---------------------------------------------|---------|--------------------------------------------------|
9
+ | `disabled` | `disabled` | `boolean` | false | Set disabled state |
10
+ | `error` | `error` | `boolean` | false | Set error state |
11
+ | `max` | `max` | `string \| null` | null | Set maximum value.<br />This value must be greater than or equal to the value of the `min` attribute |
12
+ | `min` | `min` | `string \| null` | null | Set minimum value.<br />This value must be less than or equal to the value of the `max` attribute |
13
+ | `noSpinner` | `no-spinner` | `boolean` | false | Set spinner's visibility |
14
+ | `placeholder` | `placeholder` | `string` | "" | Set placeholder text |
15
+ | `readonly` | `readonly` | `boolean` | false | Set readonly state |
16
+ | `selectionDirection` | | `"forward" \| "backward" \| "none" \| null` | | |
17
+ | `selectionEnd` | | `number \| null` | | |
18
+ | `selectionStart` | | `number \| null` | | |
19
+ | `step` | `step` | `string \| null` | null | Set step value |
20
+ | `transparent` | `transparent` | `boolean` | false | Disables all other states and border/background styles. |
21
+ | `value` | `value` | `string` | "" | The value of the number entered into the input. |
22
+ | `valueAsNumber (readonly)` | | `number` | | Returns the value of the element, interpreted as double number |
23
+ | `warning` | `warning` | `boolean` | false | Set warning state |
21
24
 
22
25
  ## Methods
23
26
 
24
- | Method | Type | Description |
25
- |------------------|-----------------------------------------------|--------------------------------------------------|
26
- | `checkValidity` | `(): boolean` | Returns true if an input element contains valid data. |
27
- | `reportValidity` | `(): boolean` | Validate input. Mark as error if input is invalid |
28
- | `select` | `(): void` | Select the contents of input |
29
- | `stepDown` | `(stepIncrement?: number \| undefined): void` | Decreases the input value by amount of step<br /><br />**stepIncrement**: The stepIncrement parameter is a numeric value. If no parameter is passed, stepIncrement defaults to 1. |
30
- | `stepUp` | `(stepIncrement?: number \| undefined): void` | Increases the input value by amount of step<br /><br />**stepIncrement**: The stepIncrement parameter is a numeric value. If no parameter is passed, stepIncrement defaults to 1. |
27
+ | Method | Type | Description |
28
+ |---------------------|--------------------------------------------------|--------------------------------------------------|
29
+ | `checkValidity` | `(): boolean` | Returns true if an input element contains valid data. |
30
+ | `onInputChange` | `(event: any): void` | |
31
+ | `onInputInput` | `(event: any): void` | |
32
+ | `reportValidity` | `(): boolean` | Validate input. Mark as error if input is invalid |
33
+ | `setSelectionRange` | `(startSelection: number \| null, endSelection: number \| null, selectionDirection?: "forward" \| "backward" \| "none" \| undefined): void` | |
34
+ | `stepDown` | `(stepIncrement?: number \| undefined): void` | Decreases the input value by amount of step<br /><br />**stepIncrement**: The stepIncrement parameter is a numeric value. If no parameter is passed, stepIncrement defaults to 1. |
35
+ | `stepUp` | `(stepIncrement?: number \| undefined): void` | Increases the input value by amount of step<br /><br />**stepIncrement**: The stepIncrement parameter is a numeric value. If no parameter is passed, stepIncrement defaults to 1. |
31
36
 
32
37
  ## Events
33
38
 
@@ -1,22 +1,40 @@
1
1
  import { JSXInterface } from '../jsx';
2
- import { ControlElement, CSSResultGroup, TemplateResult, PropertyValues } from '@refinitiv-ui/core';
2
+ import { FormFieldElement, CSSResultGroup, TemplateResult, PropertyValues, TapEvent } from '@refinitiv-ui/core';
3
+ import { TemplateMap } from '@refinitiv-ui/core/lib/directives/template-map.js';
3
4
  import '../icon/index.js';
5
+ declare type SelectionDirection = 'forward' | 'backward' | 'none';
6
+ declare enum Direction {
7
+ Up = 1,
8
+ Down = -1
9
+ }
4
10
  /**
5
- * Form control element for numbers
11
+ * Form control element for numbers.
6
12
  *
7
13
  * @fires value-changed - Dispatched when value changes
8
14
  * @fires error-changed - Dispatched when error state changes
9
15
  *
10
- * @attr {string} value - Input's default value
11
- * @prop {string} [value=] - Input's value
16
+ * @attr {boolean} disabled - Set disabled state
17
+ * @prop {boolean} [disabled=false] - Set disabled state
18
+ *
19
+ * @attr {boolean} error - Set error state
20
+ * @prop {boolean} [error=false] - Set error state
21
+ *
22
+ * @attr {string} placeholder - Set placeholder text
23
+ * @prop {string} [placeholder=""] - Set placeholder text
12
24
  *
13
25
  * @attr {boolean} readonly - Set readonly state
14
26
  * @prop {boolean} [readonly=false] - Set readonly state
15
27
  *
16
- * @attr {boolean} disabled - Set disabled state
17
- * @prop {boolean} [disabled=false] - Set disabled state
28
+ * @attr {boolean} transparent - Disables all other states and border/background styles.
29
+ * @prop {boolean} [transparent=false] - Disables all other states and border/background styles.
30
+ *
31
+ * @attr {boolean} warning - Set warning state
32
+ * @prop {boolean} [warning=false] - Set warning state
33
+ *
34
+ * @attr {string} value - Input's value
35
+ * @prop {string} [value=""] - Input's value
18
36
  */
19
- export declare class NumberField extends ControlElement {
37
+ export declare class NumberField extends FormFieldElement {
20
38
  /**
21
39
  * Element version number
22
40
  * @returns version number
@@ -29,10 +47,6 @@ export declare class NumberField extends ControlElement {
29
47
  * @return CSS template
30
48
  */
31
49
  static get styles(): CSSResultGroup;
32
- /**
33
- * Set placeholder text
34
- */
35
- placeholder: string | null;
36
50
  /**
37
51
  * Set spinner's visibility
38
52
  */
@@ -51,22 +65,11 @@ export declare class NumberField extends ControlElement {
51
65
  * This value must be greater than or equal to the value of the `min` attribute
52
66
  */
53
67
  max: string | null;
54
- /**
55
- * Set state to transparent
56
- */
57
- transparent: boolean;
58
- /**
59
- * Set state to error
60
- */
61
- error: boolean;
62
- /**
63
- * Set state to warning
64
- */
65
- warning: boolean;
66
68
  private interimValueState;
67
69
  /**
68
70
  * The value of the number entered into the input.
69
71
  * @param value number-field value
72
+ * @default -
70
73
  */
71
74
  set value(value: string);
72
75
  get value(): string;
@@ -74,10 +77,6 @@ export declare class NumberField extends ControlElement {
74
77
  * Returns the value of the element, interpreted as double number
75
78
  */
76
79
  get valueAsNumber(): number;
77
- /**
78
- * Get native input element from shadow root
79
- */
80
- private inputEl;
81
80
  /**
82
81
  * Get spinner up element
83
82
  */
@@ -145,47 +144,49 @@ export declare class NumberField extends ControlElement {
145
144
  * @returns string of input value
146
145
  */
147
146
  private get internalValue();
148
- /**
149
- * Get native input value
150
- * @returns string of input value
151
- */
152
- private get inputValue();
153
- /**
154
- * Set native input value
155
- * @param value input's value
156
- */
157
- private set inputValue(value);
158
147
  /**
159
148
  * Handles key down input event
160
149
  * @param event Key down event object
161
150
  * @returns {void}
162
151
  */
163
- private onNativeInputKeyDown;
152
+ protected onInputKeyDown(event: KeyboardEvent): void;
164
153
  /**
165
154
  * Run when spinner has been tapped
166
155
  * @param event tap event
167
156
  * @returns {void}
168
157
  */
169
- private onSpinnerTap;
158
+ protected onSpinnerTap(event: TapEvent): void;
170
159
  /**
171
160
  * Step down or up and notify value change
172
161
  * @param direction Up or Down
173
162
  * @returns {void}
174
163
  */
175
- private onApplyStep;
164
+ protected onApplyStep(direction: Direction): void;
176
165
  /**
177
166
  * Run before input changes
178
167
  * Prevent invalid characters
179
168
  * @param event before input event
180
169
  * @returns {void}
181
170
  */
182
- private onNativeBeforeInputChange;
171
+ protected onBeforeInputChange(event: InputEvent): void;
172
+ /**
173
+ * Runs on input element `input` event
174
+ * @param event `input` event
175
+ * @returns {void}
176
+ */
177
+ protected onInputInput(event: InputEvent): void;
178
+ /**
179
+ * Runs on input element `change` event
180
+ * @param event `change` event
181
+ * @returns {void}
182
+ */
183
+ protected onInputChange(event: InputEvent): void;
183
184
  /**
184
185
  * Triggers when native input value change with input event or change event
185
186
  * @param event Input event
186
187
  * @returns {void}
187
188
  */
188
- private onNativeInputChange;
189
+ protected onNativeInputChange(event: InputEvent): void;
189
190
  /**
190
191
  * Stripe characters from input text based on previous input and data
191
192
  * @param input The new input to process
@@ -262,15 +263,58 @@ export declare class NumberField extends ControlElement {
262
263
  */
263
264
  reportValidity(): boolean;
264
265
  /**
265
- * Select the contents of input
266
- * @returns void
266
+ * @ignore
267
+ * @inheritDoc
268
+ */
269
+ get selectionStart(): number | null;
270
+ /**
271
+ * @ignore
272
+ * @inheritDoc
273
+ */
274
+ set selectionStart(index: number | null);
275
+ /**
276
+ * @ignore
277
+ * @inheritDoc
267
278
  */
268
- select(): void;
279
+ get selectionEnd(): number | null;
280
+ /**
281
+ * @ignore
282
+ * @inheritDoc
283
+ */
284
+ set selectionEnd(index: number | null);
285
+ /**
286
+ * @ignore
287
+ * @inheritDoc
288
+ */
289
+ get selectionDirection(): SelectionDirection | null;
290
+ /**
291
+ * @ignore
292
+ * @inheritDoc
293
+ */
294
+ set selectionDirection(direction: SelectionDirection | null);
295
+ /**
296
+ * @ignore
297
+ * @inheritDoc
298
+ */
299
+ setSelectionRange(startSelection: number | null, endSelection: number | null, selectionDirection?: SelectionDirection): void;
269
300
  /**
270
301
  * Renders spinner
271
302
  * @returns {TemplateResult} spinner part template
272
303
  */
273
- private renderSpinner;
304
+ protected renderSpinner(): TemplateResult;
305
+ /**
306
+ * Decorate `<input>` element with common properties extended from form field element:
307
+ * type="text" - always `text`
308
+ * part="input" - always "input", used for styling
309
+ * inputmode="decimal" - show decimals keyboard by default
310
+ * pattern="'^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$'" - numbers only
311
+ * role="spinbutton" - number field is actually a spinner
312
+ * aria-valuenow - current value or 0
313
+ * @keydown - Listener for `keydown` event. Runs `this.onInputKeyDown`
314
+ * @beforeinput - Listener for `beforeinput` event. Runs `this.onBeforeInputChange`
315
+ * @returns template map
316
+ */
317
+ protected get decorateInputMap(): TemplateMap;
274
318
  /**
275
319
  * A `TemplateResult` that will be used
276
320
  * to render the updated internal template.
@@ -278,6 +322,7 @@ export declare class NumberField extends ControlElement {
278
322
  */
279
323
  protected render(): TemplateResult;
280
324
  }
325
+ export {};
281
326
 
282
327
  declare global {
283
328
  interface HTMLElementTagNameMap {
@@ -286,7 +331,7 @@ declare global {
286
331
 
287
332
  namespace JSX {
288
333
  interface IntrinsicElements {
289
- 'ef-number-field': Partial<NumberField> | JSXInterface.ControlHTMLAttributes<NumberField>;
334
+ 'ef-number-field': Partial<NumberField> | JSXInterface.HTMLAttributes<NumberField>;
290
335
  }
291
336
  }
292
337
  }
@@ -1,9 +1,8 @@
1
1
  import { __decorate } from "tslib";
2
- import { ControlElement, html, css, FocusedPropertyKey } from '@refinitiv-ui/core';
2
+ import { FormFieldElement, html, css, FocusedPropertyKey } from '@refinitiv-ui/core';
3
3
  import { customElement } from '@refinitiv-ui/core/lib/decorators/custom-element.js';
4
4
  import { property } from '@refinitiv-ui/core/lib/decorators/property.js';
5
5
  import { query } from '@refinitiv-ui/core/lib/decorators/query.js';
6
- import { ifDefined } from '@refinitiv-ui/core/lib/directives/if-defined.js';
7
6
  import { VERSION } from '../version.js';
8
7
  import '../icon/index.js';
9
8
  const NUMBER_PATTERN = '^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$';
@@ -15,27 +14,35 @@ var Direction;
15
14
  Direction[Direction["Down"] = -1] = "Down";
16
15
  })(Direction || (Direction = {}));
17
16
  /**
18
- * Form control element for numbers
17
+ * Form control element for numbers.
19
18
  *
20
19
  * @fires value-changed - Dispatched when value changes
21
20
  * @fires error-changed - Dispatched when error state changes
22
21
  *
23
- * @attr {string} value - Input's default value
24
- * @prop {string} [value=] - Input's value
22
+ * @attr {boolean} disabled - Set disabled state
23
+ * @prop {boolean} [disabled=false] - Set disabled state
24
+ *
25
+ * @attr {boolean} error - Set error state
26
+ * @prop {boolean} [error=false] - Set error state
27
+ *
28
+ * @attr {string} placeholder - Set placeholder text
29
+ * @prop {string} [placeholder=""] - Set placeholder text
25
30
  *
26
31
  * @attr {boolean} readonly - Set readonly state
27
32
  * @prop {boolean} [readonly=false] - Set readonly state
28
33
  *
29
- * @attr {boolean} disabled - Set disabled state
30
- * @prop {boolean} [disabled=false] - Set disabled state
34
+ * @attr {boolean} transparent - Disables all other states and border/background styles.
35
+ * @prop {boolean} [transparent=false] - Disables all other states and border/background styles.
36
+ *
37
+ * @attr {boolean} warning - Set warning state
38
+ * @prop {boolean} [warning=false] - Set warning state
39
+ *
40
+ * @attr {string} value - Input's value
41
+ * @prop {string} [value=""] - Input's value
31
42
  */
32
- let NumberField = class NumberField extends ControlElement {
43
+ let NumberField = class NumberField extends FormFieldElement {
33
44
  constructor() {
34
45
  super(...arguments);
35
- /**
36
- * Set placeholder text
37
- */
38
- this.placeholder = null;
39
46
  /**
40
47
  * Set spinner's visibility
41
48
  */
@@ -54,18 +61,6 @@ let NumberField = class NumberField extends ControlElement {
54
61
  * This value must be greater than or equal to the value of the `min` attribute
55
62
  */
56
63
  this.max = null;
57
- /**
58
- * Set state to transparent
59
- */
60
- this.transparent = false;
61
- /**
62
- * Set state to error
63
- */
64
- this.error = false;
65
- /**
66
- * Set state to warning
67
- */
68
- this.warning = false;
69
64
  this.interimValueState = false; // make sure that internal input field value is updated only on external value change
70
65
  }
71
66
  /**
@@ -119,6 +114,7 @@ let NumberField = class NumberField extends ControlElement {
119
114
  /**
120
115
  * The value of the number entered into the input.
121
116
  * @param value number-field value
117
+ * @default -
122
118
  */
123
119
  set value(value) {
124
120
  this.interimValueState = true;
@@ -231,28 +227,14 @@ let NumberField = class NumberField extends ControlElement {
231
227
  */
232
228
  get internalValue() {
233
229
  // cover the case when value getter is called before first render or in interim state
234
- return this.interimValueState || !this.inputEl ? super.value : this.inputValue;
235
- }
236
- /**
237
- * Get native input value
238
- * @returns string of input value
239
- */
240
- get inputValue() {
241
- return this.inputEl.value;
242
- }
243
- /**
244
- * Set native input value
245
- * @param value input's value
246
- */
247
- set inputValue(value) {
248
- this.inputEl.value = value;
230
+ return this.interimValueState || !this.inputElement ? super.value : this.inputValue;
249
231
  }
250
232
  /**
251
233
  * Handles key down input event
252
234
  * @param event Key down event object
253
235
  * @returns {void}
254
236
  */
255
- onNativeInputKeyDown(event) {
237
+ onInputKeyDown(event) {
256
238
  if (this.readonly || this.disabled || event.defaultPrevented) {
257
239
  return;
258
240
  }
@@ -309,7 +291,7 @@ let NumberField = class NumberField extends ControlElement {
309
291
  * @returns {void}
310
292
  */
311
293
  /* istanbul ignore next */
312
- onNativeBeforeInputChange(event) {
294
+ onBeforeInputChange(event) {
313
295
  // The event is not supported in IE11 and old browsers
314
296
  // Therefore just try to prevent some of invalid characters to be entered
315
297
  // but still do full validation on actual `input` and `change` events
@@ -317,7 +299,8 @@ let NumberField = class NumberField extends ControlElement {
317
299
  // cover all insert types, such as type, paste, drag&drop and others
318
300
  if (inputType.startsWith('insert')) {
319
301
  const data = event.data || '';
320
- const inputEl = this.inputEl;
302
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
303
+ const inputEl = this.inputElement;
321
304
  const oldInput = this.inputValue;
322
305
  // Calculate what could be the new input
323
306
  const selectionStart = inputEl.selectionStart || 0;
@@ -337,6 +320,22 @@ let NumberField = class NumberField extends ControlElement {
337
320
  }
338
321
  }
339
322
  }
323
+ /**
324
+ * Runs on input element `input` event
325
+ * @param event `input` event
326
+ * @returns {void}
327
+ */
328
+ onInputInput(event) {
329
+ this.onNativeInputChange(event);
330
+ }
331
+ /**
332
+ * Runs on input element `change` event
333
+ * @param event `change` event
334
+ * @returns {void}
335
+ */
336
+ onInputChange(event) {
337
+ this.onNativeInputChange(event);
338
+ }
340
339
  /**
341
340
  * Triggers when native input value change with input event or change event
342
341
  * @param event Input event
@@ -346,7 +345,8 @@ let NumberField = class NumberField extends ControlElement {
346
345
  const currentInput = this.inputValue;
347
346
  const inputValue = this.stripeInvalidCharacters(currentInput, this.value, event.data || '');
348
347
  if (inputValue !== currentInput) {
349
- const inputEl = this.inputEl;
348
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
349
+ const inputEl = this.inputElement;
350
350
  // we can only stripe the characters, so try to make the best guess where the cursor should be
351
351
  const selectionStart = inputEl.selectionStart || 0;
352
352
  const selectionEnd = inputEl.selectionEnd || 0;
@@ -606,13 +606,60 @@ let NumberField = class NumberField extends ControlElement {
606
606
  return !hasError;
607
607
  }
608
608
  /**
609
- * Select the contents of input
610
- * @returns void
609
+ * @ignore
610
+ * @inheritDoc
611
611
  */
612
- select() {
613
- if (!this.disabled) {
614
- this.inputEl && this.inputEl.select();
615
- }
612
+ /* istanbul ignore next */
613
+ get selectionStart() {
614
+ return null;
615
+ }
616
+ /**
617
+ * @ignore
618
+ * @inheritDoc
619
+ */
620
+ /* istanbul ignore next */
621
+ set selectionStart(index) {
622
+ throw new Error('Failed to set the \'selectionStart\' property on \'NumberField\': The element does not support selection.');
623
+ }
624
+ /**
625
+ * @ignore
626
+ * @inheritDoc
627
+ */
628
+ /* istanbul ignore next */
629
+ get selectionEnd() {
630
+ return null;
631
+ }
632
+ /**
633
+ * @ignore
634
+ * @inheritDoc
635
+ */
636
+ /* istanbul ignore next */
637
+ set selectionEnd(index) {
638
+ throw new Error('Failed to set the \'selectionEnd\' property on \'NumberField\': The element does not support selection.');
639
+ }
640
+ /**
641
+ * @ignore
642
+ * @inheritDoc
643
+ */
644
+ /* istanbul ignore next */
645
+ get selectionDirection() {
646
+ return null;
647
+ }
648
+ /**
649
+ * @ignore
650
+ * @inheritDoc
651
+ */
652
+ /* istanbul ignore next */
653
+ set selectionDirection(direction) {
654
+ throw new Error('Failed to set the \'selectionDirection\' property on \'NumberField\': The element does not support selection.');
655
+ }
656
+ /**
657
+ * @ignore
658
+ * @inheritDoc
659
+ */
660
+ /* istanbul ignore next */
661
+ setSelectionRange(startSelection, endSelection, selectionDirection) {
662
+ throw new Error('Failed to execute \'setSelectionRange\' on \'NumberField\': The element does not support selection.');
616
663
  }
617
664
  /**
618
665
  * Renders spinner
@@ -638,6 +685,21 @@ let NumberField = class NumberField extends ControlElement {
638
685
  </div>
639
686
  `;
640
687
  }
688
+ /**
689
+ * Decorate `<input>` element with common properties extended from form field element:
690
+ * type="text" - always `text`
691
+ * part="input" - always "input", used for styling
692
+ * inputmode="decimal" - show decimals keyboard by default
693
+ * pattern="'^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$'" - numbers only
694
+ * role="spinbutton" - number field is actually a spinner
695
+ * aria-valuenow - current value or 0
696
+ * @keydown - Listener for `keydown` event. Runs `this.onInputKeyDown`
697
+ * @beforeinput - Listener for `beforeinput` event. Runs `this.onBeforeInputChange`
698
+ * @returns template map
699
+ */
700
+ get decorateInputMap() {
701
+ return Object.assign(Object.assign({}, super.decorateInputMap), { 'type': 'text', 'part': 'input', 'inputmode': 'decimal', 'pattern': NUMBER_PATTERN, 'role': 'spinbutton', 'aria-valuenow': `${this.value || 0}`, '@keydown': this.onInputKeyDown, '@beforeinput': this.onBeforeInputChange });
702
+ }
641
703
  /**
642
704
  * A `TemplateResult` that will be used
643
705
  * to render the updated internal template.
@@ -645,27 +707,10 @@ let NumberField = class NumberField extends ControlElement {
645
707
  */
646
708
  render() {
647
709
  return html `
648
- <input
649
- part="input"
650
- type="text"
651
- inputmode="decimal"
652
- pattern="${NUMBER_PATTERN}"
653
- ?readonly=${this.readonly}
654
- ?disabled=${this.disabled}
655
- placeholder=${ifDefined(this.placeholder ? this.placeholder : undefined)}
656
- @input="${this.onNativeInputChange}"
657
- @keydown="${this.onNativeInputKeyDown}"
658
- @beforeinput="${this.onNativeBeforeInputChange}"
659
- @change="${this.onNativeInputChange}"
660
- autocomplete="off"
661
- >
662
- ${this.noSpinner ? null : this.renderSpinner()}
663
- `;
710
+ ${super.render()}
711
+ ${this.noSpinner ? null : this.renderSpinner()}`;
664
712
  }
665
713
  };
666
- __decorate([
667
- property({ type: String, reflect: true })
668
- ], NumberField.prototype, "placeholder", void 0);
669
714
  __decorate([
670
715
  property({ type: Boolean, attribute: 'no-spinner', reflect: true })
671
716
  ], NumberField.prototype, "noSpinner", void 0);
@@ -678,21 +723,9 @@ __decorate([
678
723
  __decorate([
679
724
  property({ type: String, reflect: true })
680
725
  ], NumberField.prototype, "max", void 0);
681
- __decorate([
682
- property({ type: Boolean, reflect: true })
683
- ], NumberField.prototype, "transparent", void 0);
684
- __decorate([
685
- property({ type: Boolean, reflect: true })
686
- ], NumberField.prototype, "error", void 0);
687
- __decorate([
688
- property({ type: Boolean, reflect: true })
689
- ], NumberField.prototype, "warning", void 0);
690
726
  __decorate([
691
727
  property({ type: String })
692
728
  ], NumberField.prototype, "value", null);
693
- __decorate([
694
- query('[part=input]')
695
- ], NumberField.prototype, "inputEl", void 0);
696
729
  __decorate([
697
730
  query('[part=spinner-up]')
698
731
  ], NumberField.prototype, "spinnerUpEl", void 0);