@proximus/lavender-drawer 2.0.0-alpha.19 → 2.0.0-alpha.190

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
@@ -6,22 +6,42 @@ import '@proximus/lavender-heading';
6
6
  import { type Icon } from '@proximus/lavender-icon';
7
7
  export declare const HIDE_EVENT = "px.lavender.drawer.hide";
8
8
  export declare class Drawer extends HTMLElement {
9
+ observer: MutationObserver | null;
10
+ private previousFocusedElement;
9
11
  template: string;
10
12
  constructor();
11
13
  connectedCallback(): void;
12
14
  static get observedAttributes(): string[];
13
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
15
+ attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
14
16
  disconnectedCallback(): void;
15
17
  show(): void;
16
18
  hide(): void;
17
19
  toggleFooterVisibility(): void;
20
+ addOpenListener(): void;
21
+ addCloseListener(): void;
22
+ get $opener(): HTMLElement;
23
+ get $closer(): HTMLElement;
18
24
  get $closeButton(): Icon;
19
25
  get $dialog(): HTMLDialogElement;
20
26
  get open(): boolean;
21
- get $slotFooter(): HTMLSlotElement;
22
- get $slottedFooter(): HTMLElement;
27
+ get $slotFooter(): HTMLSlotElement | null;
28
+ get $slottedFooter(): HTMLElement | null;
23
29
  get $footer(): HTMLElement;
24
30
  set open(value: boolean);
25
- get closeButtonAriaLabel(): string;
26
- set closeButtonAriaLabel(value: string);
31
+ get closeButtonAriaLabel(): string | null;
32
+ set closeButtonAriaLabel(value: string | null);
33
+ get openedby(): string | null;
34
+ set openedby(value: string | null);
35
+ get closedby(): string | null;
36
+ set closedby(value: string | null);
37
+ get fullscreen(): boolean;
38
+ set fullscreen(value: boolean);
39
+ get fullscreenMobile(): boolean;
40
+ set fullscreenMobile(value: boolean);
41
+ get fullscreenTablet(): boolean;
42
+ set fullscreenTablet(value: boolean);
43
+ get fullscreenLaptop(): boolean;
44
+ set fullscreenLaptop(value: boolean);
45
+ get fullscreenDesktop(): boolean;
46
+ set fullscreenDesktop(value: boolean);
27
47
  }
package/dist/index.es.js CHANGED
@@ -3,134 +3,153 @@ 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 = ':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-default)}#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
- s.replaceSync(n);
8
- const l = "px.lavender.drawer.hide";
9
- class d extends HTMLElement {
10
- constructor() {
11
- super(), this.template = `<dialog popover role="dialog" aria-modal="true" >
12
- <div id="container">
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
- <px-separator size="m"></px-separator>
26
- <px-stack
27
- gap="s"
28
- justify-content="flex-end"
29
- align-items="center"
30
- align-items--mobile="stretch"
31
- direction="row"
32
- direction--mobile="column-reverse"
33
- >
34
- <slot name="footer"></slot>
35
- </px-stack>
36
- </px-vstack>
37
- <px-button-icon variant="secondary" size="small" id="close">
38
- <px-icon name="cross" from="lavender"></px-icon>
39
- </px-button-icon>
40
- </div>
41
- </dialog>`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [s], this.toggleFooterVisibility = this.toggleFooterVisibility.bind(this);
42
- }
43
- connectedCallback() {
44
- var t;
45
- if (this.hasAttribute("showfrom") || this.setAttribute("showfrom", "bottom"), this.hasAttribute("closedby")) {
46
- const e = document.querySelector(
47
- `#${this.getAttribute("closedby")}`
48
- );
49
- e == null || e.addEventListener("click", () => {
50
- this.hide();
51
- });
52
- }
53
- if (this.hasAttribute("openedby")) {
54
- const e = document.querySelector(
55
- `px-button#${this.getAttribute("openedby")}`
56
- );
57
- e == null || e.addEventListener("click", () => {
58
- this.show();
59
- });
60
- }
61
- this.$closeButton.addEventListener("click", () => {
62
- this.hide();
63
- }), this.toggleFooterVisibility(), (t = this.$slotFooter) == null || t.addEventListener(
64
- "slotchange",
65
- this.toggleFooterVisibility
66
- );
67
- }
68
- static get observedAttributes() {
69
- return ["open", "close-button-aria-label"];
70
- }
71
- attributeChangedCallback(t, e, i) {
72
- var a, o, r;
73
- t === "open" ? i !== null ? this.show() : this.hide() : t === "close-button-aria-label" && (i ? (r = (o = this.$closeButton) == null ? void 0 : o.setAttribute) == null || r.call(
74
- o,
75
- "aria-label",
76
- i || "Close drawer"
77
- ) : (a = this.$closeButton) == null || a.removeAttribute("aria-label"));
78
- }
79
- disconnectedCallback() {
80
- var t;
81
- (t = this.$slotFooter) == null || t.removeEventListener(
82
- "slotchange",
83
- this.toggleFooterVisibility
84
- );
85
- }
86
- show() {
87
- var t, e;
88
- (e = (t = this.$dialog).showPopover) == null || e.call(t);
89
- }
90
- hide() {
91
- var t, e;
92
- (e = (t = this.$dialog).hidePopover) == null || e.call(t), this.dispatchEvent(
93
- new Event(l, {
94
- bubbles: !0,
95
- composed: !0
96
- })
97
- );
98
- }
99
- toggleFooterVisibility() {
100
- this.$slottedFooter ? this.$footer.style.display = "block" : this.$footer.style.display = "none";
101
- }
102
- get $closeButton() {
103
- return this.shadowRoot.querySelector("px-button-icon");
104
- }
105
- get $dialog() {
106
- return this.shadowRoot.querySelector("dialog");
107
- }
108
- get open() {
109
- return this.hasAttribute("open");
110
- }
111
- get $slotFooter() {
112
- return this.shadowRoot.querySelector(
113
- 'slot[name="footer"]'
114
- );
115
- }
116
- get $slottedFooter() {
117
- return this.querySelector('[slot="footer"]');
118
- }
119
- get $footer() {
120
- return this.shadowRoot.querySelector("#footer");
121
- }
122
- set open(t) {
123
- t ? this.setAttribute("open", "") : this.removeAttribute("open");
124
- }
125
- get closeButtonAriaLabel() {
126
- return this.getAttribute("close-button-aria-label");
127
- }
128
- set closeButtonAriaLabel(t) {
129
- this.setAttribute("close-button-aria-label", t);
130
- }
131
- }
132
- customElements.get("px-drawer") || customElements.define("px-drawer", d);
133
- export {
134
- d as Drawer,
135
- l as HIDE_EVENT
6
+ import { booleanPropertyToAttributeSetter as e, propertyToAttributeSetter as t } from "@proximus/lavender-common";
7
+ //#region src/drawer.css?inline
8
+ var n = ":host *{box-sizing:border-box}::backdrop{-webkit-backdrop-filter:saturate(180%)blur(15px);backdrop-filter:saturate(180%)blur(15px);background:#0000004d}dialog{box-shadow:none;border-radius:var(--px-radius-main) var(--px-radius-main) 0 0;background-color:var(--px-color-background-surface-light);border:0;width:100%;margin:auto 0 0;padding:0;animation:.3s dialog-fade-in-bottom}#container{column-gap:var(--px-spacing-l-mobile);padding:var(--px-padding-l-mobile);grid-template:\"header close\"\"content content\"1fr\"footer footer\"/1fr auto;max-height:90dvh;display:grid}#header{margin-bottom:var(--px-spacing-l-mobile);grid-area:header}#close{grid-area:close}#content{grid-area:content;overflow:hidden auto}#footer{margin-top:var(--px-spacing-l-mobile);grid-area:footer}:host([fullscreen]) #container{height:90dvh}@media screen and (width<=47.938rem){:host([fullscreen--mobile]) #container{height:90dvh}}@media screen and (width>=48rem) and (width<=64rem){:host([fullscreen--tablet]) #container{height:90dvh}}@media screen and (width>=48rem){#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 screen and (width>=64.0625rem) and (width<=90rem){:host([fullscreen--laptop]:not([showfrom=left]):not([showfrom=right])) #container{height:90dvh}}@media screen and (width>=64.0625rem){#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)}:is(:host([showfrom=right]),:host([showfrom=left])) dialog{width:75%;height:100%}:is(:host([showfrom=right]),:host([showfrom=left])) #container{height:100%;max-height:100%}:host([showfrom=right]) dialog{border-radius:var(--px-radius-main) 0 0 var(--px-radius-main);margin:0 0 0 auto;animation:.3s dialog-fade-in-right}:host([showfrom=right]) #container{margin:0 auto 0 0}:host([showfrom=left]) dialog{border-radius:0 var(--px-radius-main) var(--px-radius-main) 0;margin:0 auto 0 0;animation:.3s dialog-fade-in-left}:host([showfrom=left]) #container{margin:0 0 0 auto}:is(:host([showfrom=right][fullscreen]),:host([showfrom=left][fullscreen])) #container{height:100%}}@media screen and (width>=90.0625rem){#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)}:host([fullscreen--desktop]:not([showfrom=left]):not([showfrom=right])) #container{height:90dvh}}@keyframes dialog-fade-in-right{0%{margin-right:-1080px}to{margin-right:0}}@keyframes dialog-fade-in-left{0%{margin-left:-1080px}to{margin-left:0}}@keyframes dialog-fade-in-bottom{0%{margin-bottom:-200px}to{margin-bottom:0}}", r = new CSSStyleSheet();
9
+ r.replaceSync(n);
10
+ var i = "px.lavender.drawer.hide", a = class extends HTMLElement {
11
+ constructor() {
12
+ super(), this.observer = null, this.previousFocusedElement = null, this.template = "<dialog popover role=\"dialog\" aria-modal=\"true\" >\n <div id=\"container\">\n <px-vstack gap=\"heading-to-subtitle\" id=\"header\">\n <px-h1 variant=\"title-2xl\">\n <slot name=\"title\"></slot>\n </px-h1>\n <px-h2 variant=\"subtitle\" color=\"neutral\">\n <slot name=\"subtitle\"></slot>\n </px-h2>\n </px-vstack>\n <div id=\"content\">\n <slot></slot>\n </div>\n <px-vstack gap=\"l\" id=\"footer\">\n <px-separator size=\"m\"></px-separator>\n <px-stack\n gap=\"s\"\n justify-content=\"flex-end\"\n align-items=\"center\"\n align-items--mobile=\"stretch\"\n direction=\"row\"\n direction--mobile=\"column-reverse\"\n >\n <slot name=\"footer\"></slot>\n </px-stack>\n </px-vstack>\n <px-button-icon variant=\"secondary\" size=\"small\" id=\"close\">\n <px-icon name=\"cross\" from=\"lavender\"></px-icon>\n </px-button-icon>\n </div>\n </dialog>", this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [r];
13
+ }
14
+ connectedCallback() {
15
+ this.toggleFooterVisibility = this.toggleFooterVisibility.bind(this), this.$opener && this.addOpenListener(), this.$closer && this.addCloseListener(), this.hasAttribute("showfrom") || this.setAttribute("showfrom", "bottom"), this.$closeButton.addEventListener("click", () => {
16
+ this.hide();
17
+ }), this.$dialog.addEventListener("toggle", (e) => {
18
+ e.newState === "closed" && this.hide();
19
+ }), this.toggleFooterVisibility(), this.$slotFooter?.addEventListener("slotchange", this.toggleFooterVisibility);
20
+ }
21
+ static get observedAttributes() {
22
+ return [
23
+ "open",
24
+ "close-button-aria-label",
25
+ "openedby",
26
+ "closedby",
27
+ "fullscreen",
28
+ "fullscreen--mobile",
29
+ "fullscreen--tablet",
30
+ "fullscreen--laptop",
31
+ "fullscreen--desktop"
32
+ ];
33
+ }
34
+ attributeChangedCallback(e, t, n) {
35
+ switch (e) {
36
+ case "open":
37
+ n === null ? this.hide() : this.show();
38
+ break;
39
+ case "close-button-aria-label":
40
+ n ? this.$closeButton?.setAttribute?.("aria-label", n || "Close drawer") : this.$closeButton?.removeAttribute("aria-label");
41
+ break;
42
+ case "openedby":
43
+ n !== t && (t && document.querySelector(`#${t}`)?.removeEventListener("click", () => this.show()), this.addOpenListener());
44
+ break;
45
+ case "closedby": this.addCloseListener();
46
+ }
47
+ }
48
+ disconnectedCallback() {
49
+ this.$slotFooter?.removeEventListener("slotchange", this.toggleFooterVisibility), this.observer?.disconnect(), this.$opener && this.$opener.removeEventListener("click", () => this.show()), this.$closer && this.$closer.removeEventListener("click", () => this.hide());
50
+ }
51
+ show() {
52
+ let e = document.activeElement;
53
+ this.previousFocusedElement = e?.shadowRoot?.activeElement ?? e, this.$dialog.showPopover?.(), document.body.style.overflow = "hidden";
54
+ }
55
+ hide() {
56
+ this.$dialog.hidePopover?.(), document.body.style.overflow = "", this.previousFocusedElement?.focus(), this.previousFocusedElement = null, this.dispatchEvent(new Event(i, {
57
+ bubbles: !0,
58
+ composed: !0
59
+ }));
60
+ }
61
+ toggleFooterVisibility() {
62
+ this.$slottedFooter ? this.$footer.style.display = "block" : this.$footer.style.display = "none";
63
+ }
64
+ addOpenListener() {
65
+ this.$opener ? this.$opener.getAttribute("data-has-opener") !== "true" && (this.$opener.setAttribute("data-has-opener", "true"), this.$opener.addEventListener("click", () => this.show())) : (this.observer = new MutationObserver(() => {
66
+ this.$opener && (this.observer.disconnect(), this.observer = null, this.addOpenListener());
67
+ }), this.observer.observe(document.body, {
68
+ childList: !0,
69
+ subtree: !0
70
+ }));
71
+ }
72
+ addCloseListener() {
73
+ this.$closer && this.$closer?.addEventListener("click", () => {
74
+ this.hide();
75
+ });
76
+ }
77
+ get $opener() {
78
+ return document.querySelector(`#${this.getAttribute("openedby")}`);
79
+ }
80
+ get $closer() {
81
+ return document.querySelector(`#${this.getAttribute("closedby")}`);
82
+ }
83
+ get $closeButton() {
84
+ return this.shadowRoot.querySelector("px-button-icon");
85
+ }
86
+ get $dialog() {
87
+ return this.shadowRoot.querySelector("dialog");
88
+ }
89
+ get open() {
90
+ return this.hasAttribute("open");
91
+ }
92
+ get $slotFooter() {
93
+ return this.shadowRoot.querySelector("slot[name=\"footer\"]");
94
+ }
95
+ get $slottedFooter() {
96
+ return this.querySelector("[slot=\"footer\"]");
97
+ }
98
+ get $footer() {
99
+ return this.shadowRoot.querySelector("#footer");
100
+ }
101
+ set open(t) {
102
+ e(this, "open", t);
103
+ }
104
+ get closeButtonAriaLabel() {
105
+ return this.getAttribute("close-button-aria-label");
106
+ }
107
+ set closeButtonAriaLabel(e) {
108
+ t(this, "close-button-aria-label", e);
109
+ }
110
+ get openedby() {
111
+ return this.getAttribute("openedby");
112
+ }
113
+ set openedby(e) {
114
+ t(this, "openedby", e);
115
+ }
116
+ get closedby() {
117
+ return this.getAttribute("closedby");
118
+ }
119
+ set closedby(e) {
120
+ t(this, "closedby", e);
121
+ }
122
+ get fullscreen() {
123
+ return this.hasAttribute("fullscreen");
124
+ }
125
+ set fullscreen(t) {
126
+ e(this, "fullscreen", t);
127
+ }
128
+ get fullscreenMobile() {
129
+ return this.hasAttribute("fullscreen--mobile");
130
+ }
131
+ set fullscreenMobile(t) {
132
+ e(this, "fullscreen--mobile", t);
133
+ }
134
+ get fullscreenTablet() {
135
+ return this.hasAttribute("fullscreen--tablet");
136
+ }
137
+ set fullscreenTablet(t) {
138
+ e(this, "fullscreen--tablet", t);
139
+ }
140
+ get fullscreenLaptop() {
141
+ return this.hasAttribute("fullscreen--laptop");
142
+ }
143
+ set fullscreenLaptop(t) {
144
+ e(this, "fullscreen--laptop", t);
145
+ }
146
+ get fullscreenDesktop() {
147
+ return this.hasAttribute("fullscreen--desktop");
148
+ }
149
+ set fullscreenDesktop(t) {
150
+ e(this, "fullscreen--desktop", t);
151
+ }
136
152
  };
153
+ customElements.get("px-drawer") || customElements.define("px-drawer", a);
154
+ //#endregion
155
+ export { a as Drawer, i as HIDE_EVENT };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-drawer",
3
- "version": "2.0.0-alpha.19",
3
+ "version": "2.0.0-alpha.190",
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"