@proximus/lavender-modal 2.0.0-alpha.38 → 2.0.0-alpha.39

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/dist/Modal.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare class Modal extends HTMLElement {
12
12
  connectedCallback(): void;
13
13
  static get observedAttributes(): string[];
14
14
  attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
15
+ disconnectedCallback(): void;
15
16
  handleOpenChange(): void;
16
17
  handleStatusChange(oldStatus: string, newStatus: string): void;
17
18
  getIcon(status: string): "checkmark_fill" | "exclamation_mark_fill" | "minus_fill" | "information_fill";
@@ -19,6 +20,13 @@ export declare class Modal extends HTMLElement {
19
20
  close(): void;
20
21
  updateMediaSrc(src: string): void;
21
22
  addOpenListener(): void;
23
+ toggleDescriptionVisibility(): void;
24
+ toggleCloseButtonSafeArea(): void;
25
+ get $slottedCloseButton(): HTMLSlotElement;
26
+ get $slotCloseButton(): HTMLSlotElement;
27
+ get $slottedDescription(): HTMLSlotElement;
28
+ get $slotDescription(): HTMLSlotElement;
29
+ get $descriptionContainer(): HTMLParagraphElement;
22
30
  get $opener(): HTMLButtonElement;
23
31
  get status(): string;
24
32
  set status(value: string);
package/dist/index.es.js CHANGED
@@ -4,17 +4,17 @@ import "@proximus/lavender-layout";
4
4
  import "@proximus/lavender-icon";
5
5
  import "@proximus/lavender-heading";
6
6
  import "@proximus/lavender-paragraph";
7
- const a = "*{box-sizing:border-box}#container{display:flex;flex-wrap:nowrap;font-family:var(--px-font-family);font-size:var(--px-font-size-base);color:var(--px-color-text-neutral-default);width:1080px;border-radius:var(--px-radius-main);background-color:var(--px-color-background-surface-default);overflow:hidden}#container.info{border-left:5px var(--px-color-icon-brand-default) solid}#container.success{border-left:5px var(--px-color-icon-purpose-success-default) solid}#container.warning{border-left:5px var(--px-color-icon-purpose-warning-default) solid}#container.error{border-left:5px var(--px-color-icon-purpose-error-default) solid}#content-container{padding:var(--px-padding-m-mobile);flex-grow:1}#media-container{display:none}::slotted(px-button-icon){position:absolute;top:var(--px-padding-m-desktop);right:var(--px-padding-m-desktop)}dialog{background:transparent;border-radius:0;box-shadow:none;padding:0;border:0;box-sizing:border-box;transform:scale(.95);animation:modalIn .3s ease-out forwards}::backdrop{background:#0000004d;-webkit-backdrop-filter:saturate(180%) blur(15px);backdrop-filter:saturate(180%) blur(15px)}#content{max-height:12.5em;overflow:auto}@media screen and (max-width: 1081px){#container{width:inherit}#content-container{padding:var(--px-padding-m-mobile)}::slotted(px-button-icon){top:var(--px-padding-m-mobile);right:var(--px-padding-m-mobile)}}@media only screen and (min-width: 48em){::slotted(px-button-icon){position:absolute;top:var(--px-padding-m-tablet);right:var(--px-padding-m-tablet)}#content{max-height:25em}}@media only screen and (min-width: 64.0625em){:host([media-src]) #media-container{display:block;background-size:cover;background-position:center center;background-repeat:no-repeat;flex-basis:25em;flex-shrink:0}}@keyframes modalIn{0%{transform:scale(.95);opacity:0}to{transform:scale(1);opacity:1}}", n = new CSSStyleSheet();
8
- n.replaceSync(a);
7
+ const a = '*{box-sizing:border-box}#container{display:flex;flex-wrap:nowrap;font-family:var(--px-font-family);font-size:var(--px-font-size-base);color:var(--px-color-text-neutral-default);width:inherit;border-radius:var(--px-radius-main);background-color:var(--px-color-background-surface-default);overflow:hidden}#container.info{border-left:5px var(--px-color-icon-brand-default) solid}#container.success{border-left:5px var(--px-color-icon-purpose-success-default) solid}#container.warning{border-left:5px var(--px-color-icon-purpose-warning-default) solid}#container.error{border-left:5px var(--px-color-icon-purpose-error-default) solid}#container.has-close-button #icon-container{max-width:calc(100% - (var(--px-size-m) + var(--px-spacing-s-mobile)))}#content-container{padding:var(--px-padding-m-mobile);flex-grow:1}#media-container{display:none}::slotted(px-button-icon[slot="close-button"]){position:absolute;top:var(--px-padding-m-mobile);right:var(--px-padding-m-mobile)}dialog{background:transparent;border-radius:0;box-shadow:none;padding:0;border:0;box-sizing:border-box;transform:scale(.95);animation:modalIn .3s ease-out forwards}::backdrop{background:#0000004d;-webkit-backdrop-filter:saturate(180%) blur(15px);backdrop-filter:saturate(180%) blur(15px)}#content{max-height:12.5em;overflow:auto}@media only screen and (min-width: 48em){#container.has-close-button #icon-container{max-width:calc(100% - (var(--px-size-m) + var(--px-spacing-s-tablet)))}::slotted(px-button-icon[slot="close-button"]){position:absolute;top:var(--px-padding-m-tablet);right:var(--px-padding-m-tablet)}#content{max-height:25em}}@media only screen and (min-width: 64.0625em){#container.has-close-button #icon-container{max-width:calc(100% - (var(--px-size-m) + var(--px-spacing-s-laptop)))}::slotted(px-button-icon[slot="close-button"]){top:var(--px-padding-m-laptop);right:var(--px-padding-m-laptop)}:host([media-src]) #container.has-close-button #icon-container{max-width:100%}:host([media-src]) #media-container{display:block;background-size:cover;background-position:center center;background-repeat:no-repeat;flex-basis:25em;flex-shrink:0}}@media screen and (min-width: 1118px){#container{width:1080px}}@media only screen and (min-width: 90.0625em){:host(:not([media-src])) #container.has-close-button #icon-container{max-width:calc(100% - (var(--px-size-m) + var(--px-spacing-s-desktop)))}::slotted(px-button-icon[slot="close-button"]){position:absolute;top:var(--px-padding-m-desktop);right:var(--px-padding-m-desktop)}}@keyframes modalIn{0%{transform:scale(.95);opacity:0}to{transform:scale(1);opacity:1}}', r = new CSSStyleSheet();
8
+ r.replaceSync(a);
9
9
  const c = "px.lavender.modal.close";
10
- class d extends HTMLElement {
10
+ class l extends HTMLElement {
11
11
  constructor() {
12
- super(), this.template = ` <dialog>
12
+ super(), this.template = `<dialog>
13
13
  <div id="container">
14
14
  <div id="content-container">
15
15
  <px-vstack gap="default" >
16
16
  <px-hstack id="icon-container" gap="s" align-items="flex-start">
17
- <px-vstack gap="s">
17
+ <px-vstack gap="xs">
18
18
  <px-h1 variant="title-l">
19
19
  <slot name="title"></slot>
20
20
  </px-h1>
@@ -43,50 +43,64 @@ class d extends HTMLElement {
43
43
  <div id="media-container">
44
44
  </div>
45
45
  </div>
46
- </dialog>`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [n];
46
+ </dialog>`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [r];
47
47
  }
48
48
  connectedCallback() {
49
- if (this.hasAttribute("open") && this.show(), this.hasAttribute("closedby")) {
50
- const t = document.querySelector(
49
+ var t, e;
50
+ if (this.toggleDescriptionVisibility = this.toggleDescriptionVisibility.bind(this), this.toggleCloseButtonSafeArea = this.toggleCloseButtonSafeArea.bind(this), this.hasAttribute("open") && this.show(), this.hasAttribute("closedby")) {
51
+ const o = document.querySelector(
51
52
  `#${this.getAttribute("closedby")}`
52
53
  );
53
- t == null || t.addEventListener("click", () => {
54
+ o == null || o.addEventListener("click", () => {
54
55
  this.close();
55
56
  });
56
57
  }
57
- this.hasAttribute("openedby") && this.addOpenListener(), this.hasAttribute("media-src") && this.updateMediaSrc(this.getAttribute("media-src"));
58
+ this.hasAttribute("openedby") && this.addOpenListener(), this.hasAttribute("media-src") && this.updateMediaSrc(this.getAttribute("media-src")), this.toggleDescriptionVisibility(), (t = this.$slotDescription) == null || t.addEventListener(
59
+ "slotchange",
60
+ this.toggleDescriptionVisibility
61
+ ), this.toggleCloseButtonSafeArea(), (e = this.$slotCloseButton) == null || e.addEventListener(
62
+ "slotchange",
63
+ this.toggleCloseButtonSafeArea
64
+ );
58
65
  }
59
66
  static get observedAttributes() {
60
67
  return ["open", "status", "media-src", "openedby"];
61
68
  }
62
- attributeChangedCallback(t, e, i) {
69
+ attributeChangedCallback(t, e, o) {
63
70
  switch (t) {
64
71
  case "open":
65
72
  this.handleOpenChange();
66
73
  break;
67
74
  case "status":
68
- this.handleStatusChange(e, i);
75
+ this.handleStatusChange(e, o);
69
76
  break;
70
77
  case "media-src":
71
- this.updateMediaSrc(i);
78
+ this.updateMediaSrc(o);
72
79
  break;
73
80
  case "openedby":
74
81
  this.addOpenListener();
75
82
  break;
76
83
  }
77
84
  }
85
+ disconnectedCallback() {
86
+ var t;
87
+ (t = this.$slotDescription) == null || t.removeEventListener(
88
+ "slotchange",
89
+ this.toggleDescriptionVisibility
90
+ );
91
+ }
78
92
  handleOpenChange() {
79
93
  this.hasAttribute("open") ? this.show() : this.close();
80
94
  }
81
95
  handleStatusChange(t, e) {
82
- var i, r, s;
96
+ var o, s, n;
83
97
  if (e === "info" ? this.$container.classList.add("info") : this.$container.classList.remove("info"), e === "success" ? this.$container.classList.add("success") : this.$container.classList.remove("success"), e === "error" ? this.$container.classList.add("error") : this.$container.classList.remove("error"), e === "warning" ? this.$container.classList.add("warning") : this.$container.classList.remove("warning"), e === null && this.$statusIcon)
84
- (i = this.$statusIcon) == null || i.remove();
98
+ (o = this.$statusIcon) == null || o.remove();
85
99
  else if (t === null && e && !this.$statusIcon) {
86
- const o = document.createElement("px-icon");
87
- o.setAttribute("name", this.getIcon(e)), o.setAttribute("from", "lavender"), o.setAttribute("color", `purpose-${e}`), o.setAttribute("size", "l"), this.$iconContainer.prepend(o);
100
+ const i = document.createElement("px-icon");
101
+ i.setAttribute("name", this.getIcon(e)), i.setAttribute("from", "lavender"), i.setAttribute("color", `purpose-${e}`), i.setAttribute("size", "l"), this.$iconContainer.prepend(i);
88
102
  } else
89
- (r = this.$statusIcon) == null || r.setAttribute("name", this.getIcon(e)), (s = this.$statusIcon) == null || s.setAttribute("color", `purpose-${e}`);
103
+ (s = this.$statusIcon) == null || s.setAttribute("name", this.getIcon(e)), (n = this.$statusIcon) == null || n.setAttribute("color", `purpose-${e}`);
90
104
  }
91
105
  getIcon(t) {
92
106
  return t === "success" ? "checkmark_fill" : t === "warning" ? "exclamation_mark_fill" : t === "error" ? "minus_fill" : "information_fill";
@@ -106,8 +120,36 @@ class d extends HTMLElement {
106
120
  this.$mediaContainer.style.backgroundImage = `url(${t})`;
107
121
  }
108
122
  addOpenListener() {
109
- var t, e, i;
110
- ((t = this.$opener) == null ? void 0 : t.getAttribute("data-has-opener")) !== "true" && ((e = this.$opener) == null || e.setAttribute("data-has-opener", "true"), (i = this.$opener) == null || i.addEventListener("click", () => this.show()));
123
+ var t, e, o;
124
+ ((t = this.$opener) == null ? void 0 : t.getAttribute("data-has-opener")) !== "true" && ((e = this.$opener) == null || e.setAttribute("data-has-opener", "true"), (o = this.$opener) == null || o.addEventListener("click", () => this.show()));
125
+ }
126
+ toggleDescriptionVisibility() {
127
+ this.$slottedDescription ? this.$descriptionContainer.style.display = "block" : this.$descriptionContainer.style.display = "none";
128
+ }
129
+ toggleCloseButtonSafeArea() {
130
+ var t, e, o;
131
+ this.$slottedCloseButton ? (t = this.$container) == null || t.classList.add("has-close-button") : (e = this.$container) != null && e.classList.contains("has-close-button") && ((o = this.$container) == null || o.classList.remove("has-close-button"));
132
+ }
133
+ get $slottedCloseButton() {
134
+ return this.querySelector('[slot="close-button"]');
135
+ }
136
+ get $slotCloseButton() {
137
+ return this.shadowRoot.querySelector(
138
+ 'slot[name="close-button"]'
139
+ );
140
+ }
141
+ get $slottedDescription() {
142
+ return this.querySelector('[slot="description"]');
143
+ }
144
+ get $slotDescription() {
145
+ return this.shadowRoot.querySelector(
146
+ 'slot[name="description"]'
147
+ );
148
+ }
149
+ get $descriptionContainer() {
150
+ return this.shadowRoot.querySelector(
151
+ 'px-p[font-weight="title"]'
152
+ );
111
153
  }
112
154
  get $opener() {
113
155
  return document.querySelector(
@@ -156,7 +198,7 @@ class d extends HTMLElement {
156
198
  return this.$dialog.open;
157
199
  }
158
200
  }
159
- customElements.get("px-modal") || customElements.define("px-modal", d);
201
+ customElements.get("px-modal") || customElements.define("px-modal", l);
160
202
  export {
161
- d as Modal
203
+ l as Modal
162
204
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-modal",
3
- "version": "2.0.0-alpha.38",
3
+ "version": "2.0.0-alpha.39",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",