@unlk/keymaster 1.6.2 → 1.6.4

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.
@@ -1,18 +1,18 @@
1
- import BaseComponent from 'bootstrap/js/src/base-component.js';
2
1
  import EventHandler from 'bootstrap/js/src/dom/event-handler.js';
3
2
  import SelectorEngine from 'bootstrap/js/src/dom/selector-engine.js';
4
- import { defineJQueryPlugin } from 'bootstrap/js/src/util/index.js';
5
3
 
6
- const NAME = 'carouselCaption';
7
- const EVENT_SLID = 'slid.bs.carousel';
4
+ const EVENT_SLID = 'slid.bs.carousel';
8
5
  const SELECTOR_CAROUSEL = '.carousel';
9
- const SELECTOR_CAPTION = '.carousel-caption-container p';
6
+ const SELECTOR_CAPTION = '.carousel-caption-container p';
10
7
 
11
- class CarouselCaption extends BaseComponent {
8
+ const instances = new WeakMap();
9
+
10
+ class CarouselCaption {
12
11
  constructor(element) {
13
- super(element);
14
- this._captionEl = this._findCaptionEl();
12
+ this._element = element;
13
+ this._captionEl = element.querySelector(SELECTOR_CAPTION) || null;
15
14
  this._updateCaption();
15
+ instances.set(element, this);
16
16
  }
17
17
 
18
18
  _updateCaption() {
@@ -21,18 +21,8 @@ class CarouselCaption extends BaseComponent {
21
21
  this._captionEl.textContent = activeItem?.getAttribute('data-caption') ?? '';
22
22
  }
23
23
 
24
- _findCaptionEl() {
25
- return this._element.querySelector(SELECTOR_CAPTION) || null;
26
- }
27
-
28
- static get NAME() {
29
- return NAME;
30
- }
31
-
32
- static jQueryInterface(config) {
33
- return this.each(function () {
34
- CarouselCaption.getOrCreateInstance(this, config);
35
- });
24
+ static getOrCreateInstance(element) {
25
+ return instances.get(element) || new CarouselCaption(element);
36
26
  }
37
27
  }
38
28
 
@@ -40,6 +30,4 @@ EventHandler.on(document, EVENT_SLID, SELECTOR_CAROUSEL, function () {
40
30
  CarouselCaption.getOrCreateInstance(this)._updateCaption();
41
31
  });
42
32
 
43
- defineJQueryPlugin(CarouselCaption);
44
-
45
33
  export default CarouselCaption;
@@ -1,56 +1,54 @@
1
- import BaseComponent from 'bootstrap/js/src/base-component.js';
2
1
  import EventHandler from 'bootstrap/js/src/dom/event-handler.js';
3
2
  import SelectorEngine from 'bootstrap/js/src/dom/selector-engine.js';
4
- import { defineJQueryPlugin } from 'bootstrap/js/src/util/index.js';
5
3
 
6
- const NAME = 'carouselHeight';
7
4
  const EVENT_SLIDE = 'slide.bs.carousel';
8
5
  const EVENT_SLID = 'slid.bs.carousel';
9
6
  const SELECTOR_CAROUSEL = '.carousel';
10
7
  const SELECTOR_INNER = '.carousel-inner';
11
8
 
12
- class CarouselHeight extends BaseComponent {
9
+ const instances = new WeakMap();
10
+
11
+ class CarouselHeight {
13
12
  constructor(element) {
14
- super(element);
15
- this._inner = SelectorEngine.findOne(SELECTOR_INNER, this._element);
13
+ this._element = element;
14
+ this._inner = SelectorEngine.findOne(SELECTOR_INNER, element);
15
+ if (this._inner) this._bindEvents();
16
+ instances.set(element, this);
17
+ }
18
+
19
+ dispose() {
20
+ EventHandler.off(this._element, EVENT_SLIDE);
21
+ EventHandler.off(this._element, EVENT_SLID);
22
+ instances.delete(this._element);
23
+ }
24
+
25
+ _bindEvents() {
26
+ EventHandler.on(this._element, EVENT_SLIDE, (e) => this._onSlide(e));
27
+ EventHandler.on(this._element, EVENT_SLID, () => this._onSlid());
16
28
  }
17
29
 
18
30
  _onSlide(e) {
19
- if (!this._inner) return;
20
31
  const nextSlide = e.relatedTarget;
21
32
  if (!nextSlide) return;
22
-
23
- this._inner.style.height = `${this._inner.offsetHeight}px`;
24
-
33
+ this._inner.style.height = `${this._inner.offsetHeight }px`;
25
34
  requestAnimationFrame(() => {
26
- this._inner.style.height = `${nextSlide.offsetHeight}px`;
35
+ this._inner.style.height = `${nextSlide.offsetHeight }px`;
27
36
  });
28
37
  }
29
38
 
30
39
  _onSlid() {
31
- if (!this._inner) return;
32
40
  this._inner.style.height = '';
33
41
  }
34
42
 
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
+ static getOrCreateInstance(element) {
44
+ return instances.get(element) || new CarouselHeight(element);
43
45
  }
44
46
  }
45
47
 
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();
48
+ document.addEventListener('DOMContentLoaded', () => {
49
+ for (const el of SelectorEngine.find(SELECTOR_CAROUSEL)) {
50
+ CarouselHeight.getOrCreateInstance(el);
51
+ }
52
52
  });
53
53
 
54
- defineJQueryPlugin(CarouselHeight);
55
-
56
54
  export default CarouselHeight;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unlk/keymaster",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -4,15 +4,15 @@
4
4
  align-items: center;
5
5
 
6
6
  // Icon on the left, add margin to its right
7
- > i:first-child,
8
- > .icon:first-child {
7
+ > i:first-child:not(:only-child),
8
+ > .icon:first-child:not(:only-child) {
9
9
  width: fit-content;
10
10
  margin-right: $spacer * .5;
11
11
  }
12
12
 
13
13
  // Icon on the right, add margin to its left
14
- > i:last-child,
15
- > .icon:last-child {
14
+ > i:last-child:not(:only-child),
15
+ > .icon:last-child:not(:only-child) {
16
16
  width: fit-content;
17
17
  margin-left: $spacer * .5;
18
18
  }
@@ -30,27 +30,29 @@
30
30
  }
31
31
  .btn-#{$color} {
32
32
  @if $color == "secondary" {
33
- @include button-variant(
33
+ @include custom-button-variant(
34
34
  $value,
35
35
  $value,
36
36
  $hover-background: tint-color($value, $btn-hover-bg-shade-amount),
37
37
  $hover-border: tint-color($value, $btn-hover-border-shade-amount),
38
38
  $active-background: tint-color($value, $btn-active-bg-shade-amount),
39
39
  $active-border: tint-color($value, $btn-active-border-shade-amount),
40
- $disabled-color: $gray-900
40
+
41
41
  );
42
42
  } @else {
43
- @include button-variant(
43
+ @include custom-button-variant(
44
44
  $value,
45
45
  $value,
46
46
  $hover-background: shade-color($value, $btn-hover-bg-shade-amount),
47
47
  $hover-border: shade-color($value, $btn-hover-border-shade-amount),
48
48
  $active-background: shade-color($value, $btn-active-bg-shade-amount),
49
49
  $active-border: shade-color($value, $btn-active-border-shade-amount),
50
- $disabled-color: $white
51
50
  );
52
51
  }
53
52
  }
53
+ .btn-outline-#{$color} {
54
+ @include custom-button-outline-variant($value);
55
+ }
54
56
  .btn-icon-#{$color} {
55
57
  @if $color == "secondary" {
56
58
  @include button-icon-variant(
@@ -69,7 +71,6 @@
69
71
  $hover-border: shade-color($value, $btn-hover-border-shade-amount),
70
72
  $active-background: shade-color($value, $btn-active-bg-shade-amount),
71
73
  $active-border: shade-color($value, $btn-active-border-shade-amount),
72
- $disabled-color: $white
73
74
  );
74
75
  }
75
76
  }
@@ -87,7 +88,6 @@
87
88
 
88
89
  [class*="btn-icon-"],
89
90
  [class*="btn-icon-outline-"] {
90
-
91
91
  &.btn-sm {
92
92
  width: rfs-value(32px);
93
93
  height: rfs-value(32px);
@@ -100,6 +100,7 @@
100
100
  height: rfs-value(48px);
101
101
  }
102
102
  }
103
+
103
104
  .btn-sm {
104
105
  > i:first-child,
105
106
  > .icon:first-child {
@@ -382,6 +382,7 @@ $btn-active-bg-shade-amount: 40% !default;
382
382
  $btn-active-bg-tint-amount: 20% !default;
383
383
  $btn-active-border-shade-amount: 40% !default;
384
384
  $btn-active-border-tint-amount: 10% !default;
385
+ $btn-disabled-opacity: 1 !default;
385
386
 
386
387
  // Border Radius
387
388
  $border-radius: .5rem !default;
@@ -1,2 +1,2 @@
1
1
  // GENERATED FILE – do not edit manually
2
- $km-version: "1.6.2" !default;
2
+ $km-version: "1.6.4" !default;
@@ -1,5 +1,4 @@
1
- // scss-docs-start btn-variant-mixin
2
- @mixin button-variant(
1
+ @mixin custom-button-variant(
3
2
  $background,
4
3
  $border,
5
4
  $color: color-contrast($background),
@@ -9,9 +8,9 @@
9
8
  $active-background: if($color == $color-contrast-light, shade-color($background, $btn-active-bg-shade-amount), tint-color($background, $btn-active-bg-tint-amount)),
10
9
  $active-border: if($color == $color-contrast-light, shade-color($border, $btn-active-border-shade-amount), tint-color($border, $btn-active-border-tint-amount)),
11
10
  $active-color: color-contrast($active-background),
12
- $disabled-background: rgba($background, 1),
13
- $disabled-border: rgba($border, 1),
14
- $disabled-color: color-contrast($disabled-background)
11
+ $disabled-background: $gray-200,
12
+ $disabled-border: $gray-200,
13
+ $disabled-color: $gray-400
15
14
  ) {
16
15
  --#{$prefix}btn-color: #{$color};
17
16
  --#{$prefix}btn-bg: #{$background};
@@ -28,7 +27,35 @@
28
27
  --#{$prefix}btn-disabled-bg: #{$disabled-background};
29
28
  --#{$prefix}btn-disabled-border-color: #{$disabled-border};
30
29
  }
31
- // scss-docs-end btn-variant-mixin
30
+
31
+ @mixin custom-button-outline-variant(
32
+ $color,
33
+ $btn-color: $color,
34
+ $btn-border: $color,
35
+ $color-hover: $color,
36
+ $hover-background: tint-color($color, 90%),
37
+ $hover-border: $color,
38
+ $active-background: shade-color($color, 20%),
39
+ $active-border: shade-color($color, 20%),
40
+ $active-color: color-contrast($active-background),
41
+ $disabled-color: $gray-400,
42
+ $disabled-border: $gray-200,
43
+ ) {
44
+ --#{$prefix}btn-color: #{$btn-color};
45
+ --#{$prefix}btn-border-color: #{$btn-border};
46
+ --#{$prefix}btn-hover-color: #{$color-hover};
47
+ --#{$prefix}btn-hover-bg: #{$hover-background};
48
+ --#{$prefix}btn-hover-border-color: #{$hover-border};
49
+ --#{$prefix}btn-focus-shadow-rgb: #{to-rgb($color)};
50
+ --#{$prefix}btn-active-color: #{$active-color};
51
+ --#{$prefix}btn-active-bg: #{$active-background};
52
+ --#{$prefix}btn-active-border-color: #{$active-border};
53
+ --#{$prefix}btn-active-shadow: #{$btn-active-box-shadow};
54
+ --#{$prefix}btn-disabled-color: #{$disabled-color};
55
+ --#{$prefix}btn-disabled-bg: transparent;
56
+ --#{$prefix}btn-disabled-border-color: #{$disabled-border};
57
+ --#{$prefix}gradient: none;
58
+ }
32
59
 
33
60
  @mixin button-link-variant(
34
61
  $color,
@@ -37,7 +64,7 @@
37
64
  $active-background: shade-color($color, 20%),
38
65
  $active-border: $color,
39
66
  $active-color: $white,
40
- $disabled-color: $gray-300
67
+ $disabled-color: $gray-400
41
68
  ) {
42
69
  --#{$prefix}btn-color: #{$btn-color};
43
70
  --#{$prefix}btn-bg: transparent;
@@ -65,9 +92,9 @@
65
92
  $active-background: if($color == $color-contrast-light, shade-color($background, $btn-active-bg-shade-amount), tint-color($background, $btn-active-bg-tint-amount)),
66
93
  $active-border: if($color == $color-contrast-light, shade-color($border, $btn-active-border-shade-amount), tint-color($border, $btn-active-border-tint-amount)),
67
94
  $active-color: color-contrast($active-background),
68
- $disabled-background: rgba($background, 1),
69
- $disabled-border: rgba($border, 1),
70
- $disabled-color: color-contrast($disabled-background)
95
+ $disabled-background: $gray-200,
96
+ $disabled-border: $gray-200,
97
+ $disabled-color: $gray-400,
71
98
  ) {
72
99
  width: rfs-value(40px);
73
100
  height: rfs-value(40px);
@@ -100,8 +127,8 @@
100
127
  $active-border: if($color == $color-contrast-light, shade-color($border, $btn-active-border-shade-amount), tint-color($border, $btn-active-border-tint-amount)),
101
128
  $active-color: color-contrast($active-background),
102
129
  $disabled-background: transparent,
103
- $disabled-border: rgba($border, 1),
104
- $disabled-color: rgba($color, 1)
130
+ $disabled-border: $gray-200,
131
+ $disabled-color: $gray-400
105
132
  ) {
106
133
  width: rfs-value(40px);
107
134
  height: rfs-value(40px);