@proximus/lavender-light 1.4.5-alpha.9 → 1.4.5
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.
|
@@ -27,7 +27,7 @@ function getSupportedAttributeNames(htmlElementName) {
|
|
|
27
27
|
}
|
|
28
28
|
const commonStyleSheet = new CSSStyleSheet();
|
|
29
29
|
commonStyleSheet.replaceSync(commonStyles);
|
|
30
|
-
const PX_COMPONENT_DEBUG = typeof import.meta !== "undefined" && typeof __vite_import_meta_env__ !== "undefined" &&
|
|
30
|
+
const PX_COMPONENT_DEBUG = typeof import.meta !== "undefined" && typeof __vite_import_meta_env__ !== "undefined" && false;
|
|
31
31
|
if (typeof window !== "undefined") {
|
|
32
32
|
window.isComponentDebug = isComponentDebug;
|
|
33
33
|
}
|
|
@@ -35,9 +35,6 @@ function isComponentDebug() {
|
|
|
35
35
|
return PX_COMPONENT_DEBUG;
|
|
36
36
|
}
|
|
37
37
|
function log(message) {
|
|
38
|
-
if (isComponentDebug()) {
|
|
39
|
-
console.error(message);
|
|
40
|
-
}
|
|
41
38
|
}
|
|
42
39
|
if (typeof window !== "undefined") {
|
|
43
40
|
window.isComponentDebug = isComponentDebug;
|
|
@@ -3360,9 +3357,15 @@ const styles$3 = '*{box-sizing:border-box}#container{display:flex;flex-wrap:nowr
|
|
|
3360
3357
|
const styleSheet$1 = new CSSStyleSheet();
|
|
3361
3358
|
styleSheet$1.replaceSync(styles$3);
|
|
3362
3359
|
const CLOSE_EVENT = "px.lavender.modal.close";
|
|
3360
|
+
const statusValues = ["", "info", "success", "error", "warning"];
|
|
3363
3361
|
class Modal extends HTMLElement {
|
|
3364
3362
|
constructor() {
|
|
3365
3363
|
super();
|
|
3364
|
+
this.onOpenClick = () => this.show();
|
|
3365
|
+
this.onCloseClick = () => this.close();
|
|
3366
|
+
this.commandButtonCleanups = [];
|
|
3367
|
+
this.openerElement = null;
|
|
3368
|
+
this.closerElement = null;
|
|
3366
3369
|
this.template = `<dialog>
|
|
3367
3370
|
<div id="container">
|
|
3368
3371
|
<div id="content-container">
|
|
@@ -3378,6 +3381,7 @@ class Modal extends HTMLElement {
|
|
|
3378
3381
|
</px-vstack>
|
|
3379
3382
|
</px-hstack>
|
|
3380
3383
|
<div id="content">
|
|
3384
|
+
<slot name="content"></slot>
|
|
3381
3385
|
<slot></slot>
|
|
3382
3386
|
</div>
|
|
3383
3387
|
<px-separator size="m"></px-separator>
|
|
@@ -3404,18 +3408,14 @@ class Modal extends HTMLElement {
|
|
|
3404
3408
|
}
|
|
3405
3409
|
connectedCallback() {
|
|
3406
3410
|
var _a, _b;
|
|
3411
|
+
this.addEventListenersToCommandButtons();
|
|
3407
3412
|
this.toggleDescriptionVisibility = this.toggleDescriptionVisibility.bind(this);
|
|
3408
3413
|
this.toggleCloseButtonSafeArea = this.toggleCloseButtonSafeArea.bind(this);
|
|
3409
3414
|
if (this.hasAttribute("open")) {
|
|
3410
3415
|
this.show();
|
|
3411
3416
|
}
|
|
3412
3417
|
if (this.hasAttribute("closedby")) {
|
|
3413
|
-
|
|
3414
|
-
`#${this.getAttribute("closedby")}`
|
|
3415
|
-
);
|
|
3416
|
-
$closer == null ? void 0 : $closer.addEventListener("click", () => {
|
|
3417
|
-
this.close();
|
|
3418
|
-
});
|
|
3418
|
+
this.addCloseListener(this.getAttribute("closedby"));
|
|
3419
3419
|
}
|
|
3420
3420
|
if (this.hasAttribute("openedby")) {
|
|
3421
3421
|
this.addOpenListener();
|
|
@@ -3435,7 +3435,7 @@ class Modal extends HTMLElement {
|
|
|
3435
3435
|
);
|
|
3436
3436
|
}
|
|
3437
3437
|
static get observedAttributes() {
|
|
3438
|
-
return ["open", "status", "media-src", "openedby"];
|
|
3438
|
+
return ["open", "status", "media-src", "openedby", "closedby", "id"];
|
|
3439
3439
|
}
|
|
3440
3440
|
attributeChangedCallback(attrName, oldValue, newValue) {
|
|
3441
3441
|
switch (attrName) {
|
|
@@ -3451,14 +3451,49 @@ class Modal extends HTMLElement {
|
|
|
3451
3451
|
case "openedby":
|
|
3452
3452
|
this.addOpenListener();
|
|
3453
3453
|
break;
|
|
3454
|
+
case "closedby":
|
|
3455
|
+
this.addCloseListener(newValue);
|
|
3456
|
+
break;
|
|
3457
|
+
case "id":
|
|
3458
|
+
this.addEventListenersToCommandButtons();
|
|
3459
|
+
break;
|
|
3454
3460
|
}
|
|
3455
3461
|
}
|
|
3456
3462
|
disconnectedCallback() {
|
|
3457
|
-
var _a;
|
|
3463
|
+
var _a, _b;
|
|
3458
3464
|
(_a = this.$slotDescription) == null ? void 0 : _a.removeEventListener(
|
|
3459
3465
|
"slotchange",
|
|
3460
3466
|
this.toggleDescriptionVisibility
|
|
3461
3467
|
);
|
|
3468
|
+
(_b = this.$slotCloseButton) == null ? void 0 : _b.removeEventListener(
|
|
3469
|
+
"slotchange",
|
|
3470
|
+
this.toggleCloseButtonSafeArea
|
|
3471
|
+
);
|
|
3472
|
+
this.removeCommandButtonListeners();
|
|
3473
|
+
this.removeOpenListener();
|
|
3474
|
+
this.removeCloseListener();
|
|
3475
|
+
}
|
|
3476
|
+
addEventListenersToCommandButtons() {
|
|
3477
|
+
this.removeCommandButtonListeners();
|
|
3478
|
+
if (this.id) {
|
|
3479
|
+
document.querySelectorAll(`[commandfor="${this.id}"]`).forEach(($clickable) => {
|
|
3480
|
+
if ($clickable.getAttribute("command") === "show-modal") {
|
|
3481
|
+
$clickable.addEventListener("click", this.onOpenClick);
|
|
3482
|
+
this.commandButtonCleanups.push(
|
|
3483
|
+
() => $clickable.removeEventListener("click", this.onOpenClick)
|
|
3484
|
+
);
|
|
3485
|
+
} else if ($clickable.getAttribute("command") === "close") {
|
|
3486
|
+
$clickable.addEventListener("click", this.onCloseClick);
|
|
3487
|
+
this.commandButtonCleanups.push(
|
|
3488
|
+
() => $clickable.removeEventListener("click", this.onCloseClick)
|
|
3489
|
+
);
|
|
3490
|
+
}
|
|
3491
|
+
});
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
removeCommandButtonListeners() {
|
|
3495
|
+
this.commandButtonCleanups.forEach((cleanup) => cleanup());
|
|
3496
|
+
this.commandButtonCleanups = [];
|
|
3462
3497
|
}
|
|
3463
3498
|
handleOpenChange() {
|
|
3464
3499
|
if (this.hasAttribute("open")) {
|
|
@@ -3469,6 +3504,13 @@ class Modal extends HTMLElement {
|
|
|
3469
3504
|
}
|
|
3470
3505
|
handleStatusChange(oldStatus, newStatus) {
|
|
3471
3506
|
var _a, _b, _c;
|
|
3507
|
+
if (statusValues.includes(newStatus)) {
|
|
3508
|
+
this.$titleContainer.setAttribute("color", `neutral`);
|
|
3509
|
+
} else {
|
|
3510
|
+
if (this.$titleContainer.hasAttribute("color")) {
|
|
3511
|
+
this.$titleContainer.removeAttribute("color");
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3472
3514
|
if (newStatus === "info") {
|
|
3473
3515
|
this.$container.classList.add("info");
|
|
3474
3516
|
} else {
|
|
@@ -3524,12 +3566,32 @@ class Modal extends HTMLElement {
|
|
|
3524
3566
|
this.$mediaContainer.style.backgroundImage = `url(${src})`;
|
|
3525
3567
|
}
|
|
3526
3568
|
addOpenListener() {
|
|
3527
|
-
var _a
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3569
|
+
var _a;
|
|
3570
|
+
this.removeOpenListener();
|
|
3571
|
+
this.openerElement = this.$opener;
|
|
3572
|
+
(_a = this.openerElement) == null ? void 0 : _a.addEventListener("click", this.onOpenClick);
|
|
3573
|
+
}
|
|
3574
|
+
removeOpenListener() {
|
|
3575
|
+
var _a;
|
|
3576
|
+
(_a = this.openerElement) == null ? void 0 : _a.removeEventListener("click", this.onOpenClick);
|
|
3577
|
+
this.openerElement = null;
|
|
3578
|
+
}
|
|
3579
|
+
addCloseListener(value) {
|
|
3580
|
+
var _a, _b;
|
|
3581
|
+
if (value === "none") {
|
|
3582
|
+
(_a = this.$dialog) == null ? void 0 : _a.setAttribute("closedby", "none");
|
|
3583
|
+
}
|
|
3584
|
+
this.removeCloseListener();
|
|
3585
|
+
if (value && value !== "none") {
|
|
3586
|
+
this.closerElement = document.querySelector(`#${value}`);
|
|
3587
|
+
(_b = this.closerElement) == null ? void 0 : _b.addEventListener("click", this.onCloseClick);
|
|
3531
3588
|
}
|
|
3532
3589
|
}
|
|
3590
|
+
removeCloseListener() {
|
|
3591
|
+
var _a;
|
|
3592
|
+
(_a = this.closerElement) == null ? void 0 : _a.removeEventListener("click", this.onCloseClick);
|
|
3593
|
+
this.closerElement = null;
|
|
3594
|
+
}
|
|
3533
3595
|
toggleDescriptionVisibility() {
|
|
3534
3596
|
if (!this.$slottedDescription) {
|
|
3535
3597
|
this.$descriptionContainer.style.display = "none";
|
|
@@ -3568,6 +3630,9 @@ class Modal extends HTMLElement {
|
|
|
3568
3630
|
'px-p[font-weight="title"]'
|
|
3569
3631
|
);
|
|
3570
3632
|
}
|
|
3633
|
+
get $titleContainer() {
|
|
3634
|
+
return this.shadowRoot.querySelector("px-h1");
|
|
3635
|
+
}
|
|
3571
3636
|
get $opener() {
|
|
3572
3637
|
return document.querySelector(
|
|
3573
3638
|
`px-button#${this.getAttribute("openedby")}`
|
|
@@ -3585,6 +3650,12 @@ class Modal extends HTMLElement {
|
|
|
3585
3650
|
set openedby(value) {
|
|
3586
3651
|
this.setAttribute("openedby", value);
|
|
3587
3652
|
}
|
|
3653
|
+
get closedby() {
|
|
3654
|
+
return this.getAttribute("closedby");
|
|
3655
|
+
}
|
|
3656
|
+
set closedby(value) {
|
|
3657
|
+
this.setAttribute("closedby", value);
|
|
3658
|
+
}
|
|
3588
3659
|
get $closeButton() {
|
|
3589
3660
|
return this.shadowRoot.querySelector("px-button-icon");
|
|
3590
3661
|
}
|
|
@@ -5587,20 +5658,20 @@ const _ContentHeader = class _ContentHeader extends PxElement {
|
|
|
5587
5658
|
}
|
|
5588
5659
|
createGridding(value) {
|
|
5589
5660
|
const breakpoints = [
|
|
5590
|
-
{ prop: "hasGridding",
|
|
5661
|
+
{ prop: "hasGridding", gridProp: "gridCols", attr: "col-span" },
|
|
5591
5662
|
{
|
|
5592
5663
|
prop: "hasGriddingMobile",
|
|
5593
|
-
|
|
5664
|
+
gridProp: "gridColsMobile",
|
|
5594
5665
|
attr: "col-span--mobile"
|
|
5595
5666
|
},
|
|
5596
5667
|
{
|
|
5597
5668
|
prop: "hasGriddingTablet",
|
|
5598
|
-
|
|
5669
|
+
gridProp: "gridColsTablet",
|
|
5599
5670
|
attr: "col-span--tablet"
|
|
5600
5671
|
},
|
|
5601
5672
|
{
|
|
5602
5673
|
prop: "hasGriddingLaptop",
|
|
5603
|
-
|
|
5674
|
+
gridProp: "gridColsLaptop",
|
|
5604
5675
|
attr: "col-span--laptop"
|
|
5605
5676
|
}
|
|
5606
5677
|
];
|
|
@@ -5608,16 +5679,16 @@ const _ContentHeader = class _ContentHeader extends PxElement {
|
|
|
5608
5679
|
"px-grid > px-container"
|
|
5609
5680
|
);
|
|
5610
5681
|
if (value !== null) {
|
|
5611
|
-
breakpoints.forEach(({ prop,
|
|
5682
|
+
breakpoints.forEach(({ prop, gridProp, attr }) => {
|
|
5612
5683
|
if (this[prop]) {
|
|
5613
|
-
this.$grid
|
|
5614
|
-
spanElement
|
|
5684
|
+
this.$grid[gridProp] = "3";
|
|
5685
|
+
spanElement.setAttribute(attr, "2");
|
|
5615
5686
|
}
|
|
5616
5687
|
});
|
|
5617
5688
|
} else {
|
|
5618
|
-
breakpoints.forEach(({
|
|
5619
|
-
this.$grid
|
|
5620
|
-
spanElement
|
|
5689
|
+
breakpoints.forEach(({ gridProp, attr }) => {
|
|
5690
|
+
this.$grid[gridProp] = "1";
|
|
5691
|
+
spanElement.removeAttribute(attr);
|
|
5621
5692
|
});
|
|
5622
5693
|
}
|
|
5623
5694
|
}
|
|
@@ -5785,5 +5856,6 @@ export {
|
|
|
5785
5856
|
Typography,
|
|
5786
5857
|
contentAlignmentValues,
|
|
5787
5858
|
gridColsValues,
|
|
5788
|
-
itemsAlignmentValues
|
|
5859
|
+
itemsAlignmentValues,
|
|
5860
|
+
statusValues
|
|
5789
5861
|
};
|