@vouchfor/embeds 0.0.0-experiment.f4df018 → 0.0.0-experiment.f6e3687

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. package/dist/es/browser-0cb0f446.js +433 -0
  2. package/dist/es/browser-0cb0f446.js.map +1 -0
  3. package/dist/es/embeds.js +12 -1499
  4. package/dist/es/embeds.js.map +1 -1
  5. package/dist/es/index-326f29ee.js +9536 -0
  6. package/dist/es/index-326f29ee.js.map +1 -0
  7. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
  8. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
  9. package/dist/es/src/components/DialogEmbed/index.d.ts +36 -0
  10. package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  11. package/dist/es/{components/Embed → src/components/PlayerEmbed}/controllers/fetcher.d.ts +5 -4
  12. package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  13. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  14. package/dist/es/{components/Embed → src/components/PlayerEmbed}/index.d.ts +28 -19
  15. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  16. package/dist/es/src/index.d.ts +2 -0
  17. package/dist/iife/dialog-embed/browser-fcb64823.js +433 -0
  18. package/dist/iife/dialog-embed/browser-fcb64823.js.map +1 -0
  19. package/dist/iife/dialog-embed/embed.iife.js +1723 -0
  20. package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
  21. package/dist/iife/dialog-embed/embed.js +5 -0
  22. package/dist/iife/dialog-embed/embed.js.map +1 -0
  23. package/dist/iife/dialog-embed/index-804846ae.js +33256 -0
  24. package/dist/iife/dialog-embed/index-804846ae.js.map +1 -0
  25. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
  26. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
  27. package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +36 -0
  28. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  29. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
  30. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  31. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  32. package/dist/iife/dialog-embed/src/components/PlayerEmbed/index.d.ts +73 -0
  33. package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  34. package/dist/iife/dialog-embed/src/index.d.ts +2 -0
  35. package/dist/iife/dialog-embed/src/utils/env.d.ts +12 -0
  36. package/dist/iife/dialog-embed/src/utils/events.d.ts +2 -0
  37. package/dist/iife/embeds.iife.js +637 -344
  38. package/dist/iife/embeds.iife.js.map +1 -1
  39. package/dist/iife/player-embed/browser-910b9dcb.js +433 -0
  40. package/dist/iife/player-embed/browser-910b9dcb.js.map +1 -0
  41. package/dist/iife/player-embed/embed.iife.js +1585 -0
  42. package/dist/iife/player-embed/embed.iife.js.map +1 -0
  43. package/dist/iife/player-embed/embed.js +5 -0
  44. package/dist/iife/player-embed/embed.js.map +1 -0
  45. package/dist/iife/player-embed/index-154c6a23.js +32811 -0
  46. package/dist/iife/player-embed/index-154c6a23.js.map +1 -0
  47. package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
  48. package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
  49. package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +36 -0
  50. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  51. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
  52. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  53. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  54. package/dist/iife/player-embed/src/components/PlayerEmbed/index.d.ts +73 -0
  55. package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  56. package/dist/iife/player-embed/src/index.d.ts +2 -0
  57. package/dist/iife/player-embed/src/utils/env.d.ts +12 -0
  58. package/dist/iife/player-embed/src/utils/events.d.ts +2 -0
  59. package/package.json +13 -5
  60. package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
  61. package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
  62. package/src/components/DialogEmbed/DialogPortal.ts +126 -0
  63. package/src/components/DialogEmbed/index.ts +97 -0
  64. package/src/components/{Embed/Embed.stories.ts → PlayerEmbed/PlayerEmbed.stories.ts} +27 -14
  65. package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +6 -5
  66. package/src/components/PlayerEmbed/controllers/fetcher.ts +152 -0
  67. package/src/components/PlayerEmbed/controllers/tracking/index.ts +224 -0
  68. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
  69. package/src/components/{Embed → PlayerEmbed}/index.ts +78 -27
  70. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +80 -0
  71. package/src/components/PlayerEmbed/tests/data.ts +183 -0
  72. package/src/index.ts +2 -1
  73. package/dist/es/components/Embed/controllers/tracking.d.ts +0 -28
  74. package/dist/es/index.d.ts +0 -1
  75. package/src/components/Embed/controllers/fetcher.ts +0 -113
  76. package/src/components/Embed/controllers/tracking.ts +0 -261
  77. /package/dist/es/{utils → src/utils}/env.d.ts +0 -0
  78. /package/dist/es/{utils → src/utils}/events.d.ts +0 -0
@@ -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,36 @@
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 _id;
20
+ private _handleRootClick;
21
+ connectedCallback(): void;
22
+ disconnectedCallback(): void;
23
+ render(): import("lit").TemplateResult<1>;
24
+ }
25
+ declare global {
26
+ interface HTMLElementTagNameMap {
27
+ 'vouch-embed-dialog': DialogEmbed;
28
+ }
29
+ namespace JSX {
30
+ interface IntrinsicElements {
31
+ 'vouch-embed-dialog': DialogEmbed;
32
+ }
33
+ }
34
+ }
35
+ export { DialogEmbed };
36
+ 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,73 @@
1
+ import { LitElement } from 'lit';
2
+ import type { Scene, Scenes, TemplateInstance } from '@vouchfor/canvas-video';
3
+ import type { MediaPlayer, MediaPlayerProps } from '@vouchfor/media-player';
4
+ import type { Environment } from '../../utils/env';
5
+ type PlayerEmbedProps = Pick<MediaPlayerProps, 'data' | 'aspectRatio' | 'preload' | 'autoplay' | 'controls'> & {
6
+ env: Environment;
7
+ apiKey: string;
8
+ disableTracking?: boolean;
9
+ trackingSource?: string;
10
+ vouchId?: string;
11
+ templateId?: string;
12
+ questions?: number[];
13
+ };
14
+ declare class PlayerEmbed extends LitElement {
15
+ static styles: import("lit").CSSResult[];
16
+ data: PlayerEmbedProps['data'];
17
+ vouchId: PlayerEmbedProps['vouchId'];
18
+ templateId: PlayerEmbedProps['templateId'];
19
+ questions: PlayerEmbedProps['questions'];
20
+ env: PlayerEmbedProps['env'];
21
+ apiKey: PlayerEmbedProps['apiKey'];
22
+ disableTracking: PlayerEmbedProps['disableTracking'];
23
+ trackingSource: PlayerEmbedProps['trackingSource'];
24
+ controls: PlayerEmbedProps['controls'];
25
+ preload: PlayerEmbedProps['preload'];
26
+ autoplay: PlayerEmbedProps['autoplay'];
27
+ aspectRatio: PlayerEmbedProps['aspectRatio'];
28
+ private eventController;
29
+ private _fetcherController;
30
+ private _trackingController;
31
+ vouch: PlayerEmbedProps['data'];
32
+ template: TemplateInstance | undefined;
33
+ get fetching(): boolean;
34
+ private _mediaPlayerRef;
35
+ get waiting(): boolean | undefined;
36
+ get initialised(): Promise<boolean> | undefined;
37
+ get seeking(): boolean | undefined;
38
+ get paused(): boolean | undefined;
39
+ get captions(): boolean | undefined;
40
+ get fullscreen(): boolean | undefined;
41
+ get duration(): number | undefined;
42
+ set currentTime(value: number);
43
+ get currentTime(): number;
44
+ set playbackRate(value: number);
45
+ get playbackRate(): number;
46
+ set volume(value: number);
47
+ get volume(): number;
48
+ set muted(value: boolean);
49
+ get muted(): boolean;
50
+ get scene(): Scene | null;
51
+ get scenes(): Scene[];
52
+ get sceneConfig(): Scenes | null;
53
+ get videoState(): import("@vouchfor/media-player/dist/src/components/MediaPlayer/controllers/scenes").VideoStateMap | undefined;
54
+ get mediaPlayer(): MediaPlayer | undefined;
55
+ play(): void;
56
+ pause(): void;
57
+ reset(time?: number, play?: boolean): void;
58
+ setScene(index: number): void;
59
+ private _renderStyles;
60
+ render(): import("lit").TemplateResult<1>;
61
+ }
62
+ declare global {
63
+ interface HTMLElementTagNameMap {
64
+ 'vouch-embed-player': PlayerEmbed;
65
+ }
66
+ namespace JSX {
67
+ interface IntrinsicElements {
68
+ 'vouch-embed-player': PlayerEmbed;
69
+ }
70
+ }
71
+ }
72
+ export { PlayerEmbed };
73
+ export type { PlayerEmbedProps };
@@ -0,0 +1,3 @@
1
+ import type { Vouch } from '@vouchfor/media-player';
2
+ declare const data: Vouch;
3
+ export { data };
@@ -0,0 +1,2 @@
1
+ export { PlayerEmbed } from './components/PlayerEmbed';
2
+ export { DialogEmbed } from './components/DialogEmbed';
@@ -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 };
@@ -0,0 +1,2 @@
1
+ declare function forwardEvent(type: string, fromElement: HTMLElement, toElement: HTMLElement): () => void;
2
+ export { forwardEvent };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@vouchfor/embeds",
3
- "version": "0.0.0-experiment.f4df018",
3
+ "version": "0.0.0-experiment.f6e3687",
4
4
  "license": "MIT",
5
5
  "author": "Aaron Williams",
6
6
  "main": "dist/es/embeds.js",
7
7
  "module": "dist/es/embeds.js",
8
8
  "type": "module",
9
- "types": "dist/es/index.d.ts",
9
+ "types": "dist/es/src/index.d.ts",
10
10
  "exports": {
11
11
  ".": "./dist/es/embeds.js"
12
12
  },
@@ -16,8 +16,9 @@
16
16
  "access": "public"
17
17
  },
18
18
  "scripts": {
19
- "build": "rm -rf dist && tsc && vite build --mode iife && vite build --mode es",
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",
@@ -28,15 +29,17 @@
28
29
  "size": "size-limit",
29
30
  "storybook": "yarn prebuild && storybook dev -p 6007",
30
31
  "prebuild": "yarn build:deps && yarn generate:manifest",
31
- "test": "true"
32
+ "test": "rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner",
33
+ "test:ci": "yarn test --config web-test-runner.ci.config.js"
32
34
  },
33
35
  "lint-staged": {
34
36
  "**/*.{ts,tsx,js}": "eslint --fix --quiet",
35
37
  "**/*.{md,json,yml}": "prettier --write"
36
38
  },
37
39
  "dependencies": {
40
+ "@a11y/focus-trap": "^1.0.5",
38
41
  "@lit/task": "^1.0.0",
39
- "@vouchfor/media-player": "0.0.0-experiment.f4df018",
42
+ "@vouchfor/media-player": "0.0.0-experiment.f6e3687",
40
43
  "uuid": "^9.0.1"
41
44
  },
42
45
  "peerDependencies": {
@@ -61,14 +64,19 @@
61
64
  "dotenv": "^16.3.1",
62
65
  "eslint": "^8.50.0",
63
66
  "eslint-plugin-import": "^2.28.1",
67
+ "glob": "^10.3.10",
64
68
  "lint-staged": "^14.0.1",
65
69
  "lit": "^3.1.0",
70
+ "lodash": "^4.17.21",
66
71
  "prettier": "^3.0.3",
67
72
  "react": "^18.2.0",
68
73
  "react-dom": "^18.2.0",
74
+ "rollup-plugin-internal": "^1.0.4",
75
+ "sinon": "^17.0.1",
69
76
  "storybook": "^7.4.5",
70
77
  "typescript": "^5.1.3",
71
78
  "vite": "^4.4.9",
79
+ "vite-plugin-commonjs": "^0.10.0",
72
80
  "vite-plugin-dts": "^3.6.0",
73
81
  "web-component-analyzer": "^1.1.7"
74
82
  }
@@ -0,0 +1,91 @@
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
+ <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>
50
+ </div>
51
+ `;
52
+ };
53
+
54
+ // More on how to set up stories at: https://storybook.js.org/docs/web-components/writing-stories/introduction
55
+ const meta = {
56
+ title: 'Dialog',
57
+ tags: ['autodocs'],
58
+ render: (args) => _DialogEmbed(args),
59
+ component: 'vouch-embed-dialog'
60
+ } satisfies Meta<DialogEmbedProps>;
61
+
62
+ type Story = StoryObj<DialogEmbedArgs>;
63
+
64
+ const Dialog: Story = {
65
+ args: {
66
+ env: 'dev',
67
+ apiKey: 'TVik9uTMgE-PD25UTHIS6gyl0hMBWC7AT4dkpdlLBT4VIfDWZJrQiCk6Ak7m1',
68
+ vouchId: '6JQEIPeStt',
69
+ templateId: '357fc118-e179-4171-9446-ff2b8e9d1b29',
70
+ questions: [],
71
+ aspectRatio: 0,
72
+ preload: 'none',
73
+ autoplay: false
74
+ },
75
+ argTypes: {
76
+ env: {
77
+ control: 'radio',
78
+ options: ['local', 'dev', 'staging', 'prod']
79
+ },
80
+ preload: {
81
+ control: 'radio',
82
+ options: ['auto', 'none']
83
+ }
84
+ },
85
+ parameters: {
86
+ layout: 'fullscreen'
87
+ }
88
+ };
89
+
90
+ export default meta;
91
+ export { Dialog };
@@ -0,0 +1,131 @@
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: fixed;
25
+ display: flex;
26
+ inset: 0;
27
+ opacity: 1;
28
+ z-index: 2147483647;
29
+ align-items: center;
30
+ justify-content: center;
31
+ transition: opacity 100ms ease-in;
32
+ }
33
+
34
+ .hidden {
35
+ opacity: 0;
36
+ pointer-events: none;
37
+ }
38
+
39
+ .background {
40
+ position: absolute;
41
+ inset: 0;
42
+ opacity: var(--overlay-background-opacity);
43
+ background-color: var(--overlay-background-color);
44
+ }
45
+
46
+ focus-trap {
47
+ display: flex;
48
+ align-items: center;
49
+ justify-content: center;
50
+ margin: 40px;
51
+ width: var(--dialog-width);
52
+ height: var(--dialog-height);
53
+ max-width: calc(100% - 80px);
54
+ max-height: calc(100% - 80px);
55
+ }
56
+
57
+ .video-frame {
58
+ position: relative;
59
+ display: flex;
60
+ align-items: center;
61
+ justify-content: center;
62
+ max-width: 100%;
63
+ max-height: 100%;
64
+ }
65
+
66
+ .video-frame.grow {
67
+ width: 100%;
68
+ height: 100%;
69
+ }
70
+
71
+ vmp-icon-button {
72
+ position: absolute;
73
+ top: 0;
74
+ right: 0;
75
+ margin: 10px;
76
+ }
77
+ `
78
+ ];
79
+
80
+ @property({ type: Boolean }) open = false;
81
+ @property({ type: Number }) aspectRatio: DialogEmbedProps['aspectRatio'] = 0;
82
+
83
+ render() {
84
+ return html`
85
+ <div
86
+ class=${classMap({
87
+ container: true,
88
+ hidden: !this.open
89
+ })}
90
+ >
91
+ <div
92
+ class="background"
93
+ @click=${() => this.dispatchEvent(new CustomEvent('overlay:click', { bubbles: true, composed: true }))}
94
+ ></div>
95
+ <focus-trap>
96
+ <div
97
+ class=${classMap({
98
+ 'video-frame': true,
99
+ grow: this.aspectRatio === 0
100
+ })}
101
+ style=${styleMap({
102
+ aspectRatio: this.aspectRatio
103
+ })}
104
+ >
105
+ <slot></slot>
106
+ <vmp-icon-button
107
+ icon="close"
108
+ rounded="full"
109
+ weight="heavy"
110
+ @click=${() => this.dispatchEvent(new CustomEvent('close:click', { bubbles: true, composed: true }))}
111
+ ></vmp-icon-button>
112
+ </div>
113
+ </focus-trap>
114
+ </div>
115
+ `;
116
+ }
117
+ }
118
+
119
+ declare global {
120
+ interface HTMLElementTagNameMap {
121
+ 'vouch-embed-dialog-overlay': DialogOverlay;
122
+ }
123
+
124
+ namespace JSX {
125
+ interface IntrinsicElements {
126
+ 'vouch-embed-dialog-overlay': DialogOverlay;
127
+ }
128
+ }
129
+ }
130
+
131
+ export { DialogOverlay };