@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,23 +1,36 @@
1
1
  import { JSXInterface } from '../jsx';
2
- import { ControlElement, CSSResultGroup, PropertyValues, TemplateResult } from '@refinitiv-ui/core';
2
+ import { FormFieldElement, CSSResultGroup, PropertyValues, TemplateResult } from '@refinitiv-ui/core';
3
+ import { TemplateMap } from '@refinitiv-ui/core/lib/directives/template-map.js';
3
4
  import '../icon/index.js';
4
- declare type SelectionIndex = number | null;
5
5
  /**
6
- * Form control element for text
6
+ * Form control element for text.
7
7
  *
8
8
  * @fires value-changed - Dispatched when value changes
9
9
  * @fires error-changed - Dispatched when error state changes
10
+ * @fires icon-click - Dispatched when icon is clicked
10
11
  *
11
- * @attr {string} value - Input's value
12
- * @prop {string} [value=] - Input's value
12
+ * @attr {boolean} disabled - Set disabled state
13
+ * @prop {boolean} [disabled=false] - Set disabled state
14
+ *
15
+ * @attr {boolean} error - Set error state
16
+ * @prop {boolean} [error=false] - Set error state
17
+ *
18
+ * @attr {string} placeholder - Set placeholder text
19
+ * @prop {string} [placeholder=""] - Set placeholder text
13
20
  *
14
21
  * @attr {boolean} readonly - Set readonly state
15
22
  * @prop {boolean} [readonly=false] - Set readonly state
16
23
  *
17
- * @attr {boolean} disabled - Set disabled state
18
- * @prop {boolean} [disabled=false] - Set disabled state
24
+ * @attr {boolean} transparent - Disables all other states and border/background styles.
25
+ * @prop {boolean} [transparent=false] - Disables all other states and border/background styles.
26
+ *
27
+ * @attr {boolean} warning - Set warning state
28
+ * @prop {boolean} [warning=false] - Set warning state
29
+ *
30
+ * @attr {string} value - Input's value
31
+ * @prop {string} [value=""] - Input's value
19
32
  */
20
- export declare class TextField extends ControlElement {
33
+ export declare class TextField extends FormFieldElement {
21
34
  /**
22
35
  * Element version number
23
36
  * @returns version number
@@ -33,47 +46,14 @@ export declare class TextField extends ControlElement {
33
46
  * Set regular expression for input validation
34
47
  */
35
48
  pattern: string;
36
- /**
37
- * Set place holder text
38
- */
39
- placeholder: string;
40
- /**
41
- * Set state to error
42
- */
43
- error: boolean;
44
- /**
45
- * Aria indicating if the field is required
46
- * @ignore
47
- */
48
- ariaRequired: string;
49
- /**
50
- * Aria description used to describe input or error to screen reader
51
- * @ignore
52
- */
53
- ariaDescription: string;
54
- /**
55
- * Aria label used to label input to screen reader
56
- * @ignore
57
- */
58
- ariaLabel: string;
59
- /**
60
- * Set state to warning
61
- */
62
- warning: boolean;
63
49
  /**
64
50
  * Specify icon to display in input. Value can be icon name
65
51
  */
66
- icon: string;
52
+ icon: string | null;
67
53
  /**
68
54
  * Specify when icon need to be clickable
69
55
  */
70
56
  iconHasAction: boolean;
71
- /**
72
- * Disables all other states and border/background styles.
73
- * Use with advanced composite elements requiring e.g. multi selection in
74
- * combo-box when parent container handles element states.
75
- */
76
- transparent: boolean;
77
57
  /**
78
58
  * Set character max limit
79
59
  */
@@ -82,32 +62,6 @@ export declare class TextField extends ControlElement {
82
62
  * Set character min limit
83
63
  */
84
64
  minLength: number | null;
85
- /**
86
- * Get native input element from shadow roots
87
- */
88
- private inputElement;
89
- /**
90
- * Selection start index
91
- */
92
- get selectionStart(): number | null;
93
- set selectionStart(index: SelectionIndex);
94
- /**
95
- * Selection end index
96
- */
97
- get selectionEnd(): number | null;
98
- set selectionEnd(index: SelectionIndex);
99
- /**
100
- * Select the contents of input
101
- * @returns void
102
- */
103
- select(): void;
104
- /**
105
- * Set the selection range
106
- * @param startSelection Start of selection
107
- * @param endSelection End of the selection
108
- * @returns {void}
109
- */
110
- setSelectionRange(startSelection: number, endSelection: number): void;
111
65
  /**
112
66
  * Called after the component is first rendered
113
67
  * @param changedProperties Properties which have changed
@@ -125,58 +79,62 @@ export declare class TextField extends ControlElement {
125
79
  * @param changedProperties Properties that has changed
126
80
  * @returns True if input should be re-validated
127
81
  */
128
- private shouldValidateInput;
82
+ protected shouldValidateInput(changedProperties: PropertyValues): boolean;
129
83
  /**
130
- * Renders icon element if property present
84
+ * Runs on input element `input` event
85
+ * @param event `input` event
131
86
  * @returns {void}
132
87
  */
133
- private renderIcon;
88
+ protected onInputInput(event: InputEvent): void;
134
89
  /**
135
- * A `TemplateResult` that will be used
136
- * to render the updated internal template.
137
- * @return Render template
90
+ * Runs on input element `change` event
91
+ * @param event `change` event
92
+ * @returns {void}
138
93
  */
139
- protected render(): TemplateResult;
94
+ protected onInputChange(event: InputEvent): void;
140
95
  /**
141
96
  * Check if value is changed and fire event
142
97
  * @returns {void}
143
98
  */
144
- private onPossibleValueChange;
99
+ protected onPossibleValueChange(event: InputEvent): void;
145
100
  /**
146
101
  * Validate input according `pattern`, `minLength` and `maxLength` properties
147
102
  * change state of `error` property according pattern validation
148
- * @returns void
103
+ * @returns {void}
149
104
  */
150
- private validateInput;
105
+ protected validateInput(): void;
151
106
  /**
152
107
  * @param error existing state of error
153
108
  * @returns true if there is no error and browser is IE11 and minLength more than 0 and value exists
154
109
  */
155
- private shouldValidateForMinLength;
110
+ protected shouldValidateForMinLength(error: boolean): boolean;
156
111
  /**
157
112
  * Fires event on `icon` click
158
113
  * @returns {void}
159
114
  */
160
- private iconClick;
115
+ protected iconClick(): void;
161
116
  /**
162
- * Handles the focus event
163
- * @returns {void}
117
+ * Decorate `<input>` element with common properties extended from form field element:
118
+ * type="text" - always `text`
119
+ * part="input" - always "input", used for styling
120
+ * maxlength - calculated from `this.maxLength`
121
+ * minlength - calculated from `this.minLength`
122
+ * pattern - calculated from `this.pattern`
123
+ * @returns template map
164
124
  */
165
- private onFocus;
125
+ protected get decorateInputMap(): TemplateMap;
166
126
  /**
167
- * Query field's label from host to native input
168
- * to support aria label when using screen reader
127
+ * Renders icon element if property present
169
128
  * @returns {void}
170
129
  */
171
- private queryFieldLabel;
130
+ protected renderIcon(): TemplateResult | null;
172
131
  /**
173
- * Query field's description from host to native input
174
- * to support aria description when using screen reader
175
- * @returns {void}
132
+ * A `TemplateResult` that will be used
133
+ * to render the updated internal template.
134
+ * @return Render template
176
135
  */
177
- private queryFieldDescription;
136
+ protected render(): TemplateResult;
178
137
  }
179
- export {};
180
138
 
181
139
  declare global {
182
140
  interface HTMLElementTagNameMap {
@@ -185,7 +143,7 @@ declare global {
185
143
 
186
144
  namespace JSX {
187
145
  interface IntrinsicElements {
188
- 'ef-text-field': Partial<TextField> | JSXInterface.ControlHTMLAttributes<TextField>;
146
+ 'ef-text-field': Partial<TextField> | JSXInterface.HTMLAttributes<TextField>;
189
147
  }
190
148
  }
191
149
  }
@@ -1,8 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
- import { ControlElement, css, html } from '@refinitiv-ui/core';
2
+ import { FormFieldElement, css, html } 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
- import { query } from '@refinitiv-ui/core/lib/decorators/query.js';
6
5
  import { ifDefined } from '@refinitiv-ui/core/lib/directives/if-defined.js';
7
6
  import { VERSION } from '../version.js';
8
7
  import { isIE } from '@refinitiv-ui/utils/lib/browser.js';
@@ -10,68 +9,48 @@ import '../icon/index.js';
10
9
  import { registerOverflowTooltip } from '../tooltip/index.js';
11
10
  const hasChanged = (newVal, oldVal) => oldVal === undefined ? false : newVal !== oldVal;
12
11
  /**
13
- * Form control element for text
12
+ * Form control element for text.
14
13
  *
15
14
  * @fires value-changed - Dispatched when value changes
16
15
  * @fires error-changed - Dispatched when error state changes
16
+ * @fires icon-click - Dispatched when icon is clicked
17
17
  *
18
- * @attr {string} value - Input's value
19
- * @prop {string} [value=] - Input's value
18
+ * @attr {boolean} disabled - Set disabled state
19
+ * @prop {boolean} [disabled=false] - Set disabled state
20
+ *
21
+ * @attr {boolean} error - Set error state
22
+ * @prop {boolean} [error=false] - Set error state
23
+ *
24
+ * @attr {string} placeholder - Set placeholder text
25
+ * @prop {string} [placeholder=""] - Set placeholder text
20
26
  *
21
27
  * @attr {boolean} readonly - Set readonly state
22
28
  * @prop {boolean} [readonly=false] - Set readonly state
23
29
  *
24
- * @attr {boolean} disabled - Set disabled state
25
- * @prop {boolean} [disabled=false] - Set disabled state
30
+ * @attr {boolean} transparent - Disables all other states and border/background styles.
31
+ * @prop {boolean} [transparent=false] - Disables all other states and border/background styles.
32
+ *
33
+ * @attr {boolean} warning - Set warning state
34
+ * @prop {boolean} [warning=false] - Set warning state
35
+ *
36
+ * @attr {string} value - Input's value
37
+ * @prop {string} [value=""] - Input's value
26
38
  */
27
- let TextField = class TextField extends ControlElement {
39
+ let TextField = class TextField extends FormFieldElement {
28
40
  constructor() {
29
41
  super(...arguments);
30
42
  /**
31
43
  * Set regular expression for input validation
32
44
  */
33
45
  this.pattern = '';
34
- /**
35
- * Set place holder text
36
- */
37
- this.placeholder = '';
38
- /**
39
- * Set state to error
40
- */
41
- this.error = false;
42
- /**
43
- * Aria indicating if the field is required
44
- * @ignore
45
- */
46
- this.ariaRequired = 'false';
47
- /**
48
- * Aria description used to describe input or error to screen reader
49
- * @ignore
50
- */
51
- this.ariaDescription = '';
52
- /**
53
- * Aria label used to label input to screen reader
54
- * @ignore
55
- */
56
- this.ariaLabel = '';
57
- /**
58
- * Set state to warning
59
- */
60
- this.warning = false;
61
46
  /**
62
47
  * Specify icon to display in input. Value can be icon name
63
48
  */
64
- this.icon = '';
49
+ this.icon = null;
65
50
  /**
66
51
  * Specify when icon need to be clickable
67
52
  */
68
53
  this.iconHasAction = false;
69
- /**
70
- * Disables all other states and border/background styles.
71
- * Use with advanced composite elements requiring e.g. multi selection in
72
- * combo-box when parent container handles element states.
73
- */
74
- this.transparent = false;
75
54
  /**
76
55
  * Set character max limit
77
56
  */
@@ -122,42 +101,6 @@ let TextField = class TextField extends ControlElement {
122
101
  }
123
102
  `;
124
103
  }
125
- /**
126
- * Selection start index
127
- */
128
- get selectionStart() {
129
- return this.inputElement.selectionStart;
130
- }
131
- set selectionStart(index) {
132
- this.inputElement.selectionStart = index;
133
- }
134
- /**
135
- * Selection end index
136
- */
137
- get selectionEnd() {
138
- return this.inputElement.selectionEnd;
139
- }
140
- set selectionEnd(index) {
141
- this.inputElement.selectionEnd = index;
142
- }
143
- /**
144
- * Select the contents of input
145
- * @returns void
146
- */
147
- select() {
148
- if (!this.disabled && !this.readonly) {
149
- this.inputElement.select();
150
- }
151
- }
152
- /**
153
- * Set the selection range
154
- * @param startSelection Start of selection
155
- * @param endSelection End of the selection
156
- * @returns {void}
157
- */
158
- setSelectionRange(startSelection, endSelection) {
159
- this.inputElement.setSelectionRange(startSelection, endSelection);
160
- }
161
104
  /**
162
105
  * Called after the component is first rendered
163
106
  * @param changedProperties Properties which have changed
@@ -165,8 +108,9 @@ let TextField = class TextField extends ControlElement {
165
108
  */
166
109
  firstUpdated(changedProperties) {
167
110
  super.firstUpdated(changedProperties);
168
- registerOverflowTooltip(this.inputElement, () => this.value);
169
- this.addEventListener('focus', this.onFocus);
111
+ if (this.inputElement) {
112
+ registerOverflowTooltip(this.inputElement, () => this.value);
113
+ }
170
114
  }
171
115
  /**
172
116
  * Called when the element’s DOM has been updated and rendered
@@ -175,8 +119,8 @@ let TextField = class TextField extends ControlElement {
175
119
  */
176
120
  updated(changedProperties) {
177
121
  super.updated(changedProperties);
178
- if (this.inputElement.value !== this.value) {
179
- this.inputElement.value = this.value;
122
+ if (this.inputValue !== this.value) {
123
+ this.inputValue = this.value;
180
124
  }
181
125
  if (this.shouldValidateInput(changedProperties)) {
182
126
  this.validateInput();
@@ -187,83 +131,58 @@ let TextField = class TextField extends ControlElement {
187
131
  * @param changedProperties Properties that has changed
188
132
  * @returns True if input should be re-validated
189
133
  */
134
+ /* istanbul ignore next */
190
135
  shouldValidateInput(changedProperties) {
136
+ // TODO: This validation should be refactored
191
137
  return (changedProperties.has('pattern') || !!(this.pattern && changedProperties.has('value')))
192
- || (changedProperties.has('minLength') || !!(this.minLength && changedProperties.has('value')));
138
+ || (changedProperties.has('minLength') || !!(this.minLength && changedProperties.has('value')))
139
+ || (changedProperties.has('maxLength') || !!(this.maxLength && changedProperties.has('value')));
193
140
  }
194
141
  /**
195
- * Renders icon element if property present
142
+ * Runs on input element `input` event
143
+ * @param event `input` event
196
144
  * @returns {void}
197
145
  */
198
- renderIcon() {
199
- return this.icon ? html `
200
- <ef-icon
201
- role="${ifDefined(this.iconHasAction ? 'button' : undefined)}"
202
- part="icon"
203
- icon="${this.icon}"
204
- aria-label="${ifDefined(this.iconHasAction ? this.icon : undefined)}"
205
- ?readonly="${this.readonly}"
206
- ?disabled="${this.disabled}"
207
- @tap="${this.iconClick}"
208
- tabindex="${ifDefined(this.iconHasAction ? '0' : undefined)}"
209
- ></ef-icon>
210
- ` : null;
146
+ onInputInput(event) {
147
+ this.onPossibleValueChange(event);
211
148
  }
212
149
  /**
213
- * A `TemplateResult` that will be used
214
- * to render the updated internal template.
215
- * @return Render template
150
+ * Runs on input element `change` event
151
+ * @param event `change` event
152
+ * @returns {void}
216
153
  */
217
- render() {
218
- return html `
219
- <input
220
- type="text"
221
- part="input"
222
- aria-required="${this.ariaRequired}"
223
- aria-label="${ifDefined(this.ariaLabel || undefined)}"
224
- aria-invalid="${ifDefined(this.error || undefined)}"
225
- aria-description="${ifDefined(this.ariaDescription || undefined)}"
226
- ?readonly="${this.readonly}"
227
- ?disabled="${this.disabled}"
228
- placeholder="${ifDefined(this.placeholder || undefined)}"
229
- maxlength="${ifDefined(this.maxLength || undefined)}"
230
- minlength="${ifDefined(this.minLength || undefined)}"
231
- @input="${this.onPossibleValueChange}"
232
- @change="${this.onPossibleValueChange}"
233
- pattern="${ifDefined(this.pattern || undefined)}"
234
- autocomplete="off"
235
- />
236
- ${this.renderIcon()}
237
- `;
154
+ onInputChange(event) {
155
+ this.onPossibleValueChange(event);
238
156
  }
239
157
  /**
240
158
  * Check if value is changed and fire event
241
159
  * @returns {void}
242
160
  */
243
- onPossibleValueChange() {
244
- const value = this.inputElement.value;
161
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
162
+ onPossibleValueChange(event) {
163
+ var _a;
164
+ const value = ((_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.value) || '';
245
165
  this.setValueAndNotify(value);
246
166
  }
247
167
  /**
248
168
  * Validate input according `pattern`, `minLength` and `maxLength` properties
249
169
  * change state of `error` property according pattern validation
250
- * @returns void
170
+ * @returns {void}
251
171
  */
252
172
  validateInput() {
253
- let error = !this.inputElement.checkValidity();
173
+ var _a;
174
+ let error = !((_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.checkValidity());
175
+ /* istanbul ignore next */
254
176
  if (this.shouldValidateForMinLength(error)) {
255
177
  error = !!this.minLength && (this.minLength > this.value.length);
256
178
  }
257
- if (this.error !== error) {
258
- this.error = error;
259
- this.notifyPropertyChange('error', this.error);
260
- this.queryFieldDescription();
261
- }
179
+ this.notifyErrorChange(error);
262
180
  }
263
181
  /**
264
182
  * @param error existing state of error
265
183
  * @returns true if there is no error and browser is IE11 and minLength more than 0 and value exists
266
184
  */
185
+ /* istanbul ignore next */
267
186
  shouldValidateForMinLength(error) {
268
187
  return !!(!error && isIE && this.minLength && !!this.value);
269
188
  }
@@ -272,135 +191,67 @@ let TextField = class TextField extends ControlElement {
272
191
  * @returns {void}
273
192
  */
274
193
  iconClick() {
275
- if (this.iconHasAction) {
276
- /**
277
- * Dispatched only when element has icon-has-action attribute and icon is clicked
278
- */
194
+ if (this.iconHasAction && !this.disabled) {
279
195
  this.dispatchEvent(new CustomEvent('icon-click', { bubbles: false }));
280
196
  }
281
197
  }
282
198
  /**
283
- * Handles the focus event
284
- * @returns {void}
199
+ * Decorate `<input>` element with common properties extended from form field element:
200
+ * type="text" - always `text`
201
+ * part="input" - always "input", used for styling
202
+ * maxlength - calculated from `this.maxLength`
203
+ * minlength - calculated from `this.minLength`
204
+ * pattern - calculated from `this.pattern`
205
+ * @returns template map
285
206
  */
286
- onFocus() {
287
- this.queryFieldLabel();
288
- this.queryFieldDescription();
207
+ get decorateInputMap() {
208
+ return Object.assign(Object.assign({}, super.decorateInputMap), { 'type': 'text', 'part': 'input', 'maxlength': this.maxLength, 'minlength': this.minLength, 'pattern': this.pattern || null });
289
209
  }
290
210
  /**
291
- * Query field's label from host to native input
292
- * to support aria label when using screen reader
211
+ * Renders icon element if property present
293
212
  * @returns {void}
294
213
  */
295
- queryFieldLabel() {
296
- if (this.hasAttribute('aria-labelledby')) {
297
- const ids = this.getAttribute('aria-labelledby');
298
- if (!ids) {
299
- return;
300
- }
301
- const elementIds = ids.split(' ');
302
- elementIds.forEach(id => {
303
- const element = document.getElementById(id);
304
- if (!element) {
305
- return;
306
- }
307
- const label = element.textContent || '';
308
- if (this.ariaLabel && label) {
309
- this.ariaLabel += ' ';
310
- }
311
- this.ariaLabel += label;
312
- });
313
- }
314
- else if (this.hasAttribute('aria-label')) {
315
- this.ariaLabel = this.getAttribute('aria-label') || '';
316
- }
317
- else if (this.id) {
318
- const labelForElement = document.querySelector(`label[for="${this.id}"]`);
319
- if (!labelForElement) {
320
- return;
321
- }
322
- this.ariaLabel = labelForElement.textContent || '';
323
- }
214
+ renderIcon() {
215
+ return this.icon ? html `
216
+ <ef-icon
217
+ role="${ifDefined(this.iconHasAction ? 'button' : undefined)}"
218
+ part="icon"
219
+ icon="${this.icon}"
220
+ aria-label="${ifDefined(this.iconHasAction ? this.icon : undefined)}"
221
+ ?readonly="${this.readonly}"
222
+ ?disabled="${this.disabled}"
223
+ @tap="${this.iconClick}"
224
+ tabindex="${ifDefined(this.iconHasAction ? '0' : undefined)}"
225
+ ></ef-icon>
226
+ ` : null;
324
227
  }
325
228
  /**
326
- * Query field's description from host to native input
327
- * to support aria description when using screen reader
328
- * @returns {void}
229
+ * A `TemplateResult` that will be used
230
+ * to render the updated internal template.
231
+ * @return Render template
329
232
  */
330
- queryFieldDescription() {
331
- if (!this.hasAttribute('aria-describedby')) {
332
- // Support `aria-description` only if `aria-describedby` is not in use.
333
- if (!this.hasAttribute('aria-description')) {
334
- return;
335
- }
336
- this.ariaDescription = this.getAttribute('aria-description') || '';
337
- return;
338
- }
339
- this.ariaDescription = '';
340
- const ids = this.getAttribute('aria-describedby');
341
- if (!ids) {
342
- return;
343
- }
344
- // In scenarios where there is multiple ids
345
- const elementIds = ids.split(' ');
346
- elementIds.forEach(id => {
347
- const element = document.getElementById(id);
348
- if (!element) {
349
- return;
350
- }
351
- const text = element.textContent || '';
352
- if (this.ariaDescription && text) {
353
- this.ariaDescription += ' ';
354
- }
355
- this.ariaDescription += text;
356
- });
233
+ render() {
234
+ return html `
235
+ ${super.render()}
236
+ ${this.renderIcon()}
237
+ `;
357
238
  }
358
239
  };
359
240
  __decorate([
360
241
  property({ type: String, hasChanged })
361
242
  ], TextField.prototype, "pattern", void 0);
362
- __decorate([
363
- property({ type: String })
364
- ], TextField.prototype, "placeholder", void 0);
365
- __decorate([
366
- property({ type: Boolean, reflect: true })
367
- ], TextField.prototype, "error", void 0);
368
- __decorate([
369
- property({ type: String, attribute: 'aria-required' })
370
- ], TextField.prototype, "ariaRequired", void 0);
371
- __decorate([
372
- property({ type: String })
373
- ], TextField.prototype, "ariaDescription", void 0);
374
- __decorate([
375
- property({ type: String })
376
- ], TextField.prototype, "ariaLabel", void 0);
377
- __decorate([
378
- property({ type: Boolean, reflect: true })
379
- ], TextField.prototype, "warning", void 0);
380
243
  __decorate([
381
244
  property({ type: String, reflect: true })
382
245
  ], TextField.prototype, "icon", void 0);
383
246
  __decorate([
384
247
  property({ type: Boolean, reflect: true, attribute: 'icon-has-action' })
385
248
  ], TextField.prototype, "iconHasAction", void 0);
386
- __decorate([
387
- property({ type: Boolean, reflect: true })
388
- ], TextField.prototype, "transparent", void 0);
389
249
  __decorate([
390
250
  property({ type: Number, attribute: 'maxlength', reflect: true })
391
251
  ], TextField.prototype, "maxLength", void 0);
392
252
  __decorate([
393
253
  property({ type: Number, attribute: 'minlength', reflect: true, hasChanged })
394
254
  ], TextField.prototype, "minLength", void 0);
395
- __decorate([
396
- query('[part="input"]')
397
- ], TextField.prototype, "inputElement", void 0);
398
- __decorate([
399
- property({ type: Number, attribute: false })
400
- ], TextField.prototype, "selectionStart", null);
401
- __decorate([
402
- property({ type: Number, attribute: false })
403
- ], TextField.prototype, "selectionEnd", null);
404
255
  TextField = __decorate([
405
256
  customElement('ef-text-field', {
406
257
  alias: 'coral-text-field'
@@ -8,10 +8,10 @@ Control the time input
8
8
  |---------------|----------------|------------------|---------|--------------------------------------------------|
9
9
  | `amPm` | `am-pm` | `boolean` | false | Toggles 12hr time display |
10
10
  | `disabled` | `disabled` | `boolean` | false | Set disabled state |
11
- | `hours` | `hours` | `number \| null` | | Hours time segment in 24hr format |
12
- | `minutes` | `minutes` | `number \| null` | | Minutes time segment |
11
+ | `hours` | `hours` | `number \| null` | null | Hours time segment in 24hr format |
12
+ | `minutes` | `minutes` | `number \| null` | null | Minutes time segment |
13
13
  | `readonly` | `readonly` | `boolean` | false | Set readonly state |
14
- | `seconds` | `seconds` | `number \| null` | | Seconds time segment |
14
+ | `seconds` | `seconds` | `number \| null` | null | Seconds time segment |
15
15
  | `showSeconds` | `show-seconds` | `boolean` | false | Flag to show seconds time segment in display.<br />Seconds are automatically shown when `hh:mm:ss` time format is provided as a value. |
16
16
  | `value` | `value` | `string` | "" | Value of the element |
17
17