@ui5/webcomponents 0.31.14 → 0.31.18
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 +57 -0
- package/README.md +1 -1
- package/dist/Avatar.js +8 -6
- package/dist/CalendarHeader.js +75 -1
- package/dist/Card.js +19 -2
- package/dist/ComboBox.js +10 -0
- package/dist/DateComponentBase.js +12 -0
- package/dist/DatePicker.js +48 -9
- package/dist/DayPicker.js +21 -2
- package/dist/FileUploader.js +8 -0
- package/dist/GroupHeaderListItem.js +4 -0
- package/dist/Icon.js +6 -6
- package/dist/Input.js +10 -2
- package/dist/Label.js +1 -1
- package/dist/List.js +8 -5
- package/dist/ListItem.js +25 -4
- package/dist/Panel.js +17 -5
- package/dist/Popup.js +16 -5
- package/dist/RadioButton.js +15 -2
- package/dist/ResponsivePopover.js +3 -2
- package/dist/SegmentedButton.js +85 -53
- package/dist/SegmentedButtonItem.js +112 -0
- package/dist/Toast.js +11 -0
- package/dist/TreeListItem.js +2 -12
- package/dist/api.json +1 -1
- package/dist/generated/assets/themes/sap_belize/parameters-bundle.css.json +1 -1
- package/dist/generated/assets/themes/sap_belize_hcb/parameters-bundle.css.json +1 -1
- package/dist/generated/assets/themes/sap_belize_hcw/parameters-bundle.css.json +1 -1
- package/dist/generated/assets/themes/sap_fiori_3/parameters-bundle.css.json +1 -1
- package/dist/generated/assets/themes/sap_fiori_3_dark/parameters-bundle.css.json +1 -1
- package/dist/generated/assets/themes/sap_fiori_3_hcb/parameters-bundle.css.json +1 -1
- package/dist/generated/assets/themes/sap_fiori_3_hcw/parameters-bundle.css.json +1 -1
- package/dist/generated/i18n/i18n-defaults.js +2 -2
- package/dist/generated/templates/CalendarHeaderTemplate.lit.js +3 -1
- package/dist/generated/templates/CalendarTemplate.lit.js +1 -1
- package/dist/generated/templates/CardTemplate.lit.js +1 -1
- package/dist/generated/templates/CustomListItemTemplate.lit.js +3 -3
- package/dist/generated/templates/DatePickerPopoverTemplate.lit.js +1 -1
- package/dist/generated/templates/DateTimePickerPopoverTemplate.lit.js +1 -1
- package/dist/generated/templates/DayPickerTemplate.lit.js +7 -6
- package/dist/generated/templates/FileUploaderTemplate.lit.js +1 -1
- package/dist/generated/templates/GroupHeaderListItemTemplate.lit.js +1 -1
- package/dist/generated/templates/ListItemTemplate.lit.js +3 -3
- package/dist/generated/templates/ListTemplate.lit.js +1 -1
- package/dist/generated/templates/RadioButtonTemplate.lit.js +1 -1
- package/dist/generated/templates/SegmentedButtonItemTemplate.lit.js +15 -0
- package/dist/generated/templates/SegmentedButtonTemplate.lit.js +1 -1
- package/dist/generated/templates/StandardListItemTemplate.lit.js +3 -3
- package/dist/generated/templates/SuggestionListItemTemplate.lit.js +3 -3
- package/dist/generated/templates/ToastTemplate.lit.js +2 -1
- package/dist/generated/templates/TreeListItemTemplate.lit.js +3 -3
- package/dist/generated/templates/TreeTemplate.lit.js +1 -1
- package/dist/generated/themes/Badge.css.js +1 -1
- package/dist/generated/themes/Button.css.js +1 -1
- package/dist/generated/themes/CalendarHeader.css.js +1 -1
- package/dist/generated/themes/Card.css.js +1 -1
- package/dist/generated/themes/CheckBox.css.js +1 -1
- package/dist/generated/themes/ComboBox.css.js +1 -1
- package/dist/generated/themes/DatePicker.css.js +1 -1
- package/dist/generated/themes/DayPicker.css.js +1 -1
- package/dist/generated/themes/GroupHeaderListItem.css.js +1 -1
- package/dist/generated/themes/Input.css.js +1 -1
- package/dist/generated/themes/InvisibleTextStyles.css.js +1 -1
- package/dist/generated/themes/Label.css.js +1 -1
- package/dist/generated/themes/Link.css.js +1 -1
- package/dist/generated/themes/ListItem.css.js +1 -1
- package/dist/generated/themes/MessageStrip.css.js +1 -1
- package/dist/generated/themes/MultiComboBox.css.js +1 -1
- package/dist/generated/themes/Panel.css.js +1 -1
- package/dist/generated/themes/RadioButton.css.js +1 -1
- package/dist/generated/themes/SegmentedButton.css.js +1 -1
- package/dist/generated/themes/Select.css.js +1 -1
- package/dist/generated/themes/SliderBase.css.js +1 -1
- package/dist/generated/themes/StepInput.css.js +1 -1
- package/dist/generated/themes/Switch.css.js +1 -1
- package/dist/generated/themes/TextArea.css.js +1 -1
- package/dist/generated/themes/Tokenizer.css.js +1 -1
- package/dist/generated/themes/Tree.css.js +1 -1
- package/dist/generated/themes/TreeListItem.css.js +1 -1
- package/dist/generated/themes/ValueStateMessage.css.js +1 -1
- package/dist/generated/themes/sap_belize/parameters-bundle.css.js +1 -1
- package/dist/generated/themes/sap_belize_hcb/parameters-bundle.css.js +1 -1
- package/dist/generated/themes/sap_belize_hcw/parameters-bundle.css.js +1 -1
- package/dist/generated/themes/sap_fiori_3/parameters-bundle.css.js +1 -1
- package/dist/generated/themes/sap_fiori_3_dark/parameters-bundle.css.js +1 -1
- package/dist/generated/themes/sap_fiori_3_hcb/parameters-bundle.css.js +1 -1
- package/dist/generated/themes/sap_fiori_3_hcw/parameters-bundle.css.js +1 -1
- package/dist/i18n/messagebundle.properties +13 -1
- package/dist/popup-utils/OpenedPopupsRegistry.js +1 -1
- package/package.json +7 -7
- package/src/Avatar.js +8 -6
- package/src/Calendar.hbs +2 -0
- package/src/CalendarHeader.hbs +11 -4
- package/src/CalendarHeader.js +75 -1
- package/src/Card.hbs +1 -1
- package/src/Card.js +19 -2
- package/src/ComboBox.js +10 -0
- package/src/DateComponentBase.js +12 -0
- package/src/DatePicker.js +48 -9
- package/src/DatePickerPopover.hbs +1 -0
- package/src/DateTimePickerPopover.hbs +4 -4
- package/src/DayPicker.hbs +6 -1
- package/src/DayPicker.js +21 -2
- package/src/FileUploader.hbs +1 -0
- package/src/FileUploader.js +8 -0
- package/src/GroupHeaderListItem.hbs +3 -3
- package/src/GroupHeaderListItem.js +4 -0
- package/src/Icon.js +6 -6
- package/src/Input.js +10 -2
- package/src/Label.js +1 -1
- package/src/List.hbs +1 -2
- package/src/List.js +8 -5
- package/src/ListItem.hbs +3 -1
- package/src/ListItem.js +25 -4
- package/src/Panel.js +17 -5
- package/src/Popup.js +16 -5
- package/src/RadioButton.hbs +1 -1
- package/src/RadioButton.js +15 -2
- package/src/ResponsivePopover.js +3 -2
- package/src/SegmentedButton.hbs +12 -5
- package/src/SegmentedButton.js +85 -53
- package/src/SegmentedButtonItem.hbs +42 -0
- package/src/SegmentedButtonItem.js +112 -0
- package/src/Toast.hbs +13 -11
- package/src/Toast.js +11 -0
- package/src/Tree.hbs +1 -1
- package/src/TreeListItem.js +2 -12
- package/src/i18n/messagebundle.properties +13 -1
- package/src/popup-utils/OpenedPopupsRegistry.js +1 -1
package/dist/ListItem.js
CHANGED
|
@@ -8,7 +8,13 @@ import ListItemBase from "./ListItemBase.js";
|
|
|
8
8
|
import RadioButton from "./RadioButton.js";
|
|
9
9
|
import CheckBox from "./CheckBox.js";
|
|
10
10
|
import Button from "./Button.js";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
DELETE,
|
|
13
|
+
ARIA_LABEL_LIST_ITEM_CHECKBOX,
|
|
14
|
+
ARIA_LABEL_LIST_ITEM_RADIO_BUTTON,
|
|
15
|
+
LIST_ITEM_SELECTED,
|
|
16
|
+
LIST_ITEM_NOT_SELECTED,
|
|
17
|
+
} from "./generated/i18n/i18n-defaults.js";
|
|
12
18
|
|
|
13
19
|
// Styles
|
|
14
20
|
import styles from "./generated/themes/ListItem.css.js";
|
|
@@ -72,13 +78,13 @@ const metadata = {
|
|
|
72
78
|
*
|
|
73
79
|
* @private
|
|
74
80
|
* @type {String}
|
|
75
|
-
* @defaultvalue "
|
|
81
|
+
* @defaultvalue "listitem"
|
|
76
82
|
* @since 1.0.0-rc.9
|
|
77
83
|
*
|
|
78
84
|
*/
|
|
79
85
|
role: {
|
|
80
86
|
type: String,
|
|
81
|
-
defaultValue: "
|
|
87
|
+
defaultValue: "listitem",
|
|
82
88
|
},
|
|
83
89
|
|
|
84
90
|
_mode: {
|
|
@@ -312,6 +318,20 @@ class ListItem extends ListItemBase {
|
|
|
312
318
|
return undefined;
|
|
313
319
|
}
|
|
314
320
|
|
|
321
|
+
get ariaSelectedText() {
|
|
322
|
+
let ariaSelectedText;
|
|
323
|
+
|
|
324
|
+
// Selected state needs to be supported separately since now the role mapping is list -> listitem[]
|
|
325
|
+
// to avoid the issue of nesting interactive elements, ex. (option -> radio/checkbox);
|
|
326
|
+
// The text is added to aria-describedby because as part of the aria-labelledby
|
|
327
|
+
// the whole content of the item is readout when the aria-labelledby value is changed.
|
|
328
|
+
if (this.ariaSelected !== undefined) {
|
|
329
|
+
ariaSelectedText = this.ariaSelected ? this.i18nBundle.getText(LIST_ITEM_SELECTED) : this.i18nBundle.getText(LIST_ITEM_NOT_SELECTED);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return ariaSelectedText;
|
|
333
|
+
}
|
|
334
|
+
|
|
315
335
|
get deleteText() {
|
|
316
336
|
return this.i18nBundle.getText(DELETE);
|
|
317
337
|
}
|
|
@@ -322,7 +342,8 @@ class ListItem extends ListItemBase {
|
|
|
322
342
|
ariaExpanded: undefined,
|
|
323
343
|
ariaLevel: undefined,
|
|
324
344
|
ariaLabel: this.i18nBundle.getText(ARIA_LABEL_LIST_ITEM_CHECKBOX),
|
|
325
|
-
|
|
345
|
+
ariaLabelRadioButton: this.i18nBundle.getText(ARIA_LABEL_LIST_ITEM_RADIO_BUTTON),
|
|
346
|
+
ariaSelectedText: this.ariaSelectedText,
|
|
326
347
|
};
|
|
327
348
|
}
|
|
328
349
|
|
package/dist/Panel.js
CHANGED
|
@@ -95,7 +95,19 @@ const metadata = {
|
|
|
95
95
|
},
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
98
|
+
* Indicates whether the transition between the expanded and the collapsed state of the component is animated. By default the animation is enabled.
|
|
99
|
+
*
|
|
100
|
+
* @type {boolean}
|
|
101
|
+
* @defaultvalue false
|
|
102
|
+
* @public
|
|
103
|
+
* @since 1.0.0-rc.16
|
|
104
|
+
*/
|
|
105
|
+
noAnimation: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Sets the accessible aria role of the component.
|
|
99
111
|
* Depending on the usage, you can change the role from the default <code>Form</code>
|
|
100
112
|
* to <code>Region</code> or <code>Complementary</code>.
|
|
101
113
|
*
|
|
@@ -282,8 +294,8 @@ class Panel extends UI5Element {
|
|
|
282
294
|
return true;
|
|
283
295
|
}
|
|
284
296
|
|
|
285
|
-
|
|
286
|
-
return getAnimationMode()
|
|
297
|
+
shouldNotAnimate() {
|
|
298
|
+
return this.noAnimation || getAnimationMode() === AnimationMode.None;
|
|
287
299
|
}
|
|
288
300
|
|
|
289
301
|
_headerClick(event) {
|
|
@@ -332,7 +344,7 @@ class Panel extends UI5Element {
|
|
|
332
344
|
|
|
333
345
|
this.collapsed = !this.collapsed;
|
|
334
346
|
|
|
335
|
-
if (
|
|
347
|
+
if (this.shouldNotAnimate()) {
|
|
336
348
|
this.fireEvent("toggle");
|
|
337
349
|
return;
|
|
338
350
|
}
|
|
@@ -368,7 +380,7 @@ class Panel extends UI5Element {
|
|
|
368
380
|
get classes() {
|
|
369
381
|
return {
|
|
370
382
|
headerBtn: {
|
|
371
|
-
"ui5-panel-header-button-animated": this.
|
|
383
|
+
"ui5-panel-header-button-animated": !this.shouldNotAnimate(),
|
|
372
384
|
},
|
|
373
385
|
};
|
|
374
386
|
}
|
package/dist/Popup.js
CHANGED
|
@@ -9,7 +9,7 @@ import { isTabPrevious } from "@ui5/webcomponents-base/dist/Keys.js";
|
|
|
9
9
|
import { getNextZIndex, getFocusedElement, isFocusedElementWithinNode } from "@ui5/webcomponents-base/dist/util/PopupUtils.js";
|
|
10
10
|
import PopupTemplate from "./generated/templates/PopupTemplate.lit.js";
|
|
11
11
|
import PopupBlockLayer from "./generated/templates/PopupBlockLayerTemplate.lit.js";
|
|
12
|
-
import {
|
|
12
|
+
import { addOpenedPopup, removeOpenedPopup } from "./popup-utils/OpenedPopupsRegistry.js";
|
|
13
13
|
|
|
14
14
|
// Styles
|
|
15
15
|
import styles from "./generated/themes/Popup.css.js";
|
|
@@ -150,6 +150,8 @@ const createBlockingStyle = () => {
|
|
|
150
150
|
|
|
151
151
|
createBlockingStyle();
|
|
152
152
|
|
|
153
|
+
let bodyScrollingBlockers = 0;
|
|
154
|
+
|
|
153
155
|
/**
|
|
154
156
|
* @class
|
|
155
157
|
* <h3 class="comment-api-title">Overview</h3>
|
|
@@ -237,6 +239,12 @@ class Popup extends UI5Element {
|
|
|
237
239
|
* @protected
|
|
238
240
|
*/
|
|
239
241
|
static blockBodyScrolling() {
|
|
242
|
+
bodyScrollingBlockers++;
|
|
243
|
+
|
|
244
|
+
if (bodyScrollingBlockers !== 1) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
240
248
|
if (window.pageYOffset > 0) {
|
|
241
249
|
document.body.style.top = `-${window.pageYOffset}px`;
|
|
242
250
|
}
|
|
@@ -248,6 +256,12 @@ class Popup extends UI5Element {
|
|
|
248
256
|
* @protected
|
|
249
257
|
*/
|
|
250
258
|
static unblockBodyScrolling() {
|
|
259
|
+
bodyScrollingBlockers--;
|
|
260
|
+
|
|
261
|
+
if (bodyScrollingBlockers !== 0) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
251
265
|
document.body.classList.remove("ui5-popup-scroll-blocker");
|
|
252
266
|
window.scrollTo(0, -parseFloat(document.body.style.top));
|
|
253
267
|
document.body.style.top = "";
|
|
@@ -422,12 +436,9 @@ class Popup extends UI5Element {
|
|
|
422
436
|
return;
|
|
423
437
|
}
|
|
424
438
|
|
|
425
|
-
const openedPopups = getOpenedPopups();
|
|
426
439
|
if (this.isModal) {
|
|
427
440
|
this._blockLayerHidden = true;
|
|
428
|
-
|
|
429
|
-
Popup.unblockBodyScrolling();
|
|
430
|
-
}
|
|
441
|
+
Popup.unblockBodyScrolling();
|
|
431
442
|
}
|
|
432
443
|
|
|
433
444
|
this.hide();
|
package/dist/RadioButton.js
CHANGED
|
@@ -162,6 +162,19 @@ const metadata = {
|
|
|
162
162
|
type: Boolean,
|
|
163
163
|
},
|
|
164
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Defines the text alternative of the component.
|
|
167
|
+
* If not provided a default text alternative will be set, if present.
|
|
168
|
+
*
|
|
169
|
+
* @type {string}
|
|
170
|
+
* @defaultvalue ""
|
|
171
|
+
* @private
|
|
172
|
+
* @since 1.0.0-rc.16
|
|
173
|
+
*/
|
|
174
|
+
accessibleName: {
|
|
175
|
+
type: String,
|
|
176
|
+
},
|
|
177
|
+
|
|
165
178
|
_tabIndex: {
|
|
166
179
|
type: String,
|
|
167
180
|
defaultValue: "-1",
|
|
@@ -383,8 +396,8 @@ class RadioButton extends UI5Element {
|
|
|
383
396
|
return this.disabled ? "true" : undefined;
|
|
384
397
|
}
|
|
385
398
|
|
|
386
|
-
get
|
|
387
|
-
return this.text
|
|
399
|
+
get ariaLabelText() {
|
|
400
|
+
return [this.text, this.accessibleName].filter(Boolean).join(" ");
|
|
388
401
|
}
|
|
389
402
|
|
|
390
403
|
get ariaDescribedBy() {
|
|
@@ -116,9 +116,10 @@ class ResponsivePopover extends Popover {
|
|
|
116
116
|
/**
|
|
117
117
|
* Opens popover on desktop and dialog on mobile.
|
|
118
118
|
* @param {HTMLElement} opener the element that the popover is opened by
|
|
119
|
+
* @param {boolean} preventInitialFocus prevents applying the focus inside the popup
|
|
119
120
|
* @public
|
|
120
121
|
*/
|
|
121
|
-
open(opener) {
|
|
122
|
+
open(opener, preventInitialFocus = false) {
|
|
122
123
|
this.style.display = this._isPhone ? "contents" : "";
|
|
123
124
|
|
|
124
125
|
if (this.isOpen() || (this._dialog && this._dialog.isOpen())) {
|
|
@@ -131,7 +132,7 @@ class ResponsivePopover extends Popover {
|
|
|
131
132
|
this._minWidth = Math.max(POPOVER_MIN_WIDTH, opener.getBoundingClientRect().width);
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
this.openBy(opener);
|
|
135
|
+
this.openBy(opener, preventInitialFocus);
|
|
135
136
|
} else {
|
|
136
137
|
this.style.zIndex = getNextZIndex();
|
|
137
138
|
this._dialog.open();
|
package/dist/SegmentedButton.js
CHANGED
|
@@ -5,8 +5,9 @@ import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18
|
|
|
5
5
|
import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
|
|
6
6
|
import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
|
|
7
7
|
import { isIE } from "@ui5/webcomponents-base/dist/Device.js";
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
8
|
+
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
|
|
9
|
+
import { SEGMENTEDBUTTON_ARIA_DESCRIPTION, SEGMENTEDBUTTON_ARIA_DESCRIBEDBY } from "./generated/i18n/i18n-defaults.js";
|
|
10
|
+
import SegmentedButtonItem from "./SegmentedButtonItem.js";
|
|
10
11
|
|
|
11
12
|
// Template
|
|
12
13
|
import SegmentedButtonTemplate from "./generated/templates/SegmentedButtonTemplate.lit.js";
|
|
@@ -18,39 +19,40 @@ import SegmentedButtonCss from "./generated/themes/SegmentedButton.css.js";
|
|
|
18
19
|
* @public
|
|
19
20
|
*/
|
|
20
21
|
const metadata = {
|
|
21
|
-
tag: "ui5-
|
|
22
|
+
tag: "ui5-segmented-button",
|
|
23
|
+
altTag: "ui5-segmentedbutton",
|
|
22
24
|
languageAware: true,
|
|
23
25
|
properties: /** @lends sap.ui.webcomponents.main.SegmentedButton.prototype */ {},
|
|
24
26
|
managedSlots: true,
|
|
25
27
|
slots: /** @lends sap.ui.webcomponents.main.SegmentedButton.prototype */ {
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
|
-
* Defines the
|
|
30
|
+
* Defines the items of <code>ui5-segmented-button</code>.
|
|
29
31
|
* <br><br>
|
|
30
|
-
* <b>Note:</b> Multiple
|
|
32
|
+
* <b>Note:</b> Multiple items are allowed.
|
|
31
33
|
* <br><br>
|
|
32
|
-
* <b>Note:</b> Use the <code>ui5-
|
|
33
|
-
* @type {
|
|
34
|
-
* @slot
|
|
34
|
+
* <b>Note:</b> Use the <code>ui5-segmented-button-item</code> for the intended design.
|
|
35
|
+
* @type {sap.ui.webcomponents.main.IButton[]}
|
|
36
|
+
* @slot items
|
|
35
37
|
* @public
|
|
36
38
|
*/
|
|
37
39
|
"default": {
|
|
38
|
-
propertyName: "
|
|
40
|
+
propertyName: "items",
|
|
39
41
|
type: HTMLElement,
|
|
40
42
|
},
|
|
41
43
|
},
|
|
42
44
|
events: /** @lends sap.ui.webcomponents.main.SegmentedButton.prototype */ {
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
|
-
* Fired when the selected
|
|
47
|
+
* Fired when the selected item changes.
|
|
46
48
|
*
|
|
47
49
|
* @event sap.ui.webcomponents.main.SegmentedButton#selection-change
|
|
48
|
-
* @param {HTMLElement}
|
|
50
|
+
* @param {HTMLElement} selectedItem the pressed item.
|
|
49
51
|
* @public
|
|
50
52
|
*/
|
|
51
53
|
"selection-change": {
|
|
52
54
|
detail: {
|
|
53
|
-
|
|
55
|
+
selectedItem: { type: HTMLElement },
|
|
54
56
|
},
|
|
55
57
|
},
|
|
56
58
|
},
|
|
@@ -61,11 +63,11 @@ const metadata = {
|
|
|
61
63
|
*
|
|
62
64
|
* <h3 class="comment-api-title">Overview</h3>
|
|
63
65
|
*
|
|
64
|
-
* The <code>ui5-
|
|
65
|
-
* one of the
|
|
66
|
+
* The <code>ui5-segmented-button</code> shows a group of items. When the user clicks or taps
|
|
67
|
+
* one of the items, it stays in a pressed state. It automatically resizes the items
|
|
66
68
|
* to fit proportionally within the component. When no width is set, the component uses the available width.
|
|
67
69
|
* <br><br>
|
|
68
|
-
* <b>Note:</b> There can be just one selected <code>
|
|
70
|
+
* <b>Note:</b> There can be just one selected <code>item</code> at a time.
|
|
69
71
|
*
|
|
70
72
|
* <h3>ES6 Module Import</h3>
|
|
71
73
|
*
|
|
@@ -75,8 +77,9 @@ const metadata = {
|
|
|
75
77
|
* @author SAP SE
|
|
76
78
|
* @alias sap.ui.webcomponents.main.SegmentedButton
|
|
77
79
|
* @extends sap.ui.webcomponents.base.UI5Element
|
|
78
|
-
* @tagname ui5-
|
|
80
|
+
* @tagname ui5-segmented-button
|
|
79
81
|
* @since 1.0.0-rc.6
|
|
82
|
+
* @appenddocs SegmentedButtonItem
|
|
80
83
|
* @public
|
|
81
84
|
*/
|
|
82
85
|
class SegmentedButton extends UI5Element {
|
|
@@ -97,7 +100,7 @@ class SegmentedButton extends UI5Element {
|
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
static get dependencies() {
|
|
100
|
-
return [
|
|
103
|
+
return [SegmentedButtonItem];
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
static async onDefine() {
|
|
@@ -108,7 +111,7 @@ class SegmentedButton extends UI5Element {
|
|
|
108
111
|
super();
|
|
109
112
|
|
|
110
113
|
this._itemNavigation = new ItemNavigation(this, {
|
|
111
|
-
getItemsCallback: () => this.getSlottedNodes("
|
|
114
|
+
getItemsCallback: () => this.getSlottedNodes("items"),
|
|
112
115
|
});
|
|
113
116
|
|
|
114
117
|
this.absoluteWidthSet = false; // set to true whenever we set absolute width to the component
|
|
@@ -128,6 +131,13 @@ class SegmentedButton extends UI5Element {
|
|
|
128
131
|
}
|
|
129
132
|
|
|
130
133
|
onBeforeRendering() {
|
|
134
|
+
const items = this.getSlottedNodes("items");
|
|
135
|
+
|
|
136
|
+
items.forEach((item, index, arr) => {
|
|
137
|
+
item.posInSet = index + 1;
|
|
138
|
+
item.sizeOfSet = arr.length;
|
|
139
|
+
});
|
|
140
|
+
|
|
131
141
|
this.normalizeSelection();
|
|
132
142
|
}
|
|
133
143
|
|
|
@@ -135,24 +145,24 @@ class SegmentedButton extends UI5Element {
|
|
|
135
145
|
await this._doLayout();
|
|
136
146
|
}
|
|
137
147
|
|
|
138
|
-
|
|
148
|
+
prepareToMeasureItems() {
|
|
139
149
|
this.style.width = "";
|
|
140
|
-
this.
|
|
141
|
-
|
|
150
|
+
this.items.forEach(item => {
|
|
151
|
+
item.style.width = "";
|
|
142
152
|
});
|
|
143
153
|
}
|
|
144
154
|
|
|
145
|
-
async
|
|
155
|
+
async measureItemsWidth() {
|
|
146
156
|
await renderFinished();
|
|
147
|
-
this.
|
|
157
|
+
this.prepareToMeasureItems();
|
|
148
158
|
|
|
149
|
-
this.widths = this.
|
|
159
|
+
this.widths = this.items.map(item => {
|
|
150
160
|
// +1 is added because for width 100.44px the offsetWidth property returns 100px and not 101px
|
|
151
|
-
let width =
|
|
161
|
+
let width = item.offsetWidth + 1;
|
|
152
162
|
|
|
153
163
|
if (isIE()) {
|
|
154
|
-
// in IE we are adding 1 one px beacause the width of the border on
|
|
155
|
-
// longest
|
|
164
|
+
// in IE we are adding 1 one px beacause the width of the border on an item in the middle is not calculated and if the
|
|
165
|
+
// longest item is in the middle, it truncates
|
|
156
166
|
width += 1;
|
|
157
167
|
}
|
|
158
168
|
|
|
@@ -161,37 +171,55 @@ class SegmentedButton extends UI5Element {
|
|
|
161
171
|
}
|
|
162
172
|
|
|
163
173
|
normalizeSelection() {
|
|
164
|
-
this.
|
|
174
|
+
this._selectedItem = this.items.filter(item => item.pressed).pop();
|
|
165
175
|
|
|
166
|
-
if (this.
|
|
167
|
-
this.
|
|
168
|
-
|
|
176
|
+
if (this._selectedItem) {
|
|
177
|
+
this.items.forEach(item => {
|
|
178
|
+
item.pressed = false;
|
|
169
179
|
});
|
|
170
|
-
this.
|
|
180
|
+
this._selectedItem.pressed = true;
|
|
171
181
|
}
|
|
172
182
|
}
|
|
173
183
|
|
|
174
|
-
|
|
184
|
+
_selectItem(event) {
|
|
175
185
|
if (event.target.disabled || event.target === this.getDomRef()) {
|
|
176
186
|
return;
|
|
177
187
|
}
|
|
178
188
|
|
|
179
|
-
if (event.target !== this.
|
|
180
|
-
if (this.
|
|
181
|
-
this.
|
|
189
|
+
if (event.target !== this._selectedItem) {
|
|
190
|
+
if (this._selectedItem) {
|
|
191
|
+
this._selectedItem.pressed = false;
|
|
182
192
|
}
|
|
183
|
-
this.
|
|
193
|
+
this._selectedItem = event.target;
|
|
184
194
|
this.fireEvent("selection-change", {
|
|
185
|
-
|
|
195
|
+
selectedItem: this._selectedItem,
|
|
186
196
|
});
|
|
187
197
|
}
|
|
188
198
|
|
|
189
|
-
this.
|
|
190
|
-
this._itemNavigation.setCurrentItem(this.
|
|
199
|
+
this._selectedItem.pressed = true;
|
|
200
|
+
this._itemNavigation.setCurrentItem(this._selectedItem);
|
|
191
201
|
|
|
192
202
|
return this;
|
|
193
203
|
}
|
|
194
204
|
|
|
205
|
+
_onclick(event) {
|
|
206
|
+
this._selectItem(event);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
_onkeydown(event) {
|
|
210
|
+
if (isEnter(event)) {
|
|
211
|
+
this._selectItem(event);
|
|
212
|
+
} else if (isSpace(event)) {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
_onkeyup(event) {
|
|
218
|
+
if (isSpace(event)) {
|
|
219
|
+
this._selectItem(event);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
195
223
|
_onfocusin(event) {
|
|
196
224
|
// If the component was previously focused,
|
|
197
225
|
// update the ItemNavigation to sync butons` tabindex values
|
|
@@ -202,28 +230,28 @@ class SegmentedButton extends UI5Element {
|
|
|
202
230
|
|
|
203
231
|
// If the component is focused for the first time
|
|
204
232
|
// focus the selected item if such present
|
|
205
|
-
if (this.
|
|
206
|
-
this.
|
|
207
|
-
this._itemNavigation.setCurrentItem(this.
|
|
233
|
+
if (this.selectedItem) {
|
|
234
|
+
this.selectedItem.focus();
|
|
235
|
+
this._itemNavigation.setCurrentItem(this._selectedItem);
|
|
208
236
|
this.hasPreviouslyFocusedItem = true;
|
|
209
237
|
}
|
|
210
238
|
}
|
|
211
239
|
|
|
212
240
|
async _doLayout() {
|
|
213
|
-
const
|
|
214
|
-
if (!
|
|
215
|
-
await this.
|
|
241
|
+
const itemsHaveWidth = this.widths && this.widths.some(item => item.offsetWidth > 2); // 2 are the pixel's added for rounding & IE
|
|
242
|
+
if (!itemsHaveWidth) {
|
|
243
|
+
await this.measureItemsWidth();
|
|
216
244
|
}
|
|
217
245
|
|
|
218
246
|
const parentWidth = this.parentNode.offsetWidth;
|
|
219
247
|
|
|
220
248
|
if (!this.style.width || this.percentageWidthSet) {
|
|
221
|
-
this.style.width = `${Math.max(...this.widths) * this.
|
|
249
|
+
this.style.width = `${Math.max(...this.widths) * this.items.length}px`;
|
|
222
250
|
this.absoluteWidthSet = true;
|
|
223
251
|
}
|
|
224
252
|
|
|
225
|
-
this.
|
|
226
|
-
|
|
253
|
+
this.items.forEach(item => {
|
|
254
|
+
item.style.width = "100%";
|
|
227
255
|
});
|
|
228
256
|
|
|
229
257
|
if (parentWidth <= this.offsetWidth && this.absoluteWidthSet) {
|
|
@@ -233,14 +261,18 @@ class SegmentedButton extends UI5Element {
|
|
|
233
261
|
}
|
|
234
262
|
|
|
235
263
|
/**
|
|
236
|
-
* Currently selected
|
|
264
|
+
* Currently selected item.
|
|
237
265
|
*
|
|
238
266
|
* @readonly
|
|
239
|
-
* @type { ui5-
|
|
267
|
+
* @type { ui5-segmented-button-item }
|
|
240
268
|
* @public
|
|
241
269
|
*/
|
|
242
|
-
get
|
|
243
|
-
return this.
|
|
270
|
+
get selectedItem() {
|
|
271
|
+
return this._selectedItem;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
get ariaDescribedBy() {
|
|
275
|
+
return this.i18nBundle.getText(SEGMENTEDBUTTON_ARIA_DESCRIBEDBY);
|
|
244
276
|
}
|
|
245
277
|
|
|
246
278
|
get ariaDescription() {
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import SegmentedButtonItemTemplate from "./generated/templates/SegmentedButtonItemTemplate.lit.js";
|
|
2
|
+
import ToggleButton from "./ToggleButton.js";
|
|
3
|
+
import ButtonDesign from "./types/ButtonDesign.js";
|
|
4
|
+
|
|
5
|
+
import { SEGMENTEDBUTTONITEM_ARIA_DESCRIPTION } from "./generated/i18n/i18n-defaults.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
const metadata = {
|
|
11
|
+
tag: "ui5-segmented-button-item",
|
|
12
|
+
properties: /** @lends sap.ui.webcomponents.main.SegmentedButtonItem.prototype */ {
|
|
13
|
+
/**
|
|
14
|
+
* <b>Note:</b> The property is inherited and not supported. If set, it won't take any effect.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
design: {
|
|
19
|
+
type: ButtonDesign,
|
|
20
|
+
defaultValue: ButtonDesign.Default,
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* <b>Note:</b> The property is inherited and not supported. If set, it won't take any effect.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
iconEnd: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* <b>Note:</b> The property is inherited and not supported. If set, it won't take any effect.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
iconSize: {
|
|
38
|
+
type: String,
|
|
39
|
+
defaultValue: undefined,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* <b>Note:</b> The property is inherited and not supported. If set, it won't take any effect.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
submits: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Defines the index of the item inside of the SegmentedButton.
|
|
53
|
+
*
|
|
54
|
+
* @private
|
|
55
|
+
* @type {String}
|
|
56
|
+
*/
|
|
57
|
+
posInSet: {
|
|
58
|
+
type: String,
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Defines how many items are inside of the SegmentedButton.
|
|
63
|
+
*
|
|
64
|
+
* @private
|
|
65
|
+
* @type {String}
|
|
66
|
+
*/
|
|
67
|
+
sizeOfSet: {
|
|
68
|
+
type: String,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @class
|
|
75
|
+
*
|
|
76
|
+
*<h3 class="comment-api-title">Overview</h3>
|
|
77
|
+
*
|
|
78
|
+
* Users can use the <code>ui5-segmented-button-item</code> as part of a <code>ui5-segmented-button</code>.
|
|
79
|
+
* <br><br>
|
|
80
|
+
* Clicking or tapping on a <code>ui5-segmented-button-item</code> changes its state to <code>pressed</code>.
|
|
81
|
+
* The item returns to its initial state when the user clicks or taps on it again.
|
|
82
|
+
* By applying additional custom CSS-styling classes, apps can give a different style to any
|
|
83
|
+
* <code>ui5-segmented-button-item</code>.
|
|
84
|
+
*
|
|
85
|
+
* <h3>ES6 Module Import</h3>
|
|
86
|
+
*
|
|
87
|
+
* <code>import "@ui5/webcomponents/dist/SegmentedButtonItem";</code>
|
|
88
|
+
*
|
|
89
|
+
* @constructor
|
|
90
|
+
* @author SAP SE
|
|
91
|
+
* @alias sap.ui.webcomponents.main.SegmentedButtonItem
|
|
92
|
+
* @extends ToggleButton
|
|
93
|
+
* @tagname ui5-segmented-button-item
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
class SegmentedButtonItem extends ToggleButton {
|
|
97
|
+
static get metadata() {
|
|
98
|
+
return metadata;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static get template() {
|
|
102
|
+
return SegmentedButtonItemTemplate;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get ariaDescription() {
|
|
106
|
+
return this.i18nBundle.getText(SEGMENTEDBUTTONITEM_ARIA_DESCRIPTION);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
SegmentedButtonItem.define();
|
|
111
|
+
|
|
112
|
+
export default SegmentedButtonItem;
|
package/dist/Toast.js
CHANGED
|
@@ -79,6 +79,15 @@ const metadata = {
|
|
|
79
79
|
hover: {
|
|
80
80
|
type: Boolean,
|
|
81
81
|
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Indicates whether the component DOM is rendered.
|
|
85
|
+
* @type {boolean}
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
88
|
+
domRendered: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
},
|
|
82
91
|
},
|
|
83
92
|
slots: /** @lends sap.ui.webcomponents.main.Toast.prototype */ {
|
|
84
93
|
/**
|
|
@@ -206,6 +215,7 @@ class Toast extends UI5Element {
|
|
|
206
215
|
}
|
|
207
216
|
|
|
208
217
|
_initiateOpening() {
|
|
218
|
+
this.domRendered = true;
|
|
209
219
|
requestAnimationFrame(_ => {
|
|
210
220
|
this.open = true;
|
|
211
221
|
});
|
|
@@ -215,6 +225,7 @@ class Toast extends UI5Element {
|
|
|
215
225
|
if (this.hover) {
|
|
216
226
|
return;
|
|
217
227
|
}
|
|
228
|
+
this.domRendered = false;
|
|
218
229
|
this.open = false;
|
|
219
230
|
}
|
|
220
231
|
|
package/dist/TreeListItem.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
TREE_ITEM_ARIA_LABEL,
|
|
11
11
|
TREE_ITEM_EXPAND_NODE,
|
|
12
12
|
TREE_ITEM_COLLAPSE_NODE,
|
|
13
|
-
LIST_ITEM_SELECTED,
|
|
14
13
|
} from "./generated/i18n/i18n-defaults.js";
|
|
15
14
|
|
|
16
15
|
// Template
|
|
@@ -275,7 +274,8 @@ class TreeListItem extends ListItem {
|
|
|
275
274
|
ariaLevel: this.level,
|
|
276
275
|
posinset: this._posinset,
|
|
277
276
|
setsize: this._setsize,
|
|
278
|
-
|
|
277
|
+
ariaSelectedText: this.ariaSelectedText,
|
|
278
|
+
listItemAriaLabel: this.i18nBundle.getText(TREE_ITEM_ARIA_LABEL),
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
281
|
|
|
@@ -304,16 +304,6 @@ class TreeListItem extends ListItem {
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
get ariaLabelText() {
|
|
308
|
-
let text = this.i18nBundle.getText(TREE_ITEM_ARIA_LABEL);
|
|
309
|
-
|
|
310
|
-
if (this.selected) {
|
|
311
|
-
text += ` ${this.i18nBundle.getText(LIST_ITEM_SELECTED)}`;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return text;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
307
|
get iconAccessibleName() {
|
|
318
308
|
return this.expanded ? this.i18nBundle.getText(TREE_ITEM_COLLAPSE_NODE) : this.i18nBundle.getText(TREE_ITEM_EXPAND_NODE);
|
|
319
309
|
}
|