@mintplayer/ng-bootstrap 21.7.0 → 21.9.0

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 (65) hide show
  1. package/fesm2022/mintplayer-ng-bootstrap-accordion.mjs +16 -9
  2. package/fesm2022/mintplayer-ng-bootstrap-accordion.mjs.map +1 -1
  3. package/fesm2022/mintplayer-ng-bootstrap-calendar.mjs +2 -2
  4. package/fesm2022/mintplayer-ng-bootstrap-calendar.mjs.map +1 -1
  5. package/fesm2022/mintplayer-ng-bootstrap-code-snippet.mjs +4 -4
  6. package/fesm2022/mintplayer-ng-bootstrap-code-snippet.mjs.map +1 -1
  7. package/fesm2022/mintplayer-ng-bootstrap-color-picker.mjs +133 -130
  8. package/fesm2022/mintplayer-ng-bootstrap-color-picker.mjs.map +1 -1
  9. package/fesm2022/mintplayer-ng-bootstrap-dock.mjs +6 -6
  10. package/fesm2022/mintplayer-ng-bootstrap-dock.mjs.map +1 -1
  11. package/fesm2022/mintplayer-ng-bootstrap-dropdown-menu.mjs +5 -5
  12. package/fesm2022/mintplayer-ng-bootstrap-dropdown-menu.mjs.map +1 -1
  13. package/fesm2022/mintplayer-ng-bootstrap-dropdown.mjs +3 -0
  14. package/fesm2022/mintplayer-ng-bootstrap-dropdown.mjs.map +1 -1
  15. package/fesm2022/mintplayer-ng-bootstrap-file-upload.mjs +8 -9
  16. package/fesm2022/mintplayer-ng-bootstrap-file-upload.mjs.map +1 -1
  17. package/fesm2022/mintplayer-ng-bootstrap-modal.mjs +6 -8
  18. package/fesm2022/mintplayer-ng-bootstrap-modal.mjs.map +1 -1
  19. package/fesm2022/mintplayer-ng-bootstrap-multiselect.mjs +3 -3
  20. package/fesm2022/mintplayer-ng-bootstrap-multiselect.mjs.map +1 -1
  21. package/fesm2022/mintplayer-ng-bootstrap-navbar.mjs +25 -6
  22. package/fesm2022/mintplayer-ng-bootstrap-navbar.mjs.map +1 -1
  23. package/fesm2022/mintplayer-ng-bootstrap-range.mjs +16 -16
  24. package/fesm2022/mintplayer-ng-bootstrap-range.mjs.map +1 -1
  25. package/fesm2022/mintplayer-ng-bootstrap-resizable.mjs +58 -47
  26. package/fesm2022/mintplayer-ng-bootstrap-resizable.mjs.map +1 -1
  27. package/fesm2022/mintplayer-ng-bootstrap-scrollspy.mjs +8 -8
  28. package/fesm2022/mintplayer-ng-bootstrap-scrollspy.mjs.map +1 -1
  29. package/fesm2022/mintplayer-ng-bootstrap-searchbox.mjs +3 -1
  30. package/fesm2022/mintplayer-ng-bootstrap-searchbox.mjs.map +1 -1
  31. package/fesm2022/mintplayer-ng-bootstrap-select.mjs +48 -49
  32. package/fesm2022/mintplayer-ng-bootstrap-select.mjs.map +1 -1
  33. package/fesm2022/mintplayer-ng-bootstrap-select2.mjs +7 -7
  34. package/fesm2022/mintplayer-ng-bootstrap-select2.mjs.map +1 -1
  35. package/fesm2022/mintplayer-ng-bootstrap-shell.mjs +5 -5
  36. package/fesm2022/mintplayer-ng-bootstrap-shell.mjs.map +1 -1
  37. package/fesm2022/mintplayer-ng-bootstrap-tab-control.mjs +12 -6
  38. package/fesm2022/mintplayer-ng-bootstrap-tab-control.mjs.map +1 -1
  39. package/fesm2022/mintplayer-ng-bootstrap-timepicker.mjs +7 -7
  40. package/fesm2022/mintplayer-ng-bootstrap-timepicker.mjs.map +1 -1
  41. package/fesm2022/mintplayer-ng-bootstrap-toast.mjs +15 -18
  42. package/fesm2022/mintplayer-ng-bootstrap-toast.mjs.map +1 -1
  43. package/fesm2022/mintplayer-ng-bootstrap-toggle-button.mjs +102 -102
  44. package/fesm2022/mintplayer-ng-bootstrap-toggle-button.mjs.map +1 -1
  45. package/fesm2022/mintplayer-ng-bootstrap-typeahead.mjs +7 -7
  46. package/fesm2022/mintplayer-ng-bootstrap-typeahead.mjs.map +1 -1
  47. package/package.json +2 -2
  48. package/types/mintplayer-ng-bootstrap-accordion.d.ts +5 -3
  49. package/types/mintplayer-ng-bootstrap-code-snippet.d.ts +2 -2
  50. package/types/mintplayer-ng-bootstrap-color-picker.d.ts +37 -34
  51. package/types/mintplayer-ng-bootstrap-dock.d.ts +1 -1
  52. package/types/mintplayer-ng-bootstrap-dropdown-menu.d.ts +9 -9
  53. package/types/mintplayer-ng-bootstrap-file-upload.d.ts +1 -1
  54. package/types/mintplayer-ng-bootstrap-modal.d.ts +1 -1
  55. package/types/mintplayer-ng-bootstrap-navbar.d.ts +5 -3
  56. package/types/mintplayer-ng-bootstrap-range.d.ts +9 -9
  57. package/types/mintplayer-ng-bootstrap-resizable.d.ts +10 -10
  58. package/types/mintplayer-ng-bootstrap-scrollspy.d.ts +1 -1
  59. package/types/mintplayer-ng-bootstrap-select.d.ts +16 -16
  60. package/types/mintplayer-ng-bootstrap-select2.d.ts +3 -3
  61. package/types/mintplayer-ng-bootstrap-shell.d.ts +1 -1
  62. package/types/mintplayer-ng-bootstrap-tab-control.d.ts +1 -1
  63. package/types/mintplayer-ng-bootstrap-timepicker.d.ts +3 -3
  64. package/types/mintplayer-ng-bootstrap-toggle-button.d.ts +15 -15
  65. package/types/mintplayer-ng-bootstrap-typeahead.d.ts +2 -2
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, ElementRef, viewChild, model, output, signal, computed, effect, ChangeDetectionStrategy, Component, Directive, input, forwardRef } from '@angular/core';
2
+ import { inject, ElementRef, viewChild, input, model, output, signal, computed, effect, ChangeDetectionStrategy, Component, Directive, forwardRef } from '@angular/core';
3
3
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
4
4
 
5
5
  class BsSliderComponent {
@@ -7,6 +7,7 @@ class BsSliderComponent {
7
7
  this.element = inject((ElementRef));
8
8
  this.track = viewChild.required('track');
9
9
  this.thumb = viewChild.required('thumb');
10
+ this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
10
11
  this.value = model(0.5, ...(ngDevMode ? [{ debugName: "value" }] : []));
11
12
  this.valueChange = output();
12
13
  this.isPointerDown = signal(false, ...(ngDevMode ? [{ debugName: "isPointerDown" }] : []));
@@ -24,6 +25,8 @@ class BsSliderComponent {
24
25
  });
25
26
  }
26
27
  onPointerDown(ev) {
28
+ if (this.disabled())
29
+ return;
27
30
  ev.preventDefault();
28
31
  ev.stopPropagation();
29
32
  this.isPointerDown.set(true);
@@ -57,7 +60,7 @@ class BsSliderComponent {
57
60
  this.value.set(limited);
58
61
  }
59
62
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsSliderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
60
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.1.6", type: BsSliderComponent, isStandalone: true, selector: "bs-slider", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", valueChange: "valueChange" }, host: { listeners: { "document:mousemove": "onPointerMove($event)", "document:mouseup": "onPointerUp($event)" }, classAttribute: "d-block position-relative" }, viewQueries: [{ propertyName: "track", first: true, predicate: ["track"], descendants: true, isSignal: true }, { propertyName: "thumb", first: true, predicate: ["thumb"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"wrapper d-block position-relative\">\n <div #track class=\"track2\"\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\">\n <ng-content select=\"[bsTrack]\"></ng-content>\n </div>\n <div #thumb\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\"\n [class]=\"cursorClass()\"\n [style.margin-left.px]=\"thumbMarginLeft()\">\n <ng-content select=\"[bsThumb]\"></ng-content>\n </div>\n</div>\n", styles: [".track2{height:8px}.wrapper{padding-top:8px;padding-bottom:8px}::ng-deep .thumb{width:24px;height:24px;top:0;border-radius:50%;box-shadow:0 0 0 .1rem #646b7240}::ng-deep .track{height:8px;border-radius:8px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
63
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.1.6", type: BsSliderComponent, isStandalone: true, selector: "bs-slider", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", valueChange: "valueChange" }, host: { listeners: { "document:mousemove": "onPointerMove($event)", "document:mouseup": "onPointerUp($event)" }, classAttribute: "d-block position-relative" }, viewQueries: [{ propertyName: "track", first: true, predicate: ["track"], descendants: true, isSignal: true }, { propertyName: "thumb", first: true, predicate: ["thumb"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"wrapper d-block position-relative\">\n <div #track class=\"track2\"\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\">\n <ng-content select=\"[bsTrack]\"></ng-content>\n </div>\n <div #thumb\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\"\n [class]=\"cursorClass()\"\n [style.margin-left.px]=\"thumbMarginLeft()\">\n <ng-content select=\"[bsThumb]\"></ng-content>\n </div>\n</div>\n", styles: [".track2{height:8px}.wrapper{padding-top:8px;padding-bottom:8px}::ng-deep .thumb{width:24px;height:24px;top:0;border-radius:50%;box-shadow:0 0 0 .1rem #646b7240}::ng-deep .track{height:8px;border-radius:8px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
61
64
  }
62
65
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsSliderComponent, decorators: [{
63
66
  type: Component,
@@ -66,7 +69,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
66
69
  '(document:mousemove)': 'onPointerMove($event)',
67
70
  '(document:mouseup)': 'onPointerUp($event)',
68
71
  }, template: "<div class=\"wrapper d-block position-relative\">\n <div #track class=\"track2\"\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\">\n <ng-content select=\"[bsTrack]\"></ng-content>\n </div>\n <div #thumb\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\"\n [class]=\"cursorClass()\"\n [style.margin-left.px]=\"thumbMarginLeft()\">\n <ng-content select=\"[bsThumb]\"></ng-content>\n </div>\n</div>\n", styles: [".track2{height:8px}.wrapper{padding-top:8px;padding-bottom:8px}::ng-deep .thumb{width:24px;height:24px;top:0;border-radius:50%;box-shadow:0 0 0 .1rem #646b7240}::ng-deep .track{height:8px;border-radius:8px}\n"] }]
69
- }], ctorParameters: () => [], propDecorators: { track: [{ type: i0.ViewChild, args: ['track', { isSignal: true }] }], thumb: [{ type: i0.ViewChild, args: ['thumb', { isSignal: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }] } });
72
+ }], ctorParameters: () => [], propDecorators: { track: [{ type: i0.ViewChild, args: ['track', { isSignal: true }] }], thumb: [{ type: i0.ViewChild, args: ['thumb', { isSignal: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }] } });
70
73
  class BsThumbDirective {
71
74
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsThumbDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
72
75
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.6", type: BsThumbDirective, isStandalone: true, selector: "[bsThumb]", host: { classAttribute: "thumb position-absolute" }, ngImport: i0 }); }
@@ -97,6 +100,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
97
100
  class BsAlphaStripComponent {
98
101
  constructor() {
99
102
  this.canvas = viewChild.required('track');
103
+ this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
100
104
  this.hs = model({ hue: 0, saturation: 0 }, ...(ngDevMode ? [{ debugName: "hs" }] : []));
101
105
  this.luminosity = model(0.5, ...(ngDevMode ? [{ debugName: "luminosity" }] : []));
102
106
  this.alpha = model(1, ...(ngDevMode ? [{ debugName: "alpha" }] : []));
@@ -138,12 +142,126 @@ class BsAlphaStripComponent {
138
142
  }
139
143
  }
140
144
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsAlphaStripComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
141
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.1.6", type: BsAlphaStripComponent, isStandalone: true, selector: "bs-alpha-strip", inputs: { hs: { classPropertyName: "hs", publicName: "hs", isSignal: true, isRequired: false, transformFunction: null }, luminosity: { classPropertyName: "luminosity", publicName: "luminosity", isSignal: true, isRequired: false, transformFunction: null }, alpha: { classPropertyName: "alpha", publicName: "alpha", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { hs: "hsChange", luminosity: "luminosityChange", alpha: "alphaChange", alphaChange: "alphaChange" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["track"], descendants: true, isSignal: true }], ngImport: i0, template: "<bs-slider [value]=\"alpha()\" (valueChange)=\"alphaChange.emit($event)\">\n <canvas bsTrack class=\" track position-absolute w-100\" #track></canvas>\n\n <!-- [style.background]=\"resultBackground()\" -->\n <div bsThumb [style.background]=\"resultBackground()\"></div>\n</bs-slider>\n", styles: [".track{background-image:linear-gradient(45deg,#C0C0C0 25%,transparent 25%),linear-gradient(-45deg,#C0C0C0 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#C0C0C0 75%),linear-gradient(-45deg,transparent 75%,#C0C0C0 75%);background-size:10px 10px;background-position:0 0,0 5px,5px -5px,-5px 0px}\n"], dependencies: [{ kind: "component", type: BsSliderComponent, selector: "bs-slider", inputs: ["value"], outputs: ["valueChange"] }, { kind: "directive", type: BsThumbDirective, selector: "[bsThumb]" }, { kind: "directive", type: BsTrackDirective, selector: "[bsTrack]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
145
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.1.6", type: BsAlphaStripComponent, isStandalone: true, selector: "bs-alpha-strip", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, hs: { classPropertyName: "hs", publicName: "hs", isSignal: true, isRequired: false, transformFunction: null }, luminosity: { classPropertyName: "luminosity", publicName: "luminosity", isSignal: true, isRequired: false, transformFunction: null }, alpha: { classPropertyName: "alpha", publicName: "alpha", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { hs: "hsChange", luminosity: "luminosityChange", alpha: "alphaChange", alphaChange: "alphaChange" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["track"], descendants: true, isSignal: true }], ngImport: i0, template: "<bs-slider [disabled]=\"disabled()\" [value]=\"alpha()\" (valueChange)=\"alphaChange.emit($event)\">\n <canvas bsTrack class=\" track position-absolute w-100\" #track></canvas>\n\n <!-- [style.background]=\"resultBackground()\" -->\n <div bsThumb [style.background]=\"resultBackground()\"></div>\n</bs-slider>\n", styles: [".track{background-image:linear-gradient(45deg,#C0C0C0 25%,transparent 25%),linear-gradient(-45deg,#C0C0C0 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#C0C0C0 75%),linear-gradient(-45deg,transparent 75%,#C0C0C0 75%);background-size:10px 10px;background-position:0 0,0 5px,5px -5px,-5px 0px}\n"], dependencies: [{ kind: "component", type: BsSliderComponent, selector: "bs-slider", inputs: ["disabled", "value"], outputs: ["valueChange"] }, { kind: "directive", type: BsThumbDirective, selector: "[bsThumb]" }, { kind: "directive", type: BsTrackDirective, selector: "[bsTrack]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
142
146
  }
143
147
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsAlphaStripComponent, decorators: [{
144
148
  type: Component,
145
- args: [{ selector: 'bs-alpha-strip', imports: [BsSliderComponent, BsThumbDirective, BsTrackDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<bs-slider [value]=\"alpha()\" (valueChange)=\"alphaChange.emit($event)\">\n <canvas bsTrack class=\" track position-absolute w-100\" #track></canvas>\n\n <!-- [style.background]=\"resultBackground()\" -->\n <div bsThumb [style.background]=\"resultBackground()\"></div>\n</bs-slider>\n", styles: [".track{background-image:linear-gradient(45deg,#C0C0C0 25%,transparent 25%),linear-gradient(-45deg,#C0C0C0 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#C0C0C0 75%),linear-gradient(-45deg,transparent 75%,#C0C0C0 75%);background-size:10px 10px;background-position:0 0,0 5px,5px -5px,-5px 0px}\n"] }]
146
- }], ctorParameters: () => [], propDecorators: { canvas: [{ type: i0.ViewChild, args: ['track', { isSignal: true }] }], hs: [{ type: i0.Input, args: [{ isSignal: true, alias: "hs", required: false }] }, { type: i0.Output, args: ["hsChange"] }], luminosity: [{ type: i0.Input, args: [{ isSignal: true, alias: "luminosity", required: false }] }, { type: i0.Output, args: ["luminosityChange"] }], alpha: [{ type: i0.Input, args: [{ isSignal: true, alias: "alpha", required: false }] }, { type: i0.Output, args: ["alphaChange"] }], alphaChange: [{ type: i0.Output, args: ["alphaChange"] }] } });
149
+ args: [{ selector: 'bs-alpha-strip', imports: [BsSliderComponent, BsThumbDirective, BsTrackDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<bs-slider [disabled]=\"disabled()\" [value]=\"alpha()\" (valueChange)=\"alphaChange.emit($event)\">\n <canvas bsTrack class=\" track position-absolute w-100\" #track></canvas>\n\n <!-- [style.background]=\"resultBackground()\" -->\n <div bsThumb [style.background]=\"resultBackground()\"></div>\n</bs-slider>\n", styles: [".track{background-image:linear-gradient(45deg,#C0C0C0 25%,transparent 25%),linear-gradient(-45deg,#C0C0C0 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#C0C0C0 75%),linear-gradient(-45deg,transparent 75%,#C0C0C0 75%);background-size:10px 10px;background-position:0 0,0 5px,5px -5px,-5px 0px}\n"] }]
150
+ }], ctorParameters: () => [], propDecorators: { canvas: [{ type: i0.ViewChild, args: ['track', { isSignal: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], hs: [{ type: i0.Input, args: [{ isSignal: true, alias: "hs", required: false }] }, { type: i0.Output, args: ["hsChange"] }], luminosity: [{ type: i0.Input, args: [{ isSignal: true, alias: "luminosity", required: false }] }, { type: i0.Output, args: ["luminosityChange"] }], alpha: [{ type: i0.Input, args: [{ isSignal: true, alias: "alpha", required: false }] }, { type: i0.Output, args: ["alphaChange"] }], alphaChange: [{ type: i0.Output, args: ["alphaChange"] }] } });
151
+
152
+ class BsColorPickerValueAccessor {
153
+ constructor() {
154
+ this.host = inject(BsColorPickerComponent);
155
+ // Effect to emit value changes
156
+ effect(() => {
157
+ const hs = this.host.hs();
158
+ const luminosity = this.host.luminosity();
159
+ const rgb = this.hsl2rgb(hs.hue, hs.saturation, luminosity);
160
+ const hex = this.rgb2hex(rgb);
161
+ setTimeout(() => this.onValueChange && this.onValueChange(hex), 10);
162
+ });
163
+ }
164
+ hsl2rgb(h, s, l) {
165
+ const k = (n) => (n + h / 30) % 12;
166
+ const a = s * Math.min(l, 1 - l);
167
+ const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
168
+ const retValue = { r: 255 * f(0), g: 255 * f(8), b: 255 * f(4) };
169
+ return retValue;
170
+ }
171
+ //#region ControlValueAccessor implementation
172
+ registerOnChange(fn) {
173
+ this.onValueChange = fn;
174
+ }
175
+ registerOnTouched(fn) {
176
+ this.onTouched = fn;
177
+ }
178
+ writeValue(value) {
179
+ if (this.host && this.host.colorWheel()) {
180
+ if (value) {
181
+ const rgb = this.hex2rgb(value);
182
+ const hsl = this.rgb2Hsl(rgb);
183
+ this.host.hs.set({ hue: hsl.h, saturation: hsl.s });
184
+ this.host.luminosity.set(hsl.l);
185
+ }
186
+ }
187
+ }
188
+ setDisabledState(isDisabled) {
189
+ this.host.disabled.set(isDisabled);
190
+ }
191
+ //#endregion
192
+ //#region Color Conversion
193
+ rgb2hex(rgb) {
194
+ return '#' + (Math.round((rgb.r << 16) + (rgb.g << 8) + rgb.b)).toString(16).padStart(6, '0');
195
+ }
196
+ hex2rgb(hex) {
197
+ const r = parseInt(hex.slice(1, 3), 16), g = parseInt(hex.slice(3, 5), 16), b = parseInt(hex.slice(5, 7), 16);
198
+ return { r, g, b };
199
+ }
200
+ /**
201
+ * Divide 1 to n, handling floating point errors.
202
+ * Ensures that the value is in between 0 and 1.
203
+ **/
204
+ bound01(n, max) {
205
+ n = Math.min(max, Math.max(0, n));
206
+ if (Math.abs(n - max) < 0.000001) {
207
+ return 1;
208
+ }
209
+ else {
210
+ return (n % max) / max;
211
+ }
212
+ }
213
+ rgb2Hsl(color) {
214
+ const r01 = this.bound01(color.r, 255);
215
+ const g01 = this.bound01(color.g, 255);
216
+ const b01 = this.bound01(color.b, 255);
217
+ const max = Math.max(r01, g01, b01);
218
+ const min = Math.min(r01, g01, b01);
219
+ let h, s;
220
+ const l = (max + min) / 2;
221
+ if (max === min) {
222
+ h = s = 0;
223
+ }
224
+ else {
225
+ const d = max - min;
226
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
227
+ switch (max) {
228
+ case r01:
229
+ h = (g01 - b01) / d + (g01 < b01 ? 6 : 0);
230
+ break;
231
+ case g01:
232
+ h = (b01 - r01) / d + 2;
233
+ break;
234
+ case b01:
235
+ h = (r01 - g01) / d + 4;
236
+ break;
237
+ default: {
238
+ throw 'Invalid operation';
239
+ }
240
+ }
241
+ h /= 6;
242
+ }
243
+ h *= 360;
244
+ return { h, s, l };
245
+ }
246
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsColorPickerValueAccessor, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
247
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.6", type: BsColorPickerValueAccessor, isStandalone: true, selector: "bs-color-picker", providers: [{
248
+ provide: NG_VALUE_ACCESSOR,
249
+ useExisting: forwardRef(() => BsColorPickerValueAccessor),
250
+ multi: true
251
+ }], exportAs: ["bsColorPicker"], ngImport: i0 }); }
252
+ }
253
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsColorPickerValueAccessor, decorators: [{
254
+ type: Directive,
255
+ args: [{
256
+ selector: 'bs-color-picker',
257
+ providers: [{
258
+ provide: NG_VALUE_ACCESSOR,
259
+ useExisting: forwardRef(() => BsColorPickerValueAccessor),
260
+ multi: true
261
+ }],
262
+ exportAs: 'bsColorPicker'
263
+ }]
264
+ }], ctorParameters: () => [] });
147
265
 
148
266
  class BsColorWheelComponent {
149
267
  constructor() {
@@ -158,7 +276,7 @@ class BsColorWheelComponent {
158
276
  this.hs = model({ hue: 0, saturation: 0 }, ...(ngDevMode ? [{ debugName: "hs" }] : []));
159
277
  this.hsChange = output();
160
278
  // Internal state
161
- this.disabled = signal(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
279
+ this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
162
280
  this.viewInited = signal(false, ...(ngDevMode ? [{ debugName: "viewInited" }] : []));
163
281
  this.isPointerDown = false;
164
282
  this.canvasContext = null;
@@ -408,7 +526,7 @@ class BsColorWheelComponent {
408
526
  }
409
527
  }
410
528
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsColorWheelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
411
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.6", type: BsColorWheelComponent, isStandalone: true, selector: "bs-color-wheel", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, diameterRatio: { classPropertyName: "diameterRatio", publicName: "diameterRatio", isSignal: true, isRequired: false, transformFunction: null }, luminosity: { classPropertyName: "luminosity", publicName: "luminosity", isSignal: true, isRequired: false, transformFunction: null }, hs: { classPropertyName: "hs", publicName: "hs", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { width: "widthChange", height: "heightChange", diameterRatio: "diameterRatioChange", luminosity: "luminosityChange", hs: "hsChange", hsChange: "hsChange" }, host: { listeners: { "document:mousemove": "onMouseMove($event)", "document:mouseup": "onPointerUp($event)" }, classAttribute: "position-relative" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true, isSignal: true }], ngImport: i0, template: "<canvas\n class=\"d-block\"\n [width]=\"width()\"\n [height]=\"height()\"\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\"\n #canvas></canvas>\n\n@if (markerPosition(); as markerPosition) {\n <div class=\"thumb position-absolute pe-none\" [style.left.px]=\"markerPosition.x\" [style.top.px]=\"markerPosition.y\"></div>\n}\n", styles: [".thumb{width:30px;height:30px;border-radius:15px;margin-top:-15px;margin-left:-15px;box-sizing:border-box;border:2px solid white;box-shadow:#0000001a 0 0 10px 5px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
529
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.6", type: BsColorWheelComponent, isStandalone: true, selector: "bs-color-wheel", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, diameterRatio: { classPropertyName: "diameterRatio", publicName: "diameterRatio", isSignal: true, isRequired: false, transformFunction: null }, luminosity: { classPropertyName: "luminosity", publicName: "luminosity", isSignal: true, isRequired: false, transformFunction: null }, hs: { classPropertyName: "hs", publicName: "hs", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { width: "widthChange", height: "heightChange", diameterRatio: "diameterRatioChange", luminosity: "luminosityChange", hs: "hsChange", hsChange: "hsChange" }, host: { listeners: { "document:mousemove": "onMouseMove($event)", "document:mouseup": "onPointerUp($event)" }, classAttribute: "position-relative" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true, isSignal: true }], ngImport: i0, template: "<canvas\n class=\"d-block\"\n [width]=\"width()\"\n [height]=\"height()\"\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\"\n #canvas></canvas>\n\n@if (markerPosition(); as markerPosition) {\n <div class=\"thumb position-absolute pe-none\" [style.left.px]=\"markerPosition.x\" [style.top.px]=\"markerPosition.y\"></div>\n}\n", styles: [".thumb{width:30px;height:30px;border-radius:15px;margin-top:-15px;margin-left:-15px;box-sizing:border-box;border:2px solid white;box-shadow:#0000001a 0 0 10px 5px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
412
530
  }
413
531
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsColorWheelComponent, decorators: [{
414
532
  type: Component,
@@ -417,11 +535,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImpor
417
535
  '(document:mousemove)': 'onMouseMove($event)',
418
536
  '(document:mouseup)': 'onPointerUp($event)',
419
537
  }, template: "<canvas\n class=\"d-block\"\n [width]=\"width()\"\n [height]=\"height()\"\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\"\n #canvas></canvas>\n\n@if (markerPosition(); as markerPosition) {\n <div class=\"thumb position-absolute pe-none\" [style.left.px]=\"markerPosition.x\" [style.top.px]=\"markerPosition.y\"></div>\n}\n", styles: [".thumb{width:30px;height:30px;border-radius:15px;margin-top:-15px;margin-left:-15px;box-sizing:border-box;border:2px solid white;box-shadow:#0000001a 0 0 10px 5px}\n"] }]
420
- }], ctorParameters: () => [], propDecorators: { canvas: [{ type: i0.ViewChild, args: ['canvas', { isSignal: true }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }, { type: i0.Output, args: ["widthChange"] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }, { type: i0.Output, args: ["heightChange"] }], diameterRatio: [{ type: i0.Input, args: [{ isSignal: true, alias: "diameterRatio", required: false }] }, { type: i0.Output, args: ["diameterRatioChange"] }], luminosity: [{ type: i0.Input, args: [{ isSignal: true, alias: "luminosity", required: false }] }, { type: i0.Output, args: ["luminosityChange"] }], hs: [{ type: i0.Input, args: [{ isSignal: true, alias: "hs", required: false }] }, { type: i0.Output, args: ["hsChange"] }], hsChange: [{ type: i0.Output, args: ["hsChange"] }] } });
538
+ }], ctorParameters: () => [], propDecorators: { canvas: [{ type: i0.ViewChild, args: ['canvas', { isSignal: true }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }, { type: i0.Output, args: ["widthChange"] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }, { type: i0.Output, args: ["heightChange"] }], diameterRatio: [{ type: i0.Input, args: [{ isSignal: true, alias: "diameterRatio", required: false }] }, { type: i0.Output, args: ["diameterRatioChange"] }], luminosity: [{ type: i0.Input, args: [{ isSignal: true, alias: "luminosity", required: false }] }, { type: i0.Output, args: ["luminosityChange"] }], hs: [{ type: i0.Input, args: [{ isSignal: true, alias: "hs", required: false }] }, { type: i0.Output, args: ["hsChange"] }], hsChange: [{ type: i0.Output, args: ["hsChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
421
539
 
422
540
  class BsLuminosityStripComponent {
423
541
  constructor() {
424
542
  this.canvas = viewChild.required('canvas');
543
+ this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
425
544
  this.hs = model({ hue: 0, saturation: 0 }, ...(ngDevMode ? [{ debugName: "hs" }] : []));
426
545
  this.luminosity = model(0.5, ...(ngDevMode ? [{ debugName: "luminosity" }] : []));
427
546
  this.luminosityChange = output();
@@ -459,12 +578,12 @@ class BsLuminosityStripComponent {
459
578
  }
460
579
  }
461
580
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsLuminosityStripComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
462
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.1.6", type: BsLuminosityStripComponent, isStandalone: true, selector: "bs-luminosity-strip", inputs: { hs: { classPropertyName: "hs", publicName: "hs", isSignal: true, isRequired: false, transformFunction: null }, luminosity: { classPropertyName: "luminosity", publicName: "luminosity", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { hs: "hsChange", luminosity: "luminosityChange", luminosityChange: "luminosityChange" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true, isSignal: true }], ngImport: i0, template: "<bs-slider [value]=\"luminosity()\" (valueChange)=\"luminosityChange.emit($event)\">\n <canvas bsTrack class=\"position-absolute w-100\" #canvas></canvas>\n <div bsThumb [style.background]=\"resultBackground()\"></div>\n</bs-slider>\n", styles: [""], dependencies: [{ kind: "component", type: BsSliderComponent, selector: "bs-slider", inputs: ["value"], outputs: ["valueChange"] }, { kind: "directive", type: BsThumbDirective, selector: "[bsThumb]" }, { kind: "directive", type: BsTrackDirective, selector: "[bsTrack]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
581
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.1.6", type: BsLuminosityStripComponent, isStandalone: true, selector: "bs-luminosity-strip", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, hs: { classPropertyName: "hs", publicName: "hs", isSignal: true, isRequired: false, transformFunction: null }, luminosity: { classPropertyName: "luminosity", publicName: "luminosity", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { hs: "hsChange", luminosity: "luminosityChange", luminosityChange: "luminosityChange" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true, isSignal: true }], ngImport: i0, template: "<bs-slider [disabled]=\"disabled()\" [value]=\"luminosity()\" (valueChange)=\"luminosityChange.emit($event)\">\n <canvas bsTrack class=\"position-absolute w-100\" #canvas></canvas>\n <div bsThumb [style.background]=\"resultBackground()\"></div>\n</bs-slider>\n", styles: [""], dependencies: [{ kind: "component", type: BsSliderComponent, selector: "bs-slider", inputs: ["disabled", "value"], outputs: ["valueChange"] }, { kind: "directive", type: BsThumbDirective, selector: "[bsThumb]" }, { kind: "directive", type: BsTrackDirective, selector: "[bsTrack]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
463
582
  }
464
583
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsLuminosityStripComponent, decorators: [{
465
584
  type: Component,
466
- args: [{ selector: 'bs-luminosity-strip', imports: [BsSliderComponent, BsThumbDirective, BsTrackDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<bs-slider [value]=\"luminosity()\" (valueChange)=\"luminosityChange.emit($event)\">\n <canvas bsTrack class=\"position-absolute w-100\" #canvas></canvas>\n <div bsThumb [style.background]=\"resultBackground()\"></div>\n</bs-slider>\n" }]
467
- }], ctorParameters: () => [], propDecorators: { canvas: [{ type: i0.ViewChild, args: ['canvas', { isSignal: true }] }], hs: [{ type: i0.Input, args: [{ isSignal: true, alias: "hs", required: false }] }, { type: i0.Output, args: ["hsChange"] }], luminosity: [{ type: i0.Input, args: [{ isSignal: true, alias: "luminosity", required: false }] }, { type: i0.Output, args: ["luminosityChange"] }], luminosityChange: [{ type: i0.Output, args: ["luminosityChange"] }] } });
585
+ args: [{ selector: 'bs-luminosity-strip', imports: [BsSliderComponent, BsThumbDirective, BsTrackDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<bs-slider [disabled]=\"disabled()\" [value]=\"luminosity()\" (valueChange)=\"luminosityChange.emit($event)\">\n <canvas bsTrack class=\"position-absolute w-100\" #canvas></canvas>\n <div bsThumb [style.background]=\"resultBackground()\"></div>\n</bs-slider>\n" }]
586
+ }], ctorParameters: () => [], propDecorators: { canvas: [{ type: i0.ViewChild, args: ['canvas', { isSignal: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], hs: [{ type: i0.Input, args: [{ isSignal: true, alias: "hs", required: false }] }, { type: i0.Output, args: ["hsChange"] }], luminosity: [{ type: i0.Input, args: [{ isSignal: true, alias: "luminosity", required: false }] }, { type: i0.Output, args: ["luminosityChange"] }], luminosityChange: [{ type: i0.Output, args: ["luminosityChange"] }] } });
468
587
 
469
588
  class BsColorPickerComponent {
470
589
  constructor() {
@@ -482,129 +601,13 @@ class BsColorPickerComponent {
482
601
  });
483
602
  }
484
603
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsColorPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
485
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.6", type: BsColorPickerComponent, isStandalone: true, selector: "bs-color-picker", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, allowAlpha: { classPropertyName: "allowAlpha", publicName: "allowAlpha", isSignal: true, isRequired: false, transformFunction: null }, alpha: { classPropertyName: "alpha", publicName: "alpha", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { alpha: "alphaChange", alphaChange: "alphaChange" }, viewQueries: [{ propertyName: "colorWheel", first: true, predicate: ["wheel"], descendants: true, isSignal: true }], ngImport: i0, template: "@let letDisabled = disabled();\n@let letHS = hs();\n@let letLuminosity = luminosity();\n@let letAlpha = alpha();\n\n<bs-color-wheel [hs]=\"letHS\" (hsChange)=\"hs.set($event)\" [luminosity]=\"letLuminosity\" [width]=\"size()\" [height]=\"size()\" #wheel></bs-color-wheel>\n<bs-luminosity-strip [hs]=\"letHS\" [luminosity]=\"letLuminosity\" (luminosityChange)=\"luminosity.set($event)\" class=\"d-block mt-2\" [style.width.px]=\"size()\" #strip></bs-luminosity-strip>\n@if (allowAlpha()) {\n <bs-alpha-strip [hs]=\"letHS\" [luminosity]=\"letLuminosity\" [alpha]=\"letAlpha\" (alphaChange)=\"alpha.set($event)\" class=\"d-block mt-2\" [style.width.px]=\"size()\" #alphaStrip></bs-alpha-strip>\n}\n", styles: [""], dependencies: [{ kind: "component", type: BsColorWheelComponent, selector: "bs-color-wheel", inputs: ["width", "height", "diameterRatio", "luminosity", "hs"], outputs: ["widthChange", "heightChange", "diameterRatioChange", "luminosityChange", "hsChange"] }, { kind: "component", type: BsLuminosityStripComponent, selector: "bs-luminosity-strip", inputs: ["hs", "luminosity"], outputs: ["hsChange", "luminosityChange"] }, { kind: "component", type: BsAlphaStripComponent, selector: "bs-alpha-strip", inputs: ["hs", "luminosity", "alpha"], outputs: ["hsChange", "luminosityChange", "alphaChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
604
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.6", type: BsColorPickerComponent, isStandalone: true, selector: "bs-color-picker", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, allowAlpha: { classPropertyName: "allowAlpha", publicName: "allowAlpha", isSignal: true, isRequired: false, transformFunction: null }, alpha: { classPropertyName: "alpha", publicName: "alpha", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { alpha: "alphaChange", alphaChange: "alphaChange" }, viewQueries: [{ propertyName: "colorWheel", first: true, predicate: ["wheel"], descendants: true, isSignal: true }], hostDirectives: [{ directive: BsColorPickerValueAccessor }], ngImport: i0, template: "@let letDisabled = disabled();\n@let letHS = hs();\n@let letLuminosity = luminosity();\n@let letAlpha = alpha();\n\n<bs-color-wheel [disabled]=\"letDisabled\" [hs]=\"letHS\" (hsChange)=\"hs.set($event)\" [luminosity]=\"letLuminosity\" [width]=\"size()\" [height]=\"size()\" #wheel></bs-color-wheel>\n<bs-luminosity-strip [disabled]=\"letDisabled\" [hs]=\"letHS\" [luminosity]=\"letLuminosity\" (luminosityChange)=\"luminosity.set($event)\" class=\"d-block mt-2\" [style.width.px]=\"size()\" #strip></bs-luminosity-strip>\n@if (allowAlpha()) {\n <bs-alpha-strip [disabled]=\"letDisabled\" [hs]=\"letHS\" [luminosity]=\"letLuminosity\" [alpha]=\"letAlpha\" (alphaChange)=\"alpha.set($event)\" class=\"d-block mt-2\" [style.width.px]=\"size()\" #alphaStrip></bs-alpha-strip>\n}\n", styles: [""], dependencies: [{ kind: "component", type: BsColorWheelComponent, selector: "bs-color-wheel", inputs: ["width", "height", "diameterRatio", "luminosity", "hs", "disabled"], outputs: ["widthChange", "heightChange", "diameterRatioChange", "luminosityChange", "hsChange"] }, { kind: "component", type: BsLuminosityStripComponent, selector: "bs-luminosity-strip", inputs: ["disabled", "hs", "luminosity"], outputs: ["hsChange", "luminosityChange"] }, { kind: "component", type: BsAlphaStripComponent, selector: "bs-alpha-strip", inputs: ["disabled", "hs", "luminosity", "alpha"], outputs: ["hsChange", "luminosityChange", "alphaChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
486
605
  }
487
606
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsColorPickerComponent, decorators: [{
488
607
  type: Component,
489
- args: [{ selector: 'bs-color-picker', imports: [BsColorWheelComponent, BsLuminosityStripComponent, BsAlphaStripComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "@let letDisabled = disabled();\n@let letHS = hs();\n@let letLuminosity = luminosity();\n@let letAlpha = alpha();\n\n<bs-color-wheel [hs]=\"letHS\" (hsChange)=\"hs.set($event)\" [luminosity]=\"letLuminosity\" [width]=\"size()\" [height]=\"size()\" #wheel></bs-color-wheel>\n<bs-luminosity-strip [hs]=\"letHS\" [luminosity]=\"letLuminosity\" (luminosityChange)=\"luminosity.set($event)\" class=\"d-block mt-2\" [style.width.px]=\"size()\" #strip></bs-luminosity-strip>\n@if (allowAlpha()) {\n <bs-alpha-strip [hs]=\"letHS\" [luminosity]=\"letLuminosity\" [alpha]=\"letAlpha\" (alphaChange)=\"alpha.set($event)\" class=\"d-block mt-2\" [style.width.px]=\"size()\" #alphaStrip></bs-alpha-strip>\n}\n" }]
608
+ args: [{ selector: 'bs-color-picker', imports: [BsColorWheelComponent, BsLuminosityStripComponent, BsAlphaStripComponent], changeDetection: ChangeDetectionStrategy.OnPush, hostDirectives: [BsColorPickerValueAccessor], template: "@let letDisabled = disabled();\n@let letHS = hs();\n@let letLuminosity = luminosity();\n@let letAlpha = alpha();\n\n<bs-color-wheel [disabled]=\"letDisabled\" [hs]=\"letHS\" (hsChange)=\"hs.set($event)\" [luminosity]=\"letLuminosity\" [width]=\"size()\" [height]=\"size()\" #wheel></bs-color-wheel>\n<bs-luminosity-strip [disabled]=\"letDisabled\" [hs]=\"letHS\" [luminosity]=\"letLuminosity\" (luminosityChange)=\"luminosity.set($event)\" class=\"d-block mt-2\" [style.width.px]=\"size()\" #strip></bs-luminosity-strip>\n@if (allowAlpha()) {\n <bs-alpha-strip [disabled]=\"letDisabled\" [hs]=\"letHS\" [luminosity]=\"letLuminosity\" [alpha]=\"letAlpha\" (alphaChange)=\"alpha.set($event)\" class=\"d-block mt-2\" [style.width.px]=\"size()\" #alphaStrip></bs-alpha-strip>\n}\n" }]
490
609
  }], ctorParameters: () => [], propDecorators: { colorWheel: [{ type: i0.ViewChild, args: ['wheel', { isSignal: true }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], allowAlpha: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowAlpha", required: false }] }], alpha: [{ type: i0.Input, args: [{ isSignal: true, alias: "alpha", required: false }] }, { type: i0.Output, args: ["alphaChange"] }], alphaChange: [{ type: i0.Output, args: ["alphaChange"] }] } });
491
610
 
492
- class BsColorPickerValueAccessor {
493
- constructor() {
494
- this.host = inject(BsColorPickerComponent);
495
- // Effect to emit value changes
496
- effect(() => {
497
- const hs = this.host.hs();
498
- const luminosity = this.host.luminosity();
499
- const rgb = this.hsl2rgb(hs.hue, hs.saturation, luminosity);
500
- const hex = this.rgb2hex(rgb);
501
- setTimeout(() => this.onValueChange && this.onValueChange(hex), 10);
502
- });
503
- }
504
- hsl2rgb(h, s, l) {
505
- const k = (n) => (n + h / 30) % 12;
506
- const a = s * Math.min(l, 1 - l);
507
- const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
508
- const retValue = { r: 255 * f(0), g: 255 * f(8), b: 255 * f(4) };
509
- return retValue;
510
- }
511
- //#region ControlValueAccessor implementation
512
- registerOnChange(fn) {
513
- this.onValueChange = fn;
514
- }
515
- registerOnTouched(fn) {
516
- this.onTouched = fn;
517
- }
518
- writeValue(value) {
519
- if (this.host && this.host.colorWheel()) {
520
- if (value) {
521
- const rgb = this.hex2rgb(value);
522
- const hsl = this.rgb2Hsl(rgb);
523
- this.host.hs.set({ hue: hsl.h, saturation: hsl.s });
524
- this.host.luminosity.set(hsl.l);
525
- }
526
- }
527
- }
528
- setDisabledState(isDisabled) {
529
- if (this.host && this.host.colorWheel()) {
530
- this.host.colorWheel().disabled.set(isDisabled);
531
- }
532
- }
533
- //#endregion
534
- //#region Color Conversion
535
- rgb2hex(rgb) {
536
- return '#' + (Math.round((rgb.r << 16) + (rgb.g << 8) + rgb.b)).toString(16).padStart(6, '0');
537
- }
538
- hex2rgb(hex) {
539
- const r = parseInt(hex.slice(1, 3), 16), g = parseInt(hex.slice(3, 5), 16), b = parseInt(hex.slice(5, 7), 16);
540
- return { r, g, b };
541
- }
542
- /**
543
- * Divide 1 to n, handling floating point errors.
544
- * Ensures that the value is in between 0 and 1.
545
- **/
546
- bound01(n, max) {
547
- n = Math.min(max, Math.max(0, n));
548
- if (Math.abs(n - max) < 0.000001) {
549
- return 1;
550
- }
551
- else {
552
- return (n % max) / max;
553
- }
554
- }
555
- rgb2Hsl(color) {
556
- const r01 = this.bound01(color.r, 255);
557
- const g01 = this.bound01(color.g, 255);
558
- const b01 = this.bound01(color.b, 255);
559
- const max = Math.max(r01, g01, b01);
560
- const min = Math.min(r01, g01, b01);
561
- let h, s;
562
- const l = (max + min) / 2;
563
- if (max === min) {
564
- h = s = 0;
565
- }
566
- else {
567
- const d = max - min;
568
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
569
- switch (max) {
570
- case r01:
571
- h = (g01 - b01) / d + (g01 < b01 ? 6 : 0);
572
- break;
573
- case g01:
574
- h = (b01 - r01) / d + 2;
575
- break;
576
- case b01:
577
- h = (r01 - g01) / d + 4;
578
- break;
579
- default: {
580
- throw 'Invalid operation';
581
- }
582
- }
583
- h /= 6;
584
- }
585
- h *= 360;
586
- return { h, s, l };
587
- }
588
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsColorPickerValueAccessor, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
589
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.6", type: BsColorPickerValueAccessor, isStandalone: true, selector: "bs-color-picker", providers: [{
590
- provide: NG_VALUE_ACCESSOR,
591
- useExisting: forwardRef(() => BsColorPickerValueAccessor),
592
- multi: true
593
- }], exportAs: ["bsColorPicker"], ngImport: i0 }); }
594
- }
595
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: BsColorPickerValueAccessor, decorators: [{
596
- type: Directive,
597
- args: [{
598
- selector: 'bs-color-picker',
599
- providers: [{
600
- provide: NG_VALUE_ACCESSOR,
601
- useExisting: forwardRef(() => BsColorPickerValueAccessor),
602
- multi: true
603
- }],
604
- exportAs: 'bsColorPicker'
605
- }]
606
- }], ctorParameters: () => [] });
607
-
608
611
  /**
609
612
  * Generated bundle index. Do not edit.
610
613
  */