@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,250 +1,81 @@
1
1
  import { __decorate } from "tslib";
2
- import { ControlElement, css, html } from '@refinitiv-ui/core';
2
+ import { html } from '@refinitiv-ui/core';
3
3
  import { customElement } from '@refinitiv-ui/core/lib/decorators/custom-element.js';
4
- import { property } from '@refinitiv-ui/core/lib/decorators/property.js';
5
- import { query } from '@refinitiv-ui/core/lib/decorators/query.js';
6
4
  import { ifDefined } from '@refinitiv-ui/core/lib/directives/if-defined.js';
7
- import { VERSION } from '../version.js';
8
- import { isIE } from '@refinitiv-ui/utils/lib/browser.js';
9
5
  import '../icon/index.js';
10
- const hasChanged = (newVal, oldVal) => oldVal === undefined ? false : newVal !== oldVal;
6
+ import { TextField } from '../text-field/index.js';
7
+ import { translate } from '@refinitiv-ui/translate';
8
+ import '@refinitiv-ui/phrasebook/lib/locale/en/search-field.js';
11
9
  /**
12
10
  * Form control to get a search input from users.
13
11
  *
14
12
  * @fires value-changed - Dispatched when value changes
15
13
  * @fires error-changed - Dispatched when error state changes
14
+ * @fires icon-click - Dispatched when icon is clicked
16
15
  *
17
- * @attr {string} value - Input's value
18
- * @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 {boolean} icon-has-action - Specify when icon need to be clickable
23
+ * @prop {boolean} [iconHasAction=false] - Specify when icon need to be clickable
24
+ *
25
+ * @attr {number} maxlength - Set character max limit
26
+ * @prop {number | null} [maxLength=null] - Set character max limit
27
+ *
28
+ * @attr {number} minlength - Set character min limit
29
+ * @prop {number | null} [minLength=null] - Set character min limit
30
+ *
31
+ * @prop {string} [pattern=""] - Set regular expression for input validation
32
+ *
33
+ * @attr {string} placeholder - Set placeholder text
34
+ * @prop {string} [placeholder=""] - Set placeholder text
19
35
  *
20
36
  * @attr {boolean} readonly - Set readonly state
21
37
  * @prop {boolean} [readonly=false] - Set readonly state
22
38
  *
23
- * @attr {boolean} disabled - Set disabled state
24
- * @prop {boolean} [disabled=false] - Set disabled state
39
+ * @attr {boolean} transparent - Disables all other states and border/background styles.
40
+ * @prop {boolean} [transparent=false] - Disables all other states and border/background styles.
41
+ *
42
+ * @attr {boolean} warning - Set warning state
43
+ * @prop {boolean} [warning=false] - Set warning state
44
+ *
45
+ * @attr {string} value - Input's value
46
+ * @prop {string} [value=""] - Input's value
25
47
  */
26
- let SearchField = class SearchField extends ControlElement {
27
- constructor() {
28
- super(...arguments);
29
- /**
30
- * Set regular expression for input validation
31
- */
32
- this.pattern = '';
33
- /**
34
- * Set place holder text
35
- */
36
- this.placeholder = '';
37
- /**
38
- * Set state to error
39
- */
40
- this.error = false;
41
- /**
42
- * Set state to warning
43
- */
44
- this.warning = false;
45
- /**
46
- * Disables all other states and border/background styles.
47
- * Use with advanced composite elements requiring e.g. multi selection in
48
- * combo-box when parent container handles element states.
49
- */
50
- this.transparent = false;
51
- /**
52
- * Set character max limit
53
- */
54
- this.maxLength = null;
55
- /**
56
- * Set character min limit
57
- */
58
- this.minLength = null;
59
- /**
60
- * Specify when icon need to be clickable
61
- */
62
- this.iconHasAction = false;
63
- }
48
+ let SearchField = class SearchField extends TextField {
64
49
  /**
65
- * Element version number
66
- * @returns version number
50
+ * Decorate `<input>` element with common properties extended from text-field:
51
+ * type="search" - always `search`
52
+ * @returns template map
67
53
  */
68
- static get version() {
69
- return VERSION;
54
+ get decorateInputMap() {
55
+ return Object.assign(Object.assign({}, super.decorateInputMap), { 'type': 'search', 'inputmode': 'search' });
70
56
  }
71
57
  /**
72
- * A `CSSResultGroup` that will be used
73
- * to style the host, slotted children
74
- * and the internal template of the element.
75
- * @return CSS template
76
- */
77
- static get styles() {
78
- return css `
79
- :host {
80
- display: inline-block;
81
- }
82
- :host(:focus), :host input:focus {
83
- outline: none;
84
- }
85
- [part=input] {
86
- font: inherit;
87
- background: none;
88
- color: currentColor;
89
- border: none;
90
- text-align: inherit;
91
- }
92
- :host [part=icon]{
93
- display: flex;
94
- outline: none;
95
- }
96
- :host([transparent]) {
97
- background: none !important;
98
- border: none !important;
99
- }
100
- :host([icon-has-action]) [part=icon] {
101
- cursor: pointer;
102
- }
103
- `;
104
- }
105
- /**
106
- * Select the contents of input
107
- * @returns void
108
- */
109
- select() {
110
- if (!this.disabled && !this.readonly) {
111
- this.inputElement.select();
112
- }
113
- }
114
- /**
115
- * A `TemplateResult` that will be used
116
- * to render the updated internal template.
117
- * @return Render template
58
+ * Renders icon element
59
+ * @returns {void}
118
60
  */
119
- render() {
61
+ renderIcon() {
120
62
  return html `
121
- <input
122
- type="search"
123
- part="input"
124
- ?readonly="${this.readonly}"
125
- ?disabled="${this.disabled}"
126
- placeholder="${ifDefined(this.placeholder || undefined)}"
127
- maxlength="${ifDefined(this.maxLength || undefined)}"
128
- minlength="${ifDefined(this.minLength || undefined)}"
129
- @input="${this.onPossibleValueChange}"
130
- @change="${this.onPossibleValueChange}"
131
- pattern="${ifDefined(this.pattern || undefined)}"
132
- autocomplete="off"
133
- />
134
63
  <ef-icon
135
64
  part="icon"
65
+ role="${ifDefined(this.iconHasAction ? 'button' : undefined)}"
136
66
  icon="search"
67
+ aria-label="${this.t('SEARCH')}"
137
68
  ?readonly="${this.readonly}"
138
69
  ?disabled="${this.disabled}"
139
- @tap="${this.notifyIcon}"
140
- @keydown="${this.handleKeyDown}"
70
+ @tap="${this.iconClick}"
141
71
  tabindex="${ifDefined(this.iconHasAction ? '0' : undefined)}"
142
72
  ></ef-icon>
143
73
  `;
144
74
  }
145
- /**
146
- * Called when the element’s DOM has been updated and rendered
147
- * @param changedProperties Properties that has changed
148
- * @returns {void}
149
- */
150
- updated(changedProperties) {
151
- super.updated(changedProperties);
152
- if (this.inputElement.value !== this.value) {
153
- this.inputElement.value = this.value;
154
- }
155
- if (this.shouldValidateInput(changedProperties)) {
156
- this.validateInput();
157
- }
158
- }
159
- /**
160
- * Check if input should be re-validated
161
- * @param changedProperties Properties that has changed
162
- * @returns True if input should be re-validated
163
- */
164
- shouldValidateInput(changedProperties) {
165
- return (changedProperties.has('pattern') || !!(this.pattern && changedProperties.has('value')))
166
- || (changedProperties.has('minLength') || !!(this.minLength && changedProperties.has('value')));
167
- }
168
- /**
169
- * validate input according `pattern`, `minLength` and `maxLength` properties
170
- * change state of `error` property according pattern validation
171
- * @returns {void}
172
- */
173
- validateInput() {
174
- let error = !this.inputElement.checkValidity();
175
- if (this.shouldValidateForMinLength(error)) {
176
- error = !!this.minLength && (this.minLength > this.value.length);
177
- }
178
- if (this.error !== error) {
179
- this.error = error;
180
- this.notifyPropertyChange('error', this.error);
181
- }
182
- }
183
- /**
184
- * @param error existing state of error
185
- * @returns true if there is no error and browser is IE11 and minLength more than 0 and value exists
186
- */
187
- shouldValidateForMinLength(error) {
188
- return !!(!error && isIE && this.minLength && !!this.value);
189
- }
190
- /**
191
- * Check if value is changed
192
- * @returns {void}
193
- */
194
- onPossibleValueChange() {
195
- const value = this.inputElement.value;
196
- this.setValueAndNotify(value);
197
- }
198
- /**
199
- * Detect `enter` and `space` keydown and fire
200
- * @param event keydown event
201
- * @returns {void}
202
- */
203
- handleKeyDown(event) {
204
- if (event.key === 'Spacebar' || event.key === ' ' || event.key === 'Enter') {
205
- this.notifyIcon();
206
- }
207
- }
208
- /**
209
- * Fire event on icon click
210
- * @returns {void}
211
- */
212
- notifyIcon() {
213
- if (this.iconHasAction) {
214
- /**
215
- * Dispatched only when element has icon-has-action attribute and icon is clicked
216
- */
217
- this.dispatchEvent(new CustomEvent('icon-click', { bubbles: false }));
218
- }
219
- }
220
75
  };
221
76
  __decorate([
222
- property({ type: String, hasChanged })
223
- ], SearchField.prototype, "pattern", void 0);
224
- __decorate([
225
- property({ type: String })
226
- ], SearchField.prototype, "placeholder", void 0);
227
- __decorate([
228
- property({ type: Boolean, reflect: true })
229
- ], SearchField.prototype, "error", void 0);
230
- __decorate([
231
- property({ type: Boolean, reflect: true })
232
- ], SearchField.prototype, "warning", void 0);
233
- __decorate([
234
- property({ type: Boolean, reflect: true })
235
- ], SearchField.prototype, "transparent", void 0);
236
- __decorate([
237
- property({ type: Number, attribute: 'maxlength', reflect: true })
238
- ], SearchField.prototype, "maxLength", void 0);
239
- __decorate([
240
- property({ type: Number, attribute: 'minlength', reflect: true, hasChanged })
241
- ], SearchField.prototype, "minLength", void 0);
242
- __decorate([
243
- property({ type: Boolean, reflect: true, attribute: 'icon-has-action' })
244
- ], SearchField.prototype, "iconHasAction", void 0);
245
- __decorate([
246
- query('[part="input"]')
247
- ], SearchField.prototype, "inputElement", void 0);
77
+ translate({ scope: 'ef-search-field' })
78
+ ], SearchField.prototype, "t", void 0);
248
79
  SearchField = __decorate([
249
80
  customElement('ef-search-field', {
250
81
  alias: 'coral-search-field'
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "properties": [
40
40
  {
41
- "name": "label",
41
+ "name": "label (readonly)",
42
42
  "description": "Current text content of the selected value",
43
43
  "type": "string"
44
44
  },
@@ -78,7 +78,8 @@
78
78
  {
79
79
  "name": "value",
80
80
  "description": "Value of the element",
81
- "type": "string"
81
+ "type": "string",
82
+ "default": "\"\""
82
83
  },
83
84
  {
84
85
  "name": "disabled",
@@ -5,16 +5,16 @@ providing a fully themeable dropdown element.
5
5
 
6
6
  ## Properties
7
7
 
8
- | Property | Attribute | Modifiers | Type | Default | Description |
9
- |---------------|---------------|-----------|----------------------|---------|--------------------------------------------------|
10
- | `data` | | | `SelectData \| null` | | Construct the menu from data object. Cannot be used with slotted content |
11
- | `disabled` | `disabled` | | `boolean` | false | Set disabled state |
12
- | `error` | `error` | | `boolean` | false | Set state to error |
13
- | `label` | | readonly | `string` | | Current text content of the selected value |
14
- | `opened` | `opened` | | `boolean` | false | Toggles the opened state of the list |
15
- | `placeholder` | `placeholder` | | `string` | "" | Placeholder to display when no value is set |
16
- | `value` | | | `string` | | Value of the element |
17
- | `warning` | `warning` | | `boolean` | false | Set state to warning |
8
+ | Property | Attribute | Type | Default | Description |
9
+ |--------------------|---------------|----------------------|---------|--------------------------------------------------|
10
+ | `data` | | `SelectData \| null` | null | Construct the menu from data object. Cannot be used with slotted content |
11
+ | `disabled` | `disabled` | `boolean` | false | Set disabled state |
12
+ | `error` | `error` | `boolean` | false | Set state to error |
13
+ | `label (readonly)` | | `string` | | Current text content of the selected value |
14
+ | `opened` | `opened` | `boolean` | false | Toggles the opened state of the list |
15
+ | `placeholder` | `placeholder` | `string` | "" | Placeholder to display when no value is set |
16
+ | `value` | | `string` | "" | Value of the element |
17
+ | `warning` | `warning` | `boolean` | false | Set state to warning |
18
18
 
19
19
  ## Events
20
20
 
@@ -4,7 +4,7 @@ import '../overlay/index.js';
4
4
  import '../item/index.js';
5
5
  import '../icon/index.js';
6
6
  import type { SelectData, SelectDataItem } from './helpers/types';
7
- export { SelectData, SelectDataItem };
7
+ export type { SelectData, SelectDataItem };
8
8
  /**
9
9
  * Expands upon the native select element,
10
10
  * providing a fully themeable dropdown element.
@@ -21,6 +21,7 @@ export declare class Select extends ControlElement implements MultiValue {
21
21
  * @returns version number
22
22
  */
23
23
  static get version(): string;
24
+ protected readonly defaultRole: string | null;
24
25
  /**
25
26
  * A `CSSResultGroup` that will be used
26
27
  * to style the host, slotted children
@@ -79,6 +80,7 @@ export declare class Select extends ControlElement implements MultiValue {
79
80
  /**
80
81
  * Construct the menu from data object. Cannot be used with slotted content
81
82
  * @type {SelectData | null}
83
+ * @default null
82
84
  */
83
85
  get data(): SelectData | null;
84
86
  set data(value: SelectData | null);
@@ -91,6 +93,7 @@ export declare class Select extends ControlElement implements MultiValue {
91
93
  /**
92
94
  * Value of the element
93
95
  * @param value Element value
96
+ * @default -
94
97
  */
95
98
  set value(value: string);
96
99
  get value(): string;
@@ -101,6 +104,11 @@ export declare class Select extends ControlElement implements MultiValue {
101
104
  */
102
105
  get values(): string[];
103
106
  private menuEl?;
107
+ /**
108
+ * Called when connected to DOM
109
+ * @returns {void}
110
+ */
111
+ connectedCallback(): void;
104
112
  /**
105
113
  * Updates the element
106
114
  * @param changedProperties Properties that has changed
@@ -239,8 +247,8 @@ export declare class Select extends ControlElement implements MultiValue {
239
247
  */
240
248
  private isValidFilterKey;
241
249
  /**
242
- * Focus and highlight the next/previous element
243
- * @param direction Focus next or previous element
250
+ * Focus and highlight element according to specified direction
251
+ * @param direction previous, next, first or last focusable element
244
252
  * @returns {void}
245
253
  */
246
254
  private focusElement;
@@ -11,14 +11,6 @@ import '../icon/index.js';
11
11
  import { Item } from '../item/index.js';
12
12
  import { CollectionComposer } from '@refinitiv-ui/utils/lib/collection.js';
13
13
  import { TimeoutTaskRunner, AnimationTaskRunner } from '@refinitiv-ui/utils/lib/async.js';
14
- /**
15
- * Key direction
16
- */
17
- var Direction;
18
- (function (Direction) {
19
- Direction[Direction["Up"] = -1] = "Up";
20
- Direction[Direction["Down"] = 1] = "Down";
21
- })(Direction || (Direction = {}));
22
14
  // Observer config for items
23
15
  const observerOptions = {
24
16
  subtree: true,
@@ -36,6 +28,13 @@ const observerOptions = {
36
28
  const LABEL_SEPARATOR = ', '; // TODO: for multiselect
37
29
  const POPUP_POSITION = ['bottom-start', 'top-start'];
38
30
  const KEY_SEARCH_DEBOUNCER = 300;
31
+ var Navigation;
32
+ (function (Navigation) {
33
+ Navigation["FIRST"] = "First";
34
+ Navigation["LAST"] = "Last";
35
+ Navigation["NEXT"] = "Next";
36
+ Navigation["PREVIOUS"] = "Previous";
37
+ })(Navigation || (Navigation = {}));
39
38
  /**
40
39
  * Expands upon the native select element,
41
40
  * providing a fully themeable dropdown element.
@@ -49,6 +48,7 @@ const KEY_SEARCH_DEBOUNCER = 300;
49
48
  let Select = class Select extends ControlElement {
50
49
  constructor() {
51
50
  super(...arguments);
51
+ this.defaultRole = 'button';
52
52
  this.composer = new CollectionComposer([]);
53
53
  this._data = null;
54
54
  this.popupDynamicStyles = {}; /* set popup min-width based on select width or CSS vars */
@@ -213,6 +213,7 @@ let Select = class Select extends ControlElement {
213
213
  /**
214
214
  * Construct the menu from data object. Cannot be used with slotted content
215
215
  * @type {SelectData | null}
216
+ * @default null
216
217
  */
217
218
  get data() {
218
219
  return this._data;
@@ -239,6 +240,7 @@ let Select = class Select extends ControlElement {
239
240
  /**
240
241
  * Value of the element
241
242
  * @param value Element value
243
+ * @default -
242
244
  */
243
245
  set value(value) {
244
246
  value = this.castValue(value);
@@ -267,6 +269,15 @@ let Select = class Select extends ControlElement {
267
269
  }
268
270
  return this.selectedSlotItems.map(item => this.getItemValue(item));
269
271
  }
272
+ /**
273
+ * Called when connected to DOM
274
+ * @returns {void}
275
+ */
276
+ connectedCallback() {
277
+ super.connectedCallback();
278
+ // Indicating that this select has a popup of type listbox
279
+ this.setAttribute('aria-haspopup', 'listbox');
280
+ }
270
281
  /**
271
282
  * Updates the element
272
283
  * @param changedProperties Properties that has changed
@@ -290,6 +301,10 @@ let Select = class Select extends ControlElement {
290
301
  else {
291
302
  this.closing();
292
303
  }
304
+ this.setAttribute('aria-expanded', this.opened ? 'true' : 'false');
305
+ }
306
+ if (changedProperties.has('error')) {
307
+ this.setAttribute('aria-invalid', this.error ? 'true' : 'false');
293
308
  }
294
309
  super.update(changedProperties);
295
310
  }
@@ -541,14 +556,20 @@ let Select = class Select extends ControlElement {
541
556
  break;
542
557
  case 'Up':
543
558
  case 'ArrowUp':
544
- this.focusElement(Direction.Up);
559
+ this.focusElement(Navigation.PREVIOUS);
545
560
  break;
546
561
  case 'Down':
547
562
  case 'ArrowDown':
548
- this.focusElement(Direction.Down);
563
+ this.focusElement(Navigation.NEXT);
549
564
  break;
550
565
  case 'Tab':
551
- this.focusElement(event.shiftKey ? Direction.Up : Direction.Down);
566
+ this.focusElement(event.shiftKey ? Navigation.PREVIOUS : Navigation.NEXT);
567
+ break;
568
+ case 'Home':
569
+ this.focusElement(Navigation.FIRST);
570
+ break;
571
+ case 'End':
572
+ this.focusElement(Navigation.LAST);
552
573
  break;
553
574
  default:
554
575
  if (this.isValidFilterKey(event)) {
@@ -574,27 +595,42 @@ let Select = class Select extends ControlElement {
574
595
  && !event.metaKey;
575
596
  }
576
597
  /**
577
- * Focus and highlight the next/previous element
578
- * @param direction Focus next or previous element
598
+ * Focus and highlight element according to specified direction
599
+ * @param direction previous, next, first or last focusable element
579
600
  * @returns {void}
580
601
  */
581
602
  focusElement(direction) {
582
603
  const highlightedItem = this.highlightedItem || this.getSelectedElements()[0];
583
- const children = this.getSelectableElements();
584
- const idx = highlightedItem ? children.indexOf(highlightedItem) : -1;
585
- let focusElement;
586
- if (direction === 1) {
587
- focusElement = idx === -1 ? children[0] : children[idx + 1];
604
+ const selectableElements = this.getSelectableElements();
605
+ if (selectableElements.length === 0) {
606
+ return;
588
607
  }
589
- else {
590
- focusElement = idx === -1 ? children[children.length - 1] : children[idx - 1];
608
+ const index = highlightedItem ? selectableElements.indexOf(highlightedItem) : -1;
609
+ const firstElement = selectableElements[0];
610
+ const lastElement = selectableElements[selectableElements.length - 1];
611
+ let element;
612
+ switch (direction) {
613
+ case Navigation.PREVIOUS:
614
+ element = index === -1 ? lastElement : selectableElements[index - 1];
615
+ break;
616
+ case Navigation.NEXT:
617
+ element = index === -1 ? firstElement : selectableElements[index + 1];
618
+ break;
619
+ case Navigation.FIRST:
620
+ element = firstElement;
621
+ break;
622
+ case Navigation.LAST:
623
+ element = lastElement;
624
+ break;
625
+ default:
626
+ break;
591
627
  }
592
- if (!focusElement) {
593
- focusElement = direction === 1 ? children[0] : children[children.length - 1];
628
+ if (!element) {
629
+ element = direction === Navigation.NEXT ? firstElement : lastElement;
594
630
  }
595
- if (focusElement) {
596
- focusElement.focus();
597
- this.setItemHighlight(focusElement);
631
+ if (element) {
632
+ element.focus();
633
+ this.setItemHighlight(element);
598
634
  }
599
635
  }
600
636
  /**
@@ -805,15 +841,17 @@ let Select = class Select extends ControlElement {
805
841
  toItem(item) {
806
842
  switch (item.type) {
807
843
  case 'divider':
808
- return html `<ef-item part="item" type="divider"></ef-item>`;
844
+ return html `<ef-item role="presentation" part="item" type="divider"></ef-item>`;
809
845
  case 'header':
810
846
  return html `<ef-item
847
+ role="presentation"
811
848
  part="item"
812
849
  type="header"
813
850
  .label=${item.label}></ef-item>`;
814
851
  // no default
815
852
  }
816
853
  return html `<ef-item
854
+ role="option"
817
855
  part="item"
818
856
  .value=${item.value}
819
857
  .label=${item.label}
@@ -865,6 +903,7 @@ let Select = class Select extends ControlElement {
865
903
  tabindex="-1"
866
904
  id="menu"
867
905
  part="list"
906
+ role="listbox"
868
907
  style=${styleMap(this.popupDynamicStyles)}
869
908
  with-shadow
870
909
  lock-position-target
@@ -8,7 +8,7 @@
8
8
  {
9
9
  "name": "sidebar-width",
10
10
  "description": "Set the width of the sidebar. The value could be in both px or %, e.g. 300px, 30%",
11
- "type": "string"
11
+ "type": "string | undefined"
12
12
  },
13
13
  {
14
14
  "name": "collapsed",
@@ -28,7 +28,7 @@
28
28
  "name": "sidebarWidth",
29
29
  "attribute": "sidebar-width",
30
30
  "description": "Set the width of the sidebar. The value could be in both px or %, e.g. 300px, 30%",
31
- "type": "string"
31
+ "type": "string | undefined"
32
32
  },
33
33
  {
34
34
  "name": "collapsed",
@@ -43,10 +43,6 @@
43
43
  "description": "Set sidebar position to left or right",
44
44
  "type": "\"left\" | \"right\"",
45
45
  "default": "\"left\""
46
- },
47
- {
48
- "name": "sidebar",
49
- "description": "Property to get sidebar"
50
46
  }
51
47
  ],
52
48
  "slots": [
@@ -5,12 +5,11 @@ There are 4 sections that can be slotted a component in.
5
5
 
6
6
  ## Properties
7
7
 
8
- | Property | Attribute | Type | Default | Description |
9
- |-------------------|--------------------|---------------------|---------|--------------------------------------------------|
10
- | `collapsed` | `collapsed` | `boolean` | false | Set to hide sidebar |
11
- | `sidebar` | | | | Property to get sidebar |
12
- | `sidebarPosition` | `sidebar-position` | `"left" \| "right"` | "left" | Set sidebar position to left or right |
13
- | `sidebarWidth` | `sidebar-width` | `string` | | Set the width of the sidebar. The value could be in both px or %, e.g. 300px, 30% |
8
+ | Property | Attribute | Type | Default | Description |
9
+ |-------------------|--------------------|-----------------------|---------|--------------------------------------------------|
10
+ | `collapsed` | `collapsed` | `boolean` | false | Set to hide sidebar |
11
+ | `sidebarPosition` | `sidebar-position` | `"left" \| "right"` | "left" | Set sidebar position to left or right |
12
+ | `sidebarWidth` | `sidebar-width` | `string \| undefined` | | Set the width of the sidebar. The value could be in both px or %, e.g. 300px, 30% |
14
13
 
15
14
  ## Slots
16
15
 
@@ -26,7 +26,7 @@ export declare class SidebarLayout extends BasicElement {
26
26
  static get styles(): CSSResultGroup;
27
27
  /**
28
28
  * Set the width of the sidebar. The value could be in both px or %, e.g. 300px, 30%
29
- * @type {string}
29
+ * @type {string | undefined}
30
30
  */
31
31
  sidebarWidth?: string;
32
32
  /**
@@ -39,6 +39,7 @@ export declare class SidebarLayout extends BasicElement {
39
39
  sidebarPosition: 'left' | 'right';
40
40
  /**
41
41
  * Property to get sidebar
42
+ * @ignore
42
43
  */
43
44
  sidebar: Layout;
44
45
  /**
@@ -62,7 +62,7 @@
62
62
  "name": "value",
63
63
  "description": "Value of slider. Not applicable in range mode.",
64
64
  "type": "string",
65
- "default": "0"
65
+ "default": "\"0\""
66
66
  },
67
67
  {
68
68
  "name": "readonly",
@@ -145,7 +145,7 @@
145
145
  "attribute": "value",
146
146
  "description": "Value of slider. Not applicable in range mode.",
147
147
  "type": "string",
148
- "default": "0"
148
+ "default": "\"0\""
149
149
  },
150
150
  {
151
151
  "name": "readonly",