@refinitiv-ui/elements 5.12.0-dev.0 → 5.12.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/CHANGELOG.md +24 -0
- package/lib/collapse/custom-elements.json +4 -2
- package/lib/collapse/custom-elements.md +1 -1
- package/lib/collapse/index.d.ts +20 -16
- package/lib/collapse/index.js +78 -48
- package/lib/collapse/themes/halo/dark/index.js +1 -1
- package/lib/collapse/themes/halo/light/index.js +1 -1
- package/lib/collapse/themes/solar/charcoal/index.js +1 -1
- package/lib/collapse/themes/solar/pearl/index.js +1 -1
- package/lib/dialog/custom-elements.json +11 -0
- package/lib/dialog/custom-elements.md +4 -3
- package/lib/dialog/index.d.ts +17 -0
- package/lib/dialog/index.js +30 -5
- package/lib/radio-button/index.d.ts +2 -2
- package/lib/radio-button/index.js +3 -3
- package/lib/slider/index.js +10 -0
- package/lib/tab/custom-elements.json +13 -0
- package/lib/tab/custom-elements.md +1 -0
- package/lib/tab/index.d.ts +32 -14
- package/lib/tab/index.js +61 -33
- package/lib/tab-bar/custom-elements.json +12 -0
- package/lib/tab-bar/custom-elements.md +7 -0
- package/lib/tab-bar/index.d.ts +97 -7
- package/lib/tab-bar/index.js +247 -37
- package/lib/version.js +1 -1
- package/package.json +12 -20
package/lib/tab/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSXInterface } from '../jsx';
|
|
2
|
-
import { TemplateResult, CSSResultGroup, ControlElement } from '@refinitiv-ui/core';
|
|
2
|
+
import { TemplateResult, CSSResultGroup, ControlElement, PropertyValues } from '@refinitiv-ui/core';
|
|
3
3
|
import '../icon/index.js';
|
|
4
4
|
import '../label/index.js';
|
|
5
5
|
/**
|
|
@@ -7,6 +7,9 @@ import '../label/index.js';
|
|
|
7
7
|
* @attr {boolean} disabled - Set disabled state
|
|
8
8
|
* @prop {boolean} [disabled=false] - Set disabled state
|
|
9
9
|
*
|
|
10
|
+
* @attr {string} value - Tab's value
|
|
11
|
+
* @prop {string} [value=""] - Tab's value
|
|
12
|
+
*
|
|
10
13
|
* @fires clear - Dispatched when click on cross button occurs
|
|
11
14
|
*/
|
|
12
15
|
export declare class Tab extends ControlElement {
|
|
@@ -15,6 +18,14 @@ export declare class Tab extends ControlElement {
|
|
|
15
18
|
* @returns version number
|
|
16
19
|
*/
|
|
17
20
|
static get version(): string;
|
|
21
|
+
protected readonly defaultRole = "tab";
|
|
22
|
+
/**
|
|
23
|
+
* A `CSSResultGroup` that will be used
|
|
24
|
+
* to style the host, slotted children
|
|
25
|
+
* and the internal template of the element.
|
|
26
|
+
* @returns CSS template
|
|
27
|
+
*/
|
|
28
|
+
static get styles(): CSSResultGroup;
|
|
18
29
|
/**
|
|
19
30
|
* Specify icon name to display in tab
|
|
20
31
|
*/
|
|
@@ -51,35 +62,42 @@ export declare class Tab extends ControlElement {
|
|
|
51
62
|
/**
|
|
52
63
|
* True, if there is slotted content
|
|
53
64
|
*/
|
|
54
|
-
private
|
|
65
|
+
private isSlotHasContent;
|
|
66
|
+
/**
|
|
67
|
+
* Called after the element’s DOM has been updated the first time.
|
|
68
|
+
* @param changedProperties Properties that has changed
|
|
69
|
+
* @returns {void}
|
|
70
|
+
*/
|
|
71
|
+
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
55
72
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
73
|
+
* Compute property values that depend on other properties
|
|
74
|
+
* and are used in the rest of the update process.
|
|
75
|
+
* @param changedProperties Properties that has changed
|
|
76
|
+
* @returns {void}
|
|
58
77
|
*/
|
|
59
|
-
|
|
78
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
60
79
|
/**
|
|
61
|
-
*
|
|
80
|
+
* Run on default slot slotchange
|
|
62
81
|
* @param event slotchange
|
|
63
82
|
* @returns {void}
|
|
64
83
|
*/
|
|
65
|
-
private
|
|
84
|
+
private onSlotChange;
|
|
66
85
|
/**
|
|
67
86
|
* Omitted lineClamp if subLabel is provided
|
|
68
87
|
* @returns line Clamp value
|
|
69
88
|
*/
|
|
70
89
|
private getLineClamp;
|
|
71
90
|
/**
|
|
72
|
-
*
|
|
91
|
+
* Handles key down event
|
|
92
|
+
* @param event Key down event object
|
|
73
93
|
* @returns {void}
|
|
74
94
|
*/
|
|
75
|
-
private
|
|
95
|
+
private onKeyDown;
|
|
76
96
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* and the internal template of the element.
|
|
80
|
-
* @returns CSS template
|
|
97
|
+
* @param event event from close button
|
|
98
|
+
* @returns {void}
|
|
81
99
|
*/
|
|
82
|
-
|
|
100
|
+
private handleClickClear;
|
|
83
101
|
/**
|
|
84
102
|
* Show Close Button if allow clears
|
|
85
103
|
* @returns close button template
|
package/lib/tab/index.js
CHANGED
|
@@ -2,24 +2,25 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { html, css, ControlElement } 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 { state } from '@refinitiv-ui/core/lib/decorators/state.js';
|
|
6
|
+
import { isSlotEmpty } from '@refinitiv-ui/utils/lib/is-slot-empty.js';
|
|
5
7
|
import { VERSION } from '../version.js';
|
|
6
8
|
import '../icon/index.js';
|
|
7
9
|
import '../label/index.js';
|
|
8
|
-
const isAllWhitespaceTextNode = (node) => {
|
|
9
|
-
var _a;
|
|
10
|
-
return node.nodeType === document.TEXT_NODE
|
|
11
|
-
&& !((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim());
|
|
12
|
-
};
|
|
13
10
|
/**
|
|
14
11
|
* A building block for individual tab
|
|
15
12
|
* @attr {boolean} disabled - Set disabled state
|
|
16
13
|
* @prop {boolean} [disabled=false] - Set disabled state
|
|
17
14
|
*
|
|
15
|
+
* @attr {string} value - Tab's value
|
|
16
|
+
* @prop {string} [value=""] - Tab's value
|
|
17
|
+
*
|
|
18
18
|
* @fires clear - Dispatched when click on cross button occurs
|
|
19
19
|
*/
|
|
20
20
|
let Tab = class Tab extends ControlElement {
|
|
21
21
|
constructor() {
|
|
22
22
|
super(...arguments);
|
|
23
|
+
this.defaultRole = 'tab';
|
|
23
24
|
/**
|
|
24
25
|
* Specify icon name to display in tab
|
|
25
26
|
*/
|
|
@@ -56,16 +57,15 @@ let Tab = class Tab extends ControlElement {
|
|
|
56
57
|
/**
|
|
57
58
|
* True, if there is slotted content
|
|
58
59
|
*/
|
|
59
|
-
this.
|
|
60
|
+
this.isSlotHasContent = false;
|
|
60
61
|
/**
|
|
61
|
-
*
|
|
62
|
+
* Run on default slot slotchange
|
|
62
63
|
* @param event slotchange
|
|
63
64
|
* @returns {void}
|
|
64
65
|
*/
|
|
65
|
-
this.
|
|
66
|
+
this.onSlotChange = (event) => {
|
|
66
67
|
const slot = event.target;
|
|
67
|
-
this.
|
|
68
|
-
this.requestUpdate();
|
|
68
|
+
this.isSlotHasContent = !!slot.assignedNodes().length && isSlotEmpty(slot);
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
@@ -76,12 +76,39 @@ let Tab = class Tab extends ControlElement {
|
|
|
76
76
|
return VERSION;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
79
|
+
* A `CSSResultGroup` that will be used
|
|
80
|
+
* to style the host, slotted children
|
|
81
|
+
* and the internal template of the element.
|
|
82
|
+
* @returns CSS template
|
|
83
|
+
*/
|
|
84
|
+
static get styles() {
|
|
85
|
+
return css `
|
|
86
|
+
:host {
|
|
87
|
+
display: inline-flex;
|
|
88
|
+
flex-shrink: 0;
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Called after the element’s DOM has been updated the first time.
|
|
94
|
+
* @param changedProperties Properties that has changed
|
|
95
|
+
* @returns {void}
|
|
81
96
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
firstUpdated(changedProperties) {
|
|
98
|
+
super.firstUpdated(changedProperties);
|
|
99
|
+
this.addEventListener('keydown', this.onKeyDown);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Compute property values that depend on other properties
|
|
103
|
+
* and are used in the rest of the update process.
|
|
104
|
+
* @param changedProperties Properties that has changed
|
|
105
|
+
* @returns {void}
|
|
106
|
+
*/
|
|
107
|
+
willUpdate(changedProperties) {
|
|
108
|
+
super.willUpdate(changedProperties);
|
|
109
|
+
if (changedProperties.has('active')) {
|
|
110
|
+
this.setAttribute('aria-selected', this.active ? 'true' : 'false');
|
|
111
|
+
}
|
|
85
112
|
}
|
|
86
113
|
/**
|
|
87
114
|
* Omitted lineClamp if subLabel is provided
|
|
@@ -90,6 +117,19 @@ let Tab = class Tab extends ControlElement {
|
|
|
90
117
|
getLineClamp() {
|
|
91
118
|
return !this.lineClamp ? 0 : this.subLabel ? 1 : this.lineClamp;
|
|
92
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Handles key down event
|
|
122
|
+
* @param event Key down event object
|
|
123
|
+
* @returns {void}
|
|
124
|
+
*/
|
|
125
|
+
onKeyDown(event) {
|
|
126
|
+
if (event.defaultPrevented) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (event.key === 'Delete' && (this.clears || this.clearsOnHover)) {
|
|
130
|
+
this.dispatchEvent(new CustomEvent('clear'));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
93
133
|
/**
|
|
94
134
|
* @param event event from close button
|
|
95
135
|
* @returns {void}
|
|
@@ -101,20 +141,6 @@ let Tab = class Tab extends ControlElement {
|
|
|
101
141
|
*/
|
|
102
142
|
this.dispatchEvent(new CustomEvent('clear'));
|
|
103
143
|
}
|
|
104
|
-
/**
|
|
105
|
-
* A `CSSResultGroup` that will be used
|
|
106
|
-
* to style the host, slotted children
|
|
107
|
-
* and the internal template of the element.
|
|
108
|
-
* @returns CSS template
|
|
109
|
-
*/
|
|
110
|
-
static get styles() {
|
|
111
|
-
return css `
|
|
112
|
-
:host {
|
|
113
|
-
display: inline-flex;
|
|
114
|
-
flex-shrink: 0;
|
|
115
|
-
}
|
|
116
|
-
`;
|
|
117
|
-
}
|
|
118
144
|
/**
|
|
119
145
|
* Show Close Button if allow clears
|
|
120
146
|
* @returns close button template
|
|
@@ -131,7 +157,7 @@ let Tab = class Tab extends ControlElement {
|
|
|
131
157
|
* @returns Label template
|
|
132
158
|
*/
|
|
133
159
|
get LabelTemplate() {
|
|
134
|
-
if (!this.label ||
|
|
160
|
+
if (!this.label || this.isSlotHasContent) {
|
|
135
161
|
return null;
|
|
136
162
|
}
|
|
137
163
|
return html `
|
|
@@ -147,7 +173,7 @@ let Tab = class Tab extends ControlElement {
|
|
|
147
173
|
* @returns SubLabel template
|
|
148
174
|
*/
|
|
149
175
|
get SubLabelTemplate() {
|
|
150
|
-
if (!this.subLabel ||
|
|
176
|
+
if (!this.subLabel || this.isSlotHasContent) {
|
|
151
177
|
return null;
|
|
152
178
|
}
|
|
153
179
|
return html `
|
|
@@ -169,8 +195,7 @@ let Tab = class Tab extends ControlElement {
|
|
|
169
195
|
<div part="label-container">
|
|
170
196
|
${this.LabelTemplate}
|
|
171
197
|
${this.SubLabelTemplate}
|
|
172
|
-
<slot @slotchange="${this.
|
|
173
|
-
</slot>
|
|
198
|
+
<slot @slotchange="${this.onSlotChange}"></slot>
|
|
174
199
|
</div>
|
|
175
200
|
${this.CloseTemplate}
|
|
176
201
|
`;
|
|
@@ -200,6 +225,9 @@ __decorate([
|
|
|
200
225
|
__decorate([
|
|
201
226
|
property({ type: String, reflect: true })
|
|
202
227
|
], Tab.prototype, "level", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
state()
|
|
230
|
+
], Tab.prototype, "isSlotHasContent", void 0);
|
|
203
231
|
Tab = __decorate([
|
|
204
232
|
customElement('ef-tab', {
|
|
205
233
|
alias: 'coral-tab'
|
|
@@ -45,6 +45,18 @@
|
|
|
45
45
|
"description": "Use to switch from horizontal to vertical layout.",
|
|
46
46
|
"type": "boolean",
|
|
47
47
|
"default": "false"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "value",
|
|
51
|
+
"description": "Value of tab-bar, derived from value of an active tab.",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"default": "\"\""
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"events": [
|
|
57
|
+
{
|
|
58
|
+
"name": "value-changed",
|
|
59
|
+
"description": "Fired when the `value` changes."
|
|
48
60
|
}
|
|
49
61
|
]
|
|
50
62
|
}
|
|
@@ -8,4 +8,11 @@ Container for tabs
|
|
|
8
8
|
|-------------|-------------|---------------------------------|---------|--------------------------------------------------|
|
|
9
9
|
| `alignment` | `alignment` | `"left" \| "center" \| "right"` | "left" | Specify tab's horizontal alignment |
|
|
10
10
|
| `level` | `level` | `"1" \| "2" \| "3"` | "1" | Use level styling from theme |
|
|
11
|
+
| `value` | | `string` | "" | Value of tab-bar, derived from value of an active tab. |
|
|
11
12
|
| `vertical` | `vertical` | `boolean` | false | Use to switch from horizontal to vertical layout. |
|
|
13
|
+
|
|
14
|
+
## Events
|
|
15
|
+
|
|
16
|
+
| Event | Description |
|
|
17
|
+
|-----------------|---------------------------------|
|
|
18
|
+
| `value-changed` | Fired when the `value` changes. |
|
package/lib/tab-bar/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { TemplateResult, CSSResultGroup, PropertyValues, ResponsiveElement, Elem
|
|
|
3
3
|
import '../button/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Container for tabs
|
|
6
|
+
*
|
|
7
|
+
* @fires value-changed - Fired when the `value` changes.
|
|
6
8
|
*/
|
|
7
9
|
export declare class TabBar extends ResponsiveElement {
|
|
8
10
|
/**
|
|
@@ -10,6 +12,7 @@ export declare class TabBar extends ResponsiveElement {
|
|
|
10
12
|
* @returns version number
|
|
11
13
|
*/
|
|
12
14
|
static get version(): string;
|
|
15
|
+
protected readonly defaultRole = "tablist";
|
|
13
16
|
/**
|
|
14
17
|
* A `CSSResultGroup` that will be used
|
|
15
18
|
* to style the host, slotted children
|
|
@@ -29,6 +32,18 @@ export declare class TabBar extends ResponsiveElement {
|
|
|
29
32
|
* Use to switch from horizontal to vertical layout.
|
|
30
33
|
*/
|
|
31
34
|
vertical: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Internal value of tab bar.
|
|
37
|
+
* Controlled by public setter and getter
|
|
38
|
+
*/
|
|
39
|
+
private _value;
|
|
40
|
+
/**
|
|
41
|
+
* Value of tab-bar, derived from value of an active tab.
|
|
42
|
+
* @param value Element value
|
|
43
|
+
* @default -
|
|
44
|
+
*/
|
|
45
|
+
set value(value: string);
|
|
46
|
+
get value(): string;
|
|
32
47
|
private content;
|
|
33
48
|
private leftBtn;
|
|
34
49
|
private rightBtn;
|
|
@@ -55,26 +70,61 @@ export declare class TabBar extends ResponsiveElement {
|
|
|
55
70
|
*/
|
|
56
71
|
resizedCallback(size: ElementSize): void;
|
|
57
72
|
/**
|
|
58
|
-
*
|
|
73
|
+
* Return true if incoming value matches one of the existing tabs
|
|
74
|
+
* @param value Value to check
|
|
75
|
+
* @returns true if incoming value matches one of the existing tabs
|
|
76
|
+
*/
|
|
77
|
+
private isValidValue;
|
|
78
|
+
/**
|
|
79
|
+
* When the slot changes, set the level, toggle the scroll button, and set the value
|
|
59
80
|
* @returns {void}
|
|
60
81
|
*/
|
|
61
|
-
private
|
|
82
|
+
private onSlotChange;
|
|
62
83
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @param
|
|
84
|
+
* Mark tab as active
|
|
85
|
+
* @param value value of tab to select
|
|
65
86
|
* @returns {void}
|
|
66
87
|
*/
|
|
67
|
-
private
|
|
88
|
+
private activateTab;
|
|
89
|
+
/**
|
|
90
|
+
* Set tab value and fires `tab-changed` event
|
|
91
|
+
* @param event - Event
|
|
92
|
+
* @returns {void}
|
|
93
|
+
*/
|
|
94
|
+
private onTap;
|
|
95
|
+
/**
|
|
96
|
+
* Get the value of a tab
|
|
97
|
+
* @param tab - The tab element.
|
|
98
|
+
* @returns The value of the tab.
|
|
99
|
+
*/
|
|
100
|
+
private getTabValue;
|
|
101
|
+
/**
|
|
102
|
+
* Return the tab's label, or its textContent, or an empty string
|
|
103
|
+
* @param tab - The tab element.
|
|
104
|
+
* @returns The tab label.
|
|
105
|
+
*/
|
|
106
|
+
private getTabLabel;
|
|
107
|
+
/**
|
|
108
|
+
* Get Tab elements from slot
|
|
109
|
+
* @returns the array of Tab
|
|
110
|
+
*/
|
|
111
|
+
private getTabElements;
|
|
112
|
+
/**
|
|
113
|
+
* Get focusable tab elements
|
|
114
|
+
* @returns the array of focusable tab
|
|
115
|
+
*/
|
|
116
|
+
private getFocusableTabs;
|
|
68
117
|
/**
|
|
69
118
|
* Set tab level attribute accordingly
|
|
70
119
|
* @returns {void}
|
|
71
120
|
*/
|
|
72
121
|
private setLevel;
|
|
73
122
|
/**
|
|
74
|
-
*
|
|
123
|
+
* Hide/Show scroll button when element is overflow.
|
|
124
|
+
* @param elementWidth width of element
|
|
75
125
|
* @returns {void}
|
|
76
126
|
*/
|
|
77
|
-
private
|
|
127
|
+
private toggleScrollButton;
|
|
78
128
|
/**
|
|
79
129
|
* Update scroll position when clicked on left button
|
|
80
130
|
* @returns {void}
|
|
@@ -85,6 +135,46 @@ export declare class TabBar extends ResponsiveElement {
|
|
|
85
135
|
* @returns {void}
|
|
86
136
|
*/
|
|
87
137
|
private handleScrollRight;
|
|
138
|
+
/**
|
|
139
|
+
* Focus and set active to tab
|
|
140
|
+
* @param tab - The element that was clicked.
|
|
141
|
+
* @return {void}
|
|
142
|
+
*/
|
|
143
|
+
private focusAndSetActiveTab;
|
|
144
|
+
/**
|
|
145
|
+
* Navigate to first focusable tab of the tab bar
|
|
146
|
+
* @returns {void}
|
|
147
|
+
*/
|
|
148
|
+
private first;
|
|
149
|
+
/**
|
|
150
|
+
* Navigate to last focusable tab of the tab bar
|
|
151
|
+
* @returns {void}
|
|
152
|
+
*/
|
|
153
|
+
private last;
|
|
154
|
+
/**
|
|
155
|
+
* Navigate to next or previous focusable tab
|
|
156
|
+
* @param direction up/next; down/previous
|
|
157
|
+
* @returns {void}
|
|
158
|
+
*/
|
|
159
|
+
private navigateToSibling;
|
|
160
|
+
/**
|
|
161
|
+
* Handles key down event
|
|
162
|
+
* @param event Key down event object
|
|
163
|
+
* @returns {void}
|
|
164
|
+
*/
|
|
165
|
+
private onKeyDown;
|
|
166
|
+
/**
|
|
167
|
+
* Sets the tabindex to -1 for all tabs except the active tab.
|
|
168
|
+
* @param target the tab to be focused
|
|
169
|
+
* @param tabList Array of tabs that contains target
|
|
170
|
+
* @returns {void}
|
|
171
|
+
*/
|
|
172
|
+
private rovingTabIndex;
|
|
173
|
+
/**
|
|
174
|
+
* Set tabIndex to all tabs
|
|
175
|
+
* @returns {void}
|
|
176
|
+
*/
|
|
177
|
+
private manageTabIndex;
|
|
88
178
|
/**
|
|
89
179
|
* A `TemplateResult` that will be used
|
|
90
180
|
* to render the updated internal template.
|