@proximus/lavender-light 2.0.0-alpha.46 → 2.0.0-alpha.48
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.
|
@@ -3360,9 +3360,15 @@ const styles$3 = '*{box-sizing:border-box}#container{display:flex;flex-wrap:nowr
|
|
|
3360
3360
|
const styleSheet$1 = new CSSStyleSheet();
|
|
3361
3361
|
styleSheet$1.replaceSync(styles$3);
|
|
3362
3362
|
const CLOSE_EVENT = "px.lavender.modal.close";
|
|
3363
|
+
const statusValues = ["", "info", "success", "error", "warning"];
|
|
3363
3364
|
class Modal extends HTMLElement {
|
|
3364
3365
|
constructor() {
|
|
3365
3366
|
super();
|
|
3367
|
+
this.onOpenClick = () => this.show();
|
|
3368
|
+
this.onCloseClick = () => this.close();
|
|
3369
|
+
this.commandButtonCleanups = [];
|
|
3370
|
+
this.openerElement = null;
|
|
3371
|
+
this.closerElement = null;
|
|
3366
3372
|
this.template = `<dialog>
|
|
3367
3373
|
<div id="container">
|
|
3368
3374
|
<div id="content-container">
|
|
@@ -3378,6 +3384,7 @@ class Modal extends HTMLElement {
|
|
|
3378
3384
|
</px-vstack>
|
|
3379
3385
|
</px-hstack>
|
|
3380
3386
|
<div id="content">
|
|
3387
|
+
<slot name="content"></slot>
|
|
3381
3388
|
<slot></slot>
|
|
3382
3389
|
</div>
|
|
3383
3390
|
<px-separator size="m"></px-separator>
|
|
@@ -3404,18 +3411,14 @@ class Modal extends HTMLElement {
|
|
|
3404
3411
|
}
|
|
3405
3412
|
connectedCallback() {
|
|
3406
3413
|
var _a, _b;
|
|
3414
|
+
this.addEventListenersToCommandButtons();
|
|
3407
3415
|
this.toggleDescriptionVisibility = this.toggleDescriptionVisibility.bind(this);
|
|
3408
3416
|
this.toggleCloseButtonSafeArea = this.toggleCloseButtonSafeArea.bind(this);
|
|
3409
3417
|
if (this.hasAttribute("open")) {
|
|
3410
3418
|
this.show();
|
|
3411
3419
|
}
|
|
3412
3420
|
if (this.hasAttribute("closedby")) {
|
|
3413
|
-
|
|
3414
|
-
`#${this.getAttribute("closedby")}`
|
|
3415
|
-
);
|
|
3416
|
-
$closer == null ? void 0 : $closer.addEventListener("click", () => {
|
|
3417
|
-
this.close();
|
|
3418
|
-
});
|
|
3421
|
+
this.addCloseListener(this.getAttribute("closedby"));
|
|
3419
3422
|
}
|
|
3420
3423
|
if (this.hasAttribute("openedby")) {
|
|
3421
3424
|
this.addOpenListener();
|
|
@@ -3435,7 +3438,7 @@ class Modal extends HTMLElement {
|
|
|
3435
3438
|
);
|
|
3436
3439
|
}
|
|
3437
3440
|
static get observedAttributes() {
|
|
3438
|
-
return ["open", "status", "media-src", "openedby"];
|
|
3441
|
+
return ["open", "status", "media-src", "openedby", "closedby", "id"];
|
|
3439
3442
|
}
|
|
3440
3443
|
attributeChangedCallback(attrName, oldValue, newValue) {
|
|
3441
3444
|
switch (attrName) {
|
|
@@ -3451,14 +3454,49 @@ class Modal extends HTMLElement {
|
|
|
3451
3454
|
case "openedby":
|
|
3452
3455
|
this.addOpenListener();
|
|
3453
3456
|
break;
|
|
3457
|
+
case "closedby":
|
|
3458
|
+
this.addCloseListener(newValue);
|
|
3459
|
+
break;
|
|
3460
|
+
case "id":
|
|
3461
|
+
this.addEventListenersToCommandButtons();
|
|
3462
|
+
break;
|
|
3454
3463
|
}
|
|
3455
3464
|
}
|
|
3456
3465
|
disconnectedCallback() {
|
|
3457
|
-
var _a;
|
|
3466
|
+
var _a, _b;
|
|
3458
3467
|
(_a = this.$slotDescription) == null ? void 0 : _a.removeEventListener(
|
|
3459
3468
|
"slotchange",
|
|
3460
3469
|
this.toggleDescriptionVisibility
|
|
3461
3470
|
);
|
|
3471
|
+
(_b = this.$slotCloseButton) == null ? void 0 : _b.removeEventListener(
|
|
3472
|
+
"slotchange",
|
|
3473
|
+
this.toggleCloseButtonSafeArea
|
|
3474
|
+
);
|
|
3475
|
+
this.removeCommandButtonListeners();
|
|
3476
|
+
this.removeOpenListener();
|
|
3477
|
+
this.removeCloseListener();
|
|
3478
|
+
}
|
|
3479
|
+
addEventListenersToCommandButtons() {
|
|
3480
|
+
this.removeCommandButtonListeners();
|
|
3481
|
+
if (this.id) {
|
|
3482
|
+
document.querySelectorAll(`[commandfor="${this.id}"]`).forEach(($clickable) => {
|
|
3483
|
+
if ($clickable.getAttribute("command") === "show-modal") {
|
|
3484
|
+
$clickable.addEventListener("click", this.onOpenClick);
|
|
3485
|
+
this.commandButtonCleanups.push(
|
|
3486
|
+
() => $clickable.removeEventListener("click", this.onOpenClick)
|
|
3487
|
+
);
|
|
3488
|
+
} else if ($clickable.getAttribute("command") === "close") {
|
|
3489
|
+
$clickable.addEventListener("click", this.onCloseClick);
|
|
3490
|
+
this.commandButtonCleanups.push(
|
|
3491
|
+
() => $clickable.removeEventListener("click", this.onCloseClick)
|
|
3492
|
+
);
|
|
3493
|
+
}
|
|
3494
|
+
});
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
removeCommandButtonListeners() {
|
|
3498
|
+
this.commandButtonCleanups.forEach((cleanup) => cleanup());
|
|
3499
|
+
this.commandButtonCleanups = [];
|
|
3462
3500
|
}
|
|
3463
3501
|
handleOpenChange() {
|
|
3464
3502
|
if (this.hasAttribute("open")) {
|
|
@@ -3469,6 +3507,13 @@ class Modal extends HTMLElement {
|
|
|
3469
3507
|
}
|
|
3470
3508
|
handleStatusChange(oldStatus, newStatus) {
|
|
3471
3509
|
var _a, _b, _c;
|
|
3510
|
+
if (statusValues.includes(newStatus)) {
|
|
3511
|
+
this.$titleContainer.setAttribute("color", `neutral`);
|
|
3512
|
+
} else {
|
|
3513
|
+
if (this.$titleContainer.hasAttribute("color")) {
|
|
3514
|
+
this.$titleContainer.removeAttribute("color");
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3472
3517
|
if (newStatus === "info") {
|
|
3473
3518
|
this.$container.classList.add("info");
|
|
3474
3519
|
} else {
|
|
@@ -3524,11 +3569,31 @@ class Modal extends HTMLElement {
|
|
|
3524
3569
|
this.$mediaContainer.style.backgroundImage = `url(${src})`;
|
|
3525
3570
|
}
|
|
3526
3571
|
addOpenListener() {
|
|
3527
|
-
var _a
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3572
|
+
var _a;
|
|
3573
|
+
this.removeOpenListener();
|
|
3574
|
+
this.openerElement = this.$opener;
|
|
3575
|
+
(_a = this.openerElement) == null ? void 0 : _a.addEventListener("click", this.onOpenClick);
|
|
3576
|
+
}
|
|
3577
|
+
removeOpenListener() {
|
|
3578
|
+
var _a;
|
|
3579
|
+
(_a = this.openerElement) == null ? void 0 : _a.removeEventListener("click", this.onOpenClick);
|
|
3580
|
+
this.openerElement = null;
|
|
3581
|
+
}
|
|
3582
|
+
addCloseListener(value) {
|
|
3583
|
+
var _a, _b;
|
|
3584
|
+
if (value === "none") {
|
|
3585
|
+
(_a = this.$dialog) == null ? void 0 : _a.setAttribute("closedby", "none");
|
|
3531
3586
|
}
|
|
3587
|
+
this.removeCloseListener();
|
|
3588
|
+
if (value && value !== "none") {
|
|
3589
|
+
this.closerElement = document.querySelector(`#${value}`);
|
|
3590
|
+
(_b = this.closerElement) == null ? void 0 : _b.addEventListener("click", this.onCloseClick);
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
removeCloseListener() {
|
|
3594
|
+
var _a;
|
|
3595
|
+
(_a = this.closerElement) == null ? void 0 : _a.removeEventListener("click", this.onCloseClick);
|
|
3596
|
+
this.closerElement = null;
|
|
3532
3597
|
}
|
|
3533
3598
|
toggleDescriptionVisibility() {
|
|
3534
3599
|
if (!this.$slottedDescription) {
|
|
@@ -3568,6 +3633,9 @@ class Modal extends HTMLElement {
|
|
|
3568
3633
|
'px-p[font-weight="title"]'
|
|
3569
3634
|
);
|
|
3570
3635
|
}
|
|
3636
|
+
get $titleContainer() {
|
|
3637
|
+
return this.shadowRoot.querySelector("px-h1");
|
|
3638
|
+
}
|
|
3571
3639
|
get $opener() {
|
|
3572
3640
|
return document.querySelector(
|
|
3573
3641
|
`px-button#${this.getAttribute("openedby")}`
|
|
@@ -3585,6 +3653,12 @@ class Modal extends HTMLElement {
|
|
|
3585
3653
|
set openedby(value) {
|
|
3586
3654
|
this.setAttribute("openedby", value);
|
|
3587
3655
|
}
|
|
3656
|
+
get closedby() {
|
|
3657
|
+
return this.getAttribute("closedby");
|
|
3658
|
+
}
|
|
3659
|
+
set closedby(value) {
|
|
3660
|
+
this.setAttribute("closedby", value);
|
|
3661
|
+
}
|
|
3588
3662
|
get $closeButton() {
|
|
3589
3663
|
return this.shadowRoot.querySelector("px-button-icon");
|
|
3590
3664
|
}
|
|
@@ -5785,5 +5859,6 @@ export {
|
|
|
5785
5859
|
Typography,
|
|
5786
5860
|
contentAlignmentValues,
|
|
5787
5861
|
gridColsValues,
|
|
5788
|
-
itemsAlignmentValues
|
|
5862
|
+
itemsAlignmentValues,
|
|
5863
|
+
statusValues
|
|
5789
5864
|
};
|