@vouchfor/embeds 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/es/{browser-47f3e1d6.js → browser-4d54600e.js} +2 -2
- package/dist/es/{browser-47f3e1d6.js.map → browser-4d54600e.js.map} +1 -1
- package/dist/es/embeds.js +1 -1
- package/dist/es/{index-d6ce78b6.js → index-14868944.js} +90 -88
- package/dist/es/{index-d6ce78b6.js.map → index-14868944.js.map} +1 -1
- package/dist/es/src/components/DialogEmbed/index.d.ts +1 -0
- package/dist/iife/dialog-embed/{browser-7ead22f3.js → browser-d8ab928d.js} +2 -2
- package/dist/iife/dialog-embed/{browser-7ead22f3.js.map → browser-d8ab928d.js.map} +1 -1
- package/dist/iife/dialog-embed/embed.iife.js +51 -50
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
- package/dist/iife/dialog-embed/embed.js +1 -1
- package/dist/iife/dialog-embed/{index-0f8b2027.js → index-568f189c.js} +247 -246
- package/dist/iife/dialog-embed/{index-0f8b2027.js.map → index-568f189c.js.map} +1 -1
- package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +1 -0
- package/dist/iife/embeds.iife.js +26 -25
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/{browser-e97870ba.js → browser-951710ee.js} +2 -2
- package/dist/iife/player-embed/{browser-e97870ba.js.map → browser-951710ee.js.map} +1 -1
- package/dist/iife/player-embed/embed.iife.js +1 -1
- package/dist/iife/player-embed/embed.js +1 -1
- package/dist/iife/player-embed/{index-5907ffee.js → index-86dfade0.js} +4 -4
- package/dist/iife/player-embed/{index-5907ffee.js.map → index-86dfade0.js.map} +1 -1
- package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/DialogEmbed/Dialog.stories.ts +12 -0
- package/src/components/DialogEmbed/DialogPortal.ts +22 -10
- package/src/components/DialogEmbed/index.ts +5 -1
@@ -16,6 +16,7 @@ declare class DialogEmbed extends LitElement {
|
|
16
16
|
preload: DialogEmbedProps['preload'];
|
17
17
|
disableAutoplay: DialogEmbedProps['disableAutoplay'];
|
18
18
|
aspectRatio: DialogEmbedProps['aspectRatio'];
|
19
|
+
private _id;
|
19
20
|
private _handleRootClick;
|
20
21
|
connectedCallback(): void;
|
21
22
|
disconnectedCallback(): void;
|
package/package.json
CHANGED
@@ -35,6 +35,18 @@ const _DialogEmbed = ({
|
|
35
35
|
aspectRatio=${ifDefined(aspectRatio)}
|
36
36
|
@error=${console.log}
|
37
37
|
></vouch-embed-dialog>
|
38
|
+
<vouch-embed-dialog
|
39
|
+
env=${ifDefined(env)}
|
40
|
+
apiKey=${ifDefined(apiKey)}
|
41
|
+
vouchId=${ifDefined(vouchId)}
|
42
|
+
templateId=${ifDefined(templateId)}
|
43
|
+
.questions=${questions}
|
44
|
+
.controls=${controls}
|
45
|
+
?autoplay=${autoplay}
|
46
|
+
preload=${ifDefined(preload)}
|
47
|
+
aspectRatio=${ifDefined(aspectRatio)}
|
48
|
+
@error=${console.log}
|
49
|
+
></vouch-embed-dialog>
|
38
50
|
</div>
|
39
51
|
`;
|
40
52
|
};
|
@@ -29,19 +29,25 @@ class DialogPortal extends LitElement {
|
|
29
29
|
|
30
30
|
@state() open = false;
|
31
31
|
|
32
|
-
private _handleToggle = () => {
|
33
|
-
this
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
private _handleToggle = ({ detail }: CustomEvent<string>) => {
|
33
|
+
// Because we have to attach this listener to the document since this element is portalled outside of the button,
|
34
|
+
// we also have to make sure that this player is actually the one we want to open and play by passing in an ID
|
35
|
+
// from the button wrapper parent and checking against that same ID we pass as the event detail
|
36
|
+
if (this.id === detail) {
|
37
|
+
this.open = !this.open;
|
38
|
+
|
39
|
+
if (this.open) {
|
40
|
+
if (!this.disableAutoplay && this._mediaPlayerRef?.value) {
|
41
|
+
this._mediaPlayerRef.value.muted = false;
|
42
|
+
this._mediaPlayerRef.value.play();
|
43
|
+
}
|
44
|
+
} else {
|
45
|
+
this._mediaPlayerRef?.value?.pause();
|
39
46
|
}
|
40
|
-
} else {
|
41
|
-
this._mediaPlayerRef?.value?.pause();
|
42
47
|
}
|
43
48
|
};
|
44
49
|
|
50
|
+
// We could do the same thing on close and check for the correct ID but it doesn't really matter
|
45
51
|
private _handleClose = () => {
|
46
52
|
this.open = false;
|
47
53
|
this._mediaPlayerRef?.value?.pause();
|
@@ -70,7 +76,13 @@ class DialogPortal extends LitElement {
|
|
70
76
|
}
|
71
77
|
|
72
78
|
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
73
|
-
|
79
|
+
// We must create a new node here because portalling into the same node (document.body) causes the second
|
80
|
+
// element to overwrite the first for some reason (not behaviour really stated in the docs)
|
81
|
+
// I am fairly certain this function is only run once as the default behaviour creates the open shadow root
|
82
|
+
// and returns that shadow root in this function: https://lit.dev/docs/components/shadow-dom/#implementing-createrenderroot
|
83
|
+
const newNode = document.createElement('div');
|
84
|
+
document.body.appendChild(newNode);
|
85
|
+
return newNode;
|
74
86
|
}
|
75
87
|
|
76
88
|
render() {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { css, html, LitElement } from 'lit';
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
3
3
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
4
5
|
|
5
6
|
import type { PlayerEmbedProps } from '../PlayerEmbed';
|
6
7
|
|
@@ -41,8 +42,10 @@ class DialogEmbed extends LitElement {
|
|
41
42
|
@property({ type: Boolean }) disableAutoplay: DialogEmbedProps['disableAutoplay'] = false;
|
42
43
|
@property({ type: Number }) aspectRatio: DialogEmbedProps['aspectRatio'] = 0;
|
43
44
|
|
45
|
+
private _id = uuidv4();
|
46
|
+
|
44
47
|
private _handleRootClick = () => {
|
45
|
-
this.dispatchEvent(new CustomEvent('dialogembed:click', { bubbles: true, composed: true }));
|
48
|
+
this.dispatchEvent(new CustomEvent('dialogembed:click', { detail: this._id, bubbles: true, composed: true }));
|
46
49
|
};
|
47
50
|
|
48
51
|
connectedCallback(): void {
|
@@ -61,6 +64,7 @@ class DialogEmbed extends LitElement {
|
|
61
64
|
<vmp-button size="large">Play</vmp-button>
|
62
65
|
</slot>
|
63
66
|
<vouch-embed-dialog-portal
|
67
|
+
id=${this._id}
|
64
68
|
?autoplay=${false}
|
65
69
|
vouchId=${ifDefined(this.vouchId)}
|
66
70
|
templateId=${ifDefined(this.templateId)}
|