@brightspace-ui/core 3.297.0 → 3.299.0
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/components/dialog/dialog-confirm.js +1 -2
- package/components/dropdown/README.md +30 -0
- package/components/dropdown/dropdown-content.js +2 -0
- package/components/dropdown/dropdown-menu.js +2 -0
- package/components/dropdown/dropdown-popover-mixin.js +17 -0
- package/components/dropdown/dropdown-tabs.js +2 -0
- package/components/popover/popover-mixin.js +34 -2
- package/components/tooltip/tooltip.js +1 -0
- package/custom-elements.json +35 -1
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@ import { _generateResetStyles, heading3Styles } from '../typography/styles.js';
|
|
|
2
2
|
import { css, html, LitElement, nothing } from 'lit';
|
|
3
3
|
import { DialogMixin } from './dialog-mixin.js';
|
|
4
4
|
import { dialogStyles } from './dialog-styles.js';
|
|
5
|
-
import { getFlag } from '../../helpers/flags.js';
|
|
6
5
|
import { getFocusRingStyles } from '../../helpers/focus.js';
|
|
7
6
|
import { getUniqueId } from '../../helpers/uniqueId.js';
|
|
8
7
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -88,7 +87,7 @@ class DialogConfirm extends LocalizeCoreElement(DialogMixin(LitElement)) {
|
|
|
88
87
|
constructor() {
|
|
89
88
|
super();
|
|
90
89
|
this.critical = false;
|
|
91
|
-
this.preferNative =
|
|
90
|
+
this.preferNative = true;
|
|
92
91
|
this._criticalLabelId = getUniqueId();
|
|
93
92
|
this._textId = getUniqueId();
|
|
94
93
|
this._titleId = getUniqueId();
|
|
@@ -236,6 +236,7 @@ To make your usage of `d2l-dropdown-more` accessible, use the following property
|
|
|
236
236
|
| Name | Description |
|
|
237
237
|
|---|---|
|
|
238
238
|
| `d2l-dropdown-open` | Dispatched when the dropdown is opened |
|
|
239
|
+
| `d2l-dropdown-open-async` | Dispatched before the dropdown is opened for the first time, giving an opportunity to load async content |
|
|
239
240
|
| `d2l-dropdown-close` | dispatched when the dropdown is closed |
|
|
240
241
|
| `d2l-dropdown-position` | Dispatched when the dropdown position finishes adjusting |
|
|
241
242
|
| `d2l-dropdown-focus-enter` | dispatched when the 'trap-focus' attribute is applied and the focus-trap is entered (trap-focus option only) |
|
|
@@ -251,6 +252,35 @@ To make your usage of `d2l-dropdown-more` accessible, use the following property
|
|
|
251
252
|
### Methods
|
|
252
253
|
* `async resize()`: Call if the size of the content changes due to a change in a nested component. The nested component may choose to fire a custom event, which the component containing the `d2l-dropdown-content` can catch and call this method. |
|
|
253
254
|
|
|
255
|
+
### Asynchronous Content
|
|
256
|
+
|
|
257
|
+
For dropdown content that's fetched asynchronously, the `d2l-dropdown-open-async` event can be leveraged to let `<d2l-dropdown-content>` know when things are ready. That way, automatic focus and sizing logic until can be delayed.
|
|
258
|
+
|
|
259
|
+
- Add a listener for the `d2l-dropdown-open-async` event
|
|
260
|
+
- In the handler, call `preventDefault()` on the event to let it know that the content will be loaded asynchronously
|
|
261
|
+
- Fetch the content and when it's ready, call `complete()` on the event detail
|
|
262
|
+
- Note: the `d2l-dropdown-open-async` event will only be dispatched the first time the dropdown is opened, so no need to ignore subsequent calls
|
|
263
|
+
|
|
264
|
+
```javascript
|
|
265
|
+
class MyElem extends LitElement {
|
|
266
|
+
render() {
|
|
267
|
+
const content = this._loading ? 'Loading...' : 'Loaded!';
|
|
268
|
+
return html`
|
|
269
|
+
<d2l-dropdown-content
|
|
270
|
+
@d2l-dropdown-open-async="${this.#handleDropdownOpenAsync}">
|
|
271
|
+
${content}
|
|
272
|
+
</d2l-dropdown-content>
|
|
273
|
+
`;
|
|
274
|
+
}
|
|
275
|
+
async #handleDropdownOpenAsync(e) {
|
|
276
|
+
e.preventDefault();
|
|
277
|
+
await this.#fetchData();
|
|
278
|
+
this._loaded = true;
|
|
279
|
+
e.detail.complete();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
254
284
|
## Content: Menu [d2l-dropdown-menu]
|
|
255
285
|
`d2l-dropdown-menu` is a container for a [d2l-menu](https://github.com/BrightspaceUI/core/tree/main/components/menu) component. It provides additional support on top of `d2l-dropdown-content` for closing the menu when menu items are selected, resetting to the root of nested menus when reopening and automatic resizing when the menu resizes.
|
|
256
286
|
|
|
@@ -7,6 +7,8 @@ import { LitElement } from 'lit';
|
|
|
7
7
|
* @slot header - Sticky container at the top of the dropdown
|
|
8
8
|
* @slot footer - Sticky container at the bottom of the dropdown
|
|
9
9
|
* @fires d2l-dropdown-open - Dispatched when the dropdown is opened
|
|
10
|
+
* @fires d2l-dropdown-open-async - Dispatched before the dropdown is opened for the first time, giving an opportunity to load async content
|
|
11
|
+
* @fires d2l-popover-open-async - Ignore
|
|
10
12
|
*/
|
|
11
13
|
class DropdownContent extends DropdownPopoverMixin(LitElement) { }
|
|
12
14
|
customElements.define('d2l-dropdown-content', DropdownContent);
|
|
@@ -11,6 +11,8 @@ const dropdownDelay = 300;
|
|
|
11
11
|
* @slot header - Sticky container at the top of the dropdown
|
|
12
12
|
* @slot footer - Sticky container at the bottom of the dropdown
|
|
13
13
|
* @fires d2l-dropdown-open - Dispatched when the dropdown is opened
|
|
14
|
+
* @fires d2l-dropdown-open-async - Dispatched before the dropdown is opened for the first time, giving an opportunity to load async content
|
|
15
|
+
* @fires d2l-popover-open-async - Ignore
|
|
14
16
|
*/
|
|
15
17
|
class DropdownMenu extends ThemeMixin(DropdownPopoverMixin(LitElement)) {
|
|
16
18
|
|
|
@@ -198,6 +198,7 @@ export const DropdownPopoverMixin = superclass => class extends LocalizeCoreElem
|
|
|
198
198
|
this.#resizeObserver.observe(this.#contentElement);
|
|
199
199
|
}
|
|
200
200
|
this.addEventListener('d2l-popover-open', this.#handlePopoverOpen);
|
|
201
|
+
this.addEventListener('d2l-popover-open-async', this.#handlePopoverOpenAsync);
|
|
201
202
|
this.addEventListener('d2l-popover-close', this.#handlePopoverClose);
|
|
202
203
|
this.addEventListener('d2l-popover-position', this.#handlePopoverPosition);
|
|
203
204
|
this.addEventListener('d2l-popover-focus-enter', this.#handlePopoverFocusEnter);
|
|
@@ -386,6 +387,22 @@ export const DropdownPopoverMixin = superclass => class extends LocalizeCoreElem
|
|
|
386
387
|
});
|
|
387
388
|
}
|
|
388
389
|
|
|
390
|
+
#handlePopoverOpenAsync(e) {
|
|
391
|
+
const openAsyncEvent = new CustomEvent(
|
|
392
|
+
'd2l-dropdown-open-async', {
|
|
393
|
+
bubbles: false,
|
|
394
|
+
cancelable: true,
|
|
395
|
+
composed: false,
|
|
396
|
+
detail: { complete: e.detail.complete }
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
/** @ignore */
|
|
400
|
+
this.dispatchEvent(openAsyncEvent);
|
|
401
|
+
if (openAsyncEvent.defaultPrevented) {
|
|
402
|
+
e.preventDefault();
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
389
406
|
#handlePopoverPosition() {
|
|
390
407
|
this.#toggleScrollStyles();
|
|
391
408
|
|
|
@@ -7,6 +7,8 @@ import { DropdownPopoverMixin } from './dropdown-popover-mixin.js';
|
|
|
7
7
|
* @slot header - Sticky container at the top of the dropdown
|
|
8
8
|
* @slot footer - Sticky container at the bottom of the dropdown
|
|
9
9
|
* @fires d2l-dropdown-open - Dispatched when the dropdown is opened
|
|
10
|
+
* @fires d2l-dropdown-open-async - Dispatched before the dropdown is opened for the first time, giving an opportunity to load async content
|
|
11
|
+
* @fires d2l-popover-open-async - Ignore
|
|
10
12
|
*/
|
|
11
13
|
class DropdownTabs extends DropdownPopoverMixin(LitElement) {
|
|
12
14
|
|
|
@@ -10,6 +10,7 @@ import { _offscreenStyleDeclarations } from '../offscreen/offscreen.js';
|
|
|
10
10
|
import { classMap } from 'lit/directives/class-map.js';
|
|
11
11
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
12
12
|
import { tryGetIfrauBackdropService } from '../../helpers/ifrauBackdropService.js';
|
|
13
|
+
import { waitForElem } from '../../helpers/internal/waitForElem.js';
|
|
13
14
|
|
|
14
15
|
export const positionLocations = Object.freeze({
|
|
15
16
|
blockEnd: 'block-end',
|
|
@@ -369,10 +370,12 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
369
370
|
|
|
370
371
|
this._dismissibleId = setDismissible(() => this.close());
|
|
371
372
|
|
|
372
|
-
this.#focusContent(this);
|
|
373
|
-
|
|
374
373
|
this.#addRepositionHandlers();
|
|
375
374
|
|
|
375
|
+
await this.#waitForOpenAsync();
|
|
376
|
+
|
|
377
|
+
this.#focusContent(this);
|
|
378
|
+
|
|
376
379
|
/** @ignore */
|
|
377
380
|
this.dispatchEvent(new CustomEvent('d2l-popover-open', { bubbles: true, composed: true }));
|
|
378
381
|
|
|
@@ -582,6 +585,7 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
582
585
|
}
|
|
583
586
|
|
|
584
587
|
#ancestorMutations;
|
|
588
|
+
#firstOpen = true;
|
|
585
589
|
#ifrauContextInfo;
|
|
586
590
|
#mediaQueryList;
|
|
587
591
|
|
|
@@ -1194,4 +1198,32 @@ export const PopoverMixin = superclass => class extends superclass {
|
|
|
1194
1198
|
removeResizeNoopEventListener(this.#handleResize);
|
|
1195
1199
|
}
|
|
1196
1200
|
|
|
1201
|
+
async #waitForOpenAsync() {
|
|
1202
|
+
if (!this.#firstOpen) return;
|
|
1203
|
+
this.#firstOpen = false;
|
|
1204
|
+
|
|
1205
|
+
let doWait = false;
|
|
1206
|
+
await new Promise(resolve => {
|
|
1207
|
+
const openAsyncEvent = new CustomEvent(
|
|
1208
|
+
'd2l-popover-open-async', {
|
|
1209
|
+
bubbles: false,
|
|
1210
|
+
cancelable: true,
|
|
1211
|
+
composed: false,
|
|
1212
|
+
detail: { complete: resolve }
|
|
1213
|
+
}
|
|
1214
|
+
);
|
|
1215
|
+
/** @ignore */
|
|
1216
|
+
this.dispatchEvent(openAsyncEvent);
|
|
1217
|
+
if (!openAsyncEvent.defaultPrevented) {
|
|
1218
|
+
resolve();
|
|
1219
|
+
} else {
|
|
1220
|
+
doWait = true;
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
if (doWait) {
|
|
1224
|
+
await waitForElem(this.#getContentContainer());
|
|
1225
|
+
await this.position();
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1197
1229
|
};
|
|
@@ -55,6 +55,7 @@ let activeTooltip = null;
|
|
|
55
55
|
* @slot - Default content placed inside of the tooltip
|
|
56
56
|
* @fires d2l-tooltip-show - Dispatched when the tooltip is opened
|
|
57
57
|
* @fires d2l-tooltip-hide - Dispatched when the tooltip is closed
|
|
58
|
+
* @fires d2l-popover-open-async - Ignore
|
|
58
59
|
*/
|
|
59
60
|
class Tooltip extends PopoverMixin(LitElement) {
|
|
60
61
|
|
package/custom-elements.json
CHANGED
|
@@ -2745,7 +2745,8 @@
|
|
|
2745
2745
|
},
|
|
2746
2746
|
{
|
|
2747
2747
|
"name": "preferNative",
|
|
2748
|
-
"
|
|
2748
|
+
"type": "boolean",
|
|
2749
|
+
"default": "true"
|
|
2749
2750
|
}
|
|
2750
2751
|
],
|
|
2751
2752
|
"events": [
|
|
@@ -3512,6 +3513,14 @@
|
|
|
3512
3513
|
"name": "d2l-dropdown-open",
|
|
3513
3514
|
"description": "Dispatched when the dropdown is opened"
|
|
3514
3515
|
},
|
|
3516
|
+
{
|
|
3517
|
+
"name": "d2l-dropdown-open-async",
|
|
3518
|
+
"description": "Dispatched before the dropdown is opened for the first time, giving an opportunity to load async content"
|
|
3519
|
+
},
|
|
3520
|
+
{
|
|
3521
|
+
"name": "d2l-popover-open-async",
|
|
3522
|
+
"description": "Ignore"
|
|
3523
|
+
},
|
|
3515
3524
|
{
|
|
3516
3525
|
"name": "d2l-dropdown-close",
|
|
3517
3526
|
"description": "Dispatched when the dropdown is closed"
|
|
@@ -3883,6 +3892,14 @@
|
|
|
3883
3892
|
"name": "d2l-dropdown-open",
|
|
3884
3893
|
"description": "Dispatched when the dropdown is opened"
|
|
3885
3894
|
},
|
|
3895
|
+
{
|
|
3896
|
+
"name": "d2l-dropdown-open-async",
|
|
3897
|
+
"description": "Dispatched before the dropdown is opened for the first time, giving an opportunity to load async content"
|
|
3898
|
+
},
|
|
3899
|
+
{
|
|
3900
|
+
"name": "d2l-popover-open-async",
|
|
3901
|
+
"description": "Ignore"
|
|
3902
|
+
},
|
|
3886
3903
|
{
|
|
3887
3904
|
"name": "d2l-dropdown-close",
|
|
3888
3905
|
"description": "Dispatched when the dropdown is closed"
|
|
@@ -4254,6 +4271,14 @@
|
|
|
4254
4271
|
"name": "d2l-dropdown-open",
|
|
4255
4272
|
"description": "Dispatched when the dropdown is opened"
|
|
4256
4273
|
},
|
|
4274
|
+
{
|
|
4275
|
+
"name": "d2l-dropdown-open-async",
|
|
4276
|
+
"description": "Dispatched before the dropdown is opened for the first time, giving an opportunity to load async content"
|
|
4277
|
+
},
|
|
4278
|
+
{
|
|
4279
|
+
"name": "d2l-popover-open-async",
|
|
4280
|
+
"description": "Ignore"
|
|
4281
|
+
},
|
|
4257
4282
|
{
|
|
4258
4283
|
"name": "d2l-dropdown-close",
|
|
4259
4284
|
"description": "Dispatched when the dropdown is closed"
|
|
@@ -13889,6 +13914,11 @@
|
|
|
13889
13914
|
"type": "array",
|
|
13890
13915
|
"default": "[\"styles\",null]"
|
|
13891
13916
|
}
|
|
13917
|
+
],
|
|
13918
|
+
"events": [
|
|
13919
|
+
{
|
|
13920
|
+
"name": "d2l-popover-open-async"
|
|
13921
|
+
}
|
|
13892
13922
|
]
|
|
13893
13923
|
},
|
|
13894
13924
|
{
|
|
@@ -17312,6 +17342,10 @@
|
|
|
17312
17342
|
{
|
|
17313
17343
|
"name": "d2l-tooltip-hide",
|
|
17314
17344
|
"description": "Dispatched when the tooltip is closed"
|
|
17345
|
+
},
|
|
17346
|
+
{
|
|
17347
|
+
"name": "d2l-popover-open-async",
|
|
17348
|
+
"description": "Ignore"
|
|
17315
17349
|
}
|
|
17316
17350
|
],
|
|
17317
17351
|
"slots": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.299.0",
|
|
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",
|