@proximus/lavender-drawer 2.0.0-alpha.5 → 2.0.0-alpha.52

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/Drawer.d.ts CHANGED
@@ -11,14 +11,21 @@ export declare class Drawer extends HTMLElement {
11
11
  connectedCallback(): void;
12
12
  static get observedAttributes(): string[];
13
13
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
14
+ disconnectedCallback(): void;
14
15
  show(): void;
15
16
  hide(): void;
17
+ toggleFooterVisibility(): void;
18
+ addOpenListener(): void;
19
+ get $opener(): HTMLButtonElement;
16
20
  get $closeButton(): Icon;
17
21
  get $dialog(): HTMLDialogElement;
18
22
  get open(): boolean;
19
- get $buttons(): NodeListOf<Element>;
20
- get $separator(): HTMLElement;
23
+ get $slotFooter(): HTMLSlotElement;
24
+ get $slottedFooter(): HTMLElement;
25
+ get $footer(): HTMLElement;
21
26
  set open(value: boolean);
22
- get ariaLabelCloseButton(): string;
23
- set ariaLabelCloseButton(value: string);
27
+ get closeButtonAriaLabel(): string;
28
+ set closeButtonAriaLabel(value: string);
29
+ get openedby(): string;
30
+ set openedby(value: string);
24
31
  }
package/dist/index.es.js CHANGED
@@ -3,25 +3,25 @@ import "@proximus/lavender-layout";
3
3
  import "@proximus/lavender-button-icon";
4
4
  import "@proximus/lavender-icon";
5
5
  import "@proximus/lavender-heading";
6
- const n = '#container{border:0;border-radius:var(--px-radius-main);background-color:var(--px-color-background-surface-default);box-sizing:border-box}:host([showfrom="bottom"]) #container{height:auto;margin-bottom:0;width:100%}px-button-icon{position:absolute;top:var(--px-padding-l-desktop);right:var(--px-padding-l-desktop)}dialog{background:transparent;border-radius:0;box-shadow:none;padding:0;border:0;box-sizing:border-box;width:75%}::backdrop{background:#0000004d;-webkit-backdrop-filter:saturate(180%) blur(15px);backdrop-filter:saturate(180%) blur(15px)}#content{overflow:auto}@media screen and (min-width: 1080px){#container{height:100%;padding:var(--px-padding-l-desktop)}:host([showfrom="right"]) px-button-icon{right:10.625em}:host([showfrom="right"]) #container{padding-right:10.625em;border-radius:var(--px-radius-main) 0 0 var(--px-radius-main)}:host([showfrom="left"]) px-button-icon{right:var(--px-padding-l-desktop)}:host([showfrom="left"]) #container{padding-left:10.625em;border-radius:0 var(--px-radius-main) var(--px-radius-main) 0}:host([showfrom="bottom"]) #container{box-sizing:border-box}:host([showfrom="left"])>dialog{margin-left:0;animation:dialog-fade-in-left .3s;height:100%}:host([showfrom="bottom"])>dialog{margin-bottom:0;margin-inline:0;width:100%;animation:dialog-fade-in-bottom .3s}:host([showfrom="right"])>dialog{margin-right:0;animation:dialog-fade-in-right .3s;height:100%}#content{max-height:calc(100dvh - 22.625em)}}@media only screen and (max-width: 67.563em){dialog{width:100%}:host([showfrom="left"])>dialog,:host([showfrom="right"])>dialog,:host([showfrom="bottom"])>dialog{margin-bottom:0;margin-inline:0;height:revert;animation:dialog-fade-in-bottom .3s}#container{width:100%;box-sizing:border-box;padding:var(--px-padding-m-mobile);border-radius:var(--px-radius-main) var(--px-radius-main) 0 0}px-button-icon{top:var(--px-padding-m-mobile);right:var(--px-padding-m-mobile)}#content{min-height:2.813em;max-height:50dvh}}@keyframes dialog-fade-in-right{0%{margin-right:-67.5em}to{margin-right:0}}@keyframes dialog-fade-in-left{0%{margin-left:-67.5em}to{margin-left:0}}@keyframes dialog-fade-in-bottom{0%{margin-bottom:-12.5em}to{margin-bottom:0}}', s = new CSSStyleSheet();
6
+ const n = ':host *{box-sizing:border-box}::backdrop{background:#0000004d;-webkit-backdrop-filter:saturate(180%) blur(15px);backdrop-filter:saturate(180%) blur(15px)}dialog{box-shadow:none;padding:0;margin:auto 0 0;border:0;width:100%;animation:dialog-fade-in-bottom .3s;border-radius:var(--px-radius-main) var(--px-radius-main) 0 0;background-color:var(--px-color-background-surface-light)}#container{display:grid;grid-template:"header close" auto "content content" 1fr "footer footer" auto / 1fr auto;column-gap:var(--px-spacing-l-mobile);padding:var(--px-padding-l-mobile);max-height:90dvh}#header{grid-area:header;margin-bottom:var(--px-spacing-l-mobile)}#close{grid-area:close}#content{grid-area:content;overflow:hidden;overflow-y:auto}#footer{grid-area:footer;margin-top:var(--px-spacing-l-mobile)}@media only screen and (min-width: 48em){#container{column-gap:var(--px-spacing-l-tablet);padding:var(--px-padding-l-tablet)}#header{margin-bottom:var(--px-spacing-l-tablet)}#footer{margin-top:var(--px-spacing-l-tablet)}}@media only screen and (min-width: 64.0625em){#container{column-gap:var(--px-spacing-l-laptop);padding:var(--px-padding-l-laptop);max-width:var(--px-content-wrapper-max-width-laptop);margin:0 auto}#header{margin-bottom:var(--px-spacing-l-laptop)}#footer{margin-top:var(--px-spacing-l-laptop)}:host([showfrom="right"]) dialog{width:75%;height:100%;margin:0 0 0 auto;animation:dialog-fade-in-right .3s;border-radius:var(--px-radius-main) 0 0 var(--px-radius-main)}:host([showfrom="right"]) #container{max-height:100%;height:100%;margin:0 auto 0 0}:host([showfrom="left"]) dialog{width:75%;height:100%;margin:0 auto 0 0;animation:dialog-fade-in-left .3s;border-radius:0 var(--px-radius-main) var(--px-radius-main) 0}:host([showfrom="left"]) #container{margin:0 0 0 auto}}@media only screen and (min-width: 90.0625em){#container{column-gap:var(--px-spacing-l-desktop);padding:var(--px-padding-l-desktop)}#header{margin-bottom:var(--px-spacing-l-desktop)}#footer{margin-top:var(--px-spacing-l-desktop)}}@keyframes dialog-fade-in-right{0%{margin-right:-67.5em}to{margin-right:0}}@keyframes dialog-fade-in-left{0%{margin-left:-67.5em}to{margin-left:0}}@keyframes dialog-fade-in-bottom{0%{margin-bottom:-12.5em}to{margin-bottom:0}}', s = new CSSStyleSheet();
7
7
  s.replaceSync(n);
8
- const d = "px.lavender.drawer.hide";
9
- class l extends HTMLElement {
8
+ const l = "px.lavender.drawer.hide";
9
+ class d extends HTMLElement {
10
10
  constructor() {
11
11
  super(), this.template = `<dialog popover role="dialog" aria-modal="true" >
12
12
  <div id="container">
13
- <px-vstack gap="l" >
14
- <px-vstack gap="heading-to-subtitle">
15
- <px-h1 variant="title-2xl">
16
- <slot name="title"></slot>
17
- </px-h1>
18
- <px-h2 variant="subtitle" color="neutral">
19
- <slot name="subtitle"></slot>
20
- </px-h2>
21
- </px-vstack>
22
- <div id="content">
23
- <slot></slot>
24
- </div>
13
+ <px-vstack gap="heading-to-subtitle" id="header">
14
+ <px-h1 variant="title-2xl">
15
+ <slot name="title"></slot>
16
+ </px-h1>
17
+ <px-h2 variant="subtitle" color="neutral">
18
+ <slot name="subtitle"></slot>
19
+ </px-h2>
20
+ </px-vstack>
21
+ <div id="content">
22
+ <slot></slot>
23
+ </div>
24
+ <px-vstack gap="l" id="footer">
25
25
  <px-separator size="m"></px-separator>
26
26
  <px-stack
27
27
  gap="s"
@@ -34,57 +34,72 @@ class l extends HTMLElement {
34
34
  <slot name="footer"></slot>
35
35
  </px-stack>
36
36
  </px-vstack>
37
- <px-button-icon variant="secondary" size="small">
37
+ <px-button-icon variant="secondary" size="small" id="close">
38
38
  <px-icon name="cross" from="lavender"></px-icon>
39
39
  </px-button-icon>
40
40
  </div>
41
- </dialog>`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [s], this.hasAttribute("showfrom") || this.setAttribute("showfrom", "bottom");
41
+ </dialog>`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [s];
42
42
  }
43
43
  connectedCallback() {
44
- if (this.hasAttribute("closedby")) {
45
- const t = document.querySelector(
44
+ var t;
45
+ if (this.toggleFooterVisibility = this.toggleFooterVisibility.bind(this), this.hasAttribute("showfrom") || this.setAttribute("showfrom", "bottom"), this.hasAttribute("closedby")) {
46
+ const e = document.querySelector(
46
47
  `#${this.getAttribute("closedby")}`
47
48
  );
48
- t == null || t.addEventListener("click", () => {
49
+ e == null || e.addEventListener("click", () => {
49
50
  this.hide();
50
51
  });
51
52
  }
52
- if (this.hasAttribute("openedby")) {
53
- const t = document.querySelector(
54
- `px-button#${this.getAttribute("openedby")}`
55
- );
56
- t == null || t.addEventListener("click", () => {
57
- this.show();
58
- });
59
- }
60
- this.$closeButton.addEventListener("click", () => {
53
+ this.hasAttribute("openedby") && this.addOpenListener(), this.$closeButton.addEventListener("click", () => {
61
54
  this.hide();
62
- }), this.$buttons.length === 0 && this.$separator.remove();
55
+ }), this.toggleFooterVisibility(), (t = this.$slotFooter) == null || t.addEventListener(
56
+ "slotchange",
57
+ this.toggleFooterVisibility
58
+ );
63
59
  }
64
60
  static get observedAttributes() {
65
- return ["open", "aria-label-close-button"];
61
+ return ["open", "close-button-aria-label", "openedby"];
66
62
  }
67
- attributeChangedCallback(t, e, i) {
68
- var r, o, a;
69
- t === "open" ? i !== null ? this.show() : this.hide() : t === "aria-label-close-button" && (i ? (a = (o = this.$closeButton) == null ? void 0 : o.setAttribute) == null || a.call(
70
- o,
63
+ attributeChangedCallback(t, e, o) {
64
+ var a, i, r;
65
+ t === "open" ? o !== null ? this.show() : this.hide() : t === "close-button-aria-label" ? o ? (r = (i = this.$closeButton) == null ? void 0 : i.setAttribute) == null || r.call(
66
+ i,
71
67
  "aria-label",
72
- i || "Close drawer"
73
- ) : (r = this.$closeButton) == null || r.removeAttribute("aria-label"));
68
+ o || "Close drawer"
69
+ ) : (a = this.$closeButton) == null || a.removeAttribute("aria-label") : t === "openedby" && this.addOpenListener();
70
+ }
71
+ disconnectedCallback() {
72
+ var t;
73
+ (t = this.$slotFooter) == null || t.removeEventListener(
74
+ "slotchange",
75
+ this.toggleFooterVisibility
76
+ );
74
77
  }
75
78
  show() {
76
79
  var t, e;
77
- (e = (t = this.$dialog).showPopover) == null || e.call(t);
80
+ (e = (t = this.$dialog).showPopover) == null || e.call(t), document.body.style.overflow = "hidden";
78
81
  }
79
82
  hide() {
80
83
  var t, e;
81
- (e = (t = this.$dialog).hidePopover) == null || e.call(t), this.dispatchEvent(
82
- new Event(d, {
84
+ (e = (t = this.$dialog).hidePopover) == null || e.call(t), document.body.style.overflow = "", this.dispatchEvent(
85
+ new Event(l, {
83
86
  bubbles: !0,
84
87
  composed: !0
85
88
  })
86
89
  );
87
90
  }
91
+ toggleFooterVisibility() {
92
+ this.$slottedFooter ? this.$footer.style.display = "block" : this.$footer.style.display = "none";
93
+ }
94
+ addOpenListener() {
95
+ var t, e, o;
96
+ ((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()));
97
+ }
98
+ get $opener() {
99
+ return document.querySelector(
100
+ `px-button#${this.getAttribute("openedby")}`
101
+ );
102
+ }
88
103
  get $closeButton() {
89
104
  return this.shadowRoot.querySelector("px-button-icon");
90
105
  }
@@ -94,24 +109,35 @@ class l extends HTMLElement {
94
109
  get open() {
95
110
  return this.hasAttribute("open");
96
111
  }
97
- get $buttons() {
98
- return this.querySelectorAll('[slot="footer"]');
112
+ get $slotFooter() {
113
+ return this.shadowRoot.querySelector(
114
+ 'slot[name="footer"]'
115
+ );
99
116
  }
100
- get $separator() {
101
- return this.shadowRoot.querySelector("px-separator");
117
+ get $slottedFooter() {
118
+ return this.querySelector('[slot="footer"]');
119
+ }
120
+ get $footer() {
121
+ return this.shadowRoot.querySelector("#footer");
102
122
  }
103
123
  set open(t) {
104
124
  t ? this.setAttribute("open", "") : this.removeAttribute("open");
105
125
  }
106
- get ariaLabelCloseButton() {
107
- return this.getAttribute("aria-label-close-button");
126
+ get closeButtonAriaLabel() {
127
+ return this.getAttribute("close-button-aria-label");
128
+ }
129
+ set closeButtonAriaLabel(t) {
130
+ this.setAttribute("close-button-aria-label", t);
131
+ }
132
+ get openedby() {
133
+ return this.getAttribute("openedby");
108
134
  }
109
- set ariaLabelCloseButton(t) {
110
- this.setAttribute("aria-label-close-button", t);
135
+ set openedby(t) {
136
+ this.setAttribute("openedby", t);
111
137
  }
112
138
  }
113
- customElements.get("px-drawer") || customElements.define("px-drawer", l);
139
+ customElements.get("px-drawer") || customElements.define("px-drawer", d);
114
140
  export {
115
- l as Drawer,
116
- d as HIDE_EVENT
141
+ d as Drawer,
142
+ l as HIDE_EVENT
117
143
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-drawer",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.52",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "clean": "rm -rf dist",
14
14
  "build": "npm run clean && NODE_ENV=development vite build && tsc && npm run transform-package-json && npm run wc-manifest",
15
15
  "test": "vitest run --coverage",
16
- "wc-manifest": "cem analyze --globs \"src/*\" --config ../custom-elements-manifest.config.js --outdir dist"
16
+ "wc-manifest": "cem analyze --globs \"src/*\" --config ../../custom-elements-manifest.config.js --outdir dist"
17
17
  },
18
18
  "publishConfig": {
19
19
  "access": "public"