@unlk/keymaster 1.4.2 → 1.4.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/CHANGELOG.md +18 -0
- package/dist/css/keymaster.css +123 -16
- package/dist/css/keymaster.css.map +1 -1
- package/dist/css/keymaster.min.css +12 -12
- package/dist/css/keymaster.min.css.map +1 -1
- package/dist/js/keymaster.js +126 -110
- package/dist/js/keymaster.js.map +1 -1
- package/dist/js/keymaster.min.js +14 -14
- package/dist/js/keymaster.min.js.map +1 -1
- package/js/bootstrap.js +1 -0
- package/js/carousel-caption.js +5 -26
- package/js/carousel-height.js +56 -0
- package/js/datepicker.js +1 -1
- package/js/video-modal.js +18 -27
- package/package.json +7 -7
- package/scss/theme/_carousel.scss +4 -0
- package/scss/theme/_root.scss +7 -0
- package/scss/theme/_version.scss +1 -1
package/js/bootstrap.js
CHANGED
|
@@ -12,4 +12,5 @@ export { default as Tab } from 'bootstrap/js/dist/tab';
|
|
|
12
12
|
export { default as Tooltip } from 'bootstrap/js/dist/tooltip';
|
|
13
13
|
export { default as Datepicker } from './datepicker';
|
|
14
14
|
export { default as CarouselCaption } from './carousel-caption';
|
|
15
|
+
export { default as CarouselHeight } from './carousel-height';
|
|
15
16
|
export { default as VideoModal } from './video-modal';
|
package/js/carousel-caption.js
CHANGED
|
@@ -4,7 +4,6 @@ import SelectorEngine from 'bootstrap/js/src/dom/selector-engine.js';
|
|
|
4
4
|
import { defineJQueryPlugin } from 'bootstrap/js/src/util/index.js';
|
|
5
5
|
|
|
6
6
|
const NAME = 'carouselCaption';
|
|
7
|
-
const DATA_KEY = 'bs.carouselCaption';
|
|
8
7
|
const EVENT_SLID = 'slid.bs.carousel';
|
|
9
8
|
const SELECTOR_CAROUSEL = '.carousel';
|
|
10
9
|
const SELECTOR_CAPTION = '.carousel-caption-container p';
|
|
@@ -12,31 +11,14 @@ const SELECTOR_CAPTION = '.carousel-caption-container p';
|
|
|
12
11
|
class CarouselCaption extends BaseComponent {
|
|
13
12
|
constructor(element) {
|
|
14
13
|
super(element);
|
|
15
|
-
|
|
16
14
|
this._captionEl = this._findCaptionEl();
|
|
17
|
-
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
this._updateCaption(); // Initialize
|
|
22
|
-
this._bindEvents();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
dispose() {
|
|
26
|
-
EventHandler.off(this._element, EVENT_SLID);
|
|
27
|
-
super.dispose();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
_bindEvents() {
|
|
31
|
-
EventHandler.on(this._element, EVENT_SLID, () => this._updateCaption());
|
|
15
|
+
this._updateCaption();
|
|
32
16
|
}
|
|
33
17
|
|
|
34
18
|
_updateCaption() {
|
|
19
|
+
if (!this._captionEl) return;
|
|
35
20
|
const activeItem = SelectorEngine.findOne('.carousel-item.active', this._element);
|
|
36
|
-
|
|
37
|
-
if (this._captionEl && newCaption) {
|
|
38
|
-
this._captionEl.textContent = newCaption || '';
|
|
39
|
-
}
|
|
21
|
+
this._captionEl.textContent = activeItem?.getAttribute('data-caption') ?? '';
|
|
40
22
|
}
|
|
41
23
|
|
|
42
24
|
_findCaptionEl() {
|
|
@@ -54,11 +36,8 @@ class CarouselCaption extends BaseComponent {
|
|
|
54
36
|
}
|
|
55
37
|
}
|
|
56
38
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
for (const el of SelectorEngine.find(SELECTOR_CAROUSEL)) {
|
|
60
|
-
CarouselCaption.getOrCreateInstance(el);
|
|
61
|
-
}
|
|
39
|
+
EventHandler.on(document, EVENT_SLID, SELECTOR_CAROUSEL, function () {
|
|
40
|
+
CarouselCaption.getOrCreateInstance(this)._updateCaption();
|
|
62
41
|
});
|
|
63
42
|
|
|
64
43
|
defineJQueryPlugin(CarouselCaption);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import BaseComponent from 'bootstrap/js/src/base-component.js';
|
|
2
|
+
import EventHandler from 'bootstrap/js/src/dom/event-handler.js';
|
|
3
|
+
import SelectorEngine from 'bootstrap/js/src/dom/selector-engine.js';
|
|
4
|
+
import { defineJQueryPlugin } from 'bootstrap/js/src/util/index.js';
|
|
5
|
+
|
|
6
|
+
const NAME = 'carouselHeight';
|
|
7
|
+
const EVENT_SLIDE = 'slide.bs.carousel';
|
|
8
|
+
const EVENT_SLID = 'slid.bs.carousel';
|
|
9
|
+
const SELECTOR_CAROUSEL = '.carousel';
|
|
10
|
+
const SELECTOR_INNER = '.carousel-inner';
|
|
11
|
+
|
|
12
|
+
class CarouselHeight extends BaseComponent {
|
|
13
|
+
constructor(element) {
|
|
14
|
+
super(element);
|
|
15
|
+
this._inner = SelectorEngine.findOne(SELECTOR_INNER, this._element);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_onSlide(e) {
|
|
19
|
+
if (!this._inner) return;
|
|
20
|
+
const nextSlide = e.relatedTarget;
|
|
21
|
+
if (!nextSlide) return;
|
|
22
|
+
|
|
23
|
+
this._inner.style.height = `${this._inner.offsetHeight}px`;
|
|
24
|
+
|
|
25
|
+
requestAnimationFrame(() => {
|
|
26
|
+
this._inner.style.height = `${nextSlide.offsetHeight}px`;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_onSlid() {
|
|
31
|
+
if (!this._inner) return;
|
|
32
|
+
this._inner.style.height = '';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static get NAME() {
|
|
36
|
+
return NAME;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static jQueryInterface(config) {
|
|
40
|
+
return this.each(function () {
|
|
41
|
+
CarouselHeight.getOrCreateInstance(this, config);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
EventHandler.on(document, EVENT_SLIDE, SELECTOR_CAROUSEL, function (e) {
|
|
47
|
+
CarouselHeight.getOrCreateInstance(this)._onSlide(e);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
EventHandler.on(document, EVENT_SLID, SELECTOR_CAROUSEL, function () {
|
|
51
|
+
CarouselHeight.getOrCreateInstance(this)._onSlid();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
defineJQueryPlugin(CarouselHeight);
|
|
55
|
+
|
|
56
|
+
export default CarouselHeight;
|
package/js/datepicker.js
CHANGED
|
@@ -67,7 +67,7 @@ EventHandler.on(document, EVENT_FOCUS_DATA_API, SELECTOR_INPUT, (event) => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
function isTouchDevice() {
|
|
70
|
-
return 'ontouchstart' in
|
|
70
|
+
return 'ontouchstart' in globalThis || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
package/js/video-modal.js
CHANGED
|
@@ -4,24 +4,25 @@ import SelectorEngine from 'bootstrap/js/src/dom/selector-engine.js';
|
|
|
4
4
|
import { defineJQueryPlugin } from 'bootstrap/js/src/util/index.js';
|
|
5
5
|
|
|
6
6
|
const NAME = 'videoModal';
|
|
7
|
-
const DATA_KEY = 'bs.videoModal';
|
|
8
7
|
const EVENT_SHOW = 'show.bs.modal';
|
|
9
8
|
const EVENT_HIDDEN = 'hidden.bs.modal';
|
|
9
|
+
const SELECTOR_MODAL = '.modal';
|
|
10
10
|
const SELECTOR_DIALOG = '.modal-dialog-media';
|
|
11
11
|
const SELECTOR_RATIO = '.ratio';
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line no-unused-vars
|
|
14
14
|
let youTubeAPIReady = false;
|
|
15
15
|
const youTubeAPIInitPromise = new Promise((resolve) => {
|
|
16
|
-
if (
|
|
16
|
+
if (globalThis.YT?.Player) {
|
|
17
17
|
youTubeAPIReady = true;
|
|
18
18
|
resolve();
|
|
19
19
|
} else {
|
|
20
|
-
const prev =
|
|
21
|
-
|
|
20
|
+
const prev = globalThis.onYouTubeIframeAPIReady;
|
|
21
|
+
globalThis.onYouTubeIframeAPIReady = () => {
|
|
22
22
|
try {
|
|
23
23
|
if (typeof prev === 'function') prev();
|
|
24
24
|
} catch {}
|
|
25
|
+
|
|
25
26
|
youTubeAPIReady = true;
|
|
26
27
|
resolve();
|
|
27
28
|
};
|
|
@@ -35,7 +36,7 @@ const youTubeAPIInitPromise = new Promise((resolve) => {
|
|
|
35
36
|
// eslint-disable-next-line no-unused-vars
|
|
36
37
|
let vimeoAPIReady = false;
|
|
37
38
|
const vimeoAPIInitPromise = new Promise((resolve) => {
|
|
38
|
-
if (
|
|
39
|
+
if (globalThis.Vimeo?.Player) {
|
|
39
40
|
vimeoAPIReady = true;
|
|
40
41
|
resolve();
|
|
41
42
|
} else {
|
|
@@ -56,18 +57,10 @@ class VideoModal extends BaseComponent {
|
|
|
56
57
|
|
|
57
58
|
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
|
|
58
59
|
this._container = SelectorEngine.findOne(SELECTOR_RATIO, this._element);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this._youtubeSrc = this._container.getAttribute('data-src');
|
|
65
|
-
this._vimeoUrl = this._container.getAttribute('data-vimeo-url');
|
|
60
|
+
this._youtubeSrc = this._container?.getAttribute('data-src');
|
|
61
|
+
this._vimeoUrl = this._container?.getAttribute('data-vimeo-url');
|
|
66
62
|
this._youtubePlayer = null;
|
|
67
63
|
this._vimeoPlayer = null;
|
|
68
|
-
|
|
69
|
-
EventHandler.on(this._element, EVENT_SHOW, () => this._onShow());
|
|
70
|
-
EventHandler.on(this._element, EVENT_HIDDEN, () => this._onHide());
|
|
71
64
|
}
|
|
72
65
|
|
|
73
66
|
dispose() {
|
|
@@ -83,7 +76,7 @@ class VideoModal extends BaseComponent {
|
|
|
83
76
|
await vimeoAPIInitPromise;
|
|
84
77
|
const vimeoId = this._getVimeoId(this._vimeoUrl);
|
|
85
78
|
|
|
86
|
-
this._vimeoPlayer = new
|
|
79
|
+
this._vimeoPlayer = new globalThis.Vimeo.Player(this._container, {
|
|
87
80
|
id: vimeoId,
|
|
88
81
|
autoplay: true
|
|
89
82
|
});
|
|
@@ -99,7 +92,7 @@ class VideoModal extends BaseComponent {
|
|
|
99
92
|
const youtubeId = this._getYouTubeId(this._youtubeSrc);
|
|
100
93
|
const playerDiv = this._container.querySelector(`#${playerID}`);
|
|
101
94
|
|
|
102
|
-
this._youtubePlayer = new
|
|
95
|
+
this._youtubePlayer = new globalThis.YT.Player(playerDiv, {
|
|
103
96
|
videoId: youtubeId,
|
|
104
97
|
playerVars: { autoplay: 1, rel: 0 }
|
|
105
98
|
});
|
|
@@ -147,16 +140,14 @@ class VideoModal extends BaseComponent {
|
|
|
147
140
|
}
|
|
148
141
|
}
|
|
149
142
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
}
|
|
143
|
+
EventHandler.on(document, EVENT_SHOW, SELECTOR_MODAL, function () {
|
|
144
|
+
if (!SelectorEngine.findOne(SELECTOR_DIALOG, this)) return;
|
|
145
|
+
VideoModal.getOrCreateInstance(this)._onShow();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
EventHandler.on(document, EVENT_HIDDEN, SELECTOR_MODAL, function () {
|
|
149
|
+
if (!SelectorEngine.findOne(SELECTOR_DIALOG, this)) return;
|
|
150
|
+
VideoModal.getOrCreateInstance(this)._onHide();
|
|
160
151
|
});
|
|
161
152
|
|
|
162
153
|
defineJQueryPlugin(VideoModal);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unlk/keymaster",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"bs": "browser-sync start --config build/browser-sync.config.js",
|
|
11
|
-
"css": "npm-run-all css-compile css-postcss css-minify",
|
|
11
|
+
"css": "npm-run-all css-lint css-compile css-postcss css-minify",
|
|
12
12
|
"css-compile": "sass --style expanded --source-map --embed-sources --no-error-css --quiet scss/keymaster.scss:dist/css/keymaster.css",
|
|
13
|
-
"css-lint": "stylelint \"**/*.{css
|
|
13
|
+
"css-lint": "stylelint \"**/*.{scss,css}\" --cache --cache-location .cache/.stylelintcache --rd",
|
|
14
14
|
"css-minify": "cleancss -O1 --format breakWith=lf --with-rebase --source-map --source-map-inline-sources --output dist/css/ --batch --batch-suffix \".min\" \"dist/css/*.css\" \"!dist/css/*.min.css\" \"!dist/css/*rtl*.css\"",
|
|
15
15
|
"css-postcss": "postcss --config build/postcss.config.js --replace \"dist/css/*.css\" \"!dist/css/*.rtl*.css\" \"!dist/css/*.min.css\"",
|
|
16
|
-
"js": "npm-run-all js-compile js-minify",
|
|
16
|
+
"js": "npm-run-all js-lint js-compile js-minify",
|
|
17
17
|
"js-compile": "rollup --config build/rollup.config.js --sourcemap",
|
|
18
18
|
"js-lint": "eslint --cache --cache-location .cache/.eslintcache --report-unused-disable-directives --ext .html,.js .",
|
|
19
19
|
"js-minify": "terser --config-file build/terser.config.json --output dist/js/keymaster.min.js dist/js/keymaster.js",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"@babel/preset-env": "^7.27.2",
|
|
59
59
|
"@fortawesome/fontawesome-pro": "^7.0.0",
|
|
60
60
|
"@popperjs/core": "^2.11.8",
|
|
61
|
-
"@rollup/plugin-babel": "^
|
|
62
|
-
"@rollup/plugin-commonjs": "^
|
|
63
|
-
"@rollup/plugin-multi-entry": "^
|
|
61
|
+
"@rollup/plugin-babel": "^7.0.0",
|
|
62
|
+
"@rollup/plugin-commonjs": "^29.0.2",
|
|
63
|
+
"@rollup/plugin-multi-entry": "^7.1.0",
|
|
64
64
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
65
65
|
"@rollup/plugin-replace": "^6.0.2",
|
|
66
66
|
"autoprefixer": "^10.4.21",
|
package/scss/theme/_root.scss
CHANGED
|
@@ -3,4 +3,11 @@
|
|
|
3
3
|
--#{$prefix}border-radius-xs: #{$border-radius-xs};
|
|
4
4
|
--#{$prefix}font-weight-medium: #{$font-weight-medium};
|
|
5
5
|
--#{$prefix}font-weight-bold: #{$font-weight-bold};
|
|
6
|
+
$non-gray-colors: $all-colors;
|
|
7
|
+
@each $key, $value in $grays {
|
|
8
|
+
$non-gray-colors: map-remove($non-gray-colors, $key);
|
|
9
|
+
}
|
|
10
|
+
@each $color, $value in $non-gray-colors {
|
|
11
|
+
--#{$prefix}#{$color}: #{$value};
|
|
12
|
+
}
|
|
6
13
|
}
|
package/scss/theme/_version.scss
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// GENERATED FILE – do not edit manually
|
|
2
|
-
$km-version: "1.4.
|
|
2
|
+
$km-version: "1.4.5" !default;
|