@ui5/webcomponents 1.10.0 → 1.10.2

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 (101) hide show
  1. package/.dev-server-port +1 -0
  2. package/CHANGELOG.md +101 -0
  3. package/dist/Avatar.d.ts +2 -2
  4. package/dist/Badge.d.ts +3 -3
  5. package/dist/Breadcrumbs.d.ts +5 -5
  6. package/dist/Breadcrumbs.js +1 -1
  7. package/dist/BusyIndicator.d.ts +136 -0
  8. package/dist/BusyIndicator.js +126 -208
  9. package/dist/BusyIndicator.js.map +1 -0
  10. package/dist/Button.d.ts +3 -3
  11. package/dist/Calendar.d.ts +3 -3
  12. package/dist/Calendar.js +1 -1
  13. package/dist/CalendarHeader.d.ts +2 -2
  14. package/dist/Card.d.ts +3 -3
  15. package/dist/Card.js +1 -1
  16. package/dist/CardHeader.d.ts +2 -2
  17. package/dist/Carousel.d.ts +318 -0
  18. package/dist/Carousel.js +446 -642
  19. package/dist/Carousel.js.map +1 -0
  20. package/dist/CheckBox.d.ts +3 -3
  21. package/dist/ColorPalette.d.ts +5 -5
  22. package/dist/ColorPalette.js +1 -1
  23. package/dist/ColorPaletteItem.d.ts +2 -2
  24. package/dist/ColorPalettePopover.d.ts +2 -2
  25. package/dist/ColorPicker.d.ts +2 -2
  26. package/dist/ComboBox.js +2 -2
  27. package/dist/CustomListItem.d.ts +1 -1
  28. package/dist/DatePicker.d.ts +2 -2
  29. package/dist/DateTimePicker.d.ts +1 -1
  30. package/dist/DayPicker.d.ts +2 -2
  31. package/dist/Dialog.d.ts +4 -5
  32. package/dist/FileUploader.d.ts +4 -4
  33. package/dist/GroupHeaderListItem.d.ts +1 -1
  34. package/dist/Icon.d.ts +2 -2
  35. package/dist/Input.d.ts +5 -5
  36. package/dist/Input.js +1 -1
  37. package/dist/Label.d.ts +2 -2
  38. package/dist/Link.d.ts +2 -2
  39. package/dist/List.d.ts +4 -3
  40. package/dist/List.js +1 -1
  41. package/dist/ListItem.d.ts +1 -1
  42. package/dist/Menu.d.ts +3 -3
  43. package/dist/Menu.js +1 -1
  44. package/dist/MessageStrip.d.ts +2 -2
  45. package/dist/MonthPicker.d.ts +2 -2
  46. package/dist/MultiComboBox.js +6 -2
  47. package/dist/MultiInput.js +1 -1
  48. package/dist/Panel.d.ts +2 -2
  49. package/dist/Popover.d.ts +1 -1
  50. package/dist/Popup.d.ts +3 -3
  51. package/dist/ProgressIndicator.d.ts +2 -2
  52. package/dist/RangeSlider.d.ts +1 -1
  53. package/dist/ResponsivePopover.d.ts +1 -1
  54. package/dist/SegmentedButton.js +1 -1
  55. package/dist/Select.js +1 -1
  56. package/dist/Slider.d.ts +1 -1
  57. package/dist/SplitButton.d.ts +2 -2
  58. package/dist/StandardListItem.d.ts +2 -2
  59. package/dist/StepInput.d.ts +2 -2
  60. package/dist/SuggestionListItem.d.ts +1 -1
  61. package/dist/Switch.d.ts +2 -2
  62. package/dist/TabContainer.js +1 -2
  63. package/dist/Table.d.ts +6 -4
  64. package/dist/Table.js +1 -1
  65. package/dist/TableCell.d.ts +2 -2
  66. package/dist/TableColumn.d.ts +2 -2
  67. package/dist/TableGroupRow.d.ts +2 -2
  68. package/dist/TableRow.d.ts +2 -2
  69. package/dist/TimePickerBase.d.ts +4 -4
  70. package/dist/TimeSelection.d.ts +2 -2
  71. package/dist/Title.d.ts +2 -2
  72. package/dist/Tree.js +1 -1
  73. package/dist/WheelSlider.d.ts +2 -2
  74. package/dist/YearPicker.d.ts +2 -2
  75. package/dist/api.json +1 -1
  76. package/dist/generated/templates/CarouselTemplate.lit.js +2 -2
  77. package/global.d.ts +2 -2
  78. package/package.json +7 -7
  79. package/src/Badge.ts +1 -1
  80. package/src/Breadcrumbs.ts +1 -1
  81. package/src/{BusyIndicator.js → BusyIndicator.ts} +95 -100
  82. package/src/Calendar.ts +1 -1
  83. package/src/Card.ts +1 -1
  84. package/src/Carousel.hbs +3 -3
  85. package/src/{Carousel.js → Carousel.ts} +242 -234
  86. package/src/CheckBox.ts +1 -1
  87. package/src/ColorPalette.ts +1 -1
  88. package/src/ComboBox.js +2 -2
  89. package/src/Dialog.ts +2 -2
  90. package/src/Input.ts +1 -1
  91. package/src/List.ts +1 -1
  92. package/src/ListItem.ts +1 -1
  93. package/src/Menu.ts +1 -1
  94. package/src/MultiComboBox.js +6 -2
  95. package/src/MultiInput.js +1 -1
  96. package/src/SegmentedButton.js +1 -1
  97. package/src/Select.js +1 -1
  98. package/src/TabContainer.js +1 -2
  99. package/src/Table.ts +1 -1
  100. package/src/Tree.hbs +1 -1
  101. package/src/Tree.js +1 -1
package/dist/Carousel.js CHANGED
@@ -1,13 +1,20 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var Carousel_1;
1
8
  import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
9
+ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
10
+ import languageAware from "@ui5/webcomponents-base/dist/decorators/languageAware.js";
11
+ import property from "@ui5/webcomponents-base/dist/decorators/property.js";
12
+ import event from "@ui5/webcomponents-base/dist/decorators/event.js";
13
+ import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
14
+ import fastNavigation from "@ui5/webcomponents-base/dist/decorators/fastNavigation.js";
2
15
  import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
3
16
  import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
4
- import {
5
- isLeft,
6
- isRight,
7
- isDown,
8
- isUp,
9
- isF7,
10
- } from "@ui5/webcomponents-base/dist/Keys.js";
17
+ import { isLeft, isRight, isDown, isUp, isF7, } from "@ui5/webcomponents-base/dist/Keys.js";
11
18
  import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
12
19
  import ScrollEnablement from "@ui5/webcomponents-base/dist/delegate/ScrollEnablement.js";
13
20
  import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
@@ -15,211 +22,18 @@ import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
15
22
  import { isDesktop } from "@ui5/webcomponents-base/dist/Device.js";
16
23
  import AnimationMode from "@ui5/webcomponents-base/dist/types/AnimationMode.js";
17
24
  import { getAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js";
18
- import {
19
- CAROUSEL_OF_TEXT,
20
- CAROUSEL_DOT_TEXT,
21
- CAROUSEL_PREVIOUS_ARROW_TEXT,
22
- CAROUSEL_NEXT_ARROW_TEXT,
23
- } from "./generated/i18n/i18n-defaults.js";
25
+ import { CAROUSEL_OF_TEXT, CAROUSEL_DOT_TEXT, CAROUSEL_PREVIOUS_ARROW_TEXT, CAROUSEL_NEXT_ARROW_TEXT,
26
+ // @ts-ignore
27
+ } from "./generated/i18n/i18n-defaults.js";
24
28
  import CarouselArrowsPlacement from "./types/CarouselArrowsPlacement.js";
25
29
  import CarouselPageIndicatorStyle from "./types/CarouselPageIndicatorStyle.js";
26
30
  import CarouselTemplate from "./generated/templates/CarouselTemplate.lit.js";
27
31
  import "@ui5/webcomponents-icons/dist/slim-arrow-left.js";
28
32
  import "@ui5/webcomponents-icons/dist/slim-arrow-right.js";
29
-
30
33
  import Button from "./Button.js";
31
34
  import Label from "./Label.js";
32
-
33
35
  // Styles
34
36
  import CarouselCss from "./generated/themes/Carousel.css.js";
35
-
36
- /**
37
- * @public
38
- */
39
- const metadata = {
40
- tag: "ui5-carousel",
41
- languageAware: true,
42
- fastNavigation: true,
43
- properties: /** @lends sap.ui.webc.main.Carousel.prototype */ {
44
- /**
45
- * Defines whether the carousel should loop, i.e show the first page after the last page is reached and vice versa.
46
- * @type {boolean}
47
- * @defaultvalue false
48
- * @public
49
- */
50
- cyclic: {
51
- type: Boolean,
52
- },
53
-
54
- /**
55
- * Defines the number of items per page on small size (up to 640px). One item per page shown by default.
56
- * @type {sap.ui.webc.base.types.Integer}
57
- * @defaultvalue 1
58
- * @public
59
- */
60
- itemsPerPageS: {
61
- type: Integer,
62
- defaultValue: 1,
63
- },
64
-
65
- /**
66
- * Defines the number of items per page on medium size (from 640px to 1024px). One item per page shown by default.
67
- * @type {sap.ui.webc.base.types.Integer}
68
- * @defaultvalue 1
69
- * @public
70
- */
71
- itemsPerPageM: {
72
- type: Integer,
73
- defaultValue: 1,
74
- },
75
-
76
- /**
77
- * Defines the number of items per page on large size (more than 1024px). One item per page shown by default.
78
- * @type {sap.ui.webc.base.types.Integer}
79
- * @defaultvalue 1
80
- * @public
81
- */
82
- itemsPerPageL: {
83
- type: Integer,
84
- defaultValue: 1,
85
- },
86
-
87
- /**
88
- * Defines the visibility of the navigation arrows.
89
- * If set to true the navigation arrows will be hidden.
90
- * <br><br>
91
- * <b>Note:</b> The navigation arrows are never displayed on touch devices.
92
- * In this case, the user can swipe to navigate through the items.
93
- * @type {boolean}
94
- * @since 1.0.0-rc.15
95
- * @defaultvalue false
96
- * @public
97
- */
98
- hideNavigationArrows: {
99
- type: Boolean,
100
- },
101
-
102
- /**
103
- * Defines the visibility of the page indicator.
104
- * If set to true the page indicator will be hidden.
105
- * @type {boolean}
106
- * @since 1.0.0-rc.15
107
- * @defaultvalue false
108
- * @public
109
- */
110
- hidePageIndicator: {
111
- type: Boolean,
112
- },
113
-
114
- /**
115
- * Defines the style of the page indicator.
116
- * Available options are:
117
- * <ul>
118
- * <li><code>Default</code> - The page indicator will be visualized as dots if there are fewer than 9 pages. If there are more pages, the page indicator will switch to displaying the current page and the total number of pages. (e.g. X of Y)</li>
119
- * <li><code>Numeric</code> - The page indicator will display the current page and the total number of pages. (e.g. X of Y)</li>
120
- * </ul>
121
- * @type {sap.ui.webc.main.types.CarouselPageIndicatorStyle}
122
- * @since 1.10
123
- * @defaultvalue "Default"
124
- * @public
125
- */
126
- pageIndicatorStyle: {
127
- type: CarouselPageIndicatorStyle,
128
- defaultValue: CarouselPageIndicatorStyle.Default,
129
- },
130
-
131
- /**
132
- * Defines the index of the initially selected item.
133
- * @type {sap.ui.webc.base.types.Integer}
134
- * @defaultvalue 0
135
- * @private
136
- */
137
- _selectedIndex: {
138
- type: Integer,
139
- defaultValue: 0,
140
- },
141
-
142
- /**
143
- * Defines the position of arrows.
144
- * <br><br>
145
- * Available options are:
146
- * <ul>
147
- * <li><code>Content</code></li>
148
- * <li><code>Navigation</code></li>
149
- * </ul>
150
- * <br>
151
- * When set to "Content", the arrows are placed on the sides of the current page.
152
- * <br>
153
- * When set to "Navigation", the arrows are placed on the sides of the page indicator.
154
- * @type {sap.ui.webc.main.types.CarouselArrowsPlacement}
155
- * @defaultvalue "Content"
156
- * @public
157
- */
158
- arrowsPlacement: {
159
- type: CarouselArrowsPlacement,
160
- defaultValue: CarouselArrowsPlacement.Content,
161
- },
162
-
163
- /**
164
- * Defines the carousel width in pixels.
165
- * @private
166
- */
167
- _width: {
168
- type: Integer,
169
- },
170
-
171
- /**
172
- * Defines the carousel item width in pixels.
173
- * @private
174
- */
175
- _itemWidth: {
176
- type: Integer,
177
- },
178
-
179
- /**
180
- * If set to true navigation arrows are shown.
181
- * @private
182
- * @since 1.0.0-rc.15
183
- */
184
- _visibleNavigationArrows: {
185
- type: Boolean,
186
- noAttribute: true,
187
- },
188
- },
189
- managedSlots: true,
190
- slots: /** @lends sap.ui.webc.main.Carousel.prototype */ {
191
- /**
192
- * Defines the content of the component.
193
- * @type {HTMLElement[]}
194
- * @slot content
195
- * @public
196
- */
197
- "default": {
198
- propertyName: "content",
199
- type: HTMLElement,
200
- individualSlots: true,
201
- },
202
- },
203
- events: /** @lends sap.ui.webc.main.Carousel.prototype */ {
204
-
205
- /**
206
- * Fired whenever the page changes due to user interaction,
207
- * when the user clicks on the navigation arrows or while resizing,
208
- * based on the <code>items-per-page-l</code>, <code>items-per-page-m</code> and <code>items-per-page-s</code> properties.
209
- *
210
- * @event
211
- * @param {Integer} selectedIndex the current selected index
212
- * @public
213
- * @since 1.0.0-rc.7
214
- */
215
- navigate: {
216
- detail: {
217
- selectedIndex: { type: Integer },
218
- },
219
- },
220
- },
221
- };
222
-
223
37
  /**
224
38
  * @class
225
39
  *
@@ -288,444 +102,434 @@ const metadata = {
288
102
  * @since 1.0.0-rc.6
289
103
  * @public
290
104
  */
291
- class Carousel extends UI5Element {
292
- static get metadata() {
293
- return metadata;
294
- }
295
-
296
- static get render() {
297
- return litRender;
298
- }
299
-
300
- static get styles() {
301
- return CarouselCss;
302
- }
303
-
304
- static get template() {
305
- return CarouselTemplate;
306
- }
307
-
308
- static get pageTypeLimit() {
309
- return 9;
310
- }
311
-
312
- constructor() {
313
- super();
314
-
315
- this._scrollEnablement = new ScrollEnablement(this);
316
- this._scrollEnablement.attachEvent("touchend", event => {
317
- this._updateScrolling(event);
318
- });
319
- this._onResizeBound = this._onResize.bind(this);
320
- this._resizing = false; // indicates if the carousel is in process of resizing
321
-
322
- this._lastFocusedElements = [];
323
- this._orderOfLastFocusedPages = [];
324
- }
325
-
326
- onBeforeRendering() {
327
- if (this.arrowsPlacement === CarouselArrowsPlacement.Navigation) {
328
- this._visibleNavigationArrows = true;
329
- }
330
-
331
- this.validateSelectedIndex();
332
- }
333
-
334
- onAfterRendering() {
335
- this._scrollEnablement.scrollContainer = this.getDomRef();
336
- this._resizing = false; // not invalidating
337
- }
338
-
339
- onEnterDOM() {
340
- ResizeHandler.register(this, this._onResizeBound);
341
- }
342
-
343
- onExitDOM() {
344
- ResizeHandler.deregister(this, this._onResizeBound);
345
- }
346
-
347
- validateSelectedIndex() {
348
- if (!this.isIndexInRange(this._selectedIndex)) {
349
- this._selectedIndex = 0;
350
- }
351
- }
352
-
353
- _onResize() {
354
- const previousItemsPerPage = this.effectiveItemsPerPage;
355
-
356
- // Set the resizing flag to suppress animation while resizing
357
- this._resizing = true;
358
-
359
- // Change transitively effectiveItemsPerPage by modifying _width
360
- this._width = this.offsetWidth;
361
- this._itemWidth = Math.floor(this._width / this.effectiveItemsPerPage);
362
-
363
- // Items per page did not change or the current,
364
- // therefore page index does not need to be re-adjusted
365
- if (this.effectiveItemsPerPage === previousItemsPerPage) {
366
- return;
367
- }
368
-
369
- if (this._selectedIndex > this.pagesCount - 1) {
370
- this._selectedIndex = this.pagesCount - 1;
371
- this.fireEvent("navigate", { selectedIndex: this._selectedIndex });
372
- }
373
- }
374
-
375
- _updateScrolling(event) {
376
- if (!event) {
377
- return;
378
- }
379
-
380
- if (event.isLeft) {
381
- this.navigateLeft();
382
- } else if (event.isRight) {
383
- this.navigateRight();
384
- }
385
- }
386
-
387
- async _onkeydown(event) {
388
- if (isF7(event)) {
389
- this._handleF7Key(event);
390
- return;
391
- }
392
-
393
- if (event.target !== this.getDomRef()) {
394
- return;
395
- }
396
-
397
- if (isLeft(event) || isDown(event)) {
398
- this.navigateLeft();
399
- await renderFinished();
400
- this.getDomRef().focus();
401
- } else if (isRight(event) || isUp(event)) {
402
- this.navigateRight();
403
- await renderFinished();
404
- this.getDomRef().focus();
405
- }
406
- }
407
-
408
- _onfocusin(event) {
409
- if (event.target === this.getDomRef()) {
410
- return;
411
- }
412
-
413
- let pageIndex = -1;
414
-
415
- for (let i = 0; i < this.content.length; i++) {
416
- if (this.content[i].contains(event.target)) {
417
- pageIndex = i;
418
- break;
419
- }
420
- }
421
-
422
- if (pageIndex === -1) {
423
- return;
424
- }
425
-
426
- // Save reference of the last focused element for each page
427
- this._lastFocusedElements[pageIndex] = event.target;
428
-
429
- const sortedPageIndex = this._orderOfLastFocusedPages.indexOf(pageIndex);
430
- if (sortedPageIndex === -1) {
431
- this._orderOfLastFocusedPages.unshift(pageIndex);
432
- } else {
433
- this._orderOfLastFocusedPages.splice(0, 0, this._orderOfLastFocusedPages.splice(sortedPageIndex, 1)[0]);
434
- }
435
- }
436
-
437
- _onmouseout() {
438
- if (this.arrowsPlacement === CarouselArrowsPlacement.Content) {
439
- this._visibleNavigationArrows = false;
440
- }
441
- }
442
-
443
- _onmouseover() {
444
- if (this.arrowsPlacement === CarouselArrowsPlacement.Content) {
445
- this._visibleNavigationArrows = true;
446
- }
447
- }
448
-
449
- _handleF7Key(event) {
450
- const lastFocusedElement = this._lastFocusedElements[this._getLastFocusedActivePageIndex];
451
-
452
- if (event.target === this.getDomRef() && lastFocusedElement) {
453
- lastFocusedElement.focus();
454
- } else {
455
- this.getDomRef().focus();
456
- }
457
- }
458
-
459
- get _getLastFocusedActivePageIndex() {
460
- for (let i = 0; i < this._orderOfLastFocusedPages.length; i++) {
461
- const pageIndex = this._orderOfLastFocusedPages[i];
462
-
463
- if (this.isItemInViewport(pageIndex)) {
464
- return pageIndex;
465
- }
466
- }
467
-
468
- return this._selectedIndex;
469
- }
470
-
471
- navigateLeft() {
472
- this._resizing = false;
473
-
474
- const previousSelectedIndex = this._selectedIndex;
475
-
476
- if (this._selectedIndex - 1 < 0) {
477
- if (this.cyclic) {
478
- this._selectedIndex = this.pagesCount - 1;
479
- }
480
- } else {
481
- --this._selectedIndex;
482
- }
483
-
484
- if (previousSelectedIndex !== this._selectedIndex) {
485
- this.fireEvent("navigate", { selectedIndex: this._selectedIndex });
486
- }
487
- }
488
-
489
- navigateRight() {
490
- this._resizing = false;
491
-
492
- const previousSelectedIndex = this._selectedIndex;
493
-
494
- if (this._selectedIndex + 1 > this.pagesCount - 1) {
495
- if (this.cyclic) {
496
- this._selectedIndex = 0;
497
- } else {
498
- return;
499
- }
500
- } else {
501
- ++this._selectedIndex;
502
- }
503
-
504
- if (previousSelectedIndex !== this._selectedIndex) {
505
- this.fireEvent("navigate", { selectedIndex: this._selectedIndex });
506
- }
507
- }
508
-
509
- _navButtonClick(event) {
510
- if (event.target.hasAttribute("arrow-forward")) {
511
- this.navigateRight();
512
- } else {
513
- this.navigateLeft();
514
- }
515
-
516
- this.focus();
517
- }
518
-
519
- /**
520
- * Changes the currently displayed page.
521
- * @param {Integer} itemIndex The index of the target page
522
- * @since 1.0.0-rc.15
523
- * @public
524
- */
525
- navigateTo(itemIndex) {
526
- this._resizing = false;
527
- this._selectedIndex = itemIndex;
528
- }
529
-
530
- /**
531
- * Assuming that all items have the same width
532
- * @private
533
- */
534
- get items() {
535
- return this.content.map((item, idx) => {
536
- const visible = this.isItemInViewport(idx);
537
- return {
538
- id: `${this._id}-carousel-item-${idx + 1}`,
539
- item,
540
- tabIndex: visible ? "0" : "-1",
541
- posinset: idx + 1,
542
- setsize: this.content.length,
543
- styles: {
544
- width: `${this._itemWidth}px`,
545
- },
546
- classes: visible ? "" : "ui5-carousel-item--hidden",
547
- };
548
- });
549
- }
550
-
551
- get effectiveItemsPerPage() {
552
- if (this._width <= 640) {
553
- return this.itemsPerPageS;
554
- }
555
-
556
- if (this._width <= 1024) {
557
- return this.itemsPerPageM;
558
- }
559
-
560
- return this.itemsPerPageL;
561
- }
562
-
563
- isItemInViewport(index) {
564
- return index >= this._selectedIndex && index <= this._selectedIndex + this.effectiveItemsPerPage - 1;
565
- }
566
-
567
- isIndexInRange(index) {
568
- return index >= 0 && index <= this.pagesCount - 1;
569
- }
570
-
571
- /**
572
- * @private
573
- */
574
- get renderNavigation() {
575
- if (!this.hasManyPages) {
576
- return false;
577
- }
578
-
579
- if (this.arrowsPlacement === CarouselArrowsPlacement.Navigation && !this.hideNavigationArrows) {
580
- return true;
581
- }
582
-
583
- if (this.hidePageIndicator) {
584
- return false;
585
- }
586
-
587
- return true;
588
- }
589
-
590
- get hasManyPages() {
591
- return this.pagesCount > 1;
592
- }
593
-
594
- get styles() {
595
- return {
596
- content: {
597
- transform: `translateX(${this._isRTL ? "" : "-"}${this._selectedIndex * this._itemWidth}px`,
598
- },
599
- };
600
- }
601
-
602
- get classes() {
603
- return {
604
- viewport: {
605
- "ui5-carousel-viewport": true,
606
- "ui5-carousel-viewport--single": this.pagesCount === 1,
607
- },
608
- content: {
609
- "ui5-carousel-content": true,
610
- "ui5-carousel-content-no-animation": this.suppressAnimation,
611
- "ui5-carousel-content-has-navigation": this.renderNavigation,
612
- "ui5-carousel-content-has-navigation-and-buttons": this.renderNavigation && this.arrowsPlacement === CarouselArrowsPlacement.Navigation && !this.hideNavigationArrows,
613
- },
614
- navigation: {
615
- "ui5-carousel-navigation-wrapper": true,
616
- "ui5-carousel-navigation-with-buttons": this.renderNavigation && this.arrowsPlacement === CarouselArrowsPlacement.Navigation && !this.hideNavigationArrows,
617
- },
618
- navPrevButton: {
619
- "ui5-carousel-navigation-button--hidden": !this.hasPrev,
620
- },
621
- navNextButton: {
622
- "ui5-carousel-navigation-button--hidden": !this.hasNext,
623
- },
624
- };
625
- }
626
-
627
- get pagesCount() {
628
- const items = this.content.length;
629
- return items > this.effectiveItemsPerPage ? items - this.effectiveItemsPerPage + 1 : 1;
630
- }
631
-
632
- get isPageTypeDots() {
633
- if (this.pageIndicatorStyle === CarouselPageIndicatorStyle.Numeric) {
634
- return false;
635
- }
636
-
637
- return this.pagesCount < Carousel.pageTypeLimit;
638
- }
639
-
640
- get dots() {
641
- const dots = [];
642
- const pages = this.pagesCount;
643
-
644
- for (let index = 0; index < pages; index++) {
645
- dots.push({
646
- active: index === this._selectedIndex,
647
- ariaLabel: Carousel.i18nBundle.getText(CAROUSEL_DOT_TEXT, index + 1, pages),
648
- });
649
- }
650
-
651
- return dots;
652
- }
653
-
654
- get arrows() {
655
- const showArrows = this._visibleNavigationArrows && this.hasManyPages && isDesktop();
656
-
657
- return {
658
- content: !this.hideNavigationArrows && showArrows && this.arrowsPlacement === CarouselArrowsPlacement.Content,
659
- navigation: !this.hideNavigationArrows && showArrows && this.arrowsPlacement === CarouselArrowsPlacement.Navigation,
660
- };
661
- }
662
-
663
- get hasPrev() {
664
- return this.cyclic || this._selectedIndex - 1 >= 0;
665
- }
666
-
667
- get hasNext() {
668
- return this.cyclic || this._selectedIndex + 1 <= this.pagesCount - 1;
669
- }
670
-
671
- get suppressAnimation() {
672
- return this._resizing || getAnimationMode() === AnimationMode.None;
673
- }
674
-
675
- get _isRTL() {
676
- return this.effectiveDir === "rtl";
677
- }
678
-
679
- get selectedIndexToShow() {
680
- return this._isRTL ? this.pagesCount - (this.pagesCount - this._selectedIndex) + 1 : this._selectedIndex + 1;
681
- }
682
-
683
- get ofText() {
684
- return Carousel.i18nBundle.getText(CAROUSEL_OF_TEXT);
685
- }
686
-
687
- get ariaActiveDescendant() {
688
- return this.content.length ? `${this._id}-carousel-item-${this._selectedIndex + 1}` : undefined;
689
- }
690
-
691
- get nextPageText() {
692
- return Carousel.i18nBundle.getText(CAROUSEL_NEXT_ARROW_TEXT);
693
- }
694
-
695
- get previousPageText() {
696
- return Carousel.i18nBundle.getText(CAROUSEL_PREVIOUS_ARROW_TEXT);
697
- }
698
-
699
- /**
700
- * The indices of the currently visible items of the component.
701
- * @readonly
702
- * @since 1.0.0-rc.15
703
- * @returns {Integer[]} the indices of the visible items
704
- */
705
- get visibleItemsIndices() {
706
- const visibleItemsIndices = [];
707
-
708
- this.items.forEach((item, index) => {
709
- if (this.isItemInViewport(index)) {
710
- visibleItemsIndices.push(index);
711
- }
712
- });
713
-
714
- return visibleItemsIndices;
715
- }
716
-
717
- static get dependencies() {
718
- return [
719
- Button,
720
- Label,
721
- ];
722
- }
723
-
724
- static async onDefine() {
725
- Carousel.i18nBundle = await getI18nBundle("@ui5/webcomponents");
726
- }
727
- }
728
-
105
+ let Carousel = Carousel_1 = class Carousel extends UI5Element {
106
+ static get render() {
107
+ return litRender;
108
+ }
109
+ static get styles() {
110
+ return CarouselCss;
111
+ }
112
+ static get template() {
113
+ return CarouselTemplate;
114
+ }
115
+ static get pageTypeLimit() {
116
+ return 9;
117
+ }
118
+ constructor() {
119
+ super();
120
+ this._scrollEnablement = new ScrollEnablement(this);
121
+ this._scrollEnablement.attachEvent("touchend", e => {
122
+ this._updateScrolling(e);
123
+ });
124
+ this._onResizeBound = this._onResize.bind(this);
125
+ this._resizing = false; // indicates if the carousel is in process of resizing
126
+ this._lastFocusedElements = [];
127
+ this._orderOfLastFocusedPages = [];
128
+ }
129
+ onBeforeRendering() {
130
+ if (this.arrowsPlacement === CarouselArrowsPlacement.Navigation) {
131
+ this._visibleNavigationArrows = true;
132
+ }
133
+ this.validateSelectedIndex();
134
+ }
135
+ onAfterRendering() {
136
+ this._scrollEnablement.scrollContainer = this.getDomRef();
137
+ this._resizing = false; // not invalidating
138
+ }
139
+ onEnterDOM() {
140
+ ResizeHandler.register(this, this._onResizeBound);
141
+ }
142
+ onExitDOM() {
143
+ ResizeHandler.deregister(this, this._onResizeBound);
144
+ }
145
+ validateSelectedIndex() {
146
+ if (!this.isIndexInRange(this._selectedIndex)) {
147
+ this._selectedIndex = 0;
148
+ }
149
+ }
150
+ _onResize() {
151
+ const previousItemsPerPage = this.effectiveItemsPerPage;
152
+ // Set the resizing flag to suppress animation while resizing
153
+ this._resizing = true;
154
+ // Change transitively effectiveItemsPerPage by modifying _width
155
+ this._width = this.offsetWidth;
156
+ this._itemWidth = Math.floor(this._width / this.effectiveItemsPerPage);
157
+ // Items per page did not change or the current,
158
+ // therefore page index does not need to be re-adjusted
159
+ if (this.effectiveItemsPerPage === previousItemsPerPage) {
160
+ return;
161
+ }
162
+ if (this._selectedIndex > this.pagesCount - 1) {
163
+ this._selectedIndex = this.pagesCount - 1;
164
+ this.fireEvent("navigate", { selectedIndex: this._selectedIndex });
165
+ }
166
+ }
167
+ _updateScrolling(e) {
168
+ if (!e) {
169
+ return;
170
+ }
171
+ if (e.isLeft) {
172
+ this.navigateLeft();
173
+ }
174
+ else if (e.isRight) {
175
+ this.navigateRight();
176
+ }
177
+ }
178
+ async _onkeydown(e) {
179
+ if (isF7(e)) {
180
+ this._handleF7Key(e);
181
+ return;
182
+ }
183
+ if (e.target !== this.getDomRef()) {
184
+ return;
185
+ }
186
+ if (isLeft(e) || isDown(e)) {
187
+ this.navigateLeft();
188
+ await renderFinished();
189
+ this.getDomRef().focus();
190
+ }
191
+ else if (isRight(e) || isUp(e)) {
192
+ this.navigateRight();
193
+ await renderFinished();
194
+ this.getDomRef().focus();
195
+ }
196
+ }
197
+ _onfocusin(e) {
198
+ const target = e.target;
199
+ if (target === this.getDomRef()) {
200
+ return;
201
+ }
202
+ let pageIndex = -1;
203
+ for (let i = 0; i < this.content.length; i++) {
204
+ if (this.content[i].contains(target)) {
205
+ pageIndex = i;
206
+ break;
207
+ }
208
+ }
209
+ if (pageIndex === -1) {
210
+ return;
211
+ }
212
+ // Save reference of the last focused element for each page
213
+ this._lastFocusedElements[pageIndex] = target;
214
+ const sortedPageIndex = this._orderOfLastFocusedPages.indexOf(pageIndex);
215
+ if (sortedPageIndex === -1) {
216
+ this._orderOfLastFocusedPages.unshift(pageIndex);
217
+ }
218
+ else {
219
+ this._orderOfLastFocusedPages.splice(0, 0, this._orderOfLastFocusedPages.splice(sortedPageIndex, 1)[0]);
220
+ }
221
+ }
222
+ _onmouseout() {
223
+ if (this.arrowsPlacement === CarouselArrowsPlacement.Content) {
224
+ this._visibleNavigationArrows = false;
225
+ }
226
+ }
227
+ _onmouseover() {
228
+ if (this.arrowsPlacement === CarouselArrowsPlacement.Content) {
229
+ this._visibleNavigationArrows = true;
230
+ }
231
+ }
232
+ _handleF7Key(e) {
233
+ const lastFocusedElement = this._lastFocusedElements[this._getLastFocusedActivePageIndex];
234
+ if (e.target === this.getDomRef() && lastFocusedElement) {
235
+ lastFocusedElement.focus();
236
+ }
237
+ else {
238
+ this.getDomRef().focus();
239
+ }
240
+ }
241
+ get _getLastFocusedActivePageIndex() {
242
+ for (let i = 0; i < this._orderOfLastFocusedPages.length; i++) {
243
+ const pageIndex = this._orderOfLastFocusedPages[i];
244
+ if (this.isItemInViewport(pageIndex)) {
245
+ return pageIndex;
246
+ }
247
+ }
248
+ return this._selectedIndex;
249
+ }
250
+ navigateLeft() {
251
+ this._resizing = false;
252
+ const previousSelectedIndex = this._selectedIndex;
253
+ if (this._selectedIndex - 1 < 0) {
254
+ if (this.cyclic) {
255
+ this._selectedIndex = this.pagesCount - 1;
256
+ }
257
+ }
258
+ else {
259
+ --this._selectedIndex;
260
+ }
261
+ if (previousSelectedIndex !== this._selectedIndex) {
262
+ this.fireEvent("navigate", { selectedIndex: this._selectedIndex });
263
+ }
264
+ }
265
+ navigateRight() {
266
+ this._resizing = false;
267
+ const previousSelectedIndex = this._selectedIndex;
268
+ if (this._selectedIndex + 1 > this.pagesCount - 1) {
269
+ if (this.cyclic) {
270
+ this._selectedIndex = 0;
271
+ }
272
+ else {
273
+ return;
274
+ }
275
+ }
276
+ else {
277
+ ++this._selectedIndex;
278
+ }
279
+ if (previousSelectedIndex !== this._selectedIndex) {
280
+ this.fireEvent("navigate", { selectedIndex: this._selectedIndex });
281
+ }
282
+ }
283
+ _navButtonClick(e) {
284
+ const button = e.target;
285
+ if (button.hasAttribute("arrow-forward")) {
286
+ this.navigateRight();
287
+ }
288
+ else {
289
+ this.navigateLeft();
290
+ }
291
+ this.focus();
292
+ }
293
+ /**
294
+ * Changes the currently displayed page.
295
+ * @param {Integer} itemIndex The index of the target page
296
+ * @since 1.0.0-rc.15
297
+ * @method
298
+ * @name sap.ui.webc.main.Carousel#navigateTo
299
+ * @public
300
+ */
301
+ navigateTo(itemIndex) {
302
+ this._resizing = false;
303
+ this._selectedIndex = itemIndex;
304
+ }
305
+ /**
306
+ * Assuming that all items have the same width
307
+ * @private
308
+ */
309
+ get items() {
310
+ return this.content.map((item, idx) => {
311
+ const visible = this.isItemInViewport(idx);
312
+ return {
313
+ id: `${this._id}-carousel-item-${idx + 1}`,
314
+ item,
315
+ tabIndex: visible ? "0" : "-1",
316
+ posinset: `${idx + 1}`,
317
+ setsize: `${this.content.length}`,
318
+ styles: {
319
+ width: `${this._itemWidth || 0}px`,
320
+ },
321
+ classes: visible ? "" : "ui5-carousel-item--hidden",
322
+ };
323
+ });
324
+ }
325
+ get effectiveItemsPerPage() {
326
+ if (!this._width) {
327
+ return this.itemsPerPageL;
328
+ }
329
+ if (this._width <= 640) {
330
+ return this.itemsPerPageS;
331
+ }
332
+ if (this._width <= 1024) {
333
+ return this.itemsPerPageM;
334
+ }
335
+ return this.itemsPerPageL;
336
+ }
337
+ isItemInViewport(index) {
338
+ return index >= this._selectedIndex && index <= this._selectedIndex + this.effectiveItemsPerPage - 1;
339
+ }
340
+ isIndexInRange(index) {
341
+ return index >= 0 && index <= this.pagesCount - 1;
342
+ }
343
+ /**
344
+ * @private
345
+ */
346
+ get renderNavigation() {
347
+ if (!this.hasManyPages) {
348
+ return false;
349
+ }
350
+ if (this.arrowsPlacement === CarouselArrowsPlacement.Navigation && !this.hideNavigationArrows) {
351
+ return true;
352
+ }
353
+ if (this.hidePageIndicator) {
354
+ return false;
355
+ }
356
+ return true;
357
+ }
358
+ get hasManyPages() {
359
+ return this.pagesCount > 1;
360
+ }
361
+ get styles() {
362
+ const items = this._itemWidth || 0;
363
+ return {
364
+ content: {
365
+ transform: `translateX(${this._isRTL ? "" : "-"}${this._selectedIndex * items}px`,
366
+ },
367
+ };
368
+ }
369
+ get classes() {
370
+ return {
371
+ viewport: {
372
+ "ui5-carousel-viewport": true,
373
+ "ui5-carousel-viewport--single": this.pagesCount === 1,
374
+ },
375
+ content: {
376
+ "ui5-carousel-content": true,
377
+ "ui5-carousel-content-no-animation": this.suppressAnimation,
378
+ "ui5-carousel-content-has-navigation": this.renderNavigation,
379
+ "ui5-carousel-content-has-navigation-and-buttons": this.renderNavigation && this.arrowsPlacement === CarouselArrowsPlacement.Navigation && !this.hideNavigationArrows,
380
+ },
381
+ navigation: {
382
+ "ui5-carousel-navigation-wrapper": true,
383
+ "ui5-carousel-navigation-with-buttons": this.renderNavigation && this.arrowsPlacement === CarouselArrowsPlacement.Navigation && !this.hideNavigationArrows,
384
+ },
385
+ navPrevButton: {
386
+ "ui5-carousel-navigation-button--hidden": !this.hasPrev,
387
+ },
388
+ navNextButton: {
389
+ "ui5-carousel-navigation-button--hidden": !this.hasNext,
390
+ },
391
+ };
392
+ }
393
+ get pagesCount() {
394
+ const items = this.content.length;
395
+ return items > this.effectiveItemsPerPage ? items - this.effectiveItemsPerPage + 1 : 1;
396
+ }
397
+ get isPageTypeDots() {
398
+ if (this.pageIndicatorStyle === CarouselPageIndicatorStyle.Numeric) {
399
+ return false;
400
+ }
401
+ return this.pagesCount < Carousel_1.pageTypeLimit;
402
+ }
403
+ get dots() {
404
+ const dots = [];
405
+ const pages = this.pagesCount;
406
+ for (let index = 0; index < pages; index++) {
407
+ dots.push({
408
+ active: index === this._selectedIndex,
409
+ ariaLabel: Carousel_1.i18nBundle.getText(CAROUSEL_DOT_TEXT, index + 1, pages),
410
+ });
411
+ }
412
+ return dots;
413
+ }
414
+ get showArrows() {
415
+ const displayArrows = this._visibleNavigationArrows && this.hasManyPages && isDesktop();
416
+ return {
417
+ content: !this.hideNavigationArrows && displayArrows && this.arrowsPlacement === CarouselArrowsPlacement.Content,
418
+ navigation: !this.hideNavigationArrows && displayArrows && this.arrowsPlacement === CarouselArrowsPlacement.Navigation,
419
+ };
420
+ }
421
+ get hasPrev() {
422
+ return this.cyclic || this._selectedIndex - 1 >= 0;
423
+ }
424
+ get hasNext() {
425
+ return this.cyclic || this._selectedIndex + 1 <= this.pagesCount - 1;
426
+ }
427
+ get suppressAnimation() {
428
+ return this._resizing || getAnimationMode() === AnimationMode.None;
429
+ }
430
+ get _isRTL() {
431
+ return this.effectiveDir === "rtl";
432
+ }
433
+ get selectedIndexToShow() {
434
+ return this._isRTL ? this.pagesCount - (this.pagesCount - this._selectedIndex) + 1 : this._selectedIndex + 1;
435
+ }
436
+ get ofText() {
437
+ return Carousel_1.i18nBundle.getText(CAROUSEL_OF_TEXT);
438
+ }
439
+ get ariaActiveDescendant() {
440
+ return this.content.length ? `${this._id}-carousel-item-${this._selectedIndex + 1}` : undefined;
441
+ }
442
+ get nextPageText() {
443
+ return Carousel_1.i18nBundle.getText(CAROUSEL_NEXT_ARROW_TEXT);
444
+ }
445
+ get previousPageText() {
446
+ return Carousel_1.i18nBundle.getText(CAROUSEL_PREVIOUS_ARROW_TEXT);
447
+ }
448
+ /**
449
+ * The indices of the currently visible items of the component.
450
+ * @readonly
451
+ * @since 1.0.0-rc.15
452
+ * @returns {Integer[]} the indices of the visible items
453
+ */
454
+ get visibleItemsIndices() {
455
+ const visibleItemsIndices = [];
456
+ this.items.forEach((item, index) => {
457
+ if (this.isItemInViewport(index)) {
458
+ visibleItemsIndices.push(index);
459
+ }
460
+ });
461
+ return visibleItemsIndices;
462
+ }
463
+ static get dependencies() {
464
+ return [
465
+ Button,
466
+ Label,
467
+ ];
468
+ }
469
+ static async onDefine() {
470
+ Carousel_1.i18nBundle = await getI18nBundle("@ui5/webcomponents");
471
+ }
472
+ };
473
+ __decorate([
474
+ property({ type: Boolean })
475
+ ], Carousel.prototype, "cyclic", void 0);
476
+ __decorate([
477
+ property({ validator: Integer, defaultValue: 1 })
478
+ ], Carousel.prototype, "itemsPerPageS", void 0);
479
+ __decorate([
480
+ property({ validator: Integer, defaultValue: 1 })
481
+ ], Carousel.prototype, "itemsPerPageM", void 0);
482
+ __decorate([
483
+ property({ validator: Integer, defaultValue: 1 })
484
+ ], Carousel.prototype, "itemsPerPageL", void 0);
485
+ __decorate([
486
+ property({ type: Boolean })
487
+ ], Carousel.prototype, "hideNavigationArrows", void 0);
488
+ __decorate([
489
+ property({ type: Boolean })
490
+ ], Carousel.prototype, "hidePageIndicator", void 0);
491
+ __decorate([
492
+ property({ type: CarouselPageIndicatorStyle, defaultValue: CarouselPageIndicatorStyle.Default })
493
+ ], Carousel.prototype, "pageIndicatorStyle", void 0);
494
+ __decorate([
495
+ property({ validator: Integer, defaultValue: 0 })
496
+ ], Carousel.prototype, "_selectedIndex", void 0);
497
+ __decorate([
498
+ property({ type: CarouselArrowsPlacement, defaultValue: CarouselArrowsPlacement.Content })
499
+ ], Carousel.prototype, "arrowsPlacement", void 0);
500
+ __decorate([
501
+ property({ validator: Integer })
502
+ ], Carousel.prototype, "_width", void 0);
503
+ __decorate([
504
+ property({ validator: Integer })
505
+ ], Carousel.prototype, "_itemWidth", void 0);
506
+ __decorate([
507
+ property({ type: Boolean, noAttribute: true })
508
+ ], Carousel.prototype, "_visibleNavigationArrows", void 0);
509
+ __decorate([
510
+ slot({ "default": true, type: HTMLElement, individualSlots: true })
511
+ ], Carousel.prototype, "content", void 0);
512
+ Carousel = Carousel_1 = __decorate([
513
+ customElement("ui5-carousel"),
514
+ languageAware,
515
+ fastNavigation
516
+ /**
517
+ * Fired whenever the page changes due to user interaction,
518
+ * when the user clicks on the navigation arrows or while resizing,
519
+ * based on the <code>items-per-page-l</code>, <code>items-per-page-m</code> and <code>items-per-page-s</code> properties.
520
+ *
521
+ * @event sap.ui.webc.main.Carousel#navigate
522
+ * @param {Integer} selectedIndex the current selected index
523
+ * @public
524
+ * @since 1.0.0-rc.7
525
+ */
526
+ ,
527
+ event("navigate", {
528
+ detail: {
529
+ selectedIndex: { type: Integer },
530
+ },
531
+ })
532
+ ], Carousel);
729
533
  Carousel.define();
730
-
731
534
  export default Carousel;
535
+ //# sourceMappingURL=Carousel.js.map