@vonage/vwc-popup 2.29.0 → 2.30.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonage/vwc-popup",
3
- "version": "2.29.0",
3
+ "version": "2.30.2",
4
4
  "description": "popup component",
5
5
  "homepage": "https://github.com/Vonage/vivid/tree/master/components/popup#readme",
6
6
  "license": "ISC",
@@ -27,21 +27,20 @@
27
27
  "url": "https://github.com/Vonage/vivid/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@floating-ui/core": "^0.2.1",
31
- "@floating-ui/dom": "^0.1.7",
32
- "@vonage/vvd-core": "2.29.0",
33
- "@vonage/vvd-foundation": "2.29.0",
34
- "@vonage/vwc-elevation": "2.29.0",
35
- "@vonage/vwc-icon-button": "2.29.0",
30
+ "@floating-ui/dom": "^0.5.1",
31
+ "@vonage/vvd-core": "2.30.2",
32
+ "@vonage/vvd-foundation": "2.30.2",
33
+ "@vonage/vwc-elevation": "2.30.2",
34
+ "@vonage/vwc-icon-button": "2.30.2",
36
35
  "lit-element": "^2.4.0",
37
36
  "lit-html": "^1.3.0",
38
37
  "tslib": "^2.3.0"
39
38
  },
40
39
  "devDependencies": {
41
- "@vonage/vvd-design-tokens": "2.29.0",
42
- "@vonage/vvd-typography": "2.29.0",
43
- "@vonage/vvd-umbrella": "2.29.0",
40
+ "@vonage/vvd-design-tokens": "2.30.2",
41
+ "@vonage/vvd-typography": "2.30.2",
42
+ "@vonage/vvd-umbrella": "2.30.2",
44
43
  "typescript": "^4.3.2"
45
44
  },
46
- "gitHead": "eff82e41e52088ccdf71bfb7fb296cec7cb95683"
45
+ "gitHead": "d73b307cb3204f1ccde5493947bde32815a3aa9d"
47
46
  }
@@ -1,26 +1,27 @@
1
1
  import {
2
- html, LitElement, property, query, TemplateResult, PropertyValues
2
+ html, LitElement, property, query, TemplateResult
3
3
  } from 'lit-element';
4
4
  import { ClassInfo, classMap } from 'lit-html/directives/class-map.js';
5
5
  import { nothing } from 'lit-html';
6
- import { computePosition, offset, shift, flip, arrow } from '@floating-ui/dom';
7
- import type { Placement, Strategy, Padding } from '@floating-ui/core';
6
+ import { arrow, autoUpdate, computePosition, flip, hide, inline, offset, Strategy } from '@floating-ui/dom';
7
+ import type { Placement, Padding } from '@floating-ui/dom';
8
8
 
9
9
  export class VWCPopupBase extends LitElement {
10
10
  private get PADDING(): Padding { return 0; };
11
11
  private get DISTANCE(): number { return 12; };
12
+ private get arrowPosition(): any { return { top: 'bottom', right: 'left', bottom: 'top', left: 'right' }; }
13
+ private cleanup?: () => void; // cleans the autoupdate
12
14
 
13
- private onResizeWindow = this.updatePosition.bind(this);
14
15
  @query('.popup-wrapper')
15
16
  private popupEl!: HTMLElement;
16
17
  @query('.popup-arrow')
17
18
  private arrowEl!: HTMLElement;
18
19
 
19
20
  private get middleware(): Array<any> {
20
- return (
21
- this.arrow ? [flip(), shift({ padding: this.PADDING }), arrow({ element: this.arrowEl, padding: this.PADDING }), offset(this.DISTANCE)]
22
- : [flip(), shift({ padding: this.PADDING })]);
23
- };
21
+ const middleware = [flip(), hide(), inline()];
22
+ if (this.arrow) { middleware.push(arrow({ element: this.arrowEl, padding: this.PADDING }), offset(this.DISTANCE)); }
23
+ return middleware;
24
+ }
24
25
 
25
26
  /**
26
27
  * @prop open - indicates whether the popup is open
@@ -122,38 +123,22 @@ export class VWCPopupBase extends LitElement {
122
123
  this.open = false;
123
124
  }
124
125
 
125
- private sizeObserver = new ResizeObserver(() => {
126
- return this.updatePosition();
127
- });
128
-
129
- override connectedCallback(): void {
130
- super.connectedCallback();
131
- window.addEventListener('scroll', this.updatePosition);
132
- window.addEventListener('resize', this.onResizeWindow);
133
- }
134
-
135
126
  override disconnectedCallback(): void {
136
127
  super.disconnectedCallback();
137
- window.removeEventListener('scroll', this.updatePosition);
138
- window.removeEventListener('resize', this.onResizeWindow);
139
- // Disconnect the observer to stop from running in the background
140
- this.sizeObserver.disconnect();
141
- }
142
-
143
- protected override firstUpdated(_changedProperties: PropertyValues): void {
144
- super.firstUpdated(_changedProperties);
145
- this.anchorEl = this.getAnchorById();
146
- if(this.anchorEl) this.sizeObserver.observe(this.anchorEl);
128
+ this.cleanup?.();
147
129
  }
148
130
 
149
131
  protected override updated(changes: Map<string, boolean>): void {
150
132
  super.updated(changes);
151
133
  if (changes.has('anchor')) {
152
- this.sizeObserver.disconnect();
153
134
  this.anchorEl = this.getAnchorById();
154
- if(this.anchorEl) this.sizeObserver.observe(this.anchorEl);
155
135
  }
156
- this.updatePosition();
136
+ if (this.anchorEl && this.popupEl) {
137
+ this.cleanup = autoUpdate(this.anchorEl, this.popupEl, () => this.updatePosition());
138
+ }
139
+ else {
140
+ this.cleanup?.();
141
+ }
157
142
  }
158
143
 
159
144
  /**
@@ -161,14 +146,10 @@ export class VWCPopupBase extends LitElement {
161
146
  * @public
162
147
  */
163
148
  async updatePosition() {
164
- if (!this.open) {
165
- return;
166
- }
167
- if (!this.anchorEl) {
168
- this.hide();
169
- console.error('Anchor is not defined');
149
+ if (!this.open || !this.anchorEl) {
170
150
  return;
171
151
  }
152
+
172
153
  const positionData = await computePosition(this.anchorEl, this.popupEl, {
173
154
  placement: this.corner,
174
155
  strategy: this.strategy,
@@ -180,19 +161,20 @@ export class VWCPopupBase extends LitElement {
180
161
 
181
162
  private assignPopupPosition(data: any): void {
182
163
  const { x: popupX, y: popupY } = data;
164
+ const { referenceHidden } = data.middlewareData.hide;
183
165
  Object.assign(this.popupEl.style, {
184
166
  left: `${popupX}px`,
185
167
  top: `${popupY}px`,
168
+ visibility: referenceHidden ? 'hidden' : 'visible',
186
169
  });
187
170
  }
188
171
 
189
172
  private assignArrowPosition(data: any): void {
190
173
  const { x: arrowX, y: arrowY } = data.middlewareData.arrow;
191
- const staticSide: any = { top: 'bottom', right: 'left', bottom: 'top', left: 'right' };
192
- const side: string = staticSide[data.placement.split('-')[0]];
174
+ const side: string = this.arrowPosition[data.placement.split('-')[0]];
193
175
  Object.assign(this.arrowEl.style, {
194
- left: arrowX != null ? `${arrowX}px` : '',
195
- top: arrowY != null ? `${arrowY}px` : '',
176
+ left: `${arrowX}px`,
177
+ top: `${arrowY}px`,
196
178
  right: '',
197
179
  bottom: '',
198
180
  [side]: '-4px',
@@ -1,10 +1,12 @@
1
- import { LitElement, TemplateResult, PropertyValues } from 'lit-element';
1
+ import { LitElement, TemplateResult } from 'lit-element';
2
2
  import { ClassInfo } from 'lit-html/directives/class-map.js';
3
- import type { Placement, Strategy } from '@floating-ui/core';
3
+ import { Strategy } from '@floating-ui/dom';
4
+ import type { Placement } from '@floating-ui/dom';
4
5
  export declare class VWCPopupBase extends LitElement {
5
6
  private get PADDING();
6
7
  private get DISTANCE();
7
- private onResizeWindow;
8
+ private get arrowPosition();
9
+ private cleanup?;
8
10
  private popupEl;
9
11
  private arrowEl;
10
12
  private get middleware();
@@ -19,10 +21,7 @@ export declare class VWCPopupBase extends LitElement {
19
21
  private getAnchorById;
20
22
  show(): void;
21
23
  hide(): void;
22
- private sizeObserver;
23
- connectedCallback(): void;
24
24
  disconnectedCallback(): void;
25
- protected firstUpdated(_changedProperties: PropertyValues): void;
26
25
  protected updated(changes: Map<string, boolean>): void;
27
26
  updatePosition(): Promise<void>;
28
27
  private assignPopupPosition;
package/vwc-popup-base.js CHANGED
@@ -2,28 +2,27 @@ import { __decorate } from "tslib";
2
2
  import { html, LitElement, property, query } from 'lit-element';
3
3
  import { classMap } from 'lit-html/directives/class-map.js';
4
4
  import { nothing } from 'lit-html';
5
- import { computePosition, offset, shift, flip, arrow } from '@floating-ui/dom';
5
+ import { arrow, autoUpdate, computePosition, flip, hide, inline, offset } from '@floating-ui/dom';
6
6
  export class VWCPopupBase extends LitElement {
7
7
  constructor() {
8
8
  super(...arguments);
9
- this.onResizeWindow = this.updatePosition.bind(this);
10
9
  this.open = false;
11
10
  this.anchor = '';
12
11
  this.corner = 'left';
13
12
  this.strategy = 'fixed';
14
- this.sizeObserver = new ResizeObserver(() => {
15
- return this.updatePosition();
16
- });
17
13
  }
18
14
  get PADDING() { return 0; }
19
15
  ;
20
16
  get DISTANCE() { return 12; }
21
17
  ;
18
+ get arrowPosition() { return { top: 'bottom', right: 'left', bottom: 'top', left: 'right' }; }
22
19
  get middleware() {
23
- return (this.arrow ? [flip(), shift({ padding: this.PADDING }), arrow({ element: this.arrowEl, padding: this.PADDING }), offset(this.DISTANCE)]
24
- : [flip(), shift({ padding: this.PADDING })]);
20
+ const middleware = [flip(), hide(), inline()];
21
+ if (this.arrow) {
22
+ middleware.push(arrow({ element: this.arrowEl, padding: this.PADDING }), offset(this.DISTANCE));
23
+ }
24
+ return middleware;
25
25
  }
26
- ;
27
26
  getAnchorById() {
28
27
  return document.getElementById(this.anchor);
29
28
  }
@@ -36,40 +35,26 @@ export class VWCPopupBase extends LitElement {
36
35
  hide() {
37
36
  this.open = false;
38
37
  }
39
- connectedCallback() {
40
- super.connectedCallback();
41
- window.addEventListener('scroll', this.updatePosition);
42
- window.addEventListener('resize', this.onResizeWindow);
43
- }
44
38
  disconnectedCallback() {
39
+ var _a;
45
40
  super.disconnectedCallback();
46
- window.removeEventListener('scroll', this.updatePosition);
47
- window.removeEventListener('resize', this.onResizeWindow);
48
- this.sizeObserver.disconnect();
49
- }
50
- firstUpdated(_changedProperties) {
51
- super.firstUpdated(_changedProperties);
52
- this.anchorEl = this.getAnchorById();
53
- if (this.anchorEl)
54
- this.sizeObserver.observe(this.anchorEl);
41
+ (_a = this.cleanup) === null || _a === void 0 ? void 0 : _a.call(this);
55
42
  }
56
43
  updated(changes) {
44
+ var _a;
57
45
  super.updated(changes);
58
46
  if (changes.has('anchor')) {
59
- this.sizeObserver.disconnect();
60
47
  this.anchorEl = this.getAnchorById();
61
- if (this.anchorEl)
62
- this.sizeObserver.observe(this.anchorEl);
63
48
  }
64
- this.updatePosition();
49
+ if (this.anchorEl && this.popupEl) {
50
+ this.cleanup = autoUpdate(this.anchorEl, this.popupEl, () => this.updatePosition());
51
+ }
52
+ else {
53
+ (_a = this.cleanup) === null || _a === void 0 ? void 0 : _a.call(this);
54
+ }
65
55
  }
66
56
  async updatePosition() {
67
- if (!this.open) {
68
- return;
69
- }
70
- if (!this.anchorEl) {
71
- this.hide();
72
- console.error('Anchor is not defined');
57
+ if (!this.open || !this.anchorEl) {
73
58
  return;
74
59
  }
75
60
  const positionData = await computePosition(this.anchorEl, this.popupEl, {
@@ -84,18 +69,19 @@ export class VWCPopupBase extends LitElement {
84
69
  }
85
70
  assignPopupPosition(data) {
86
71
  const { x: popupX, y: popupY } = data;
72
+ const { referenceHidden } = data.middlewareData.hide;
87
73
  Object.assign(this.popupEl.style, {
88
74
  left: `${popupX}px`,
89
75
  top: `${popupY}px`,
76
+ visibility: referenceHidden ? 'hidden' : 'visible',
90
77
  });
91
78
  }
92
79
  assignArrowPosition(data) {
93
80
  const { x: arrowX, y: arrowY } = data.middlewareData.arrow;
94
- const staticSide = { top: 'bottom', right: 'left', bottom: 'top', left: 'right' };
95
- const side = staticSide[data.placement.split('-')[0]];
81
+ const side = this.arrowPosition[data.placement.split('-')[0]];
96
82
  Object.assign(this.arrowEl.style, {
97
- left: arrowX != null ? `${arrowX}px` : '',
98
- top: arrowY != null ? `${arrowY}px` : '',
83
+ left: `${arrowX}px`,
84
+ top: `${arrowY}px`,
99
85
  right: '',
100
86
  bottom: '',
101
87
  [side]: '-4px',
@@ -1 +1 @@
1
- {"version":3,"file":"vwc-popup-base.js","sourceRoot":"","sources":["src/vwc-popup-base.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAa,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,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AE9B,IAAI,CAAC,WAAW,EAAE;;;;;GAKzC,CAAC;IACA,CAAC;CACJ;AAvOA;IADI,KAAK,CAAC,gBAAgB,CAAC;6CACG;AAE3B;IADC,KAAK,CAAC,cAAc,CAAC;6CACQ;AAc7B;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAC7B;AAQb;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAC7B;AAQb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACE;AAQ5C;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDACpB;AAmBtB;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACd;AAQ3B;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACZ;AAQ7B;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAC1B;AAQhB;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CACtB","sourcesContent":["import {\n\thtml, LitElement, property, query, TemplateResult, PropertyValues\n} from 'lit-element';\nimport { ClassInfo, classMap } from 'lit-html/directives/class-map.js';\nimport { nothing } from 'lit-html';\nimport { computePosition, offset, shift, flip, arrow } from '@floating-ui/dom';\nimport type { Placement, Strategy, Padding } from '@floating-ui/core';\n\nexport class VWCPopupBase extends LitElement {\n\tprivate get PADDING(): Padding { return 0; };\n\tprivate get DISTANCE(): number { return 12; };\n\n\tprivate onResizeWindow = this.updatePosition.bind(this);\n @query('.popup-wrapper')\n\tprivate popupEl!: HTMLElement;\n @query('.popup-arrow')\n private arrowEl!: HTMLElement;\n\n private get middleware(): Array<any> {\n \treturn (\n \t\tthis.arrow ? [flip(), shift({ padding: this.PADDING }), arrow({ element: this.arrowEl, padding: this.PADDING }), offset(this.DISTANCE)]\n \t\t\t: [flip(), shift({ padding: this.PADDING })]);\n };\n\n /**\n * @prop open - indicates whether the popup is open\n * accepts boolean value\n * @public\n * */\n @property({ type: Boolean, reflect: true })\n \topen = false;\n\n /**\n * @prop anchor - ID reference to element in the popup’s owner document.\n * accepts string\n * @public\n * */\n @property({ type: String, reflect: true })\n \tanchor = '';\n\n /**\n * @prop anchorEl - popup's anchor element\n * accepts Element\n * @private\n * */\n @property({ type: Element, reflect: true })\n private anchorEl: Element | null | undefined;\n\n /**\n * @prop dismissible - adds close button to the popup\n * accepts boolean value\n * @public\n * */\n @property({ type: Boolean, reflect: true })\n \tdismissible?: boolean;\n\n /**\n * @prop corner - the placement of the popup\n * accepts | 'top'\n | 'top-start'\n | 'top-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end';\n * @public\n * */\n @property({ type: String, reflect: true })\n \tcorner: Placement = 'left';\n\n /**\n * @prop strategy - the position of the popup\n * accepts 'absolute' | 'fixed';\n * @public\n * */\n @property({ type: String, reflect: true })\n \tstrategy: Strategy = 'fixed';\n\n /**\n * @prop arrow - adds small triangle to indicate the trigger element\n * accepts boolean value\n * @public\n * */\n @property({ type: Boolean, reflect: true })\n \tarrow?: boolean;\n\n /**\n * @prop alternate - set the color-scheme to dark\n * accepts boolean value\n * @public\n * */\n @property({ type: Boolean, reflect: true })\n \talternate?: boolean;\n\n /**\n * Gets the anchor element by id\n */\n private getAnchorById(): HTMLElement | null {\n \treturn document.getElementById(this.anchor);\n };\n\n /**\n * Opens the popup\n * @public\n */\n show(): void {\n \tif (this.anchorEl) { // only if anchor element exists\n \t\tthis.open = true;\n \t}\n }\n\n /**\n * Closes the popup\n * @public\n */\n hide(): void {\n \tthis.open = false;\n }\n\n private sizeObserver = new ResizeObserver(() => {\n \treturn this.updatePosition();\n });\n\n override connectedCallback(): void {\n \tsuper.connectedCallback();\n \twindow.addEventListener('scroll', this.updatePosition);\n \twindow.addEventListener('resize', this.onResizeWindow);\n }\n\n override disconnectedCallback(): void {\n \tsuper.disconnectedCallback();\n \twindow.removeEventListener('scroll', this.updatePosition);\n \twindow.removeEventListener('resize', this.onResizeWindow);\n \t// Disconnect the observer to stop from running in the background\n \tthis.sizeObserver.disconnect();\n }\n\n protected override firstUpdated(_changedProperties: PropertyValues): void {\n \tsuper.firstUpdated(_changedProperties);\n \tthis.anchorEl = this.getAnchorById();\n \tif(this.anchorEl) this.sizeObserver.observe(this.anchorEl);\n }\n\n protected override updated(changes: Map<string, boolean>): void {\n \tsuper.updated(changes);\n \tif (changes.has('anchor')) {\n \t\tthis.sizeObserver.disconnect();\n \t\tthis.anchorEl = this.getAnchorById();\n \t\tif(this.anchorEl) this.sizeObserver.observe(this.anchorEl);\n \t}\n \tthis.updatePosition();\n }\n\n /**\n * Updates popup position, if succeeded returns - true, if not - false\n * @public\n */\n async updatePosition() {\n \tif (!this.open) {\n \t\treturn;\n \t}\n \tif (!this.anchorEl) {\n \t\tthis.hide();\n \t\tconsole.error('Anchor is not defined');\n \t\treturn;\n \t}\n \tconst positionData = await computePosition(this.anchorEl, this.popupEl, {\n \t\tplacement: this.corner,\n \t\tstrategy: this.strategy,\n \t\tmiddleware: this.middleware\n \t});\n \tthis.assignPopupPosition(positionData);\n \tif (this.arrow) { this.assignArrowPosition(positionData); }\n }\n\n private assignPopupPosition(data: any): void {\n \tconst { x: popupX, y: popupY } = data;\n \tObject.assign(this.popupEl.style, {\n \t\tleft: `${popupX}px`,\n \t\ttop: `${popupY}px`,\n \t});\n }\n\n private assignArrowPosition(data: any): void {\n \tconst { x: arrowX, y: arrowY } = data.middlewareData.arrow;\n \tconst staticSide: any = { top: 'bottom', right: 'left', bottom: 'top', left: 'right' };\n \tconst side: string = staticSide[data.placement.split('-')[0]];\n \tObject.assign(this.arrowEl.style, {\n \t\tleft: arrowX != null ? `${arrowX}px` : '',\n \t\ttop: arrowY != null ? `${arrowY}px` : '',\n \t\tright: '',\n \t\tbottom: '',\n \t\t[side]: '-4px',\n \t});\n }\n\n private handleDismissClick(): void {\n \tthis.hide();\n }\n\n private renderDismissButton(): TemplateResult | unknown {\n \treturn this.dismissible\n \t\t? html`<vwc-icon-button @click=${this.handleDismissClick} class=\"popup-dismissible-button\" icon=\"close-small-solid\"\n shape=\"circled\" dense></vwc-icon-button>`\n \t\t: nothing;\n }\n\n private renderArrow(): TemplateResult | unknown {\n \treturn this.arrow ? html`<div class=\"popup-arrow\"></div>` : nothing;\n }\n\n protected getRenderClasses(): ClassInfo {\n \treturn {\n \t\t['popup-open']: !!this.open,\n \t\t['popup-dismissible']: !!this.dismissible\n \t};\n }\n\n protected override render(): TemplateResult {\n \tconst alternate = this.alternate ? 'vvd-scheme-alternate' : '';\n \tconst aria = this.open ? 'false' : 'true';\n\n \treturn html`\n <vwc-elevation dp=\"2\">\n\t\t\t\t\t\t\t\t\t<!-- 'popup-wrapper' is selected by the wrapping elevation, thus required for shadow styling -->\n\t\t\t\t\t\t\t\t\t<!-- the reason for not applying directly to its first-child 'popup' is to avoid scenario where popup is set to alternate scheme\n\t\t\t\t\t\t\t\t\t\t\t\tand affect the shadow style surfacing contrast which should still in default scheme context -->\n\t\t\t\t\t\t\t\t\t<div class=\"popup-wrapper\">\n <div class=\"popup ${classMap(this.getRenderClasses())}\" aria-hidden=${aria} part=${alternate}>\n <div class=\"popup-content\" >\n <slot></slot>\n ${this.renderDismissButton()}\n </div>\n ${this.renderArrow()}\n </div>\n\t\t\t\t\t\t\t\t\t</div>\n </vwc-elevation>\n\n\t\t`;\n }\n}\n"]}
1
+ {"version":3,"file":"vwc-popup-base.js","sourceRoot":"","sources":["src/vwc-popup-base.ts"],"names":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EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACd;AAQ3B;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACZ;AAQ7B;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAC1B;AAQhB;IADA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CACtB","sourcesContent":["import {\n\thtml, LitElement, property, query, TemplateResult\n} from 'lit-element';\nimport { ClassInfo, classMap } from 'lit-html/directives/class-map.js';\nimport { nothing } from 'lit-html';\nimport { arrow, autoUpdate, computePosition, flip, hide, inline, offset, Strategy } from '@floating-ui/dom';\nimport type { Placement, Padding } from '@floating-ui/dom';\n\nexport class VWCPopupBase extends LitElement {\n\tprivate get PADDING(): Padding { return 0; };\n\tprivate get DISTANCE(): number { return 12; };\n\tprivate get arrowPosition(): any { return { top: 'bottom', right: 'left', bottom: 'top', left: 'right' }; }\n\tprivate cleanup?: () => void; // cleans the autoupdate\n\n @query('.popup-wrapper')\n\tprivate popupEl!: HTMLElement;\n @query('.popup-arrow')\n private arrowEl!: HTMLElement;\n\n private get middleware(): Array<any> {\n \tconst middleware = [flip(), hide(), inline()];\n \tif (this.arrow) { middleware.push(arrow({ element: this.arrowEl, padding: this.PADDING }), offset(this.DISTANCE)); }\n \treturn middleware;\n }\n\n /**\n * @prop open - indicates whether the popup is open\n * accepts boolean value\n * @public\n * */\n @property({ type: Boolean, reflect: true })\n \topen = false;\n\n /**\n * @prop anchor - ID reference to element in the popup’s owner document.\n * accepts string\n * @public\n * */\n @property({ type: String, reflect: true })\n \tanchor = '';\n\n /**\n * @prop anchorEl - popup's anchor element\n * accepts Element\n * @private\n * */\n @property({ type: Element, reflect: true })\n private anchorEl: Element | null | undefined;\n\n /**\n * @prop dismissible - adds close button to the popup\n * accepts boolean value\n * @public\n * */\n @property({ type: Boolean, reflect: true })\n \tdismissible?: boolean;\n\n /**\n * @prop corner - the placement of the popup\n * accepts | 'top'\n | 'top-start'\n | 'top-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end';\n * @public\n * */\n @property({ type: String, reflect: true })\n \tcorner: Placement = 'left';\n\n /**\n * @prop strategy - the position of the popup\n * accepts 'absolute' | 'fixed';\n * @public\n * */\n @property({ type: String, reflect: true })\n \tstrategy: Strategy = 'fixed';\n\n /**\n * @prop arrow - adds small triangle to indicate the trigger element\n * accepts boolean value\n * @public\n * */\n @property({ type: Boolean, reflect: true })\n \tarrow?: boolean;\n\n /**\n * @prop alternate - set the color-scheme to dark\n * accepts boolean value\n * @public\n * */\n @property({ type: Boolean, reflect: true })\n \talternate?: boolean;\n\n /**\n * Gets the anchor element by id\n */\n private getAnchorById(): HTMLElement | null {\n \treturn document.getElementById(this.anchor);\n };\n\n /**\n * Opens the popup\n * @public\n */\n show(): void {\n \tif (this.anchorEl) { // only if anchor element exists\n \t\tthis.open = true;\n \t}\n }\n\n /**\n * Closes the popup\n * @public\n */\n hide(): void {\n \tthis.open = false;\n }\n\n override disconnectedCallback(): void {\n \tsuper.disconnectedCallback();\n \tthis.cleanup?.();\n }\n\n protected override updated(changes: Map<string, boolean>): void {\n \tsuper.updated(changes);\n \tif (changes.has('anchor')) {\n \t\tthis.anchorEl = this.getAnchorById();\n \t}\n \tif (this.anchorEl && this.popupEl) {\n \t\tthis.cleanup = autoUpdate(this.anchorEl, this.popupEl, () => this.updatePosition());\n \t}\n \telse {\n \t\tthis.cleanup?.();\n \t}\n }\n\n /**\n * Updates popup position, if succeeded returns - true, if not - false\n * @public\n */\n async updatePosition() {\n \tif (!this.open || !this.anchorEl) {\n \t\treturn;\n \t}\n\n \tconst positionData = await computePosition(this.anchorEl, this.popupEl, {\n \t\tplacement: this.corner,\n \t\tstrategy: this.strategy,\n \t\tmiddleware: this.middleware\n \t});\n \tthis.assignPopupPosition(positionData);\n \tif (this.arrow) { this.assignArrowPosition(positionData); }\n }\n\n private assignPopupPosition(data: any): void {\n \tconst { x: popupX, y: popupY } = data;\n \tconst { referenceHidden } = data.middlewareData.hide;\n \tObject.assign(this.popupEl.style, {\n \t\tleft: `${popupX}px`,\n \t\ttop: `${popupY}px`,\n \t\tvisibility: referenceHidden ? 'hidden' : 'visible',\n \t});\n }\n\n private assignArrowPosition(data: any): void {\n \tconst { x: arrowX, y: arrowY } = data.middlewareData.arrow;\n \tconst side: string = this.arrowPosition[data.placement.split('-')[0]];\n \tObject.assign(this.arrowEl.style, {\n \t\tleft: `${arrowX}px`,\n \t\ttop: `${arrowY}px`,\n \t\tright: '',\n \t\tbottom: '',\n \t\t[side]: '-4px',\n \t});\n }\n\n private handleDismissClick(): void {\n \tthis.hide();\n }\n\n private renderDismissButton(): TemplateResult | unknown {\n \treturn this.dismissible\n \t\t? html`<vwc-icon-button @click=${this.handleDismissClick} class=\"popup-dismissible-button\" icon=\"close-small-solid\"\n shape=\"circled\" dense></vwc-icon-button>`\n \t\t: nothing;\n }\n\n private renderArrow(): TemplateResult | unknown {\n \treturn this.arrow ? html`<div class=\"popup-arrow\"></div>` : nothing;\n }\n\n protected getRenderClasses(): ClassInfo {\n \treturn {\n \t\t['popup-open']: !!this.open,\n \t\t['popup-dismissible']: !!this.dismissible\n \t};\n }\n\n protected override render(): TemplateResult {\n \tconst alternate = this.alternate ? 'vvd-scheme-alternate' : '';\n \tconst aria = this.open ? 'false' : 'true';\n\n \treturn html`\n <vwc-elevation dp=\"2\">\n\t\t\t\t\t\t\t\t\t<!-- 'popup-wrapper' is selected by the wrapping elevation, thus required for shadow styling -->\n\t\t\t\t\t\t\t\t\t<!-- the reason for not applying directly to its first-child 'popup' is to avoid scenario where popup is set to alternate scheme\n\t\t\t\t\t\t\t\t\t\t\t\tand affect the shadow style surfacing contrast which should still in default scheme context -->\n\t\t\t\t\t\t\t\t\t<div class=\"popup-wrapper\">\n <div class=\"popup ${classMap(this.getRenderClasses())}\" aria-hidden=${aria} part=${alternate}>\n <div class=\"popup-content\" >\n <slot></slot>\n ${this.renderDismissButton()}\n </div>\n ${this.renderArrow()}\n </div>\n\t\t\t\t\t\t\t\t\t</div>\n </vwc-elevation>\n\n\t\t`;\n }\n}\n"]}