@proximus/lavender-modal 1.4.5-alpha.1 → 1.4.5-alpha.11

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
@@ -6,12 +6,21 @@ import '@proximus/lavender-heading';
6
6
  import '@proximus/lavender-paragraph';
7
7
  import { type ButtonIcon } from '@proximus/lavender-button-icon';
8
8
  import { type Icon } from '@proximus/lavender-icon';
9
+ export declare const statusValues: string[];
9
10
  export declare class Modal extends HTMLElement {
11
+ private onOpenClick;
12
+ private onCloseClick;
13
+ private commandButtonCleanups;
14
+ private openerElement;
15
+ private closerElement;
10
16
  template: string;
11
17
  constructor();
12
18
  connectedCallback(): void;
13
19
  static get observedAttributes(): string[];
14
20
  attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
21
+ disconnectedCallback(): void;
22
+ addEventListenersToCommandButtons(): void;
23
+ private removeCommandButtonListeners;
15
24
  handleOpenChange(): void;
16
25
  handleStatusChange(oldStatus: string, newStatus: string): void;
17
26
  getIcon(status: string): "checkmark_fill" | "exclamation_mark_fill" | "minus_fill" | "information_fill";
@@ -19,11 +28,24 @@ export declare class Modal extends HTMLElement {
19
28
  close(): void;
20
29
  updateMediaSrc(src: string): void;
21
30
  addOpenListener(): void;
31
+ private removeOpenListener;
32
+ addCloseListener(value: string): void;
33
+ private removeCloseListener;
34
+ toggleDescriptionVisibility(): void;
35
+ toggleCloseButtonSafeArea(): void;
36
+ get $slottedCloseButton(): HTMLSlotElement;
37
+ get $slotCloseButton(): HTMLSlotElement;
38
+ get $slottedDescription(): HTMLSlotElement;
39
+ get $slotDescription(): HTMLSlotElement;
40
+ get $descriptionContainer(): HTMLParagraphElement;
41
+ get $titleContainer(): HTMLHeadingElement;
22
42
  get $opener(): HTMLButtonElement;
23
43
  get status(): string;
24
44
  set status(value: string);
25
45
  get openedby(): string;
26
46
  set openedby(value: string);
47
+ get closedby(): string;
48
+ set closedby(value: string);
27
49
  get $closeButton(): ButtonIcon;
28
50
  get $statusIcon(): Icon;
29
51
  get $mediaContainer(): HTMLDivElement;
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);
9
- const c = "px.lavender.modal.close";
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
+ const l = "px.lavender.modal.close", c = ["", "info", "success", "error", "warning"];
10
10
  class d extends HTMLElement {
11
11
  constructor() {
12
- super(), this.template = ` <dialog>
12
+ super(), this.onOpenClick = () => this.show(), this.onCloseClick = () => this.close(), this.commandButtonCleanups = [], this.openerElement = null, this.closerElement = null, 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>
@@ -24,6 +24,7 @@ class d extends HTMLElement {
24
24
  </px-vstack>
25
25
  </px-hstack>
26
26
  <div id="content">
27
+ <slot name="content"></slot>
27
28
  <slot></slot>
28
29
  </div>
29
30
  <px-separator size="m"></px-separator>
@@ -43,60 +44,87 @@ class d extends HTMLElement {
43
44
  <div id="media-container">
44
45
  </div>
45
46
  </div>
46
- </dialog>`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [n];
47
+ </dialog>`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [r];
47
48
  }
48
49
  connectedCallback() {
49
- if (this.hasAttribute("open") && this.show(), this.hasAttribute("closedby")) {
50
- const t = document.querySelector(
51
- `#${this.getAttribute("closedby")}`
52
- );
53
- t == null || t.addEventListener("click", () => {
54
- this.close();
55
- });
56
- }
57
- this.hasAttribute("openedby") && this.addOpenListener(), this.hasAttribute("media-src") && this.updateMediaSrc(this.getAttribute("media-src"));
50
+ var t, e;
51
+ this.addEventListenersToCommandButtons(), this.toggleDescriptionVisibility = this.toggleDescriptionVisibility.bind(this), this.toggleCloseButtonSafeArea = this.toggleCloseButtonSafeArea.bind(this), this.hasAttribute("open") && this.show(), this.hasAttribute("closedby") && this.addCloseListener(this.getAttribute("closedby")), this.hasAttribute("openedby") && this.addOpenListener(), this.hasAttribute("media-src") && this.updateMediaSrc(this.getAttribute("media-src")), this.toggleDescriptionVisibility(), (t = this.$slotDescription) == null || t.addEventListener(
52
+ "slotchange",
53
+ this.toggleDescriptionVisibility
54
+ ), this.toggleCloseButtonSafeArea(), (e = this.$slotCloseButton) == null || e.addEventListener(
55
+ "slotchange",
56
+ this.toggleCloseButtonSafeArea
57
+ );
58
58
  }
59
59
  static get observedAttributes() {
60
- return ["open", "status", "media-src", "openedby"];
60
+ return ["open", "status", "media-src", "openedby", "closedby", "id"];
61
61
  }
62
- attributeChangedCallback(t, e, i) {
62
+ attributeChangedCallback(t, e, o) {
63
63
  switch (t) {
64
64
  case "open":
65
65
  this.handleOpenChange();
66
66
  break;
67
67
  case "status":
68
- this.handleStatusChange(e, i);
68
+ this.handleStatusChange(e, o);
69
69
  break;
70
70
  case "media-src":
71
- this.updateMediaSrc(i);
71
+ this.updateMediaSrc(o);
72
72
  break;
73
73
  case "openedby":
74
74
  this.addOpenListener();
75
75
  break;
76
+ case "closedby":
77
+ this.addCloseListener(o);
78
+ break;
79
+ case "id":
80
+ this.addEventListenersToCommandButtons();
81
+ break;
76
82
  }
77
83
  }
84
+ disconnectedCallback() {
85
+ var t, e;
86
+ (t = this.$slotDescription) == null || t.removeEventListener(
87
+ "slotchange",
88
+ this.toggleDescriptionVisibility
89
+ ), (e = this.$slotCloseButton) == null || e.removeEventListener(
90
+ "slotchange",
91
+ this.toggleCloseButtonSafeArea
92
+ ), this.removeCommandButtonListeners(), this.removeOpenListener(), this.removeCloseListener();
93
+ }
94
+ addEventListenersToCommandButtons() {
95
+ this.removeCommandButtonListeners(), this.id && document.querySelectorAll(`[commandfor="${this.id}"]`).forEach((t) => {
96
+ t.getAttribute("command") === "show-modal" ? (t.addEventListener("click", this.onOpenClick), this.commandButtonCleanups.push(
97
+ () => t.removeEventListener("click", this.onOpenClick)
98
+ )) : t.getAttribute("command") === "close" && (t.addEventListener("click", this.onCloseClick), this.commandButtonCleanups.push(
99
+ () => t.removeEventListener("click", this.onCloseClick)
100
+ ));
101
+ });
102
+ }
103
+ removeCommandButtonListeners() {
104
+ this.commandButtonCleanups.forEach((t) => t()), this.commandButtonCleanups = [];
105
+ }
78
106
  handleOpenChange() {
79
107
  this.hasAttribute("open") ? this.show() : this.close();
80
108
  }
81
109
  handleStatusChange(t, e) {
82
- var i, r, s;
83
- 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();
110
+ var o, s, n;
111
+ if (c.includes(e) ? this.$titleContainer.setAttribute("color", "neutral") : this.$titleContainer.hasAttribute("color") && this.$titleContainer.removeAttribute("color"), 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)
112
+ (o = this.$statusIcon) == null || o.remove();
85
113
  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);
114
+ const i = document.createElement("px-icon");
115
+ i.setAttribute("name", this.getIcon(e)), i.setAttribute("from", "lavender"), i.setAttribute("color", `purpose-${e}`), i.setAttribute("size", "l"), this.$iconContainer.prepend(i);
88
116
  } else
89
- (r = this.$statusIcon) == null || r.setAttribute("name", this.getIcon(e)), (s = this.$statusIcon) == null || s.setAttribute("color", `purpose-${e}`);
117
+ (s = this.$statusIcon) == null || s.setAttribute("name", this.getIcon(e)), (n = this.$statusIcon) == null || n.setAttribute("color", `purpose-${e}`);
90
118
  }
91
119
  getIcon(t) {
92
120
  return t === "success" ? "checkmark_fill" : t === "warning" ? "exclamation_mark_fill" : t === "error" ? "minus_fill" : "information_fill";
93
121
  }
94
122
  show() {
95
- this.$dialog.showModal();
123
+ this.$dialog.showModal(), document.body.style.overflow = "hidden";
96
124
  }
97
125
  close() {
98
- this.$dialog.close(), this.dispatchEvent(
99
- new CustomEvent(c, {
126
+ this.$dialog.close(), document.body.style.overflow = "", this.dispatchEvent(
127
+ new CustomEvent(l, {
100
128
  bubbles: !0,
101
129
  composed: !0
102
130
  })
@@ -106,8 +134,51 @@ class d extends HTMLElement {
106
134
  this.$mediaContainer.style.backgroundImage = `url(${t})`;
107
135
  }
108
136
  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()));
137
+ var t;
138
+ this.removeOpenListener(), this.openerElement = this.$opener, (t = this.openerElement) == null || t.addEventListener("click", this.onOpenClick);
139
+ }
140
+ removeOpenListener() {
141
+ var t;
142
+ (t = this.openerElement) == null || t.removeEventListener("click", this.onOpenClick), this.openerElement = null;
143
+ }
144
+ addCloseListener(t) {
145
+ var e, o;
146
+ t === "none" && ((e = this.$dialog) == null || e.setAttribute("closedby", "none")), this.removeCloseListener(), t && t !== "none" && (this.closerElement = document.querySelector(`#${t}`), (o = this.closerElement) == null || o.addEventListener("click", this.onCloseClick));
147
+ }
148
+ removeCloseListener() {
149
+ var t;
150
+ (t = this.closerElement) == null || t.removeEventListener("click", this.onCloseClick), this.closerElement = null;
151
+ }
152
+ toggleDescriptionVisibility() {
153
+ this.$slottedDescription ? this.$descriptionContainer.style.display = "block" : this.$descriptionContainer.style.display = "none";
154
+ }
155
+ toggleCloseButtonSafeArea() {
156
+ var t, e, o;
157
+ 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"));
158
+ }
159
+ get $slottedCloseButton() {
160
+ return this.querySelector('[slot="close-button"]');
161
+ }
162
+ get $slotCloseButton() {
163
+ return this.shadowRoot.querySelector(
164
+ 'slot[name="close-button"]'
165
+ );
166
+ }
167
+ get $slottedDescription() {
168
+ return this.querySelector('[slot="description"]');
169
+ }
170
+ get $slotDescription() {
171
+ return this.shadowRoot.querySelector(
172
+ 'slot[name="description"]'
173
+ );
174
+ }
175
+ get $descriptionContainer() {
176
+ return this.shadowRoot.querySelector(
177
+ 'px-p[font-weight="title"]'
178
+ );
179
+ }
180
+ get $titleContainer() {
181
+ return this.shadowRoot.querySelector("px-h1");
111
182
  }
112
183
  get $opener() {
113
184
  return document.querySelector(
@@ -126,6 +197,12 @@ class d extends HTMLElement {
126
197
  set openedby(t) {
127
198
  this.setAttribute("openedby", t);
128
199
  }
200
+ get closedby() {
201
+ return this.getAttribute("closedby");
202
+ }
203
+ set closedby(t) {
204
+ this.setAttribute("closedby", t);
205
+ }
129
206
  get $closeButton() {
130
207
  return this.shadowRoot.querySelector("px-button-icon");
131
208
  }
@@ -158,5 +235,6 @@ class d extends HTMLElement {
158
235
  }
159
236
  customElements.get("px-modal") || customElements.define("px-modal", d);
160
237
  export {
161
- d as Modal
238
+ d as Modal,
239
+ c as statusValues
162
240
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-modal",
3
- "version": "1.4.5-alpha.1",
3
+ "version": "1.4.5-alpha.11",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",