@brightspace-ui/core 3.140.0 → 3.140.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.
@@ -4,7 +4,7 @@ import { css, html, LitElement } from 'lit';
|
|
4
4
|
import { getBoundingAncestor, getComposedParent, isComposedAncestor } from '../../helpers/dom.js';
|
5
5
|
import { getComposedActiveElement } from '../../helpers/focus.js';
|
6
6
|
import { getLegacyOffsetParent } from '../../helpers/offsetParent-legacy.js';
|
7
|
-
import {
|
7
|
+
import { LoadingCompleteMixin } from '../../mixins/loading-complete/loading-complete-mixin.js';
|
8
8
|
import { styleMap } from 'lit/directives/style-map.js';
|
9
9
|
|
10
10
|
const mediaQueryList = window.matchMedia('(max-height: 500px)');
|
@@ -14,7 +14,7 @@ const MINIMUM_TARGET_SIZE = 24;
|
|
14
14
|
* A wrapper component to display floating workflow buttons. When the normal position of the workflow buttons is below the bottom edge of the viewport, they will dock at the bottom edge. When the normal position becomes visible, they will undock.
|
15
15
|
* @slot - Content to be displayed in the floating container
|
16
16
|
*/
|
17
|
-
class FloatingButtons extends
|
17
|
+
class FloatingButtons extends LoadingCompleteMixin(LitElement) {
|
18
18
|
|
19
19
|
static get properties() {
|
20
20
|
return {
|
@@ -26,8 +26,7 @@ class FloatingButtons extends RtlMixin(LitElement) {
|
|
26
26
|
_containerMarginLeft: { attribute: false, type: String },
|
27
27
|
_containerMarginRight: { attribute: false, type: String },
|
28
28
|
_floating: { type: Boolean, reflect: true },
|
29
|
-
_innerContainerLeft: { attribute: false, type: String }
|
30
|
-
_innerContainerRight: { attribute: false, type: String }
|
29
|
+
_innerContainerLeft: { attribute: false, type: String }
|
31
30
|
};
|
32
31
|
}
|
33
32
|
|
@@ -80,21 +79,14 @@ class FloatingButtons extends RtlMixin(LitElement) {
|
|
80
79
|
.d2l-floating-buttons-inner-container ::slotted(d2l-button),
|
81
80
|
.d2l-floating-buttons-inner-container ::slotted(button),
|
82
81
|
.d2l-floating-buttons-inner-container ::slotted(.d2l-button) {
|
82
|
+
margin-inline-end: 0.75rem !important;
|
83
83
|
margin-bottom: 0.75rem !important;
|
84
|
-
margin-right: 0.75rem !important;
|
85
84
|
}
|
86
85
|
|
87
86
|
.d2l-floating-buttons-inner-container ::slotted(d2l-overflow-group) {
|
88
87
|
padding-bottom: 0.75rem !important;
|
89
88
|
}
|
90
89
|
|
91
|
-
:host([dir="rtl"]) .d2l-floating-buttons-inner-container ::slotted(d2l-button),
|
92
|
-
:host([dir="rtl"]) .d2l-floating-buttons-inner-container ::slotted(button),
|
93
|
-
:host([dir="rtl"]) .d2l-floating-buttons-inner-container ::slotted(.d2l-button) {
|
94
|
-
margin-left: 0.75rem !important;
|
95
|
-
margin-right: 0 !important;
|
96
|
-
}
|
97
|
-
|
98
90
|
@media (prefers-reduced-motion: reduce) {
|
99
91
|
:host([_floating]:not([always-float])) .d2l-floating-buttons-container {
|
100
92
|
transition: none;
|
@@ -110,7 +102,6 @@ class FloatingButtons extends RtlMixin(LitElement) {
|
|
110
102
|
this._containerMarginRight = '';
|
111
103
|
this._floating = false;
|
112
104
|
this._innerContainerLeft = '';
|
113
|
-
this._innerContainerRight = '';
|
114
105
|
this._intersectionObserver = null;
|
115
106
|
this._isIntersecting = false;
|
116
107
|
this._recalculateFloating = this._recalculateFloating.bind(this);
|
@@ -125,13 +116,15 @@ class FloatingButtons extends RtlMixin(LitElement) {
|
|
125
116
|
// if browser doesn't support IntersectionObserver, we don't float
|
126
117
|
if (typeof(IntersectionObserver) !== 'function') {
|
127
118
|
this._isIntersecting = true;
|
119
|
+
this.resolveLoadingComplete();
|
128
120
|
return;
|
129
121
|
}
|
130
|
-
this._intersectionObserver = this._intersectionObserver || new IntersectionObserver((entries) => {
|
131
|
-
|
122
|
+
this._intersectionObserver = this._intersectionObserver || new IntersectionObserver(async(entries) => {
|
123
|
+
for (const entry of entries) {
|
132
124
|
this._isIntersecting = entry.isIntersecting;
|
133
|
-
this._recalculateFloating();
|
134
|
-
}
|
125
|
+
await this._recalculateFloating();
|
126
|
+
}
|
127
|
+
this.resolveLoadingComplete();
|
135
128
|
});
|
136
129
|
|
137
130
|
// observe intersection of a fake sibling element since host is sticky
|
@@ -164,13 +157,12 @@ class FloatingButtons extends RtlMixin(LitElement) {
|
|
164
157
|
|
165
158
|
render() {
|
166
159
|
const containerStyle = {
|
167
|
-
|
168
|
-
|
160
|
+
marginInlineStart: this._containerMarginLeft,
|
161
|
+
marginInlineEnd: this._containerMarginRight
|
169
162
|
};
|
170
163
|
|
171
164
|
const innerContainerStyle = {
|
172
|
-
|
173
|
-
marginRight: this._innerContainerRight
|
165
|
+
marginInlineStart: this._innerContainerLeft
|
174
166
|
};
|
175
167
|
|
176
168
|
return html`
|
@@ -193,7 +185,6 @@ class FloatingButtons extends RtlMixin(LitElement) {
|
|
193
185
|
this._containerMarginLeft = '';
|
194
186
|
this._containerMarginRight = '';
|
195
187
|
this._innerContainerLeft = '';
|
196
|
-
this._innerContainerRight = '';
|
197
188
|
|
198
189
|
if (!this._floating) return;
|
199
190
|
|
@@ -218,12 +209,8 @@ class FloatingButtons extends RtlMixin(LitElement) {
|
|
218
209
|
this._containerMarginRight = `-${containerRight}px`;
|
219
210
|
}
|
220
211
|
|
221
|
-
if (
|
222
|
-
|
223
|
-
this._innerContainerLeft = `${containerLeft}px`;
|
224
|
-
}
|
225
|
-
} else {
|
226
|
-
this._innerContainerRight = `${containerRight}px`;
|
212
|
+
if (containerLeft !== 0) {
|
213
|
+
this._innerContainerLeft = `${containerLeft}px`;
|
227
214
|
}
|
228
215
|
|
229
216
|
}
|
@@ -251,29 +238,30 @@ class FloatingButtons extends RtlMixin(LitElement) {
|
|
251
238
|
|
252
239
|
}
|
253
240
|
|
254
|
-
_recalculateFloating() {
|
255
|
-
|
256
|
-
|
257
|
-
if (this.alwaysFloat) {
|
258
|
-
this._floating = true;
|
259
|
-
this._calcContainerPosition();
|
260
|
-
return;
|
261
|
-
}
|
241
|
+
async _recalculateFloating() {
|
242
|
+
await new Promise(resolve => requestAnimationFrame(resolve));
|
262
243
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
244
|
+
if (this.alwaysFloat) {
|
245
|
+
this._floating = true;
|
246
|
+
this._calcContainerPosition();
|
247
|
+
await this.updateComplete;
|
248
|
+
return;
|
249
|
+
}
|
269
250
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
251
|
+
const viewportIsLessThanMinHeight = mediaQueryList.matches;
|
252
|
+
if (viewportIsLessThanMinHeight) {
|
253
|
+
this._floating = false;
|
254
|
+
this._calcContainerPosition();
|
255
|
+
await this.updateComplete;
|
256
|
+
return;
|
257
|
+
}
|
275
258
|
|
276
|
-
|
259
|
+
const shouldFloat = !this._isIntersecting;
|
260
|
+
if (shouldFloat !== this._floating) {
|
261
|
+
this._floating = shouldFloat;
|
262
|
+
this._calcContainerPosition();
|
263
|
+
await this.updateComplete;
|
264
|
+
}
|
277
265
|
}
|
278
266
|
|
279
267
|
_scrollIfFloatObsuringFocus() {
|
package/custom-elements.json
CHANGED
@@ -1039,6 +1039,14 @@
|
|
1039
1039
|
"description": "Indicates to display buttons as always floating",
|
1040
1040
|
"type": "boolean",
|
1041
1041
|
"default": "false"
|
1042
|
+
},
|
1043
|
+
{
|
1044
|
+
"name": "loadingComplete",
|
1045
|
+
"type": "Promise<any>"
|
1046
|
+
},
|
1047
|
+
{
|
1048
|
+
"name": "resolveLoadingComplete",
|
1049
|
+
"type": "() => void"
|
1042
1050
|
}
|
1043
1051
|
],
|
1044
1052
|
"slots": [
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.140.
|
3
|
+
"version": "3.140.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",
|