@brightspace-ui/core 3.299.0 → 3.300.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.
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import './alert.js';
|
|
2
2
|
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { getFlag } from '../../helpers/flags.js';
|
|
4
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
6
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
6
7
|
|
|
8
|
+
let mockedPopoverSupported = null;
|
|
9
|
+
export function mockPopoverSupported(value) { mockedPopoverSupported = value; }
|
|
10
|
+
export function resetPopoverSupported() { mockedPopoverSupported = null; }
|
|
11
|
+
function isPopoverSupported() {
|
|
12
|
+
return mockedPopoverSupported ?? ('popover' in HTMLElement.prototype);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function usePopover() {
|
|
16
|
+
return getFlag('GAUD-10337-use-alert-toast-popover', true) && isPopoverSupported();
|
|
17
|
+
}
|
|
18
|
+
|
|
7
19
|
const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
8
20
|
let activeReduceMotion = reduceMotion;
|
|
9
21
|
export function disableReducedMotionForTesting() {
|
|
@@ -88,15 +100,20 @@ class AlertToast extends LitElement {
|
|
|
88
100
|
}
|
|
89
101
|
|
|
90
102
|
.d2l-alert-toast-container {
|
|
103
|
+
background-color: transparent; /* override popover default */
|
|
104
|
+
border: none; /* override popover */
|
|
91
105
|
border-radius: 0.3rem;
|
|
92
106
|
box-shadow: 0 0.1rem 0.6rem 0 rgba(0, 0, 0, 0.1);
|
|
107
|
+
color: var(--d2l-theme-text-color-static-standard); /* override popover default */
|
|
93
108
|
display: none;
|
|
94
|
-
|
|
109
|
+
inset: auto 0 0 0; /* override popover default */
|
|
95
110
|
margin: 0 auto 1.5rem;
|
|
96
111
|
max-width: 600px;
|
|
112
|
+
padding: 0; /* override popover */
|
|
97
113
|
position: fixed;
|
|
98
|
-
right: 0;
|
|
99
114
|
width: 100%;
|
|
115
|
+
}
|
|
116
|
+
.d2l-alert-toast-container-not-popover {
|
|
100
117
|
z-index: 10000;
|
|
101
118
|
}
|
|
102
119
|
|
|
@@ -133,7 +150,7 @@ class AlertToast extends LitElement {
|
|
|
133
150
|
}
|
|
134
151
|
|
|
135
152
|
.d2l-alert-toast-container[data-state="sliding"] {
|
|
136
|
-
transition:
|
|
153
|
+
transition: inset-block-end 600ms ease;
|
|
137
154
|
}
|
|
138
155
|
|
|
139
156
|
d2l-alert {
|
|
@@ -215,9 +232,10 @@ class AlertToast extends LitElement {
|
|
|
215
232
|
render() {
|
|
216
233
|
const spaceBetweenAlerts = this._numAlertsBelow * (this._smallWidth ? TOAST_SPACING_SMALL : TOAST_SPACING);
|
|
217
234
|
const containerStyles = {
|
|
218
|
-
|
|
235
|
+
insetBlockEnd: (this._totalSiblingHeightBelow || this._numAlertsBelow) ? `calc(${this._totalSiblingHeightBelow}px + ${spaceBetweenAlerts}rem)` : 0
|
|
219
236
|
};
|
|
220
237
|
const containerClasses = {
|
|
238
|
+
'd2l-alert-toast-container-not-popover': !usePopover(),
|
|
221
239
|
'd2l-alert-toast-container': true,
|
|
222
240
|
'd2l-alert-toast-container-close-clicked': this._closeClicked,
|
|
223
241
|
'd2l-alert-toast-container-lowest': !this._totalSiblingHeightBelow,
|
|
@@ -228,18 +246,19 @@ class AlertToast extends LitElement {
|
|
|
228
246
|
<div
|
|
229
247
|
class="${classMap(containerClasses)}"
|
|
230
248
|
data-state="${this._state}"
|
|
249
|
+
popover="${ifDefined(usePopover() ? 'manual' : undefined)}"
|
|
231
250
|
style="${styleMap(containerStyles)}"
|
|
232
|
-
@transitionend
|
|
251
|
+
@transitionend="${this._onTransitionEnd}">
|
|
233
252
|
<d2l-alert
|
|
234
|
-
@blur
|
|
253
|
+
@blur="${this._onBlur}"
|
|
235
254
|
button-text="${ifDefined(this.buttonText)}"
|
|
236
|
-
@d2l-alert-button-press
|
|
237
|
-
@d2l-alert-close
|
|
238
|
-
@focus
|
|
255
|
+
@d2l-alert-button-press="${this._handleButtonPress}"
|
|
256
|
+
@d2l-alert-close="${this._onCloseClicked}"
|
|
257
|
+
@focus="${this._onFocus}"
|
|
239
258
|
?has-close-button="${!this.hideCloseButton}"
|
|
240
259
|
?hidden="${this._state === states.CLOSED}"
|
|
241
|
-
@mouseenter
|
|
242
|
-
@mouseleave
|
|
260
|
+
@mouseenter="${this._onMouseEnter}"
|
|
261
|
+
@mouseleave="${this._onMouseLeave}"
|
|
243
262
|
role="${ifDefined(this._state !== states.CLOSED ? 'alert' : undefined)}"
|
|
244
263
|
subtext="${ifDefined(this.subtext)}"
|
|
245
264
|
type="${ifDefined(this.type)}">
|
|
@@ -397,6 +416,14 @@ class AlertToast extends LitElement {
|
|
|
397
416
|
|
|
398
417
|
_openChanged(newOpen) {
|
|
399
418
|
if (newOpen) {
|
|
419
|
+
|
|
420
|
+
if (usePopover()) {
|
|
421
|
+
// wait for popover attribute before managing top-layer (needed for case where toast is open immediately)
|
|
422
|
+
requestAnimationFrame(() => {
|
|
423
|
+
if (this.isConnected) this.shadowRoot.querySelector('[popover="manual"]')?.showPopover();
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
400
427
|
if (this._state === states.CLOSING) {
|
|
401
428
|
this._state = states.OPENING;
|
|
402
429
|
} else if (this._state === states.CLOSED) {
|
|
@@ -415,6 +442,10 @@ class AlertToast extends LitElement {
|
|
|
415
442
|
} else {
|
|
416
443
|
if (!this._innerContainer) return;
|
|
417
444
|
|
|
445
|
+
if (usePopover()) {
|
|
446
|
+
this.shadowRoot.querySelector('[popover="manual"]')?.hidePopover();
|
|
447
|
+
}
|
|
448
|
+
|
|
418
449
|
if (activeReduceMotion || this._state === states.PREOPENING) {
|
|
419
450
|
cancelAnimationFrame(this._preopenFrame);
|
|
420
451
|
} else if (this._state === states.OPENING || this._state === states.OPEN || this._state === states.SLIDING) {
|
|
@@ -70,7 +70,7 @@ The `<d2l-input-text>` element is a simple wrapper around the native `<input typ
|
|
|
70
70
|
| `required` | Boolean | Indicates that a value is required |
|
|
71
71
|
| `size` | Number | Size of the input |
|
|
72
72
|
| `step` | String | For number inputs, sets the step size |
|
|
73
|
-
| `type` | String, default: `text` | Can be one of `text`, `email`, `password`, `tel`, `url`. Type `number` is deprecated, use [d2l-input-number](./input-
|
|
73
|
+
| `type` | String, default: `text` | Can be one of `text`, `email`, `password`, `tel`, `url`. Type `number` is deprecated, use [d2l-input-number](./input-numeric.md) instead. |
|
|
74
74
|
| `unit` | String | Unit associated with the input value, displayed next to input and announced as part of the label |
|
|
75
75
|
| `value` | String, default: `''` | Value of the input |
|
|
76
76
|
|
package/custom-elements.json
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"name": "styles",
|
|
66
|
-
"default": "\"css`\\n\\t\\t:host {\\n\\t\\t\\tdisplay: block;\\n\\t\\t}\\n\\n\\t\\t.d2l-alert-toast-container {\\n\\t\\t\\tborder-radius: 0.3rem;\\n\\t\\t\\tbox-shadow: 0 0.1rem 0.6rem 0 rgba(0, 0, 0, 0.1);\\n\\t\\t\\tdisplay: none;\\n\\t\\t\\
|
|
66
|
+
"default": "\"css`\\n\\t\\t:host {\\n\\t\\t\\tdisplay: block;\\n\\t\\t}\\n\\n\\t\\t.d2l-alert-toast-container {\\n\\t\\t\\tbackground-color: transparent; /* override popover default */\\n\\t\\t\\tborder: none; /* override popover */\\n\\t\\t\\tborder-radius: 0.3rem;\\n\\t\\t\\tbox-shadow: 0 0.1rem 0.6rem 0 rgba(0, 0, 0, 0.1);\\n\\t\\t\\tcolor: var(--d2l-theme-text-color-static-standard); /* override popover default */\\n\\t\\t\\tdisplay: none;\\n\\t\\t\\tinset: auto 0 0 0; /* override popover default */\\n\\t\\t\\tmargin: 0 auto 1.5rem;\\n\\t\\t\\tmax-width: 600px;\\n\\t\\t\\tpadding: 0; /* override popover */\\n\\t\\t\\tposition: fixed;\\n\\t\\t\\twidth: 100%;\\n\\t\\t}\\n\\t\\t.d2l-alert-toast-container-not-popover {\\n\\t\\t\\tz-index: 10000;\\n\\t\\t}\\n\\n\\t\\t.d2l-alert-toast-container:not([data-state=\\\"closed\\\"]) {\\n\\t\\t\\tdisplay: block;\\n\\t\\t}\\n\\n\\t\\t.d2l-alert-toast-container[data-state=\\\"opening\\\"],\\n\\t\\t.d2l-alert-toast-container.d2l-alert-toast-container-lowest[data-state=\\\"closing\\\"] {\\n\\t\\t\\ttransition-duration: 600ms;\\n\\t\\t\\ttransition-property: opacity, transform;\\n\\t\\t\\ttransition-timing-function: ease;\\n\\t\\t}\\n\\t\\t.d2l-alert-toast-container[data-state=\\\"closing\\\"] {\\n\\t\\t\\ttransition: opacity 200ms ease;\\n\\t\\t}\\n\\n\\t\\t.d2l-alert-toast-container.d2l-alert-toast-container-close-clicked[data-state=\\\"closing\\\"] {\\n\\t\\t\\ttransition-duration: 200ms;\\n\\t\\t}\\n\\n\\t\\t.d2l-alert-toast-container[data-state=\\\"preopening\\\"],\\n\\t\\t.d2l-alert-toast-container[data-state=\\\"closing\\\"] {\\n\\t\\t\\topacity: 0;\\n\\t\\t}\\n\\t\\t.d2l-alert-toast-container[data-state=\\\"preopening\\\"],\\n\\t\\t.d2l-alert-toast-container.d2l-alert-toast-container-lowest[data-state=\\\"closing\\\"] {\\n\\t\\t\\ttransform: translateY(calc(100% + 1.5rem));\\n\\t\\t}\\n\\n\\t\\t.d2l-alert-toast-container[data-state=\\\"opening\\\"] {\\n\\t\\t\\topacity: 1;\\n\\t\\t\\ttransform: translateY(0);\\n\\t\\t}\\n\\n\\t\\t.d2l-alert-toast-container[data-state=\\\"sliding\\\"] {\\n\\t\\t\\ttransition: inset-block-end 600ms ease;\\n\\t\\t}\\n\\n\\t\\td2l-alert {\\n\\t\\t\\tanimation: none;\\n\\t\\t}\\n\\n\\t\\t@media (max-width: 615px) {\\n\\t\\t\\t.d2l-alert-toast-container {\\n\\t\\t\\t\\tmargin-bottom: 12px;\\n\\t\\t\\t\\twidth: calc(100% - 16px);\\n\\t\\t\\t}\\n\\t\\t}\\n\\t`\""
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"name": "hideCloseButton",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.300.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",
|