@refinitiv-ui/elements 5.11.0 → 5.12.0-dev.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.
- package/lib/button/index.d.ts +10 -4
- package/lib/button/index.js +23 -5
- package/lib/button-bar/index.d.ts +49 -0
- package/lib/button-bar/index.js +149 -9
- package/lib/multi-input/index.js +1 -1
- package/lib/number-field/index.js +1 -0
- package/lib/version.js +1 -1
- package/package.json +20 -12
package/lib/button/index.d.ts
CHANGED
|
@@ -58,10 +58,16 @@ export declare class Button extends ControlElement {
|
|
|
58
58
|
*/
|
|
59
59
|
ariaPressed: string;
|
|
60
60
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
* Aria indicating state of toggle button.
|
|
62
|
+
* Used when role is radio.
|
|
63
|
+
* @ignore
|
|
64
|
+
*/
|
|
65
|
+
ariaChecked: string;
|
|
66
|
+
/**
|
|
67
|
+
* Updates the element
|
|
68
|
+
* @param changedProperties Properties that has changed
|
|
69
|
+
* @returns {void}
|
|
70
|
+
*/
|
|
65
71
|
protected update(changedProperties: PropertyValues): void;
|
|
66
72
|
/**
|
|
67
73
|
* the lifecycle method called when properties changed first time
|
package/lib/button/index.js
CHANGED
|
@@ -65,6 +65,12 @@ let Button = class Button extends ControlElement {
|
|
|
65
65
|
* @ignore
|
|
66
66
|
*/
|
|
67
67
|
this.ariaPressed = '';
|
|
68
|
+
/**
|
|
69
|
+
* Aria indicating state of toggle button.
|
|
70
|
+
* Used when role is radio.
|
|
71
|
+
* @ignore
|
|
72
|
+
*/
|
|
73
|
+
this.ariaChecked = '';
|
|
68
74
|
}
|
|
69
75
|
/**
|
|
70
76
|
* Element version number
|
|
@@ -74,13 +80,18 @@ let Button = class Button extends ControlElement {
|
|
|
74
80
|
return VERSION;
|
|
75
81
|
}
|
|
76
82
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
* Updates the element
|
|
84
|
+
* @param changedProperties Properties that has changed
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
81
87
|
update(changedProperties) {
|
|
82
88
|
if (changedProperties.has('active') && this.toggles || changedProperties.has('toggles') && this.toggles) {
|
|
83
|
-
|
|
89
|
+
if (this.getAttribute('role') === 'radio') {
|
|
90
|
+
this.ariaChecked = String(this.active);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.ariaPressed = String(this.active);
|
|
94
|
+
}
|
|
84
95
|
}
|
|
85
96
|
super.update(changedProperties);
|
|
86
97
|
}
|
|
@@ -215,6 +226,13 @@ __decorate([
|
|
|
215
226
|
converter: { toAttribute: emptyStringToNull } // TODO: Remove after typescript update to allow nullable for ARIAMixin
|
|
216
227
|
})
|
|
217
228
|
], Button.prototype, "ariaPressed", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
property({ type: String,
|
|
231
|
+
reflect: true,
|
|
232
|
+
attribute: 'aria-checked',
|
|
233
|
+
converter: { toAttribute: emptyStringToNull } // TODO: Remove after typescript update to allow nullable for ARIAMixin
|
|
234
|
+
})
|
|
235
|
+
], Button.prototype, "ariaChecked", void 0);
|
|
218
236
|
Button = __decorate([
|
|
219
237
|
customElement('ef-button', {
|
|
220
238
|
alias: 'coral-button'
|
|
@@ -9,6 +9,11 @@ export declare class ButtonBar extends BasicElement {
|
|
|
9
9
|
* @returns version number
|
|
10
10
|
*/
|
|
11
11
|
static get version(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Element's role attribute for accessibility
|
|
14
|
+
* `role` should be `radiogroup` when it is managed.
|
|
15
|
+
*/
|
|
16
|
+
protected defaultRole: 'toolbar' | 'radiogroup';
|
|
12
17
|
/**
|
|
13
18
|
* A `CSSResultGroup` that will be used
|
|
14
19
|
* to style the host, slotted children
|
|
@@ -30,6 +35,45 @@ export declare class ButtonBar extends BasicElement {
|
|
|
30
35
|
* @returns {void}
|
|
31
36
|
*/
|
|
32
37
|
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
38
|
+
/**
|
|
39
|
+
* Handles key down event
|
|
40
|
+
* @param event Key down event object
|
|
41
|
+
* @returns {void}
|
|
42
|
+
*/
|
|
43
|
+
private onKeyDown;
|
|
44
|
+
/**
|
|
45
|
+
* Navigate to next or previous focusable button
|
|
46
|
+
* @param direction next | down
|
|
47
|
+
* @returns {void}
|
|
48
|
+
*/
|
|
49
|
+
private navigateToSibling;
|
|
50
|
+
/**
|
|
51
|
+
* Navigate to the first focusable button
|
|
52
|
+
* @returns {void}
|
|
53
|
+
*/
|
|
54
|
+
private first;
|
|
55
|
+
/**
|
|
56
|
+
* Navigate to the last focusable button
|
|
57
|
+
* @returns {void}
|
|
58
|
+
*/
|
|
59
|
+
private last;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the tabindex to -1 for all buttons except the currently focused one.
|
|
62
|
+
* @param target the button to be focused
|
|
63
|
+
* @param buttons Array of Buttons that contains target
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
66
|
+
private rovingTabIndex;
|
|
67
|
+
/**
|
|
68
|
+
* Set tabIndex to all buttons
|
|
69
|
+
* @returns {void}
|
|
70
|
+
*/
|
|
71
|
+
private manageTabIndex;
|
|
72
|
+
/**
|
|
73
|
+
* Check if button bar is nested, a.k.a. has parent button bar
|
|
74
|
+
* @returns `True` if button bar is nested
|
|
75
|
+
*/
|
|
76
|
+
private isNested;
|
|
33
77
|
/**
|
|
34
78
|
* Handles tap event
|
|
35
79
|
* @param event the param is the event of click and tap handlers
|
|
@@ -47,6 +91,11 @@ export declare class ButtonBar extends BasicElement {
|
|
|
47
91
|
* @returns the array of Element of the default slot
|
|
48
92
|
*/
|
|
49
93
|
private getElementsOfSlot;
|
|
94
|
+
/**
|
|
95
|
+
* Return the array of Buttons which focusable
|
|
96
|
+
* @returns the array of focusable Buttons
|
|
97
|
+
*/
|
|
98
|
+
private getFocusableButtons;
|
|
50
99
|
/**
|
|
51
100
|
* Filter Button classes by the toggles property
|
|
52
101
|
* @param buttons the array of Button items is the converted nodes of the default slot
|
package/lib/button-bar/index.js
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
|
+
var ButtonBar_1;
|
|
1
2
|
import { __decorate } from "tslib";
|
|
2
3
|
import { BasicElement, html, css } from '@refinitiv-ui/core';
|
|
3
4
|
import { customElement } from '@refinitiv-ui/core/lib/decorators/custom-element.js';
|
|
4
|
-
import { query } from '@refinitiv-ui/core/lib/decorators/query.js';
|
|
5
5
|
import { property } from '@refinitiv-ui/core/lib/decorators/property.js';
|
|
6
6
|
import { VERSION } from '../version.js';
|
|
7
7
|
import { Button } from '../button/index.js';
|
|
8
|
+
import { ref, createRef } from '@refinitiv-ui/core/lib/directives/ref.js';
|
|
8
9
|
/**
|
|
9
10
|
* Used to display multiple buttons to create a list of commands bar.
|
|
10
11
|
*/
|
|
11
|
-
let ButtonBar = class ButtonBar extends BasicElement {
|
|
12
|
+
let ButtonBar = ButtonBar_1 = class ButtonBar extends BasicElement {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
15
|
+
/**
|
|
16
|
+
* Element's role attribute for accessibility
|
|
17
|
+
* `role` should be `radiogroup` when it is managed.
|
|
18
|
+
*/
|
|
19
|
+
this.defaultRole = 'toolbar';
|
|
14
20
|
/**
|
|
15
21
|
* Manages user interaction, only allowing one toggle button to be active at any one time.
|
|
16
22
|
*/
|
|
17
23
|
this.managed = false;
|
|
24
|
+
/**
|
|
25
|
+
* Default slot
|
|
26
|
+
*/
|
|
27
|
+
this.defaultSlot = createRef();
|
|
18
28
|
}
|
|
19
29
|
/**
|
|
20
30
|
* Element version number
|
|
@@ -84,6 +94,130 @@ let ButtonBar = class ButtonBar extends BasicElement {
|
|
|
84
94
|
firstUpdated(changedProperties) {
|
|
85
95
|
super.firstUpdated(changedProperties);
|
|
86
96
|
this.addEventListener('tap', this.onTapHandler);
|
|
97
|
+
this.addEventListener('keydown', this.onKeyDown);
|
|
98
|
+
this.manageTabIndex();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Handles key down event
|
|
102
|
+
* @param event Key down event object
|
|
103
|
+
* @returns {void}
|
|
104
|
+
*/
|
|
105
|
+
onKeyDown(event) {
|
|
106
|
+
switch (event.key) {
|
|
107
|
+
case 'Tab':
|
|
108
|
+
// To prevent inserting button case, make sure there is only one tabIndex=0 in the buttons
|
|
109
|
+
this.manageTabIndex();
|
|
110
|
+
break;
|
|
111
|
+
case ' ':
|
|
112
|
+
case 'Spacebar':
|
|
113
|
+
case 'Enter':
|
|
114
|
+
this.onTapHandler(event);
|
|
115
|
+
break;
|
|
116
|
+
case 'Right':
|
|
117
|
+
case 'ArrowRight':
|
|
118
|
+
// Prevent calling twice if this component is nested
|
|
119
|
+
!this.isNested() && this.navigateToSibling('next');
|
|
120
|
+
break;
|
|
121
|
+
case 'Down':
|
|
122
|
+
case 'ArrowDown':
|
|
123
|
+
// Managed works as role radiogroup so `Up` and `Down` key can navigate among radios in the group
|
|
124
|
+
this.managed && this.navigateToSibling('next');
|
|
125
|
+
break;
|
|
126
|
+
case 'Left':
|
|
127
|
+
case 'ArrowLeft':
|
|
128
|
+
!this.isNested() && this.navigateToSibling('previous');
|
|
129
|
+
break;
|
|
130
|
+
case 'Up':
|
|
131
|
+
case 'ArrowUp':
|
|
132
|
+
this.managed && this.navigateToSibling('previous');
|
|
133
|
+
break;
|
|
134
|
+
case 'Home':
|
|
135
|
+
!this.isNested() && this.first();
|
|
136
|
+
break;
|
|
137
|
+
case 'End':
|
|
138
|
+
!this.isNested() && this.last();
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Navigate to next or previous focusable button
|
|
146
|
+
* @param direction next | down
|
|
147
|
+
* @returns {void}
|
|
148
|
+
*/
|
|
149
|
+
navigateToSibling(direction) {
|
|
150
|
+
const buttons = this.getFocusableButtons();
|
|
151
|
+
if (buttons.length <= 0) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const focusedButtonIndex = buttons.findIndex(button => button === document.activeElement);
|
|
155
|
+
const nextButton = direction === 'next'
|
|
156
|
+
? buttons[focusedButtonIndex + 1] || buttons[0]
|
|
157
|
+
: buttons[focusedButtonIndex - 1] || buttons[buttons.length - 1];
|
|
158
|
+
nextButton.focus();
|
|
159
|
+
this.rovingTabIndex(nextButton, buttons);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Navigate to the first focusable button
|
|
163
|
+
* @returns {void}
|
|
164
|
+
*/
|
|
165
|
+
first() {
|
|
166
|
+
const buttons = this.getFocusableButtons();
|
|
167
|
+
if (buttons.length <= 0) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
buttons[0].focus();
|
|
171
|
+
this.rovingTabIndex(buttons[0], buttons);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Navigate to the last focusable button
|
|
175
|
+
* @returns {void}
|
|
176
|
+
*/
|
|
177
|
+
last() {
|
|
178
|
+
const buttons = this.getFocusableButtons();
|
|
179
|
+
if (buttons.length <= 0) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
buttons[buttons.length - 1].focus();
|
|
183
|
+
this.rovingTabIndex(buttons[buttons.length - 1], buttons);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Sets the tabindex to -1 for all buttons except the currently focused one.
|
|
187
|
+
* @param target the button to be focused
|
|
188
|
+
* @param buttons Array of Buttons that contains target
|
|
189
|
+
* @returns {void}
|
|
190
|
+
*/
|
|
191
|
+
rovingTabIndex(target, buttons) {
|
|
192
|
+
buttons.forEach((button) => {
|
|
193
|
+
button.tabIndex = -1;
|
|
194
|
+
});
|
|
195
|
+
target.tabIndex = 0;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Set tabIndex to all buttons
|
|
199
|
+
* @returns {void}
|
|
200
|
+
*/
|
|
201
|
+
manageTabIndex() {
|
|
202
|
+
if (this.isNested()) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const buttons = this.getFocusableButtons();
|
|
206
|
+
if (buttons && buttons.length > 0) {
|
|
207
|
+
// Set tabindex=0 to previous focused button when new button added If not found set it to first button instead
|
|
208
|
+
let focusedButtonIndex = buttons.findIndex(button => document.activeElement === button);
|
|
209
|
+
if (focusedButtonIndex === -1) {
|
|
210
|
+
focusedButtonIndex = 0;
|
|
211
|
+
}
|
|
212
|
+
this.rovingTabIndex(buttons[focusedButtonIndex], buttons);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Check if button bar is nested, a.k.a. has parent button bar
|
|
217
|
+
* @returns `True` if button bar is nested
|
|
218
|
+
*/
|
|
219
|
+
isNested() {
|
|
220
|
+
return this.parentElement instanceof ButtonBar_1;
|
|
87
221
|
}
|
|
88
222
|
/**
|
|
89
223
|
* Handles tap event
|
|
@@ -99,6 +233,8 @@ let ButtonBar = class ButtonBar extends BasicElement {
|
|
|
99
233
|
event.stopPropagation();
|
|
100
234
|
this.manageButtons(target);
|
|
101
235
|
}
|
|
236
|
+
target.focus();
|
|
237
|
+
this.rovingTabIndex(target, this.getFocusableButtons());
|
|
102
238
|
}
|
|
103
239
|
/**
|
|
104
240
|
* Get the target Button item and handle it with other managed Button items
|
|
@@ -120,8 +256,15 @@ let ButtonBar = class ButtonBar extends BasicElement {
|
|
|
120
256
|
* @returns the array of Element of the default slot
|
|
121
257
|
*/
|
|
122
258
|
getElementsOfSlot() {
|
|
123
|
-
|
|
124
|
-
|
|
259
|
+
var _a;
|
|
260
|
+
return (_a = this.defaultSlot.value) === null || _a === void 0 ? void 0 : _a.assignedNodes().filter(node => node instanceof Element);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Return the array of Buttons which focusable
|
|
264
|
+
* @returns the array of focusable Buttons
|
|
265
|
+
*/
|
|
266
|
+
getFocusableButtons() {
|
|
267
|
+
return [...this.querySelectorAll('ef-button,coral-button')].filter(button => !button.disabled);
|
|
125
268
|
}
|
|
126
269
|
/**
|
|
127
270
|
* Filter Button classes by the toggles property
|
|
@@ -138,16 +281,13 @@ let ButtonBar = class ButtonBar extends BasicElement {
|
|
|
138
281
|
* @return {TemplateResult} Render template
|
|
139
282
|
*/
|
|
140
283
|
render() {
|
|
141
|
-
return html `<slot></slot>`;
|
|
284
|
+
return html `<slot ${ref(this.defaultSlot)} ></slot>`;
|
|
142
285
|
}
|
|
143
286
|
};
|
|
144
287
|
__decorate([
|
|
145
288
|
property({ type: Boolean, reflect: true })
|
|
146
289
|
], ButtonBar.prototype, "managed", void 0);
|
|
147
|
-
__decorate([
|
|
148
|
-
query('slot:not([name])')
|
|
149
|
-
], ButtonBar.prototype, "defaultSlot", void 0);
|
|
150
|
-
ButtonBar = __decorate([
|
|
290
|
+
ButtonBar = ButtonBar_1 = __decorate([
|
|
151
291
|
customElement('ef-button-bar', {
|
|
152
292
|
alias: 'coral-split-button'
|
|
153
293
|
})
|
package/lib/multi-input/index.js
CHANGED
|
@@ -445,7 +445,7 @@ let MultiInput = class MultiInput extends ControlElement {
|
|
|
445
445
|
onPillClearsHandler(event) {
|
|
446
446
|
const pill = event.target;
|
|
447
447
|
const index = pill.getAttribute('index');
|
|
448
|
-
if (index
|
|
448
|
+
if (index === null) {
|
|
449
449
|
return;
|
|
450
450
|
}
|
|
451
451
|
const items = this.composer.queryItems(() => true);
|
|
@@ -658,6 +658,7 @@ let NumberField = class NumberField extends FormFieldElement {
|
|
|
658
658
|
* @inheritDoc
|
|
659
659
|
*/
|
|
660
660
|
/* istanbul ignore next */
|
|
661
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
661
662
|
setSelectionRange(startSelection, endSelection, selectionDirection) {
|
|
662
663
|
throw new Error('Failed to execute \'setSelectionRange\' on \'NumberField\': The element does not support selection.');
|
|
663
664
|
}
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '5.
|
|
1
|
+
export const VERSION = '5.12.0-dev.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refinitiv-ui/elements",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0-dev.0",
|
|
4
4
|
"description": "Element Framework Elements",
|
|
5
5
|
"author": "Refinitiv",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -590,17 +590,13 @@
|
|
|
590
590
|
"lint": "node cli lint",
|
|
591
591
|
"lint:fix": "node cli lint --fix",
|
|
592
592
|
"prepublishOnly": "node scripts/release",
|
|
593
|
-
"api-analyzer": "node ../../scripts/release/api-analyzer.js"
|
|
593
|
+
"api-analyzer": "node ../../scripts/release/api-analyzer.js",
|
|
594
|
+
"version": "node ../../scripts/version"
|
|
594
595
|
},
|
|
595
596
|
"dependencies": {
|
|
596
597
|
"@refinitiv-ui/browser-sparkline": "1.1.7",
|
|
597
|
-
"@refinitiv-ui/
|
|
598
|
-
"@refinitiv-ui/
|
|
599
|
-
"@refinitiv-ui/i18n": "^5.2.6",
|
|
600
|
-
"@refinitiv-ui/phrasebook": "^5.4.1",
|
|
601
|
-
"@refinitiv-ui/solar-theme": "^5.6.2",
|
|
602
|
-
"@refinitiv-ui/translate": "^5.3.0",
|
|
603
|
-
"@refinitiv-ui/utils": "^5.1.1",
|
|
598
|
+
"@refinitiv-ui/halo-theme": "^5.4.4-dev.0",
|
|
599
|
+
"@refinitiv-ui/solar-theme": "^5.6.3-dev.0",
|
|
604
600
|
"@types/chart.js": "^2.9.31",
|
|
605
601
|
"chart.js": "~2.9.4",
|
|
606
602
|
"d3-interpolate": "^3.0.1",
|
|
@@ -609,12 +605,24 @@
|
|
|
609
605
|
"tslib": "^2.3.1"
|
|
610
606
|
},
|
|
611
607
|
"devDependencies": {
|
|
612
|
-
"@refinitiv-ui/
|
|
613
|
-
"@refinitiv-ui/
|
|
608
|
+
"@refinitiv-ui/core": "^5.4.1-dev.0",
|
|
609
|
+
"@refinitiv-ui/demo-block": "^5.1.8-dev.0",
|
|
610
|
+
"@refinitiv-ui/i18n": "^5.2.7-dev.0",
|
|
611
|
+
"@refinitiv-ui/phrasebook": "^5.4.2-dev.0",
|
|
612
|
+
"@refinitiv-ui/test-helpers": "^5.1.3-dev.0",
|
|
613
|
+
"@refinitiv-ui/translate": "^5.3.1-dev.0",
|
|
614
|
+
"@refinitiv-ui/utils": "^5.1.2-dev.0",
|
|
614
615
|
"@types/d3-interpolate": "^3.0.1"
|
|
615
616
|
},
|
|
617
|
+
"peerDependencies": {
|
|
618
|
+
"@refinitiv-ui/core": "^5.4.1-dev.0",
|
|
619
|
+
"@refinitiv-ui/i18n": "^5.2.7-dev.0",
|
|
620
|
+
"@refinitiv-ui/phrasebook": "^5.4.2-dev.0",
|
|
621
|
+
"@refinitiv-ui/translate": "^5.3.1-dev.0",
|
|
622
|
+
"@refinitiv-ui/utils": "^5.1.2-dev.0"
|
|
623
|
+
},
|
|
616
624
|
"publishConfig": {
|
|
617
625
|
"access": "public"
|
|
618
626
|
},
|
|
619
|
-
"gitHead": "
|
|
627
|
+
"gitHead": "593b957791e180fd1167f4045027ccc011143290"
|
|
620
628
|
}
|