@unlk/keymaster 1.2.3 → 1.2.5

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/js/video-modal.js CHANGED
@@ -5,12 +5,11 @@ import { defineJQueryPlugin } from 'bootstrap/js/src/util/index.js';
5
5
 
6
6
  const NAME = 'videoModal';
7
7
  const DATA_KEY = 'bs.videoModal';
8
- const EVENT_SHOW = 'show.bs.modal';
8
+ const EVENT_SHOWN = 'shown.bs.modal';
9
9
  const EVENT_HIDDEN = 'hidden.bs.modal';
10
10
  const SELECTOR_DIALOG = '.modal-dialog-media';
11
11
  const SELECTOR_RATIO = '.ratio';
12
12
 
13
- // eslint-disable-next-line no-unused-vars
14
13
  let youTubeAPIReady = false;
15
14
  const youTubeAPIInitPromise = new Promise((resolve) => {
16
15
  if (window.YT?.Player) {
@@ -21,14 +20,12 @@ const youTubeAPIInitPromise = new Promise((resolve) => {
21
20
  youTubeAPIReady = true;
22
21
  resolve();
23
22
  };
24
-
25
23
  const script = document.createElement('script');
26
24
  script.src = 'https://www.youtube.com/iframe_api';
27
25
  document.head.append(script);
28
26
  }
29
27
  });
30
28
 
31
- // eslint-disable-next-line no-unused-vars
32
29
  let vimeoAPIReady = false;
33
30
  const vimeoAPIInitPromise = new Promise((resolve) => {
34
31
  if (window.Vimeo?.Player) {
@@ -41,7 +38,6 @@ const vimeoAPIInitPromise = new Promise((resolve) => {
41
38
  vimeoAPIReady = true;
42
39
  resolve();
43
40
  });
44
-
45
41
  document.head.append(script);
46
42
  }
47
43
  });
@@ -62,7 +58,7 @@ class VideoModal extends BaseComponent {
62
58
  this._youtubePlayer = null;
63
59
  this._vimeoPlayer = null;
64
60
 
65
- EventHandler.on(this._element, EVENT_SHOW, () => this._onShow());
61
+ EventHandler.on(this._element, EVENT_SHOWN, () => this._onShown());
66
62
  EventHandler.on(this._element, EVENT_HIDDEN, () => this._onHide());
67
63
  }
68
64
 
@@ -71,27 +67,52 @@ class VideoModal extends BaseComponent {
71
67
  super.dispose();
72
68
  }
73
69
 
74
- async _onShow() {
75
- const { id } = this._element;
76
- const playerClass = `${id}-youtube-player`;
70
+ async _onShown() {
71
+ // Reset container each time
72
+ this._container.innerHTML = '';
77
73
 
78
74
  if (this._vimeoUrl) {
79
75
  await vimeoAPIInitPromise;
80
76
  const vimeoId = this._getVimeoId(this._vimeoUrl);
77
+ if (!vimeoId) return;
81
78
  this._vimeoPlayer = new window.Vimeo.Player(this._container, {
82
79
  id: vimeoId,
83
- autoplay: true
80
+ autoplay: true,
81
+ muted: true,
82
+ playsinline: true,
83
+ dnt: true
84
84
  });
85
+ this._vimeoPlayer.play?.().catch(() => {});
85
86
  }
86
87
 
87
88
  if (this._youtubeSrc) {
88
89
  await youTubeAPIInitPromise;
89
90
  const youtubeId = this._getYouTubeId(this._youtubeSrc);
90
- this._container.innerHTML = `<div class="${playerClass} w-100 h-100"></div>`;
91
- const playerDiv = this._container.querySelector(`.${playerClass}`);
91
+ if (!youtubeId) {
92
+ console.warn('[VideoModal] No YouTube ID parsed from', this._youtubeSrc);
93
+ return;
94
+ }
95
+
96
+ const playerDiv = document.createElement('div');
97
+ playerDiv.className = 'w-100 h-100';
98
+ this._container.appendChild(playerDiv);
99
+
92
100
  this._youtubePlayer = new window.YT.Player(playerDiv, {
93
101
  videoId: youtubeId,
94
- playerVars: { autoplay: 1, rel: 0 }
102
+ host: 'https://www.youtube-nocookie.com',
103
+ playerVars: {
104
+ autoplay: 1,
105
+ rel: 0,
106
+ playsinline: 1,
107
+ origin: window.location.origin
108
+ },
109
+ events: {
110
+ onReady: (e) => {
111
+ try { e.target.mute(); } catch {}
112
+ try { e.target.playVideo(); } catch {}
113
+ },
114
+ onError: (e) => console.warn('[VideoModal] YT error', e?.data)
115
+ }
95
116
  });
96
117
  }
97
118
  }
@@ -101,20 +122,22 @@ class VideoModal extends BaseComponent {
101
122
  this._vimeoPlayer.unload().catch(() => {});
102
123
  this._vimeoPlayer = null;
103
124
  }
104
-
105
125
  if (this._youtubePlayer) {
106
- this._youtubePlayer.destroy();
126
+ try { this._youtubePlayer.destroy(); } catch {}
107
127
  this._youtubePlayer = null;
108
128
  }
129
+ this._container.innerHTML = '';
109
130
  }
110
131
 
111
132
  _getYouTubeId(url) {
112
- const match = url.match(/(?:v=|youtu\.be\/)([\w-]{11})/);
113
- return match ? match[1] : '';
133
+ if (!url) return '';
134
+ // robust: supports v=, youtu.be/, embed/, shorts/
135
+ const m = String(url).match(/(?:v=|youtu\.be\/|embed\/|shorts\/)([\w-]{11})/);
136
+ return m ? m[1] : '';
114
137
  }
115
138
 
116
139
  _getVimeoId(url) {
117
- const match = url.match(/vimeo\.com\/(\d+)/);
140
+ const match = String(url).match(/vimeo\.com\/(\d+)/);
118
141
  return match ? match[1] : '';
119
142
  }
120
143
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unlk/keymaster",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -29,8 +29,10 @@
29
29
  @include button-variant(
30
30
  $value,
31
31
  $value,
32
+ $color: $body-color,
32
33
  $hover-background: tint-color($value, $btn-hover-bg-shade-amount),
33
34
  $hover-border: tint-color($value, $btn-hover-border-shade-amount),
35
+ $hover-color: $body-color,
34
36
  $active-background: tint-color($value, $btn-active-bg-shade-amount),
35
37
  $active-border: tint-color($value, $btn-active-border-shade-amount),
36
38
  $disabled-color: $gray-950
@@ -0,0 +1,61 @@
1
+ //stylelint-disable selector-class-pattern, declaration-no-important, selector-max-id
2
+ .root__A7aXF * {
3
+ font-family: $font-family-base !important;
4
+ }
5
+ //stylelint-disable-next-line
6
+ #lanyard_root * {
7
+ .\!ketch-bg-\[--k-preference-tabs-purposes-purposeListHeader-rejectAllButton-background-color\] {
8
+ @extend .btn;
9
+ @extend .btn-sm;
10
+ @extend .btn-secondary;
11
+ &:hover {
12
+ --tw-gradient-to: none !important;
13
+ --tw-gradient-from: none !important;
14
+ --tw-gradient-stops: none !important;
15
+ background-color: var(--#{$prefix}btn-hover-bg) !important;
16
+ border-color: var(--#{$prefix}btn-hover-border-color) !important;
17
+ }
18
+ }
19
+ .\!ketch-bg-\[--k-preference-tabs-purposes-purposeListHeader-acceptAllButton-background-color\] {
20
+ @extend .btn;
21
+ @extend .btn-sm;
22
+ @extend .btn-action;
23
+ &:hover {
24
+ --tw-gradient-to: none !important;
25
+ --tw-gradient-from: none !important;
26
+ --tw-gradient-stops: none !important;
27
+ background-color: var(--#{$prefix}btn-hover-bg) !important;
28
+ border-color: var(--#{$prefix}btn-hover-border-color) !important;
29
+ }
30
+
31
+
32
+ }
33
+ input,
34
+ textarea {
35
+ @extend .form-control;
36
+ border-width: $input-border-width !important;
37
+ }
38
+ }
39
+
40
+ #ketch-banner-button-primary {
41
+ @extend .btn;
42
+ @extend .btn-action;
43
+ }
44
+
45
+ button {
46
+ font-weight: $btn-font-weight !important;
47
+ }
48
+
49
+ #ketch-banner-button-secondary {
50
+ @extend .btn;
51
+ @extend .btn-secondary;
52
+ &:hover {
53
+ --k-banner-buttons-secondary-background-color: var(--#{$prefix}btn-hover-bg);
54
+ --tw-gradient-to: none !important;
55
+ --tw-gradient-from: none !important;
56
+ --tw-gradient-stops: none !important;
57
+ background-color: var(--#{$prefix}btn-hover-bg) !important;
58
+ border-color: var(--#{$prefix}btn-hover-border-color) !important;
59
+ }
60
+ }
61
+ //stylelint-enable selector-class-pattern, declaration-no-important, selector-max-id