@brightspace-ui/core 3.88.3 → 3.88.4
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.
@@ -2,7 +2,6 @@ import '../colors/colors.js';
|
|
2
2
|
import { css, html, LitElement, unsafeCSS } from 'lit';
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
4
4
|
import { getFocusPseudoClass } from '../../helpers/focus.js';
|
5
|
-
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
|
6
5
|
import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
|
7
6
|
|
8
7
|
const keyCodes = {
|
@@ -10,7 +9,7 @@ const keyCodes = {
|
|
10
9
|
SPACE: 32
|
11
10
|
};
|
12
11
|
|
13
|
-
class Tab extends SkeletonMixin(
|
12
|
+
class Tab extends SkeletonMixin(LitElement) {
|
14
13
|
|
15
14
|
static get properties() {
|
16
15
|
return {
|
@@ -44,11 +43,7 @@ class Tab extends SkeletonMixin(RtlMixin(LitElement)) {
|
|
44
43
|
top: 0.15rem;
|
45
44
|
}
|
46
45
|
:host(:first-child) .d2l-tab-text {
|
47
|
-
margin-
|
48
|
-
}
|
49
|
-
:host([dir="rtl"]:first-child) .d2l-tab-text {
|
50
|
-
margin-left: 0.6rem;
|
51
|
-
margin-right: 0;
|
46
|
+
margin-inline-start: 0;
|
52
47
|
}
|
53
48
|
.d2l-tab-selected-indicator {
|
54
49
|
border-top: 4px solid var(--d2l-color-celestine);
|
@@ -69,13 +64,9 @@ class Tab extends SkeletonMixin(RtlMixin(LitElement)) {
|
|
69
64
|
min-width: 50px;
|
70
65
|
}
|
71
66
|
:host(:first-child) .d2l-tab-selected-indicator {
|
72
|
-
margin-
|
67
|
+
margin-inline-start: 0;
|
73
68
|
width: calc(100% - 0.6rem);
|
74
69
|
}
|
75
|
-
:host([dir="rtl"]:first-child) .d2l-tab-selected-indicator {
|
76
|
-
margin-left: 0.6rem;
|
77
|
-
margin-right: 0;
|
78
|
-
}
|
79
70
|
:host(:${unsafeCSS(getFocusPseudoClass())}) > .d2l-tab-text {
|
80
71
|
border-radius: 0.3rem;
|
81
72
|
box-shadow: 0 0 0 2px var(--d2l-color-celestine);
|
package/components/tabs/tab.js
CHANGED
package/components/tabs/tabs.js
CHANGED
@@ -11,7 +11,6 @@ import { getFocusPseudoClass } from '../../helpers/focus.js';
|
|
11
11
|
import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
|
12
12
|
import { repeat } from 'lit/directives/repeat.js';
|
13
13
|
import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
|
14
|
-
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
|
15
14
|
import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
|
16
15
|
import { styleMap } from 'lit/directives/style-map.js';
|
17
16
|
|
@@ -19,41 +18,13 @@ const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
19
18
|
|
20
19
|
const scrollButtonWidth = 56;
|
21
20
|
|
22
|
-
// remove once IE11 is no longer supported
|
23
|
-
if (!Array.prototype.findIndex) {
|
24
|
-
Object.defineProperty(Array.prototype, 'findIndex', {
|
25
|
-
value: function(predicate) {
|
26
|
-
|
27
|
-
if (this === null) throw new TypeError('"this" is null or not defined');
|
28
|
-
|
29
|
-
const o = Object(this);
|
30
|
-
const len = o.length >>> 0;
|
31
|
-
|
32
|
-
if (typeof predicate !== 'function') throw new TypeError('predicate must be a function');
|
33
|
-
|
34
|
-
const thisArg = arguments[1];
|
35
|
-
let k = 0;
|
36
|
-
|
37
|
-
while (k < len) {
|
38
|
-
const kValue = o[k];
|
39
|
-
if (predicate.call(thisArg, kValue, k, o)) return k;
|
40
|
-
k++;
|
41
|
-
}
|
42
|
-
|
43
|
-
return -1;
|
44
|
-
},
|
45
|
-
configurable: true,
|
46
|
-
writable: true
|
47
|
-
});
|
48
|
-
}
|
49
|
-
|
50
21
|
/**
|
51
22
|
* A component for tabbed content. It supports the "d2l-tab-panel" component for the content, renders tabs responsively, and provides virtual scrolling for large tab lists.
|
52
23
|
* @slot - Contains the tab panels (e.g., "d2l-tab-panel" components)
|
53
24
|
* @slot ext - Additional content (e.g., a button) positioned at right
|
54
25
|
* @fires d2l-tabs-initialized - Dispatched when the component is initialized
|
55
26
|
*/
|
56
|
-
class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(
|
27
|
+
class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(LitElement))) {
|
57
28
|
|
58
29
|
static get properties() {
|
59
30
|
return {
|
@@ -113,11 +84,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
113
84
|
}
|
114
85
|
.d2l-tabs-container-ext {
|
115
86
|
flex: none;
|
116
|
-
padding-
|
117
|
-
}
|
118
|
-
:host([dir="rtl"]) .d2l-tabs-container-ext {
|
119
|
-
padding-left: 0;
|
120
|
-
padding-right: 4px;
|
87
|
+
padding-inline: 4px 0;
|
121
88
|
}
|
122
89
|
.d2l-tabs-container-list {
|
123
90
|
display: block;
|
@@ -136,27 +103,15 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
136
103
|
z-index: 1;
|
137
104
|
}
|
138
105
|
.d2l-tabs-scroll-previous-container {
|
139
|
-
|
140
|
-
margin-
|
141
|
-
}
|
142
|
-
:host([dir="rtl"]) .d2l-tabs-scroll-previous-container {
|
143
|
-
left: auto;
|
144
|
-
margin-left: 0;
|
145
|
-
margin-right: 4px;
|
146
|
-
right: 0;
|
106
|
+
inset-inline-start: 0;
|
107
|
+
margin-inline: 4px 0;
|
147
108
|
}
|
148
109
|
.d2l-tabs-container[data-allow-scroll-previous] > .d2l-tabs-scroll-previous-container {
|
149
110
|
display: inline-block;
|
150
111
|
}
|
151
112
|
.d2l-tabs-scroll-next-container {
|
152
|
-
|
153
|
-
|
154
|
-
}
|
155
|
-
:host([dir="rtl"]) .d2l-tabs-scroll-next-container {
|
156
|
-
left: 0;
|
157
|
-
margin-left: 4px;
|
158
|
-
margin-right: 0;
|
159
|
-
right: auto;
|
113
|
+
inset-inline-end: 0;
|
114
|
+
margin-inline: 0 4px;
|
160
115
|
}
|
161
116
|
.d2l-tabs-container[data-allow-scroll-next] > .d2l-tabs-scroll-next-container {
|
162
117
|
display: inline-block;
|
@@ -290,7 +245,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
290
245
|
const measures = this._getMeasures();
|
291
246
|
const newTranslationValue = this._calculateScrollPosition(tabInfo, measures);
|
292
247
|
|
293
|
-
if (this
|
248
|
+
if (!this.#isRTL()) {
|
294
249
|
if (newTranslationValue >= 0) return;
|
295
250
|
} else {
|
296
251
|
if (newTranslationValue <= 0) return;
|
@@ -434,8 +389,10 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
434
389
|
const isOverflowingLeft = (selectedTabMeasures.offsetLeft + this._translationValue < 0);
|
435
390
|
const isOverflowingRight = (selectedTabMeasures.offsetLeft + selectedTabMeasures.rect.width + this._translationValue > measures.tabsContainerRect.width);
|
436
391
|
|
392
|
+
const isRTL = this.#isRTL();
|
393
|
+
|
437
394
|
let getNewTranslationValue;
|
438
|
-
if (
|
395
|
+
if (!isRTL) {
|
439
396
|
getNewTranslationValue = () => {
|
440
397
|
if (selectedTabIndex === 0) {
|
441
398
|
// position selected tab at beginning
|
@@ -471,7 +428,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
471
428
|
let expectedPosition;
|
472
429
|
|
473
430
|
// make sure the new position will not place selected tab behind left scroll button
|
474
|
-
if (
|
431
|
+
if (!isRTL) {
|
475
432
|
expectedPosition = selectedTabMeasures.offsetLeft + newTranslationValue;
|
476
433
|
if (newTranslationValue < 0 && this._isPositionInLeftScrollArea(expectedPosition)) {
|
477
434
|
newTranslationValue = getNewTranslationValue();
|
@@ -483,7 +440,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
483
440
|
}
|
484
441
|
}
|
485
442
|
|
486
|
-
if (
|
443
|
+
if (!isRTL) {
|
487
444
|
// make sure there will not be any empty space between left side of container and first tab
|
488
445
|
if (newTranslationValue > 0) newTranslationValue = 0;
|
489
446
|
} else {
|
@@ -492,7 +449,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
492
449
|
}
|
493
450
|
|
494
451
|
// make sure the new position will not place selected tab behind the right scroll button
|
495
|
-
if (
|
452
|
+
if (!isRTL) {
|
496
453
|
expectedPosition = selectedTabMeasures.offsetLeft + selectedTabMeasures.rect.width + newTranslationValue;
|
497
454
|
if ((selectedTabIndex < this._tabInfos.length - 1) && this._isPositionInRightScrollArea(expectedPosition, measures)) {
|
498
455
|
newTranslationValue = getNewTranslationValue();
|
@@ -556,13 +513,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
556
513
|
}
|
557
514
|
|
558
515
|
_getTabInfo(id) {
|
559
|
-
|
560
|
-
return this._tabInfos.find((t) => t.id === id);
|
561
|
-
} else {
|
562
|
-
// IE11
|
563
|
-
const index = this._tabInfos.findIndex((t) => t.id === id);
|
564
|
-
return index !== -1 ? this._tabInfos[index] : null;
|
565
|
-
}
|
516
|
+
return this._tabInfos.find((t) => t.id === id);
|
566
517
|
}
|
567
518
|
|
568
519
|
_handleFocusOut(e) {
|
@@ -695,7 +646,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
695
646
|
const lastTabMeasures = measures.tabRects[measures.tabRects.length - 1];
|
696
647
|
let isOverflowingNext;
|
697
648
|
|
698
|
-
if (this
|
649
|
+
if (!this.#isRTL()) {
|
699
650
|
|
700
651
|
newTranslationValue = (this._translationValue - measures.tabsContainerRect.width + scrollButtonWidth);
|
701
652
|
if (newTranslationValue < 0) newTranslationValue += scrollButtonWidth;
|
@@ -738,7 +689,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
738
689
|
let newTranslationValue;
|
739
690
|
let isOverflowingPrevious;
|
740
691
|
|
741
|
-
if (this
|
692
|
+
if (!this.#isRTL()) {
|
742
693
|
|
743
694
|
newTranslationValue = (this._translationValue + measures.tabsContainerRect.width - scrollButtonWidth);
|
744
695
|
isOverflowingPrevious = (newTranslationValue < 0);
|
@@ -921,7 +872,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
921
872
|
return Promise.resolve();
|
922
873
|
}
|
923
874
|
|
924
|
-
if (this
|
875
|
+
if (!this.#isRTL()) {
|
925
876
|
// show/hide scroll buttons
|
926
877
|
this._allowScrollPrevious = (this._translationValue < 0);
|
927
878
|
this._allowScrollNext = (lastTabMeasures.offsetLeft + lastTabMeasures.rect.width + this._translationValue > measures.tabsContainerRect.width);
|
@@ -986,6 +937,10 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(SkeletonMixin(RtlMixin(Lit
|
|
986
937
|
return this.updateComplete;
|
987
938
|
}
|
988
939
|
|
940
|
+
#isRTL() {
|
941
|
+
return document.documentElement.getAttribute('dir') === 'rtl';
|
942
|
+
}
|
943
|
+
|
989
944
|
}
|
990
945
|
|
991
946
|
customElements.define('d2l-tabs', Tabs);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.88.
|
3
|
+
"version": "3.88.4",
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
5
5
|
"type": "module",
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|