@vouchfor/embeds 0.0.0-experiment.f7614ec → 0.0.0-experiment.f80a91a
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/es/{browser-0a211a9c.js → browser-07a8b7dc.js} +2 -2
- package/dist/es/{browser-0a211a9c.js.map → browser-07a8b7dc.js.map} +1 -1
- package/dist/es/embeds.js +5 -2
- package/dist/es/embeds.js.map +1 -1
- package/dist/es/index-0c298932.js +10473 -0
- package/dist/es/index-0c298932.js.map +1 -0
- package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
- package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
- package/dist/es/src/components/DialogEmbed/index.d.ts +35 -0
- package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
- package/dist/es/src/index.d.ts +1 -0
- package/dist/iife/dialog-embed/browser-450a324f.js +433 -0
- package/dist/iife/dialog-embed/browser-450a324f.js.map +1 -0
- package/dist/iife/dialog-embed/embed.iife.js +1721 -0
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
- package/dist/iife/dialog-embed/embed.js +5 -0
- package/dist/iife/dialog-embed/embed.js.map +1 -0
- package/dist/iife/dialog-embed/index-62750303.js +32932 -0
- package/dist/iife/dialog-embed/index-62750303.js.map +1 -0
- package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
- package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
- package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +35 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
- package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
- package/dist/iife/dialog-embed/src/index.d.ts +2 -0
- package/dist/iife/dialog-embed/src/utils/env.d.ts +12 -0
- package/dist/iife/dialog-embed/src/utils/events.d.ts +2 -0
- package/dist/iife/embeds.iife.js +406 -257
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/browser-c51cdddb.js +433 -0
- package/dist/iife/player-embed/browser-c51cdddb.js.map +1 -0
- package/dist/iife/player-embed/embed.iife.js +1585 -0
- package/dist/iife/player-embed/embed.iife.js.map +1 -0
- package/dist/iife/player-embed/embed.js +5 -0
- package/dist/iife/player-embed/embed.js.map +1 -0
- package/dist/iife/player-embed/index-0d71c577.js +32489 -0
- package/dist/iife/player-embed/index-0d71c577.js.map +1 -0
- package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
- package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
- package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +35 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
- package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
- package/dist/iife/player-embed/src/index.d.ts +2 -0
- package/dist/iife/player-embed/src/utils/env.d.ts +12 -0
- package/dist/iife/player-embed/src/utils/events.d.ts +2 -0
- package/package.json +8 -3
- package/src/components/DialogEmbed/Dialog.stories.ts +79 -0
- package/src/components/DialogEmbed/DialogOverlay.ts +130 -0
- package/src/components/DialogEmbed/DialogPortal.ts +114 -0
- package/src/components/DialogEmbed/index.ts +93 -0
- package/src/components/PlayerEmbed/controllers/event-forwarder.ts +2 -1
- package/src/components/PlayerEmbed/index.ts +5 -103
- package/src/index.ts +1 -0
- package/src/mixins/media-player-proxy.ts +116 -0
- package/dist/es/index-b6636843.js +0 -9984
- package/dist/es/index-b6636843.js.map +0 -1
- package/dist/es/src/components/PlayerEmbed/index.d.ts +0 -72
@@ -0,0 +1,19 @@
|
|
1
|
+
import { LitElement } from 'lit';
|
2
|
+
import type { DialogEmbedProps } from '.';
|
3
|
+
declare class DialogOverlay extends LitElement {
|
4
|
+
static styles: import("lit").CSSResult[];
|
5
|
+
open: boolean;
|
6
|
+
aspectRatio: DialogEmbedProps['aspectRatio'];
|
7
|
+
render(): import("lit").TemplateResult<1>;
|
8
|
+
}
|
9
|
+
declare global {
|
10
|
+
interface HTMLElementTagNameMap {
|
11
|
+
'vouch-embed-dialog-overlay': DialogOverlay;
|
12
|
+
}
|
13
|
+
namespace JSX {
|
14
|
+
interface IntrinsicElements {
|
15
|
+
'vouch-embed-dialog-overlay': DialogOverlay;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
export { DialogOverlay };
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { LitElement } from 'lit';
|
2
|
+
import type { DialogEmbedProps } from '.';
|
3
|
+
declare class DialogPortal extends LitElement {
|
4
|
+
vouchId: DialogEmbedProps['vouchId'];
|
5
|
+
templateId: DialogEmbedProps['templateId'];
|
6
|
+
questions: DialogEmbedProps['questions'];
|
7
|
+
env: DialogEmbedProps['env'];
|
8
|
+
apiKey: DialogEmbedProps['apiKey'];
|
9
|
+
disableTracking: DialogEmbedProps['disableTracking'];
|
10
|
+
trackingSource: DialogEmbedProps['trackingSource'];
|
11
|
+
controls: DialogEmbedProps['controls'];
|
12
|
+
preload: DialogEmbedProps['preload'];
|
13
|
+
disableAutoplay: DialogEmbedProps['disableAutoplay'];
|
14
|
+
aspectRatio: DialogEmbedProps['aspectRatio'];
|
15
|
+
private _mediaPlayerRef;
|
16
|
+
open: boolean;
|
17
|
+
private _handleToggle;
|
18
|
+
private _handleClose;
|
19
|
+
private _handleDocumentKeyUp;
|
20
|
+
connectedCallback(): void;
|
21
|
+
disconnectedCallback(): void;
|
22
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
23
|
+
render(): import("lit").TemplateResult<1>;
|
24
|
+
}
|
25
|
+
declare global {
|
26
|
+
interface HTMLElementTagNameMap {
|
27
|
+
'vouch-embed-dialog-portal': DialogPortal;
|
28
|
+
}
|
29
|
+
namespace JSX {
|
30
|
+
interface IntrinsicElements {
|
31
|
+
'vouch-embed-dialog-portal': DialogPortal;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
export { DialogPortal };
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { LitElement } from 'lit';
|
2
|
+
import type { PlayerEmbedProps } from '../PlayerEmbed';
|
3
|
+
type DialogEmbedProps = Omit<PlayerEmbedProps, 'data'> & {
|
4
|
+
disableAutoplay?: boolean;
|
5
|
+
};
|
6
|
+
declare class DialogEmbed extends LitElement {
|
7
|
+
static styles: import("lit").CSSResult[];
|
8
|
+
vouchId: DialogEmbedProps['vouchId'];
|
9
|
+
templateId: DialogEmbedProps['templateId'];
|
10
|
+
questions: DialogEmbedProps['questions'];
|
11
|
+
env: DialogEmbedProps['env'];
|
12
|
+
apiKey: DialogEmbedProps['apiKey'];
|
13
|
+
disableTracking: DialogEmbedProps['disableTracking'];
|
14
|
+
trackingSource: DialogEmbedProps['trackingSource'];
|
15
|
+
controls: DialogEmbedProps['controls'];
|
16
|
+
preload: DialogEmbedProps['preload'];
|
17
|
+
disableAutoplay: DialogEmbedProps['disableAutoplay'];
|
18
|
+
aspectRatio: DialogEmbedProps['aspectRatio'];
|
19
|
+
private _handleRootClick;
|
20
|
+
connectedCallback(): void;
|
21
|
+
disconnectedCallback(): void;
|
22
|
+
render(): import("lit").TemplateResult<1>;
|
23
|
+
}
|
24
|
+
declare global {
|
25
|
+
interface HTMLElementTagNameMap {
|
26
|
+
'vouch-embed-dialog': DialogEmbed;
|
27
|
+
}
|
28
|
+
namespace JSX {
|
29
|
+
interface IntrinsicElements {
|
30
|
+
'vouch-embed-dialog': DialogEmbed;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
export { DialogEmbed };
|
35
|
+
export type { DialogEmbedProps };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { PlayerEmbed } from '..';
|
2
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
3
|
+
import type { DirectiveResult } from 'lit/directive.js';
|
4
|
+
type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
|
5
|
+
declare class EventForwardController implements ReactiveController {
|
6
|
+
host: PlayerEmbedHost;
|
7
|
+
private _events;
|
8
|
+
private _cleanup;
|
9
|
+
private _forwardElementRef;
|
10
|
+
constructor(host: PlayerEmbedHost, events: string[]);
|
11
|
+
register(): DirectiveResult;
|
12
|
+
hostConnected(): void;
|
13
|
+
hostDisconnected(): void;
|
14
|
+
}
|
15
|
+
export { EventForwardController };
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { PlayerEmbed } from '..';
|
2
|
+
import type { ReactiveControllerHost } from 'lit';
|
3
|
+
type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
|
4
|
+
declare class FetcherController {
|
5
|
+
host: PlayerEmbedHost;
|
6
|
+
private _fetching;
|
7
|
+
private _vouch;
|
8
|
+
set fetching(value: boolean);
|
9
|
+
get fetching(): boolean;
|
10
|
+
private getVouch;
|
11
|
+
private getTemplate;
|
12
|
+
constructor(host: PlayerEmbedHost);
|
13
|
+
}
|
14
|
+
export { FetcherController };
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import type { PlayerEmbed } from '../..';
|
2
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
3
|
+
type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
|
4
|
+
type TrackingEvent = 'VOUCH_LOADED' | 'VOUCH_RESPONSE_VIEWED' | 'VIDEO_PLAYED' | 'VIDEO_STREAMED';
|
5
|
+
type TrackingPayload = {
|
6
|
+
vouchId?: string;
|
7
|
+
answerId?: string;
|
8
|
+
streamStart?: number;
|
9
|
+
streamEnd?: number;
|
10
|
+
};
|
11
|
+
declare class TrackingController implements ReactiveController {
|
12
|
+
host: PlayerEmbedHost;
|
13
|
+
private _batchedEvents;
|
14
|
+
private _hasPlayed;
|
15
|
+
private _hasLoaded;
|
16
|
+
private _answersViewed;
|
17
|
+
private _streamStartTime;
|
18
|
+
private _streamLatestTime;
|
19
|
+
private _currentlyPlayingVideo;
|
20
|
+
constructor(host: PlayerEmbedHost);
|
21
|
+
private _createTrackingEvent;
|
22
|
+
private _sendTrackingEvent;
|
23
|
+
private _streamEnded;
|
24
|
+
private _handleVouchLoaded;
|
25
|
+
private _handlePlay;
|
26
|
+
private _handleVideoPlay;
|
27
|
+
private _handleVideoTimeUpdate;
|
28
|
+
private _handleVideoPause;
|
29
|
+
private _pageUnloading;
|
30
|
+
private _handleVisibilityChange;
|
31
|
+
private _handlePageHide;
|
32
|
+
hostConnected(): void;
|
33
|
+
hostDisconnected(): void;
|
34
|
+
}
|
35
|
+
export { TrackingController };
|
36
|
+
export type { TrackingEvent, TrackingPayload };
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { TrackingPayload } from '.';
|
2
|
+
import type { Vouch } from '@vouchfor/media-player';
|
3
|
+
import type { Environment } from '../../../../utils/env';
|
4
|
+
declare function getUids(env: Environment): {
|
5
|
+
client: null;
|
6
|
+
tab: null;
|
7
|
+
request: string;
|
8
|
+
visitor?: undefined;
|
9
|
+
} | {
|
10
|
+
client: string;
|
11
|
+
tab: string;
|
12
|
+
request: string;
|
13
|
+
visitor: string;
|
14
|
+
};
|
15
|
+
declare function findVouchId(payload?: TrackingPayload, vouch?: Vouch): string | null | undefined;
|
16
|
+
declare function getReportingMetadata(source?: string): any;
|
17
|
+
export { getUids, findVouchId, getReportingMetadata };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
type Environment = 'local' | 'dev' | 'staging' | 'prod';
|
2
|
+
type GetEnvUrlsReturn = {
|
3
|
+
videoUrl: string;
|
4
|
+
publicApiUrl: string;
|
5
|
+
embedApiUrl: string;
|
6
|
+
};
|
7
|
+
declare const devEmbedApiUrl = "https://embed-dev.vouchfor.com/v2";
|
8
|
+
declare const stagingEmbedApiUrl = "https://embed-staging.vouchfor.com/v2";
|
9
|
+
declare const prodEmbedApiUrl = "https://embed.vouchfor.com/v2";
|
10
|
+
declare function getEnvUrls(env: Environment): GetEnvUrlsReturn;
|
11
|
+
export { devEmbedApiUrl, stagingEmbedApiUrl, prodEmbedApiUrl, getEnvUrls };
|
12
|
+
export type { Environment };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vouchfor/embeds",
|
3
|
-
"version": "0.0.0-experiment.
|
3
|
+
"version": "0.0.0-experiment.f80a91a",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Aaron Williams",
|
6
6
|
"main": "dist/es/embeds.js",
|
@@ -16,8 +16,9 @@
|
|
16
16
|
"access": "public"
|
17
17
|
},
|
18
18
|
"scripts": {
|
19
|
-
"build": "rm -rf dist && tsc &&
|
19
|
+
"build": "rm -rf dist && tsc && yarn build:self",
|
20
20
|
"build:deps": "yarn --cwd ../media-player build",
|
21
|
+
"build:self": "vite build --mode iife && vite build --mode es && node scripts/build.cjs",
|
21
22
|
"build:package": "yarn build",
|
22
23
|
"build:storybook": "yarn prebuild && storybook build",
|
23
24
|
"generate:manifest": "wca src --outFile custom-elements.json",
|
@@ -36,8 +37,9 @@
|
|
36
37
|
"**/*.{md,json,yml}": "prettier --write"
|
37
38
|
},
|
38
39
|
"dependencies": {
|
40
|
+
"@a11y/focus-trap": "^1.0.5",
|
39
41
|
"@lit/task": "^1.0.0",
|
40
|
-
"@vouchfor/media-player": "0.0.0-experiment.
|
42
|
+
"@vouchfor/media-player": "0.0.0-experiment.f80a91a",
|
41
43
|
"uuid": "^9.0.1"
|
42
44
|
},
|
43
45
|
"peerDependencies": {
|
@@ -62,11 +64,14 @@
|
|
62
64
|
"dotenv": "^16.3.1",
|
63
65
|
"eslint": "^8.50.0",
|
64
66
|
"eslint-plugin-import": "^2.28.1",
|
67
|
+
"glob": "^10.3.10",
|
65
68
|
"lint-staged": "^14.0.1",
|
66
69
|
"lit": "^3.1.0",
|
70
|
+
"lodash": "^4.17.21",
|
67
71
|
"prettier": "^3.0.3",
|
68
72
|
"react": "^18.2.0",
|
69
73
|
"react-dom": "^18.2.0",
|
74
|
+
"rollup-plugin-internal": "^1.0.4",
|
70
75
|
"sinon": "^17.0.1",
|
71
76
|
"storybook": "^7.4.5",
|
72
77
|
"typescript": "^5.1.3",
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
3
|
+
|
4
|
+
import type { DialogEmbedProps } from '.';
|
5
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
6
|
+
|
7
|
+
import '.';
|
8
|
+
|
9
|
+
type DialogEmbedArgs = DialogEmbedProps & {
|
10
|
+
showVouch?: boolean;
|
11
|
+
};
|
12
|
+
|
13
|
+
const _DialogEmbed = ({
|
14
|
+
vouchId,
|
15
|
+
templateId,
|
16
|
+
questions,
|
17
|
+
preload,
|
18
|
+
autoplay,
|
19
|
+
env,
|
20
|
+
apiKey,
|
21
|
+
controls,
|
22
|
+
aspectRatio
|
23
|
+
}: DialogEmbedArgs) => {
|
24
|
+
return html`
|
25
|
+
<div style="padding: 20px;">
|
26
|
+
<vouch-embed-dialog
|
27
|
+
env=${ifDefined(env)}
|
28
|
+
apiKey=${ifDefined(apiKey)}
|
29
|
+
vouchId=${ifDefined(vouchId)}
|
30
|
+
templateId=${ifDefined(templateId)}
|
31
|
+
.questions=${questions}
|
32
|
+
.controls=${controls}
|
33
|
+
?autoplay=${autoplay}
|
34
|
+
preload=${ifDefined(preload)}
|
35
|
+
aspectRatio=${ifDefined(aspectRatio)}
|
36
|
+
@error=${console.log}
|
37
|
+
></vouch-embed-dialog>
|
38
|
+
</div>
|
39
|
+
`;
|
40
|
+
};
|
41
|
+
|
42
|
+
// More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction
|
43
|
+
const meta = {
|
44
|
+
title: 'Dialog',
|
45
|
+
tags: ['autodocs'],
|
46
|
+
render: (args) => _DialogEmbed(args),
|
47
|
+
component: 'vouch-embed-dialog'
|
48
|
+
} satisfies Meta<DialogEmbedProps>;
|
49
|
+
|
50
|
+
type Story = StoryObj<DialogEmbedArgs>;
|
51
|
+
|
52
|
+
const Dialog: Story = {
|
53
|
+
args: {
|
54
|
+
env: 'dev',
|
55
|
+
apiKey: 'TVik9uTMgE-PD25UTHIS6gyl0hMBWC7AT4dkpdlLBT4VIfDWZJrQiCk6Ak7m1',
|
56
|
+
vouchId: '6JQEIPeStt',
|
57
|
+
templateId: '357fc118-e179-4171-9446-ff2b8e9d1b29',
|
58
|
+
questions: [],
|
59
|
+
aspectRatio: 0,
|
60
|
+
preload: 'none',
|
61
|
+
autoplay: false
|
62
|
+
},
|
63
|
+
argTypes: {
|
64
|
+
env: {
|
65
|
+
control: 'radio',
|
66
|
+
options: ['local', 'dev', 'staging', 'prod']
|
67
|
+
},
|
68
|
+
preload: {
|
69
|
+
control: 'radio',
|
70
|
+
options: ['auto', 'none']
|
71
|
+
}
|
72
|
+
},
|
73
|
+
parameters: {
|
74
|
+
layout: 'fullscreen'
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
export default meta;
|
79
|
+
export { Dialog };
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import { css, html, LitElement } from 'lit';
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
4
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
5
|
+
|
6
|
+
import type { DialogEmbedProps } from '.';
|
7
|
+
|
8
|
+
import '@a11y/focus-trap';
|
9
|
+
|
10
|
+
@customElement('vouch-embed-dialog-overlay')
|
11
|
+
class DialogOverlay extends LitElement {
|
12
|
+
static styles = [
|
13
|
+
css`
|
14
|
+
:host {
|
15
|
+
--vouch-media-player-border-radius: var(--vu-media-player-border-radius, 12px);
|
16
|
+
--overlay-background-color: var(--vu-overlay-background-color, black);
|
17
|
+
--overlay-background-opacity: var(--vu-overlay-background-opacity, 0.4);
|
18
|
+
|
19
|
+
--dialog-width: var(--vu-dialog-width, 890px);
|
20
|
+
--dialog-height: var(--vu-dialog-height, 500px);
|
21
|
+
}
|
22
|
+
|
23
|
+
.container {
|
24
|
+
position: absolute;
|
25
|
+
display: flex;
|
26
|
+
inset: 0;
|
27
|
+
opacity: 1;
|
28
|
+
align-items: center;
|
29
|
+
justify-content: center;
|
30
|
+
transition: opacity 100ms ease-in;
|
31
|
+
}
|
32
|
+
|
33
|
+
.hidden {
|
34
|
+
opacity: 0;
|
35
|
+
pointer-events: none;
|
36
|
+
}
|
37
|
+
|
38
|
+
.background {
|
39
|
+
position: absolute;
|
40
|
+
inset: 0;
|
41
|
+
opacity: var(--overlay-background-opacity);
|
42
|
+
background-color: var(--overlay-background-color);
|
43
|
+
}
|
44
|
+
|
45
|
+
focus-trap {
|
46
|
+
display: flex;
|
47
|
+
align-items: center;
|
48
|
+
justify-content: center;
|
49
|
+
margin: 40px;
|
50
|
+
width: var(--dialog-width);
|
51
|
+
height: var(--dialog-height);
|
52
|
+
max-width: calc(100% - 80px);
|
53
|
+
max-height: calc(100% - 80px);
|
54
|
+
}
|
55
|
+
|
56
|
+
.video-frame {
|
57
|
+
position: relative;
|
58
|
+
display: flex;
|
59
|
+
align-items: center;
|
60
|
+
justify-content: center;
|
61
|
+
max-width: 100%;
|
62
|
+
max-height: 100%;
|
63
|
+
}
|
64
|
+
|
65
|
+
.video-frame.grow {
|
66
|
+
width: 100%;
|
67
|
+
height: 100%;
|
68
|
+
}
|
69
|
+
|
70
|
+
vmp-icon-button {
|
71
|
+
position: absolute;
|
72
|
+
top: 0;
|
73
|
+
right: 0;
|
74
|
+
margin: 10px;
|
75
|
+
}
|
76
|
+
`
|
77
|
+
];
|
78
|
+
|
79
|
+
@property({ type: Boolean }) open = false;
|
80
|
+
@property({ type: Number }) aspectRatio: DialogEmbedProps['aspectRatio'] = 0;
|
81
|
+
|
82
|
+
render() {
|
83
|
+
return html`
|
84
|
+
<div
|
85
|
+
class=${classMap({
|
86
|
+
container: true,
|
87
|
+
hidden: !this.open
|
88
|
+
})}
|
89
|
+
>
|
90
|
+
<div
|
91
|
+
class="background"
|
92
|
+
@click=${() => this.dispatchEvent(new CustomEvent('overlay:click', { bubbles: true, composed: true }))}
|
93
|
+
></div>
|
94
|
+
<focus-trap>
|
95
|
+
<div
|
96
|
+
class=${classMap({
|
97
|
+
'video-frame': true,
|
98
|
+
grow: this.aspectRatio === 0
|
99
|
+
})}
|
100
|
+
style=${styleMap({
|
101
|
+
aspectRatio: this.aspectRatio
|
102
|
+
})}
|
103
|
+
>
|
104
|
+
<slot></slot>
|
105
|
+
<vmp-icon-button
|
106
|
+
icon="close"
|
107
|
+
rounded="full"
|
108
|
+
weight="heavy"
|
109
|
+
@click=${() => this.dispatchEvent(new CustomEvent('close:click', { bubbles: true, composed: true }))}
|
110
|
+
></vmp-icon-button>
|
111
|
+
</div>
|
112
|
+
</focus-trap>
|
113
|
+
</div>
|
114
|
+
`;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
declare global {
|
119
|
+
interface HTMLElementTagNameMap {
|
120
|
+
'vouch-embed-dialog-overlay': DialogOverlay;
|
121
|
+
}
|
122
|
+
|
123
|
+
namespace JSX {
|
124
|
+
interface IntrinsicElements {
|
125
|
+
'vouch-embed-dialog-overlay': DialogOverlay;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
export { DialogOverlay };
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import { html, LitElement } from 'lit';
|
2
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
4
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
5
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
6
|
+
|
7
|
+
import type { DialogEmbedProps } from '.';
|
8
|
+
import type { MediaPlayer } from '@vouchfor/media-player';
|
9
|
+
|
10
|
+
import './DialogOverlay';
|
11
|
+
|
12
|
+
@customElement('vouch-embed-dialog-portal')
|
13
|
+
class DialogPortal extends LitElement {
|
14
|
+
@property({ type: String }) vouchId: DialogEmbedProps['vouchId'];
|
15
|
+
@property({ type: String }) templateId: DialogEmbedProps['templateId'];
|
16
|
+
@property({ type: Array }) questions: DialogEmbedProps['questions'];
|
17
|
+
|
18
|
+
@property({ type: String }) env: DialogEmbedProps['env'] = 'prod';
|
19
|
+
@property({ type: String }) apiKey: DialogEmbedProps['apiKey'] = '';
|
20
|
+
@property({ type: Boolean }) disableTracking: DialogEmbedProps['disableTracking'] = false;
|
21
|
+
@property({ type: String }) trackingSource: DialogEmbedProps['trackingSource'] = 'embedded_player';
|
22
|
+
|
23
|
+
@property({ type: Array }) controls: DialogEmbedProps['controls'];
|
24
|
+
@property({ type: String }) preload: DialogEmbedProps['preload'] = 'none';
|
25
|
+
@property({ type: Boolean }) disableAutoplay: DialogEmbedProps['disableAutoplay'] = false;
|
26
|
+
@property({ type: Number }) aspectRatio: DialogEmbedProps['aspectRatio'] = 0;
|
27
|
+
|
28
|
+
private _mediaPlayerRef = createRef<MediaPlayer>();
|
29
|
+
|
30
|
+
@state() open = false;
|
31
|
+
|
32
|
+
private _handleToggle = () => {
|
33
|
+
this.open = !this.open;
|
34
|
+
|
35
|
+
if (this.open) {
|
36
|
+
if (!this.disableAutoplay && this._mediaPlayerRef?.value) {
|
37
|
+
this._mediaPlayerRef.value.muted = false;
|
38
|
+
this._mediaPlayerRef.value.play();
|
39
|
+
}
|
40
|
+
} else {
|
41
|
+
this._mediaPlayerRef?.value?.pause();
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
private _handleClose = () => {
|
46
|
+
this.open = false;
|
47
|
+
this._mediaPlayerRef?.value?.pause();
|
48
|
+
};
|
49
|
+
|
50
|
+
private _handleDocumentKeyUp = (e: KeyboardEvent) => {
|
51
|
+
if (e.key === 'Escape') {
|
52
|
+
this._handleClose();
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
connectedCallback(): void {
|
57
|
+
super.connectedCallback();
|
58
|
+
document.addEventListener('dialogembed:click', this._handleToggle);
|
59
|
+
document.addEventListener('keyup', this._handleDocumentKeyUp);
|
60
|
+
document.addEventListener('close:click', this._handleClose);
|
61
|
+
document.addEventListener('overlay:click', this._handleClose);
|
62
|
+
}
|
63
|
+
|
64
|
+
disconnectedCallback(): void {
|
65
|
+
super.disconnectedCallback();
|
66
|
+
document.removeEventListener('dialogembed:click', this._handleToggle);
|
67
|
+
document.removeEventListener('keyup', this._handleDocumentKeyUp);
|
68
|
+
document.removeEventListener('close:click', this._handleClose);
|
69
|
+
document.removeEventListener('overlay:click', this._handleClose);
|
70
|
+
}
|
71
|
+
|
72
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment {
|
73
|
+
return document.body;
|
74
|
+
}
|
75
|
+
|
76
|
+
render() {
|
77
|
+
return html`
|
78
|
+
<vouch-embed-dialog-overlay ?open=${this.open} aspectRatio=${this.aspectRatio}>
|
79
|
+
<vouch-embed-player
|
80
|
+
${ref(this._mediaPlayerRef)}
|
81
|
+
style=${styleMap({
|
82
|
+
maxWidth: '100%',
|
83
|
+
maxHeight: '100%'
|
84
|
+
})}
|
85
|
+
?autoplay=${false}
|
86
|
+
vouchId=${ifDefined(this.vouchId)}
|
87
|
+
templateId=${ifDefined(this.templateId)}
|
88
|
+
.questions=${this.questions}
|
89
|
+
.controls=${this.controls}
|
90
|
+
env=${ifDefined(this.env)}
|
91
|
+
apiKey=${ifDefined(this.apiKey)}
|
92
|
+
?disableTracking=${this.disableTracking}
|
93
|
+
trackingSource=${ifDefined(this.trackingSource)}
|
94
|
+
preload=${ifDefined(this.preload)}
|
95
|
+
aspectRatio=${this.aspectRatio}
|
96
|
+
></vouch-embed-player>
|
97
|
+
</vouch-embed-dialog-overlay>
|
98
|
+
`;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
declare global {
|
103
|
+
interface HTMLElementTagNameMap {
|
104
|
+
'vouch-embed-dialog-portal': DialogPortal;
|
105
|
+
}
|
106
|
+
|
107
|
+
namespace JSX {
|
108
|
+
interface IntrinsicElements {
|
109
|
+
'vouch-embed-dialog-portal': DialogPortal;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
export { DialogPortal };
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import { css, html, LitElement } from 'lit';
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
4
|
+
|
5
|
+
import type { PlayerEmbedProps } from '../PlayerEmbed';
|
6
|
+
|
7
|
+
import '../PlayerEmbed';
|
8
|
+
import './DialogPortal';
|
9
|
+
|
10
|
+
type DialogEmbedProps = Omit<PlayerEmbedProps, 'data'> & {
|
11
|
+
disableAutoplay?: boolean;
|
12
|
+
};
|
13
|
+
|
14
|
+
@customElement('vouch-embed-dialog')
|
15
|
+
class DialogEmbed extends LitElement {
|
16
|
+
static styles = [
|
17
|
+
css`
|
18
|
+
:host {
|
19
|
+
--vu-button-padding: 10px 20px;
|
20
|
+
--vu-button-background: #287179;
|
21
|
+
--vu-button-background-hover: #4faab2;
|
22
|
+
|
23
|
+
display: flex;
|
24
|
+
width: fit-content;
|
25
|
+
height: fit-content;
|
26
|
+
}
|
27
|
+
`
|
28
|
+
];
|
29
|
+
|
30
|
+
@property({ type: String }) vouchId: DialogEmbedProps['vouchId'];
|
31
|
+
@property({ type: String }) templateId: DialogEmbedProps['templateId'];
|
32
|
+
@property({ type: Array }) questions: DialogEmbedProps['questions'];
|
33
|
+
|
34
|
+
@property({ type: String }) env: DialogEmbedProps['env'] = 'prod';
|
35
|
+
@property({ type: String }) apiKey: DialogEmbedProps['apiKey'] = '';
|
36
|
+
@property({ type: Boolean }) disableTracking: DialogEmbedProps['disableTracking'] = false;
|
37
|
+
@property({ type: String }) trackingSource: DialogEmbedProps['trackingSource'] = 'embedded_player';
|
38
|
+
|
39
|
+
@property({ type: Array }) controls: DialogEmbedProps['controls'];
|
40
|
+
@property({ type: String }) preload: DialogEmbedProps['preload'] = 'none';
|
41
|
+
@property({ type: Boolean }) disableAutoplay: DialogEmbedProps['disableAutoplay'] = false;
|
42
|
+
@property({ type: Number }) aspectRatio: DialogEmbedProps['aspectRatio'] = 0;
|
43
|
+
|
44
|
+
private _handleRootClick = () => {
|
45
|
+
this.dispatchEvent(new CustomEvent('dialogembed:click', { bubbles: true, composed: true }));
|
46
|
+
};
|
47
|
+
|
48
|
+
connectedCallback(): void {
|
49
|
+
super.connectedCallback();
|
50
|
+
this.addEventListener('click', this._handleRootClick);
|
51
|
+
}
|
52
|
+
|
53
|
+
disconnectedCallback(): void {
|
54
|
+
super.disconnectedCallback();
|
55
|
+
this.removeEventListener('click', this._handleRootClick);
|
56
|
+
}
|
57
|
+
|
58
|
+
render() {
|
59
|
+
return html`
|
60
|
+
<slot>
|
61
|
+
<vmp-button size="large">Play</vmp-button>
|
62
|
+
</slot>
|
63
|
+
<vouch-embed-dialog-portal
|
64
|
+
?autoplay=${false}
|
65
|
+
vouchId=${ifDefined(this.vouchId)}
|
66
|
+
templateId=${ifDefined(this.templateId)}
|
67
|
+
.questions=${this.questions}
|
68
|
+
.controls=${this.controls}
|
69
|
+
env=${ifDefined(this.env)}
|
70
|
+
apiKey=${ifDefined(this.apiKey)}
|
71
|
+
?disableTracking=${this.disableTracking}
|
72
|
+
trackingSource=${ifDefined(this.trackingSource)}
|
73
|
+
preload=${ifDefined(this.preload)}
|
74
|
+
aspectRatio=${this.aspectRatio}
|
75
|
+
></vouch-embed-dialog-portal>
|
76
|
+
`;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
declare global {
|
81
|
+
interface HTMLElementTagNameMap {
|
82
|
+
'vouch-embed-dialog': DialogEmbed;
|
83
|
+
}
|
84
|
+
|
85
|
+
namespace JSX {
|
86
|
+
interface IntrinsicElements {
|
87
|
+
'vouch-embed-dialog': DialogEmbed;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
export { DialogEmbed };
|
93
|
+
export type { DialogEmbedProps };
|
@@ -2,6 +2,7 @@ import { createRef, ref } from 'lit/directives/ref.js';
|
|
2
2
|
|
3
3
|
import type { PlayerEmbed } from '..';
|
4
4
|
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
5
|
+
import type { DirectiveResult } from 'lit/directive.js';
|
5
6
|
import type { Ref } from 'lit/directives/ref.js';
|
6
7
|
|
7
8
|
import { forwardEvent } from '~/utils/events';
|
@@ -21,7 +22,7 @@ class EventForwardController implements ReactiveController {
|
|
21
22
|
host.addController(this);
|
22
23
|
}
|
23
24
|
|
24
|
-
register() {
|
25
|
+
register(): DirectiveResult {
|
25
26
|
return ref(this._forwardElementRef);
|
26
27
|
}
|
27
28
|
|