@redvars/peacock 4.2.1 → 4.3.1

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.
Files changed (254) hide show
  1. package/dist/{BaseField-D8ByB0l3.js → BaseField-CHBcjVc2.js} +3 -3
  2. package/dist/{BaseField-D8ByB0l3.js.map → BaseField-CHBcjVc2.js.map} +1 -1
  3. package/dist/{BaseInput-xCHvT4AN.js → BaseInput-DZp2O8Gh.js} +2 -2
  4. package/dist/{BaseInput-xCHvT4AN.js.map → BaseInput-DZp2O8Gh.js.map} +1 -1
  5. package/dist/ai-badge.js +2 -2
  6. package/dist/ai-summary.js +2 -2
  7. package/dist/alert.js +2 -2
  8. package/dist/anchor-nav.js +2 -2
  9. package/dist/app-shell.js +2 -2
  10. package/dist/assistant-panel.js +2 -2
  11. package/dist/assistant-step.js +2 -2
  12. package/dist/assistant-steps.js +2 -2
  13. package/dist/avatar-group.js +2 -2
  14. package/dist/banner.js +2 -2
  15. package/dist/{base-progress-DxNgAQtw.js → base-progress-CKQ32Ruw.js} +2 -2
  16. package/dist/{base-progress-DxNgAQtw.js.map → base-progress-CKQ32Ruw.js.map} +1 -1
  17. package/dist/bottom-sheet.js +2 -2
  18. package/dist/breadcrumb.js +2 -2
  19. package/dist/calendar.js +2 -2
  20. package/dist/{canvas-base-DHKf2CmA.js → canvas-base-BoKef3yr.js} +2 -2
  21. package/dist/{canvas-base-DHKf2CmA.js.map → canvas-base-BoKef3yr.js.map} +1 -1
  22. package/dist/carousel.js +644 -0
  23. package/dist/carousel.js.map +1 -0
  24. package/dist/{cartesian-chart-G6VX1aKk.js → cartesian-chart-DqZxnoG1.js} +2 -2
  25. package/dist/{cartesian-chart-G6VX1aKk.js.map → cartesian-chart-DqZxnoG1.js.map} +1 -1
  26. package/dist/{cb-group-base-BBDUgxne.js → cb-group-base-DHwx72Gt.js} +3 -1
  27. package/dist/{cb-group-base-BBDUgxne.js.map → cb-group-base-DHwx72Gt.js.map} +1 -1
  28. package/dist/{cb-group-base-CZLzCnXK.js → cb-group-base-DXnAJxEK.js} +3 -3
  29. package/dist/{cb-group-base-CZLzCnXK.js.map → cb-group-base-DXnAJxEK.js.map} +1 -1
  30. package/dist/cb-group.js +7 -4
  31. package/dist/cb-group.js.map +1 -1
  32. package/dist/cb-rule.js +3 -3
  33. package/dist/chart-area.js +4 -4
  34. package/dist/chart-bar.js +4 -4
  35. package/dist/{chart-base-DREru2P0.js → chart-base-ByCJM_9C.js} +2 -2
  36. package/dist/{chart-base-DREru2P0.js.map → chart-base-ByCJM_9C.js.map} +1 -1
  37. package/dist/chart-doughnut.js +3 -3
  38. package/dist/chart-line.js +4 -4
  39. package/dist/chart-pie.js +3 -3
  40. package/dist/chat-event.js +2 -2
  41. package/dist/chat-message.js +2 -2
  42. package/dist/chat-thread.js +2 -2
  43. package/dist/checkbox-group.js +3 -3
  44. package/dist/checkbox.js +3 -3
  45. package/dist/chip-set.js +2 -2
  46. package/dist/chip.js +2 -2
  47. package/dist/circular-progress.js +3 -3
  48. package/dist/citation.js +2 -2
  49. package/dist/code-editor.js +3 -3
  50. package/dist/code-highlighter.js +2 -2
  51. package/dist/color-field.js +4 -4
  52. package/dist/color-picker.js +2 -2
  53. package/dist/command-palette.js +2 -2
  54. package/dist/comment-composer.js +4 -4
  55. package/dist/condition-builder.js +4 -4
  56. package/dist/confirm-dialog.js +2 -2
  57. package/dist/copy-button.js +2 -2
  58. package/dist/currency-field.js +4 -4
  59. package/dist/custom-elements-jsdocs.json +902 -74
  60. package/dist/custom-elements.json +3301 -446
  61. package/dist/date-field.js +5 -5
  62. package/dist/date-picker.js +2 -2
  63. package/dist/date-range-field.js +5 -5
  64. package/dist/datetime-field.js +5 -5
  65. package/dist/dependency-map.js +3 -3
  66. package/dist/description-item.js +2 -2
  67. package/dist/description-list.js +2 -2
  68. package/dist/{diagram-CHF70xTL.js → diagram-Cnrj-4y3.js} +2 -2
  69. package/dist/{diagram-CHF70xTL.js.map → diagram-Cnrj-4y3.js.map} +1 -1
  70. package/dist/diagram-controls.js +2 -2
  71. package/dist/diagram-minimap.js +2 -2
  72. package/dist/diagram.js +4 -4
  73. package/dist/diff-viewer.js +2 -2
  74. package/dist/discussion-activity.js +2 -2
  75. package/dist/discussion-comment.js +2 -2
  76. package/dist/discussion.js +4 -4
  77. package/dist/{document-editor-Cb9fCxvA.js → document-editor-C8ThjDQ7.js} +2 -2
  78. package/dist/{document-editor-Cb9fCxvA.js.map → document-editor-C8ThjDQ7.js.map} +1 -1
  79. package/dist/document-editor.js +3 -3
  80. package/dist/draft-card.js +2 -2
  81. package/dist/erd.js +3 -3
  82. package/dist/file-upload.js +3 -3
  83. package/dist/filter-bar.js +2 -2
  84. package/dist/flow.js +4 -4
  85. package/dist/form.js +2 -2
  86. package/dist/{generative-view-C4fJ2zI7.js → generative-view-CQ8-g1wY.js} +2 -2
  87. package/dist/{generative-view-C4fJ2zI7.js.map → generative-view-CQ8-g1wY.js.map} +1 -1
  88. package/dist/generative-view.js +3 -3
  89. package/dist/highlight-Be0wu7kh.js +252 -0
  90. package/dist/highlight-Be0wu7kh.js.map +1 -0
  91. package/dist/highlight.js +6 -0
  92. package/dist/highlight.js.map +1 -0
  93. package/dist/html-editor.js +4 -4
  94. package/dist/{i18n-controller-CH4e9sju.js → i18n-controller-DLJcJ5gO.js} +2 -2
  95. package/dist/{i18n-controller-CH4e9sju.js.map → i18n-controller-DLJcJ5gO.js.map} +1 -1
  96. package/dist/image.js +2 -2
  97. package/dist/index.js +27 -17
  98. package/dist/index.js.map +1 -1
  99. package/dist/inline-edit.js +2 -2
  100. package/dist/input.js +3 -3
  101. package/dist/json-viewer.js +2 -2
  102. package/dist/kanban.js +2 -2
  103. package/dist/kbd.js +2 -2
  104. package/dist/linear-progress.js +3 -3
  105. package/dist/listbox.js +2 -2
  106. package/dist/loader-full.js +19 -9
  107. package/dist/loader-full.js.map +1 -1
  108. package/dist/loader.js +46 -9
  109. package/dist/loader.js.map +1 -1
  110. package/dist/markdown-editor.js +4 -4
  111. package/dist/mention-input.js +4 -4
  112. package/dist/modal.js +2 -2
  113. package/dist/navigation-bar.js +2 -2
  114. package/dist/navigation-drawer.js +2 -2
  115. package/dist/navigation-rail.js +2 -2
  116. package/dist/notification-center.js +2 -2
  117. package/dist/number-field.js +4 -4
  118. package/dist/page-header.js +2 -2
  119. package/dist/pagination.js +2 -2
  120. package/dist/password-field.js +4 -4
  121. package/dist/password-rules.js +2 -2
  122. package/dist/phone-field.js +4 -4
  123. package/dist/{picker-field-loXW-xrW.js → picker-field-B5xOFc3-.js} +3 -3
  124. package/dist/{picker-field-loXW-xrW.js.map → picker-field-B5xOFc3-.js.map} +1 -1
  125. package/dist/pin-input.js +4 -4
  126. package/dist/presence-indicator.js +2 -2
  127. package/dist/prompt-input.js +4 -4
  128. package/dist/radio.js +3 -3
  129. package/dist/rating.js +3 -3
  130. package/dist/redvars-loader.js +2 -2
  131. package/dist/relative-time.js +2 -2
  132. package/dist/resizable-panels.js +2 -2
  133. package/dist/{rich-text-input-B5j0eqCJ.js → rich-text-input-C4B9D6oD.js} +3 -3
  134. package/dist/{rich-text-input-B5j0eqCJ.js.map → rich-text-input-C4B9D6oD.js.map} +1 -1
  135. package/dist/{schema-BJzlGRP1.js → schema-CPhNrjrx.js} +2 -2
  136. package/dist/{schema-BJzlGRP1.js.map → schema-CPhNrjrx.js.map} +1 -1
  137. package/dist/search.js +3 -3
  138. package/dist/select.js +4 -4
  139. package/dist/side-sheet.js +2 -2
  140. package/dist/signature-pad.js +3 -3
  141. package/dist/site-footer-group.js +142 -0
  142. package/dist/site-footer-group.js.map +1 -0
  143. package/dist/site-footer.js +338 -0
  144. package/dist/site-footer.js.map +1 -0
  145. package/dist/site-header.js +774 -0
  146. package/dist/site-header.js.map +1 -0
  147. package/dist/site-nav-group.js +123 -0
  148. package/dist/site-nav-group.js.map +1 -0
  149. package/dist/site-nav-link.js +321 -0
  150. package/dist/site-nav-link.js.map +1 -0
  151. package/dist/site-nav-menu.js +506 -0
  152. package/dist/site-nav-menu.js.map +1 -0
  153. package/dist/site-nav-shared-BDR2HG8e.js +23 -0
  154. package/dist/site-nav-shared-BDR2HG8e.js.map +1 -0
  155. package/dist/slider.js +3 -3
  156. package/dist/snackbar.js +2 -2
  157. package/dist/sparkline.js +2 -2
  158. package/dist/split-button.js +2 -2
  159. package/dist/src/__internal/i18n/strings.d.ts +24 -0
  160. package/dist/src/carousel/carousel.d.ts +135 -0
  161. package/dist/src/carousel/index.d.ts +1 -0
  162. package/dist/src/highlight/highlight.d.ts +56 -0
  163. package/dist/src/highlight/index.d.ts +2 -0
  164. package/dist/src/highlight/matches.d.ts +9 -0
  165. package/dist/src/index.d.ts +9 -0
  166. package/dist/src/site-footer/index.d.ts +2 -0
  167. package/dist/src/site-footer/site-footer-group.d.ts +34 -0
  168. package/dist/src/site-footer/site-footer.d.ts +74 -0
  169. package/dist/src/site-header/index.d.ts +4 -0
  170. package/dist/src/site-header/site-header.d.ts +170 -0
  171. package/dist/src/site-header/site-nav-group.d.ts +32 -0
  172. package/dist/src/site-header/site-nav-link.d.ts +65 -0
  173. package/dist/src/site-header/site-nav-menu.d.ts +104 -0
  174. package/dist/src/site-header/site-nav-shared.d.ts +13 -0
  175. package/dist/src/table/table.d.ts +5 -0
  176. package/dist/src/video/index.d.ts +2 -0
  177. package/dist/src/video/video-source.d.ts +12 -0
  178. package/dist/src/video/video.d.ts +80 -0
  179. package/dist/stat.js +2 -2
  180. package/dist/status-indicator.js +2 -2
  181. package/dist/step.js +2 -2
  182. package/dist/stepper.js +2 -2
  183. package/dist/{strings-o6v6Hrmn.js → strings-MXyrGrNs.js} +28 -1
  184. package/dist/strings-MXyrGrNs.js.map +1 -0
  185. package/dist/svg.js +2 -2
  186. package/dist/switch.js +3 -3
  187. package/dist/table.js +53 -10
  188. package/dist/table.js.map +1 -1
  189. package/dist/test/carousel.test.d.ts +1 -0
  190. package/dist/test/highlight.test.d.ts +1 -0
  191. package/dist/test/site-footer.test.d.ts +1 -0
  192. package/dist/test/site-header.test.d.ts +1 -0
  193. package/dist/test/video.test.d.ts +1 -0
  194. package/dist/textarea.js +4 -4
  195. package/dist/time-field.js +5 -5
  196. package/dist/time-picker.js +2 -2
  197. package/dist/timeline-item.js +2 -2
  198. package/dist/timeline.js +2 -2
  199. package/dist/{toggle-base-BSzBnLZN.js → toggle-base-I1wE_fVe.js} +2 -2
  200. package/dist/{toggle-base-BSzBnLZN.js.map → toggle-base-I1wE_fVe.js.map} +1 -1
  201. package/dist/tour.js +2 -2
  202. package/dist/transfer-list.js +3 -3
  203. package/dist/tree-chart.js +3 -3
  204. package/dist/tree-item.js +2 -2
  205. package/dist/tree.js +2 -2
  206. package/dist/tsconfig.tsbuildinfo +1 -1
  207. package/dist/typing-indicator.js +2 -2
  208. package/dist/url-field.js +4 -4
  209. package/dist/user-menu.js +2 -2
  210. package/dist/video-IwNmHyft.js +509 -0
  211. package/dist/video-IwNmHyft.js.map +1 -0
  212. package/dist/video.js +12 -0
  213. package/dist/video.js.map +1 -0
  214. package/dist/virtual-list.js +2 -2
  215. package/dist/workflow-timeline.js +2 -2
  216. package/dist/workflow.js +3 -3
  217. package/dist/workspace-switcher.js +2 -2
  218. package/package.json +1 -1
  219. package/readme.md +5 -0
  220. package/src/__internal/i18n/strings.ts +31 -0
  221. package/src/carousel/carousel.scss +124 -0
  222. package/src/carousel/carousel.ts +547 -0
  223. package/src/carousel/index.ts +1 -0
  224. package/src/condition-builder/cb-group-base.scss +5 -1
  225. package/src/condition-builder/cb-group-base.ts +1 -1
  226. package/src/condition-builder/cb-group.scss +4 -0
  227. package/src/highlight/highlight.scss +25 -0
  228. package/src/highlight/highlight.ts +123 -0
  229. package/src/highlight/index.ts +2 -0
  230. package/src/highlight/matches.ts +94 -0
  231. package/src/index.ts +18 -0
  232. package/src/loader.ts +36 -0
  233. package/src/site-footer/index.ts +2 -0
  234. package/src/site-footer/site-footer-group.scss +53 -0
  235. package/src/site-footer/site-footer-group.ts +52 -0
  236. package/src/site-footer/site-footer.scss +171 -0
  237. package/src/site-footer/site-footer.ts +151 -0
  238. package/src/site-header/index.ts +8 -0
  239. package/src/site-header/site-header.scss +238 -0
  240. package/src/site-header/site-header.ts +565 -0
  241. package/src/site-header/site-nav-group.scss +29 -0
  242. package/src/site-header/site-nav-group.ts +57 -0
  243. package/src/site-header/site-nav-link.scss +154 -0
  244. package/src/site-header/site-nav-link.ts +140 -0
  245. package/src/site-header/site-nav-menu.scss +182 -0
  246. package/src/site-header/site-nav-menu.ts +336 -0
  247. package/src/site-header/site-nav-shared.ts +27 -0
  248. package/src/table/table.scss +52 -2
  249. package/src/table/table.ts +20 -6
  250. package/src/video/index.ts +2 -0
  251. package/src/video/video-source.ts +80 -0
  252. package/src/video/video.scss +183 -0
  253. package/src/video/video.ts +246 -0
  254. package/dist/strings-o6v6Hrmn.js.map +0 -1
@@ -0,0 +1,183 @@
1
+ @use '../../scss/mixin';
2
+
3
+ @include mixin.base-styles;
4
+
5
+ :host {
6
+ display: block;
7
+ }
8
+
9
+ .frame {
10
+ container-type: inline-size;
11
+ position: relative;
12
+ overflow: hidden;
13
+ inline-size: 100%;
14
+ border-radius: var(--video-shape, var(--shape-corner-large));
15
+ background-color: var(--color-surface-container-highest);
16
+ color: var(--color-on-surface);
17
+ }
18
+
19
+ .player {
20
+ display: block;
21
+ inline-size: 100%;
22
+ block-size: 100%;
23
+ border: 0;
24
+ background-color: var(--color-black);
25
+ }
26
+
27
+ // ── Poster ────────────────────────────────────────────────────────────────
28
+
29
+ .play-button {
30
+ @include mixin.reset-button-styles;
31
+
32
+ position: absolute;
33
+ inset: 0;
34
+ display: block;
35
+ inline-size: 100%;
36
+ block-size: 100%;
37
+ overflow: hidden;
38
+ border-radius: inherit;
39
+ color: var(--color-white);
40
+ cursor: pointer;
41
+ text-align: start;
42
+
43
+ .focus-ring {
44
+ --focus-ring-container-shape-start-start: var(
45
+ --video-shape,
46
+ var(--shape-corner-large)
47
+ );
48
+ --focus-ring-container-shape-start-end: var(
49
+ --video-shape,
50
+ var(--shape-corner-large)
51
+ );
52
+ --focus-ring-container-shape-end-start: var(
53
+ --video-shape,
54
+ var(--shape-corner-large)
55
+ );
56
+ --focus-ring-container-shape-end-end: var(
57
+ --video-shape,
58
+ var(--shape-corner-large)
59
+ );
60
+ // Inside the frame, which clips anything outside it.
61
+ --focus-ring-inset: -0.25rem;
62
+ }
63
+ }
64
+
65
+ // Without a poster, the frame is a plain surface with text in the surface's colour.
66
+ .play-button:not(:has(.poster)) {
67
+ color: var(--color-on-surface);
68
+
69
+ .play-icon {
70
+ background-color: var(--color-primary);
71
+ color: var(--color-on-primary);
72
+ }
73
+ }
74
+
75
+ .poster {
76
+ position: absolute;
77
+ inset: 0;
78
+ inline-size: 100%;
79
+ block-size: 100%;
80
+ object-fit: cover;
81
+ }
82
+
83
+ .title,
84
+ .meta {
85
+ position: absolute;
86
+ inset-inline: 0;
87
+ padding: var(--spacing-200) var(--spacing-300);
88
+ }
89
+
90
+ .title {
91
+ @include mixin.get-typography(title-medium);
92
+
93
+ inset-block-start: 0;
94
+ background: linear-gradient(
95
+ color-mix(in srgb, var(--color-scrim, black) 65%, transparent),
96
+ transparent
97
+ );
98
+ }
99
+
100
+ .meta {
101
+ @include mixin.get-typography(body-small);
102
+
103
+ inset-block-end: 0;
104
+ display: flex;
105
+ justify-content: space-between;
106
+ gap: var(--spacing-200);
107
+ padding-block: var(--spacing-150);
108
+ background: linear-gradient(
109
+ transparent,
110
+ color-mix(in srgb, var(--color-scrim, black) 70%, transparent)
111
+ );
112
+ }
113
+
114
+ .play-button:not(:has(.poster)) :is(.title, .meta) {
115
+ background: none;
116
+ }
117
+
118
+ .play-icon {
119
+ position: absolute;
120
+ inset: 0;
121
+ display: grid;
122
+ place-items: center;
123
+ inline-size: 4.5rem;
124
+ block-size: 4.5rem;
125
+ margin: auto;
126
+ border-radius: var(--shape-corner-full);
127
+ background-color: var(--color-surface-bright);
128
+ color: var(--color-primary);
129
+ box-shadow: var(--elevation-level2);
130
+ transition: transform var(--duration-short4) var(--easing-standard);
131
+
132
+ wc-icon {
133
+ --icon-size: 2.5rem;
134
+ --icon-color: currentColor;
135
+ }
136
+ }
137
+
138
+ .play-button:hover .play-icon {
139
+ transform: scale(1.08);
140
+ }
141
+
142
+ // A small frame, such as on a phone: smaller type and play button, so the three don't crowd.
143
+ @container (max-width: 24rem) {
144
+ .title,
145
+ .meta {
146
+ padding-inline: var(--spacing-200);
147
+ }
148
+
149
+ .title {
150
+ @include mixin.get-typography(title-small);
151
+
152
+ padding-block: var(--spacing-150);
153
+ }
154
+
155
+ .meta {
156
+ padding-block: var(--spacing-100);
157
+ }
158
+
159
+ .play-icon {
160
+ inline-size: 3.5rem;
161
+ block-size: 3.5rem;
162
+
163
+ wc-icon {
164
+ --icon-size: 2rem;
165
+ }
166
+ }
167
+ }
168
+
169
+ @media (prefers-reduced-motion: reduce) {
170
+ .play-icon {
171
+ transition: none;
172
+ }
173
+
174
+ .play-button:hover .play-icon {
175
+ transform: none;
176
+ }
177
+ }
178
+
179
+ @media (forced-colors: active) {
180
+ .play-icon {
181
+ border: 2px solid ButtonText;
182
+ }
183
+ }
@@ -0,0 +1,246 @@
1
+ import { html, LitElement, nothing, type PropertyValues } from 'lit';
2
+ import { property, query, state } from 'lit/decorators.js';
3
+ import { styleMap } from 'lit/directives/style-map.js';
4
+ import IndividualComponent from '@/IndividualComponent.js';
5
+ import { I18nController } from '@/__internal/i18n/i18n-controller.js';
6
+ import {
7
+ parseVideoSource,
8
+ type VideoProvider,
9
+ type VideoSource,
10
+ } from './video-source.js';
11
+ import styles from './video.scss';
12
+
13
+ export type { VideoProvider } from './video-source.js';
14
+
15
+ /**
16
+ * @label Video
17
+ * @tag wc-video
18
+ * @rawTag video
19
+ *
20
+ * @summary A video from YouTube, Vimeo or a file, that loads its player only when the person presses play.
21
+ * @overview
22
+ * <p>Video shows a poster with a play button. A YouTube or Vimeo player loads only on that click, so
23
+ * the page makes no request to the video site until the person asks for the video: no cookies, no
24
+ * tracking, and a faster page. YouTube plays through <code>youtube-nocookie.com</code> and Vimeo with
25
+ * Do Not Track, and a line on the poster says where the video plays from.</p>
26
+ * <p>Any other <code>src</code> is a video file, shown in the browser's own player with its
27
+ * controls. Put <code>&lt;track&gt;</code> elements in the video for captions and subtitles.</p>
28
+ * <p>The video keeps its <code>aspect-ratio</code> before and after it loads, so nothing on the page
29
+ * moves.</p>
30
+ *
31
+ * @slot - `<track>` elements for a video file's captions and subtitles.
32
+ *
33
+ * @csspart base - The frame that holds the poster or the player.
34
+ * @csspart play-button - The poster button that loads and plays the video.
35
+ * @csspart player - The `<iframe>` or `<video>`.
36
+ *
37
+ * @cssprop --video-shape - Corner radius of the frame. Defaults to `--shape-corner-large`.
38
+ *
39
+ * @fires {CustomEvent} play - Dispatched when the person starts the video: the player loads, or the file starts playing.
40
+ *
41
+ * @example
42
+ * ```html
43
+ * <wc-video
44
+ * src="https://www.youtube.com/watch?v=aqz-KE-bpKQ"
45
+ * label="Build a portal in ten minutes"
46
+ * duration="9:42"
47
+ * poster="/img/portal-video.webp"
48
+ * ></wc-video>
49
+ * ```
50
+ * @example
51
+ * ```html
52
+ * <wc-video src="/media/tour.mp4" poster="/media/tour.webp" label="Product tour">
53
+ * <track kind="captions" src="/media/tour.en.vtt" srclang="en" label="English" default />
54
+ * </wc-video>
55
+ * ```
56
+ * @tags media
57
+ */
58
+ @IndividualComponent
59
+ export class Video extends LitElement {
60
+ // ── Static ───────────────────────────────────────────────────────────────
61
+
62
+ static styles = [styles];
63
+
64
+ // ── Properties ───────────────────────────────────────────────────────────
65
+
66
+ /** A YouTube or Vimeo link, or the URL of a video file. */
67
+ @property({ reflect: true })
68
+ src = '';
69
+
70
+ /** An image shown before the video plays. Without one, the frame shows the label on a plain surface. */
71
+ @property({ reflect: true })
72
+ poster = '';
73
+
74
+ /** The video's title: shown on the poster, and the name of the play button and the player. */
75
+ @property({ reflect: true })
76
+ label = '';
77
+
78
+ /** The video's length as text, such as `9:42`, shown on the poster. */
79
+ @property({ reflect: true })
80
+ duration = '';
81
+
82
+ /** The frame's width to height, as a CSS `aspect-ratio`. */
83
+ @property({ attribute: 'aspect-ratio', reflect: true })
84
+ aspectRatio = '16 / 9';
85
+
86
+ // ── State ────────────────────────────────────────────────────────────────
87
+
88
+ /** Whether the person pressed play, so the YouTube or Vimeo player is loaded. */
89
+ @state() private loaded = false;
90
+
91
+ // ── Queries ──────────────────────────────────────────────────────────────
92
+
93
+ @query('.player') private readonly player?:
94
+ | HTMLIFrameElement
95
+ | HTMLVideoElement;
96
+
97
+ // ── Private fields ───────────────────────────────────────────────────────
98
+
99
+ private readonly i18n = new I18nController(this);
100
+
101
+ /** Whether the next update moves focus to the player that just loaded. */
102
+ private focusPlayer = false;
103
+
104
+ // ── Lifecycle ────────────────────────────────────────────────────────────
105
+
106
+ protected override willUpdate(changed: PropertyValues<this>) {
107
+ super.willUpdate(changed);
108
+ if (changed.has('src') && changed.get('src') !== undefined) {
109
+ this.loaded = false;
110
+ }
111
+ }
112
+
113
+ protected override updated(changed: PropertyValues<this>) {
114
+ super.updated(changed);
115
+ if (this.player instanceof HTMLVideoElement) this.syncTracks();
116
+ if (this.focusPlayer && this.player) {
117
+ this.focusPlayer = false;
118
+ this.player.focus();
119
+ }
120
+ }
121
+
122
+ // ── Public methods ───────────────────────────────────────────────────────
123
+
124
+ /** Where the video plays from, read from `src`. */
125
+ get provider(): VideoProvider {
126
+ return this.source.provider;
127
+ }
128
+
129
+ /** Loads the player and starts the video, as the play button does. */
130
+ play() {
131
+ if (this.player instanceof HTMLVideoElement) {
132
+ this.player.play().catch(() => {
133
+ // The browser refused to play without a gesture; its controls are still there.
134
+ });
135
+ return;
136
+ }
137
+ if (this.loaded) return;
138
+ this.loaded = true;
139
+ this.focusPlayer = true;
140
+ this.dispatchEvent(new CustomEvent('play'));
141
+ }
142
+
143
+ // ── Private methods ──────────────────────────────────────────────────────
144
+
145
+ private get source(): VideoSource {
146
+ return parseVideoSource(this.src);
147
+ }
148
+
149
+ private get name() {
150
+ return this.label || this.i18n.t('video');
151
+ }
152
+
153
+ /** Copies the light DOM `<track>` children into the shadow `<video>`, where tracks must be. */
154
+ private syncTracks() {
155
+ const video = this.player as HTMLVideoElement;
156
+ const tracks = Array.from(this.querySelectorAll(':scope > track'));
157
+ const current = Array.from(video.querySelectorAll('track'));
158
+ const same =
159
+ tracks.length === current.length &&
160
+ tracks.every((track, i) => track.isEqualNode(current[i]));
161
+ if (same) return;
162
+ current.forEach(track => track.remove());
163
+ tracks.forEach(track => video.append(track.cloneNode(true)));
164
+ }
165
+
166
+ private readonly handleSlotChange = () => {
167
+ if (this.player instanceof HTMLVideoElement) this.syncTracks();
168
+ };
169
+
170
+ private readonly handleVideoPlay = () => {
171
+ this.dispatchEvent(new CustomEvent('play'));
172
+ };
173
+
174
+ // ── Render helpers ───────────────────────────────────────────────────────
175
+
176
+ private renderFile(url: string) {
177
+ return html`<video
178
+ class="player"
179
+ part="player"
180
+ src=${url}
181
+ poster=${this.poster || nothing}
182
+ aria-label=${this.name}
183
+ controls
184
+ playsinline
185
+ preload="none"
186
+ @play=${this.handleVideoPlay}
187
+ ></video>`;
188
+ }
189
+
190
+ private renderEmbed(source: VideoSource) {
191
+ if (this.loaded) {
192
+ return html`<iframe
193
+ class="player"
194
+ part="player"
195
+ src=${source.url}
196
+ title=${this.name}
197
+ allow="autoplay; encrypted-media; fullscreen; picture-in-picture"
198
+ allowfullscreen
199
+ referrerpolicy="strict-origin-when-cross-origin"
200
+ ></iframe>`;
201
+ }
202
+ const from =
203
+ source.provider === 'youtube'
204
+ ? this.i18n.t('videoFromYouTube')
205
+ : this.i18n.t('videoFromVimeo');
206
+ return html`<button
207
+ id="play"
208
+ class="play-button"
209
+ part="play-button"
210
+ type="button"
211
+ aria-label=${this.i18n.t('playVideo')(this.name)}
212
+ @click=${() => this.play()}
213
+ >
214
+ ${this.poster
215
+ ? html`<img class="poster" src=${this.poster} alt="" />`
216
+ : nothing}
217
+ ${this.label
218
+ ? html`<span class="title" aria-hidden="true">${this.label}</span>`
219
+ : nothing}
220
+ <span class="play-icon" aria-hidden="true">
221
+ <wc-icon name="play_arrow"></wc-icon>
222
+ </span>
223
+ <span class="meta" aria-hidden="true">
224
+ <span>${from}</span>
225
+ ${this.duration ? html`<span>${this.duration}</span>` : nothing}
226
+ </span>
227
+ <wc-focus-ring class="focus-ring" for="play"></wc-focus-ring>
228
+ </button>`;
229
+ }
230
+
231
+ // ── Render ───────────────────────────────────────────────────────────────
232
+
233
+ render() {
234
+ const { source } = this;
235
+ return html`<div
236
+ class="frame"
237
+ part="base"
238
+ style=${styleMap({ aspectRatio: this.aspectRatio })}
239
+ >
240
+ ${source.provider === 'file'
241
+ ? this.renderFile(source.url)
242
+ : this.renderEmbed(source)}
243
+ </div>
244
+ <slot hidden @slotchange=${this.handleSlotChange}></slot>`;
245
+ }
246
+ }