@brightspace-ui/core 2.72.0 → 2.73.1
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.
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
|
|
30
30
|
<d2l-demo-snippet>
|
|
31
31
|
<template>
|
|
32
|
-
<d2l-more-less height="
|
|
33
|
-
<p id="img-target">
|
|
32
|
+
<d2l-more-less height="8em">
|
|
33
|
+
<p id="img-target">Lorem ipsum dolor sit amet, consectetur adipiscing elit, magna aliqua quis. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident <a href="">proident.</a></p>
|
|
34
34
|
</d2l-more-less>
|
|
35
35
|
</template>
|
|
36
36
|
</d2l-demo-snippet>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
<d2l-demo-snippet>
|
|
41
41
|
<template>
|
|
42
|
-
<d2l-more-less expanded
|
|
42
|
+
<d2l-more-less expanded>
|
|
43
43
|
<p id="clone-target">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum elementum venenatis arcu sit amet varius. Maecenas posuere magna arcu, quis maximus odio fringilla ac. Integer ligula lorem, faucibus sit amet cursus vel, pellentesque a justo. Aliquam urna metus, molestie at tempor eget, vestibulum a purus. Donec aliquet rutrum mi. Duis ornare congue tempor. Nullam sed massa fermentum, tincidunt leo eu, vestibulum orci. Sed ultrices est in lacus venenatis, posuere suscipit arcu scelerisque. In aliquam ipsum rhoncus, lobortis ligula ut, molestie orci. Proin scelerisque tempor posuere. Phasellus consequat, lorem quis hendrerit tempor, sem lectus sagittis nunc, in tristique dui arcu non arcu. Nunc aliquam nisi et sapien commodo lacinia. <a href="">Quisque</a> iaculis orci vel odio varius porta. Fusce tincidunt dolor enim, vitae sollicitudin purus suscipit eu.</p>
|
|
44
44
|
</d2l-more-less>
|
|
45
45
|
</template>
|
|
@@ -46,9 +46,9 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
|
|
|
46
46
|
* @type {boolean}
|
|
47
47
|
*/
|
|
48
48
|
inactive: { type: Boolean, reflect: true },
|
|
49
|
-
__blurBackground: {
|
|
50
|
-
|
|
51
|
-
__transitionAdded: {
|
|
49
|
+
__blurBackground: { state: true },
|
|
50
|
+
__maxHeight: { state: true },
|
|
51
|
+
__transitionAdded: { state: true }
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -62,7 +62,7 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
|
|
|
62
62
|
overflow: hidden;
|
|
63
63
|
}
|
|
64
64
|
.d2l-more-less-transition {
|
|
65
|
-
transition: height 400ms cubic-bezier(0, 0.7, 0.5, 1);
|
|
65
|
+
transition: max-height 400ms cubic-bezier(0, 0.7, 0.5, 1);
|
|
66
66
|
}
|
|
67
67
|
.d2l-more-less-blur {
|
|
68
68
|
display: none;
|
|
@@ -83,13 +83,14 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
|
|
|
83
83
|
constructor() {
|
|
84
84
|
super();
|
|
85
85
|
|
|
86
|
-
this.__blurBackground = 'linear-gradient(rgba(255, 255, 255, 0) 0%, rgb(255, 255, 255) 100%)';
|
|
87
|
-
this.__transitionAdded = false;
|
|
88
|
-
|
|
89
86
|
this.expanded = false;
|
|
90
87
|
this.height = '4em';
|
|
91
88
|
this.inactive = false;
|
|
92
89
|
|
|
90
|
+
this.__blurBackground = 'linear-gradient(rgba(255, 255, 255, 0) 0%, rgb(255, 255, 255) 100%)';
|
|
91
|
+
this.__transitionAdded = false;
|
|
92
|
+
this.__maxHeight = this.height;
|
|
93
|
+
|
|
93
94
|
this.__baseHeight = 0;
|
|
94
95
|
this.__contentId = getUniqueId();
|
|
95
96
|
this.__resizeObserver = null;
|
|
@@ -135,9 +136,6 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
|
|
|
135
136
|
|
|
136
137
|
this.__content = this.shadowRoot.querySelector('.d2l-more-less-content');
|
|
137
138
|
this.__contentSlot = this.shadowRoot.querySelector('.d2l-more-less-content slot');
|
|
138
|
-
if (this.__content.offsetParent !== null) {
|
|
139
|
-
this.__init_setBaseHeight();
|
|
140
|
-
}
|
|
141
139
|
this.__init_setupBlurColour();
|
|
142
140
|
this.__init_setupListeners();
|
|
143
141
|
|
|
@@ -160,7 +158,7 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
|
|
|
160
158
|
'd2l-more-less-transition': this.__transitionAdded
|
|
161
159
|
};
|
|
162
160
|
return html`
|
|
163
|
-
<div id="${this.__contentId}" class=${classMap(contentClasses)} style=${styleMap({
|
|
161
|
+
<div id="${this.__contentId}" class=${classMap(contentClasses)} style=${styleMap({ maxHeight: `${this.__maxHeight}` })}>
|
|
164
162
|
<slot></slot>
|
|
165
163
|
</div>
|
|
166
164
|
<div class="d2l-more-less-blur" style=${styleMap({ background: `${this.__blurBackground}` })}></div>
|
|
@@ -204,17 +202,17 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
|
|
|
204
202
|
|
|
205
203
|
__adjustToContent_makeActive() {
|
|
206
204
|
this.inactive = false;
|
|
207
|
-
this.
|
|
205
|
+
this.__maxHeight = this.height;
|
|
208
206
|
}
|
|
209
207
|
|
|
210
208
|
__adjustToContent_makeInactive() {
|
|
211
209
|
this.inactive = true;
|
|
212
210
|
this.expanded = false;
|
|
213
|
-
this.
|
|
211
|
+
this.__maxHeight = `${this.__content.scrollHeight}px`;
|
|
214
212
|
}
|
|
215
213
|
|
|
216
214
|
__adjustToContent_resize(contentHeight) {
|
|
217
|
-
this.
|
|
215
|
+
this.__maxHeight = `${contentHeight}px`;
|
|
218
216
|
}
|
|
219
217
|
|
|
220
218
|
__computeAriaExpanded() {
|
|
@@ -231,7 +229,7 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
|
|
|
231
229
|
|
|
232
230
|
__expand() {
|
|
233
231
|
this.__transitionAdded = true;
|
|
234
|
-
this.
|
|
232
|
+
this.__maxHeight = `${this.__content.scrollHeight}px`;
|
|
235
233
|
this.expanded = true;
|
|
236
234
|
}
|
|
237
235
|
|
|
@@ -266,7 +264,7 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
|
|
|
266
264
|
}
|
|
267
265
|
|
|
268
266
|
__init_setBaseHeight() {
|
|
269
|
-
this.
|
|
267
|
+
this.__maxHeight = this.height;
|
|
270
268
|
|
|
271
269
|
requestAnimationFrame(() => {
|
|
272
270
|
this.__init_measureBaseHeight();
|
|
@@ -341,7 +339,7 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
|
|
|
341
339
|
|
|
342
340
|
__shrink() {
|
|
343
341
|
this.__transitionAdded = true;
|
|
344
|
-
this.
|
|
342
|
+
this.__maxHeight = this.height;
|
|
345
343
|
this.expanded = false;
|
|
346
344
|
}
|
|
347
345
|
|
package/custom-elements.json
CHANGED
|
@@ -11385,6 +11385,12 @@
|
|
|
11385
11385
|
"type": "boolean",
|
|
11386
11386
|
"default": "false"
|
|
11387
11387
|
},
|
|
11388
|
+
{
|
|
11389
|
+
"name": "secondary-first",
|
|
11390
|
+
"description": "When set to true, the secondary panel will be displayed on the left (or the\nright in RTL) in the desktop view. This attribute has no effect on the mobile view.",
|
|
11391
|
+
"type": "boolean",
|
|
11392
|
+
"default": "false"
|
|
11393
|
+
},
|
|
11388
11394
|
{
|
|
11389
11395
|
"name": "width-type",
|
|
11390
11396
|
"description": "Whether content fills the screen or not",
|
|
@@ -11419,6 +11425,13 @@
|
|
|
11419
11425
|
"type": "boolean",
|
|
11420
11426
|
"default": "false"
|
|
11421
11427
|
},
|
|
11428
|
+
{
|
|
11429
|
+
"name": "secondaryFirst",
|
|
11430
|
+
"attribute": "secondary-first",
|
|
11431
|
+
"description": "When set to true, the secondary panel will be displayed on the left (or the\nright in RTL) in the desktop view. This attribute has no effect on the mobile view.",
|
|
11432
|
+
"type": "boolean",
|
|
11433
|
+
"default": "false"
|
|
11434
|
+
},
|
|
11422
11435
|
{
|
|
11423
11436
|
"name": "widthType",
|
|
11424
11437
|
"attribute": "width-type",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.73.1",
|
|
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",
|
|
@@ -55,6 +55,7 @@ If either of the panels contain an `iframe`, resizing may not work properly. Thi
|
|
|
55
55
|
| `background-shading` | String, default: `'none'` | Controls whether the primary and secondary panels have shaded backgrounds. Can be one of `'primary'`, `'secondary'`, `'none'`. |
|
|
56
56
|
| `primary-overflow` | String, default: `'default'` | Controls how the primary panel's contents overflow. Can be one of `'default'`, `'hidden'`. |
|
|
57
57
|
| `resizable` | Boolean, default: `false` | Whether the panels are user resizable. This only applies to desktop users, mobile users will always be able to resize. |
|
|
58
|
+
| `secondary-first` | Boolean, default: `false` | When set to true, the secondary panel will be displayed on the left (or the right in RTL) in the desktop view. This attribute has no effect on the mobile view. |
|
|
58
59
|
| `storage-key` | String | The key used to persist the divider's position to local storage. This key should not be shared between appliactions so that users can save different divider positions for different applications. If no key is provided, the template will fall back its default size. |
|
|
59
60
|
| `width-type` | String, default: `'fullscreen'` | Whether content fills the screen or not. When set to `normal`, the width of the template is constrained to `1230px`. Can be one of `'fullscreen'`, `'normal'`. |
|
|
60
61
|
|
|
@@ -49,6 +49,7 @@ class Resizer {
|
|
|
49
49
|
this.isMobile = false;
|
|
50
50
|
this.panelSize = 0;
|
|
51
51
|
this.isRtl = false;
|
|
52
|
+
this.secondaryFirst = false;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
clampHeight(height) {
|
|
@@ -112,15 +113,18 @@ class DesktopKeyboardResizer extends Resizer {
|
|
|
112
113
|
if (this.isMobile) {
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
-
const rightKeyCode = this.isRtl ? keyCodes.LEFT : keyCodes.RIGHT;
|
|
117
|
-
if (e.keyCode !== leftKeyCode && e.keyCode !== rightKeyCode) {
|
|
116
|
+
if (e.keyCode !== keyCodes.LEFT && e.keyCode !== keyCodes.RIGHT) {
|
|
118
117
|
return;
|
|
119
118
|
}
|
|
120
119
|
e.preventDefault();
|
|
120
|
+
|
|
121
|
+
// The direction of the container is flipped if exactly one of isRtl and secondaryFirst is true
|
|
122
|
+
const isFlipped = this.isRtl ^ this.secondaryFirst;
|
|
123
|
+
const direction = e.keyCode === keyCodes.LEFT && !isFlipped
|
|
124
|
+
|| e.keyCode === keyCodes.RIGHT && isFlipped ? 1 : -1;
|
|
121
125
|
let secondaryWidth;
|
|
122
126
|
if (this.panelSize === 0) {
|
|
123
|
-
if (
|
|
127
|
+
if (direction === 1) {
|
|
124
128
|
secondaryWidth = this.contentBounds.minWidth;
|
|
125
129
|
} else {
|
|
126
130
|
secondaryWidth = 0;
|
|
@@ -129,7 +133,6 @@ class DesktopKeyboardResizer extends Resizer {
|
|
|
129
133
|
const steps = clamp(Math.round((this.contentBounds.maxWidth - this.contentBounds.minWidth) / desktopStepDelta), desktopMinSteps, desktopMaxSteps);
|
|
130
134
|
const delta = (this.contentBounds.maxWidth - this.contentBounds.minWidth) / steps;
|
|
131
135
|
|
|
132
|
-
const direction = e.keyCode === leftKeyCode ? 1 : -1;
|
|
133
136
|
const desiredWidth = this.panelSize + delta * direction;
|
|
134
137
|
const desiredSteppedWidth = this.contentBounds.minWidth + delta * Math.round((desiredWidth - this.contentBounds.minWidth) / delta);
|
|
135
138
|
|
|
@@ -180,7 +183,8 @@ class DesktopMouseResizer extends Resizer {
|
|
|
180
183
|
|
|
181
184
|
_computeContentX(clientX) {
|
|
182
185
|
const x = clientX - this.contentRect.left;
|
|
183
|
-
|
|
186
|
+
// The direction of the container is flipped if exactly one of isRtl and secondaryFirst is true
|
|
187
|
+
return this.isRtl ^ this.secondaryFirst ? x : this.contentRect.width - x;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
_onMouseDown(e) {
|
|
@@ -487,6 +491,12 @@ class TemplatePrimarySecondary extends FocusVisiblePolyfillMixin(RtlMixin(Locali
|
|
|
487
491
|
* @type {boolean}
|
|
488
492
|
*/
|
|
489
493
|
resizable: { type: Boolean, reflect: true },
|
|
494
|
+
/**
|
|
495
|
+
* When set to true, the secondary panel will be displayed on the left (or the
|
|
496
|
+
* right in RTL) in the desktop view. This attribute has no effect on the mobile view.
|
|
497
|
+
* @type {boolean}
|
|
498
|
+
*/
|
|
499
|
+
secondaryFirst: { type: Boolean, attribute: 'secondary-first', reflect: true },
|
|
490
500
|
/**
|
|
491
501
|
* The key used to persist the divider's position to local storage. This key
|
|
492
502
|
* should not be shared between pages so that users can save different divider
|
|
@@ -887,6 +897,7 @@ class TemplatePrimarySecondary extends FocusVisiblePolyfillMixin(RtlMixin(Locali
|
|
|
887
897
|
|
|
888
898
|
this.backgroundShading = 'none';
|
|
889
899
|
this.resizable = false;
|
|
900
|
+
this.secondaryFirst = false;
|
|
890
901
|
this.widthType = 'fullscreen';
|
|
891
902
|
|
|
892
903
|
this._animateResize = false;
|
|
@@ -933,11 +944,19 @@ class TemplatePrimarySecondary extends FocusVisiblePolyfillMixin(RtlMixin(Locali
|
|
|
933
944
|
'd2l-template-scroll': isWindows
|
|
934
945
|
};
|
|
935
946
|
const keyboardHelpText = this._isMobile ? this.localize('templates.primary-secondary.keyboardVertical') : this.localize('templates.primary-secondary.keyboardHorizontal');
|
|
947
|
+
const primarySection = html`<main class="${classMap(scrollClasses)}"><slot name="primary"></slot></main>`;
|
|
948
|
+
const secondarySection = html`
|
|
949
|
+
<div style=${styleMap(secondaryPanelStyles)} class="d2l-template-primary-secondary-secondary-container" @transitionend=${this._onTransitionEnd}>
|
|
950
|
+
<div class="d2l-template-primary-secondary-divider-shadow"></div>
|
|
951
|
+
<aside class="${classMap(scrollClasses)}">
|
|
952
|
+
<slot name="secondary"></slot>
|
|
953
|
+
</aside>
|
|
954
|
+
</div>`;
|
|
936
955
|
return html`
|
|
937
956
|
<div class="d2l-template-primary-secondary-container">
|
|
938
957
|
<header><slot name="header"></slot></header>
|
|
939
958
|
<div class="d2l-template-primary-secondary-content" data-background-shading="${this.backgroundShading}" ?data-animate-resize=${this._animateResize} ?data-is-collapsed=${this._isCollapsed} ?data-is-expanded=${this._isExpanded}>
|
|
940
|
-
|
|
959
|
+
${this.secondaryFirst && !this._isMobile ? secondarySection : primarySection}
|
|
941
960
|
<d2l-offscreen id="${this._keyboardDescId}">${keyboardHelpText}</d2l-offscreen>
|
|
942
961
|
<div tabindex="${ifDefined(tabindex)}" class="d2l-template-primary-secondary-divider" role=separator aria-label="${this.localize('templates.primary-secondary.adjustableSplitView')}" aria-describedby="${this._keyboardDescId}" aria-orientation=${this._isMobile ? 'horizontal' : 'vertical'} aria-valuenow="${ifDefined(separatorVal)}" aria-valuemax="${ifDefined(separatorMax)}">
|
|
943
962
|
<div class="d2l-template-primary-secondary-divider-handle" @click=${this._onHandleTap} @mousedown=${this._onHandleTapStart}>
|
|
@@ -959,13 +978,7 @@ class TemplatePrimarySecondary extends FocusVisiblePolyfillMixin(RtlMixin(Locali
|
|
|
959
978
|
</div>
|
|
960
979
|
</div>
|
|
961
980
|
</div>
|
|
962
|
-
|
|
963
|
-
<div class="d2l-template-primary-secondary-divider-shadow">
|
|
964
|
-
</div>
|
|
965
|
-
<aside class="${classMap(scrollClasses)}">
|
|
966
|
-
<slot name="secondary"></slot>
|
|
967
|
-
</aside>
|
|
968
|
-
</div>
|
|
981
|
+
${this.secondaryFirst && !this._isMobile ? primarySection : secondarySection}
|
|
969
982
|
</div>
|
|
970
983
|
<footer ?hidden="${!this._hasFooter}">
|
|
971
984
|
<div class="d2l-template-primary-secondary-footer"><slot name="footer" @slotchange="${this._handleFooterSlotChange}"></div></slot>
|
|
@@ -986,6 +999,10 @@ class TemplatePrimarySecondary extends FocusVisiblePolyfillMixin(RtlMixin(Locali
|
|
|
986
999
|
}
|
|
987
1000
|
}
|
|
988
1001
|
}
|
|
1002
|
+
if (changedProperties.has('secondaryFirst')) {
|
|
1003
|
+
this._desktopKeyboardResizer.secondaryFirst = this.secondaryFirst;
|
|
1004
|
+
this._desktopMouseResizer.secondaryFirst = this.secondaryFirst;
|
|
1005
|
+
}
|
|
989
1006
|
if (!this._secondary) {
|
|
990
1007
|
this._secondary = this.shadowRoot.querySelector('aside');
|
|
991
1008
|
this._divider = this.shadowRoot.querySelector('.d2l-template-primary-secondary-divider');
|