@mintplayer/ng-bootstrap 16.6.0 → 16.7.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.
- package/color-picker/color-picker.module.d.ts +15 -0
- package/color-picker/components/alpha-strip/alpha-strip.component.d.ts +23 -0
- package/color-picker/components/color-picker/color-picker.component.d.ts +24 -0
- package/color-picker/components/color-wheel/color-wheel.component.d.ts +53 -0
- package/color-picker/components/index.d.ts +5 -0
- package/color-picker/components/luminosity-strip/luminosity-strip.component.d.ts +20 -0
- package/color-picker/components/slider/slider.component.d.ts +35 -0
- package/color-picker/directives/color-picker-value-accessor/color-picker-value-accessor.directive.d.ts +28 -0
- package/color-picker/directives/index.d.ts +1 -0
- package/color-picker/index.d.ts +5 -0
- package/color-picker/interfaces/hs.d.ts +4 -0
- package/color-picker/interfaces/hsl-color.d.ts +5 -0
- package/color-picker/interfaces/index.d.ts +3 -0
- package/color-picker/interfaces/rgb-color.d.ts +5 -0
- package/color-picker/types/html-color.d.ts +1 -0
- package/color-picker/types/index.d.ts +1 -0
- package/container/index.d.ts +1 -0
- package/container/src/container/container.component.d.ts +5 -0
- package/container/src/container.module.d.ts +8 -0
- package/container/src/index.d.ts +2 -0
- package/esm2022/color-picker/color-picker.module.mjs +65 -0
- package/esm2022/color-picker/components/alpha-strip/alpha-strip.component.mjs +80 -0
- package/esm2022/color-picker/components/color-picker/color-picker.component.mjs +60 -0
- package/esm2022/color-picker/components/color-wheel/color-wheel.component.mjs +321 -0
- package/esm2022/color-picker/components/index.mjs +6 -0
- package/esm2022/color-picker/components/luminosity-strip/luminosity-strip.component.mjs +72 -0
- package/esm2022/color-picker/components/slider/slider.component.mjs +125 -0
- package/esm2022/color-picker/directives/color-picker-value-accessor/color-picker-value-accessor.directive.mjs +130 -0
- package/esm2022/color-picker/directives/index.mjs +2 -0
- package/esm2022/color-picker/index.mjs +6 -0
- package/esm2022/color-picker/interfaces/hs.mjs +2 -0
- package/esm2022/color-picker/interfaces/hsl-color.mjs +2 -0
- package/esm2022/color-picker/interfaces/index.mjs +4 -0
- package/esm2022/color-picker/interfaces/rgb-color.mjs +2 -0
- package/esm2022/color-picker/mintplayer-ng-bootstrap-color-picker.mjs +5 -0
- package/esm2022/color-picker/types/html-color.mjs +2 -0
- package/esm2022/color-picker/types/index.mjs +2 -0
- package/esm2022/container/index.mjs +2 -0
- package/esm2022/container/mintplayer-ng-bootstrap-container.mjs +5 -0
- package/esm2022/container/src/container/container.component.mjs +11 -0
- package/esm2022/container/src/container.module.mjs +18 -0
- package/esm2022/container/src/index.mjs +3 -0
- package/esm2022/grid/src/component/grid.component.mjs +5 -4
- package/esm2022/grid/src/grid.module.mjs +5 -4
- package/esm2022/navbar/src/navbar/navbar.component.mjs +6 -5
- package/esm2022/navbar/src/navbar.module.mjs +6 -2
- package/esm2022/sticky-footer/index.mjs +2 -0
- package/esm2022/sticky-footer/mintplayer-ng-bootstrap-sticky-footer.mjs +5 -0
- package/esm2022/sticky-footer/src/index.mjs +4 -0
- package/esm2022/sticky-footer/src/sticky-footer/sticky-footer.component.mjs +29 -0
- package/esm2022/sticky-footer/src/sticky-footer-parent/sticky-footer-parent.directive.mjs +16 -0
- package/esm2022/sticky-footer/src/sticky-footer.module.mjs +19 -0
- package/fesm2022/mintplayer-ng-bootstrap-color-picker.mjs +819 -0
- package/fesm2022/mintplayer-ng-bootstrap-color-picker.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-bootstrap-container.mjs +33 -0
- package/fesm2022/mintplayer-ng-bootstrap-container.mjs.map +1 -0
- package/fesm2022/mintplayer-ng-bootstrap-grid.mjs +8 -6
- package/fesm2022/mintplayer-ng-bootstrap-grid.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-bootstrap-navbar.mjs +12 -7
- package/fesm2022/mintplayer-ng-bootstrap-navbar.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-bootstrap-sticky-footer.mjs +63 -0
- package/fesm2022/mintplayer-ng-bootstrap-sticky-footer.mjs.map +1 -0
- package/grid/src/grid.module.d.ts +2 -1
- package/navbar/src/navbar.module.d.ts +6 -5
- package/package.json +19 -1
- package/sticky-footer/index.d.ts +1 -0
- package/sticky-footer/src/index.d.ts +3 -0
- package/sticky-footer/src/sticky-footer/sticky-footer.component.d.ts +14 -0
- package/sticky-footer/src/sticky-footer-parent/sticky-footer-parent.directive.d.ts +6 -0
- package/sticky-footer/src/sticky-footer.module.d.ts +9 -0
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, Component, HostBinding, Input, ViewChild, Output, HostListener, Directive, forwardRef, Inject, NgModule } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
4
|
+
import * as i1 from '@angular/common';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
import * as i2 from '@mintplayer/ng-bootstrap/let';
|
|
7
|
+
import { BsLetModule } from '@mintplayer/ng-bootstrap/let';
|
|
8
|
+
import { BehaviorSubject, combineLatest, map, debounceTime, switchMap, take } from 'rxjs';
|
|
9
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
10
|
+
|
|
11
|
+
class BsColorWheelComponent {
|
|
12
|
+
constructor(element) {
|
|
13
|
+
// this.resizeObserver = new ResizeObserver((entries) => {
|
|
14
|
+
// for (const entry of entries) {
|
|
15
|
+
// if (entry.target === this.element.nativeElement) {
|
|
16
|
+
// console.log(entry.contentRect);
|
|
17
|
+
// this.width$.next(entry.contentRect.width);
|
|
18
|
+
// this.height$.next(entry.contentRect.height);
|
|
19
|
+
// break;
|
|
20
|
+
// }
|
|
21
|
+
// }
|
|
22
|
+
// });
|
|
23
|
+
this.element = element;
|
|
24
|
+
this.positionRelative = true;
|
|
25
|
+
//#region Hue/Luminosity
|
|
26
|
+
this.hs$ = new BehaviorSubject({ hue: 0, saturation: 0 });
|
|
27
|
+
this.hsChange = new EventEmitter();
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region Luminosity
|
|
30
|
+
this.luminosity$ = new BehaviorSubject(0);
|
|
31
|
+
//#endregion
|
|
32
|
+
// private resizeObserver: ResizeObserver;
|
|
33
|
+
this.canvasContext = null;
|
|
34
|
+
this.isPointerDown = false;
|
|
35
|
+
this.width$ = new BehaviorSubject(150);
|
|
36
|
+
this.height$ = new BehaviorSubject(150);
|
|
37
|
+
this.diameterRatio$ = new BehaviorSubject(0);
|
|
38
|
+
this.disabled$ = new BehaviorSubject(false);
|
|
39
|
+
this.viewInited$ = new BehaviorSubject(false);
|
|
40
|
+
this.squareSize$ = combineLatest([this.width$, this.height$])
|
|
41
|
+
.pipe(map(([width, height]) => {
|
|
42
|
+
if ((width === null) || (height === null)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const squareSize = Math.min(width, height);
|
|
46
|
+
return squareSize;
|
|
47
|
+
}));
|
|
48
|
+
this.shiftX$ = combineLatest([this.width$, this.height$])
|
|
49
|
+
.pipe(map(([width, height]) => {
|
|
50
|
+
if ((width === null) || (height === null)) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
else if (width < height) {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return (width - height) / 2;
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
this.shiftY$ = combineLatest([this.width$, this.height$])
|
|
61
|
+
.pipe(map(([width, height]) => {
|
|
62
|
+
if ((width === null) || (height === null)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
else if (width < height) {
|
|
66
|
+
return (height - width) / 2;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
this.innerRadius$ = combineLatest([this.squareSize$, this.diameterRatio$])
|
|
73
|
+
.pipe(map(([squareSize, diameterRatio]) => {
|
|
74
|
+
if (squareSize) {
|
|
75
|
+
return squareSize / 2 * diameterRatio;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
this.outerRadius$ = combineLatest([this.squareSize$, this.diameterRatio$])
|
|
82
|
+
.pipe(map(([squareSize, diameterRatio]) => {
|
|
83
|
+
if (squareSize) {
|
|
84
|
+
return squareSize / 2;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return 150;
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
combineLatest([this.innerRadius$, this.outerRadius$, this.shiftX$, this.shiftY$])
|
|
91
|
+
.pipe(debounceTime(20), takeUntilDestroyed())
|
|
92
|
+
.subscribe(([innerRadius, outerRadius, shiftX, shiftY]) => {
|
|
93
|
+
if (this.canvasContext && (innerRadius !== null) && (outerRadius !== null) && (shiftX !== null) && (shiftY !== null)) {
|
|
94
|
+
this.canvasContext.clearRect(0, 0, this.canvas.nativeElement.width, this.canvas.nativeElement.height);
|
|
95
|
+
this.canvasContext.save();
|
|
96
|
+
this.canvasContext.translate(shiftX + outerRadius, shiftY + outerRadius);
|
|
97
|
+
for (let x = 0; x < 360; x++) {
|
|
98
|
+
this.canvasContext.rotate(1 * Math.PI / 180);
|
|
99
|
+
const gradient = this.canvasContext.createLinearGradient(innerRadius, 0, outerRadius, 0);
|
|
100
|
+
gradient.addColorStop(0, `hsl(${x}, 0%, 50%)`);
|
|
101
|
+
gradient.addColorStop(1, `hsl(${x}, 100%, 50%)`);
|
|
102
|
+
this.canvasContext.fillStyle = gradient;
|
|
103
|
+
this.canvasContext.fillRect(innerRadius, 0, outerRadius - innerRadius, outerRadius / 50);
|
|
104
|
+
}
|
|
105
|
+
this.canvasContext.restore();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
this.markerPosition$ = combineLatest([this.hs$, this.shiftX$, this.shiftY$])
|
|
109
|
+
.pipe(switchMap(([hs, shiftX, shiftY]) => {
|
|
110
|
+
return this.color2position(hs)
|
|
111
|
+
.pipe(map((position) => ({ position, shiftX: (shiftX ?? 0), shiftY: (shiftY ?? 0) })));
|
|
112
|
+
}))
|
|
113
|
+
.pipe(map(({ position, shiftX, shiftY }) => {
|
|
114
|
+
return {
|
|
115
|
+
x: position.x + shiftX,
|
|
116
|
+
y: position.y + shiftY,
|
|
117
|
+
};
|
|
118
|
+
}));
|
|
119
|
+
this.hs$.pipe(takeUntilDestroyed())
|
|
120
|
+
.subscribe((hs) => this.hsChange.emit(hs));
|
|
121
|
+
}
|
|
122
|
+
set diameterRatio(value) {
|
|
123
|
+
this.diameterRatio$.next(value);
|
|
124
|
+
}
|
|
125
|
+
set width(value) {
|
|
126
|
+
this.width$.next(value);
|
|
127
|
+
}
|
|
128
|
+
set height(value) {
|
|
129
|
+
this.height$.next(value);
|
|
130
|
+
}
|
|
131
|
+
get hs() {
|
|
132
|
+
return this.hs$.value;
|
|
133
|
+
}
|
|
134
|
+
set hs(value) {
|
|
135
|
+
this.hs$.next(value);
|
|
136
|
+
}
|
|
137
|
+
get luminosity() {
|
|
138
|
+
return this.luminosity$.value;
|
|
139
|
+
}
|
|
140
|
+
set luminosity(value) {
|
|
141
|
+
this.luminosity$.next(value);
|
|
142
|
+
}
|
|
143
|
+
ngAfterViewInit() {
|
|
144
|
+
// this.resizeObserver.observe(this.element.nativeElement);
|
|
145
|
+
this.viewInited$.next(true);
|
|
146
|
+
this.canvasContext = this.canvas.nativeElement.getContext('2d', { willReadFrequently: true });
|
|
147
|
+
}
|
|
148
|
+
onPointerDown(ev) {
|
|
149
|
+
if (!this.disabled$.value) {
|
|
150
|
+
ev.preventDefault();
|
|
151
|
+
this.isPointerDown = true;
|
|
152
|
+
this.updateColor(ev, !('touches' in ev));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
onPointerMove(ev) {
|
|
156
|
+
if (this.isPointerDown) {
|
|
157
|
+
ev.preventDefault();
|
|
158
|
+
ev.stopPropagation();
|
|
159
|
+
this.updateColor(ev, !('touches' in ev));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
onMouseMove(ev) {
|
|
163
|
+
this.onPointerMove(ev);
|
|
164
|
+
}
|
|
165
|
+
onPointerUp(ev) {
|
|
166
|
+
this.isPointerDown = false;
|
|
167
|
+
}
|
|
168
|
+
updateColor(ev, subtract) {
|
|
169
|
+
let co;
|
|
170
|
+
const rect = this.canvas.nativeElement.getBoundingClientRect();
|
|
171
|
+
if ('touches' in ev) {
|
|
172
|
+
co = {
|
|
173
|
+
x: ev.touches[0].clientX - rect.left,
|
|
174
|
+
y: ev.touches[0].clientY - rect.top,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
co = {
|
|
179
|
+
x: ev.clientX - (subtract ? rect.left : 0),
|
|
180
|
+
y: ev.clientY - (subtract ? rect.top : 0),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
this.position2color(co.x, co.y).pipe(take(1)).subscribe((color) => {
|
|
184
|
+
if (color) {
|
|
185
|
+
this.hs$.next({ hue: color.hue, saturation: color.saturation });
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
console.warn('Color is null');
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
isInsideCircle(x, y) {
|
|
193
|
+
return combineLatest([this.squareSize$, this.shiftX$, this.shiftY$])
|
|
194
|
+
.pipe(map(([squareSize, shiftX, shiftY]) => {
|
|
195
|
+
// Position to the square
|
|
196
|
+
const sx = x - (shiftX ?? 0);
|
|
197
|
+
const sy = y - (shiftY ?? 0);
|
|
198
|
+
// Square radius
|
|
199
|
+
const sr = (squareSize ?? 0) / 2;
|
|
200
|
+
const radius = Math.sqrt(Math.pow(sx - sr, 2) + Math.pow(sy - sr, 2));
|
|
201
|
+
const angle = (Math.atan2(sr - sy, sr - sx) + Math.PI) % 360;
|
|
202
|
+
return {
|
|
203
|
+
inside: radius <= sr,
|
|
204
|
+
angle
|
|
205
|
+
};
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
208
|
+
position2color(x, y) {
|
|
209
|
+
return this.isInsideCircle(x, y).pipe(map((result) => {
|
|
210
|
+
if (!this.canvasContext) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
if (result.inside) {
|
|
214
|
+
const imageData = this.canvasContext.getImageData(x, y, 1, 1).data;
|
|
215
|
+
const hsl = this.rgb2Hsl({ r: imageData[0], g: imageData[1], b: imageData[2] });
|
|
216
|
+
return hsl;
|
|
217
|
+
}
|
|
218
|
+
return { hue: result.angle * 180 / Math.PI, saturation: 1, luminosity: 0.5 };
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
color2position(hs) {
|
|
222
|
+
return combineLatest([this.innerRadius$, this.outerRadius$])
|
|
223
|
+
.pipe(map(([innerRadius, outerRadius]) => {
|
|
224
|
+
if (innerRadius === null) {
|
|
225
|
+
innerRadius = 0;
|
|
226
|
+
}
|
|
227
|
+
if (!outerRadius) {
|
|
228
|
+
outerRadius = 100;
|
|
229
|
+
}
|
|
230
|
+
const theta = hs.hue * Math.PI / 180;
|
|
231
|
+
const c = {
|
|
232
|
+
x: -outerRadius * Math.cos(theta),
|
|
233
|
+
y: -outerRadius * Math.sin(theta)
|
|
234
|
+
};
|
|
235
|
+
const d = hs.saturation * (outerRadius - innerRadius) + innerRadius;
|
|
236
|
+
const o = { x: outerRadius, y: outerRadius };
|
|
237
|
+
return {
|
|
238
|
+
x: o.x - d * (c.x / outerRadius),
|
|
239
|
+
y: o.y - d * (c.y / outerRadius),
|
|
240
|
+
};
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
rgb2Hsl(color) {
|
|
244
|
+
const r01 = this.bound01(color.r, 255);
|
|
245
|
+
const g01 = this.bound01(color.g, 255);
|
|
246
|
+
const b01 = this.bound01(color.b, 255);
|
|
247
|
+
const max = Math.max(r01, g01, b01);
|
|
248
|
+
const min = Math.min(r01, g01, b01);
|
|
249
|
+
let h, s;
|
|
250
|
+
const l = (max + min) / 2;
|
|
251
|
+
if (max === min) {
|
|
252
|
+
h = s = 0;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
const d = max - min;
|
|
256
|
+
s = (l > 0.5) ? (d / (2 - max - min)) : (d / (max + min));
|
|
257
|
+
switch (max) {
|
|
258
|
+
case r01:
|
|
259
|
+
{
|
|
260
|
+
h = (g01 - b01) / d + ((g01 < b01) ? 6 : 0);
|
|
261
|
+
}
|
|
262
|
+
break;
|
|
263
|
+
case g01:
|
|
264
|
+
{
|
|
265
|
+
h = (b01 - r01) / d + 2;
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
case b01:
|
|
269
|
+
{
|
|
270
|
+
h = (r01 - g01) / d + 4;
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
273
|
+
default: {
|
|
274
|
+
throw 'Invalid operation';
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
h /= 6;
|
|
278
|
+
}
|
|
279
|
+
h *= 360;
|
|
280
|
+
return { hue: h, saturation: s, luminosity: l };
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Divide 1 to n, handling floating point errors.
|
|
284
|
+
* Ensures that the value is in between 0 and 1.
|
|
285
|
+
**/
|
|
286
|
+
bound01(n, max) {
|
|
287
|
+
n = Math.min(max, Math.max(0, n));
|
|
288
|
+
if ((Math.abs(n - max) < 0.000001)) {
|
|
289
|
+
return 1;
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
return (n % max) / max;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsColorWheelComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
296
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: BsColorWheelComponent, selector: "bs-color-wheel", inputs: { diameterRatio: "diameterRatio", width: "width", height: "height", hs: "hs", luminosity: "luminosity" }, outputs: { hsChange: "hsChange" }, host: { listeners: { "document:mousemove": "onMouseMove($event)", "document:mouseup": "onPointerUp($event)" }, properties: { "class.position-relative": "this.positionRelative" } }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true }], ngImport: i0, template: "<canvas\n class=\"d-block\"\n [width]=\"width$ | async\"\n [height]=\"height$ | async\"\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\"\n #canvas></canvas>\n\n<ng-container *ngIf=\"(markerPosition$ | async) as markerPosition\">\n <div class=\"thumb position-absolute pe-none\" [style.left.px]=\"markerPosition.x\" [style.top.px]=\"markerPosition.y\"></div>\n</ng-container>", 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"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] }); }
|
|
297
|
+
}
|
|
298
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsColorWheelComponent, decorators: [{
|
|
299
|
+
type: Component,
|
|
300
|
+
args: [{ selector: 'bs-color-wheel', template: "<canvas\n class=\"d-block\"\n [width]=\"width$ | async\"\n [height]=\"height$ | async\"\n (mousedown)=\"onPointerDown($event)\"\n (touchstart)=\"onPointerDown($event)\"\n (touchmove)=\"onPointerMove($event)\"\n (touchend)=\"onPointerUp($event)\"\n #canvas></canvas>\n\n<ng-container *ngIf=\"(markerPosition$ | async) as markerPosition\">\n <div class=\"thumb position-absolute pe-none\" [style.left.px]=\"markerPosition.x\" [style.top.px]=\"markerPosition.y\"></div>\n</ng-container>", 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"] }]
|
|
301
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { positionRelative: [{
|
|
302
|
+
type: HostBinding,
|
|
303
|
+
args: ['class.position-relative']
|
|
304
|
+
}], diameterRatio: [{
|
|
305
|
+
type: Input
|
|
306
|
+
}], width: [{
|
|
307
|
+
type: Input
|
|
308
|
+
}], height: [{
|
|
309
|
+
type: Input
|
|
310
|
+
}], canvas: [{
|
|
311
|
+
type: ViewChild,
|
|
312
|
+
args: ['canvas']
|
|
313
|
+
}], hsChange: [{
|
|
314
|
+
type: Output
|
|
315
|
+
}], hs: [{
|
|
316
|
+
type: Input
|
|
317
|
+
}], luminosity: [{
|
|
318
|
+
type: Input
|
|
319
|
+
}], onMouseMove: [{
|
|
320
|
+
type: HostListener,
|
|
321
|
+
args: ['document:mousemove', ['$event']]
|
|
322
|
+
}], onPointerUp: [{
|
|
323
|
+
type: HostListener,
|
|
324
|
+
args: ['document:mouseup', ['$event']]
|
|
325
|
+
}] } });
|
|
326
|
+
|
|
327
|
+
class BsSliderComponent {
|
|
328
|
+
constructor(element, zone) {
|
|
329
|
+
this.element = element;
|
|
330
|
+
this.zone = zone;
|
|
331
|
+
this.dBlock = true;
|
|
332
|
+
this.positionRelative = true;
|
|
333
|
+
//#region Value
|
|
334
|
+
this.value$ = new BehaviorSubject(0.5);
|
|
335
|
+
this.valueChange = new EventEmitter();
|
|
336
|
+
//#endregion
|
|
337
|
+
this.isPointerDown$ = new BehaviorSubject(false);
|
|
338
|
+
this.value$.pipe(takeUntilDestroyed())
|
|
339
|
+
.subscribe((value) => this.valueChange.emit(value));
|
|
340
|
+
this.thumbMarginLeft$ = this.value$.pipe(map((value) => {
|
|
341
|
+
const res = value * element.nativeElement.clientWidth - 12;
|
|
342
|
+
return res;
|
|
343
|
+
}));
|
|
344
|
+
this.cursorClass$ = this.isPointerDown$.pipe(map((isPointerDown) => {
|
|
345
|
+
return isPointerDown ? 'cursor-grabbing' : 'cursor-grab';
|
|
346
|
+
}));
|
|
347
|
+
}
|
|
348
|
+
get value() {
|
|
349
|
+
return this.value$.value;
|
|
350
|
+
}
|
|
351
|
+
set value(value) {
|
|
352
|
+
this.value$.next(value);
|
|
353
|
+
}
|
|
354
|
+
onPointerDown(ev) {
|
|
355
|
+
ev.preventDefault();
|
|
356
|
+
this.zone.run(() => this.isPointerDown$.next(true));
|
|
357
|
+
this.updateColor(ev);
|
|
358
|
+
}
|
|
359
|
+
onPointerMove(ev) {
|
|
360
|
+
if (this.isPointerDown$.value) {
|
|
361
|
+
ev.preventDefault();
|
|
362
|
+
ev.stopPropagation();
|
|
363
|
+
this.updateColor(ev);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
onPointerUp(ev) {
|
|
367
|
+
this.isPointerDown$.next(false);
|
|
368
|
+
}
|
|
369
|
+
updateColor(ev) {
|
|
370
|
+
let co;
|
|
371
|
+
const rect = this.track.nativeElement.getBoundingClientRect();
|
|
372
|
+
if ('touches' in ev) {
|
|
373
|
+
co = {
|
|
374
|
+
x: ev.touches[0].clientX - rect.left,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
co = {
|
|
379
|
+
x: ev.clientX - rect.left,
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
const percent = co.x / this.track.nativeElement.clientWidth;
|
|
383
|
+
const limited = Math.max(0, Math.min(1, percent));
|
|
384
|
+
this.value$.next(limited);
|
|
385
|
+
}
|
|
386
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsSliderComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
387
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: BsSliderComponent, selector: "bs-slider", inputs: { value: "value" }, outputs: { valueChange: "valueChange" }, host: { listeners: { "document:mousemove": "onPointerMove($event)", "document:mouseup": "onPointerUp($event)" }, properties: { "class.d-block": "this.dBlock", "class.position-relative": "this.positionRelative" } }, viewQueries: [{ propertyName: "track", first: true, predicate: ["track"], descendants: true }, { propertyName: "thumb", first: true, predicate: ["thumb"], descendants: 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$ | async\"\n [style.margin-left.px]=\"thumbMarginLeft$ | async\">\n <ng-content select=\"[bsThumb]\"></ng-content>\n </div>\n</div>", 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"], dependencies: [{ kind: "pipe", type: i1.AsyncPipe, name: "async" }] }); }
|
|
388
|
+
}
|
|
389
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsSliderComponent, decorators: [{
|
|
390
|
+
type: Component,
|
|
391
|
+
args: [{ selector: 'bs-slider', 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$ | async\"\n [style.margin-left.px]=\"thumbMarginLeft$ | async\">\n <ng-content select=\"[bsThumb]\"></ng-content>\n </div>\n</div>", 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"] }]
|
|
392
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { dBlock: [{
|
|
393
|
+
type: HostBinding,
|
|
394
|
+
args: ['class.d-block']
|
|
395
|
+
}], positionRelative: [{
|
|
396
|
+
type: HostBinding,
|
|
397
|
+
args: ['class.position-relative']
|
|
398
|
+
}], track: [{
|
|
399
|
+
type: ViewChild,
|
|
400
|
+
args: ['track']
|
|
401
|
+
}], thumb: [{
|
|
402
|
+
type: ViewChild,
|
|
403
|
+
args: ['thumb']
|
|
404
|
+
}], valueChange: [{
|
|
405
|
+
type: Output
|
|
406
|
+
}], value: [{
|
|
407
|
+
type: Input
|
|
408
|
+
}], onPointerMove: [{
|
|
409
|
+
type: HostListener,
|
|
410
|
+
args: ['document:mousemove', ['$event']]
|
|
411
|
+
}], onPointerUp: [{
|
|
412
|
+
type: HostListener,
|
|
413
|
+
args: ['document:mouseup', ['$event']]
|
|
414
|
+
}] } });
|
|
415
|
+
class BsThumbDirective {
|
|
416
|
+
constructor() {
|
|
417
|
+
this.thumbClass = true;
|
|
418
|
+
}
|
|
419
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsThumbDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
420
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.2", type: BsThumbDirective, selector: "[bsThumb]", host: { properties: { "class.thumb": "this.thumbClass", "class.position-absolute": "this.thumbClass" } }, ngImport: i0 }); }
|
|
421
|
+
}
|
|
422
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsThumbDirective, decorators: [{
|
|
423
|
+
type: Directive,
|
|
424
|
+
args: [{ selector: '[bsThumb]' }]
|
|
425
|
+
}], propDecorators: { thumbClass: [{
|
|
426
|
+
type: HostBinding,
|
|
427
|
+
args: ['class.thumb']
|
|
428
|
+
}, {
|
|
429
|
+
type: HostBinding,
|
|
430
|
+
args: ['class.position-absolute']
|
|
431
|
+
}] } });
|
|
432
|
+
class BsTrackDirective {
|
|
433
|
+
constructor() {
|
|
434
|
+
this.trackClass = true;
|
|
435
|
+
}
|
|
436
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsTrackDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
437
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.2", type: BsTrackDirective, selector: "[bsTrack]", host: { properties: { "class.track": "this.trackClass" } }, ngImport: i0 }); }
|
|
438
|
+
}
|
|
439
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsTrackDirective, decorators: [{
|
|
440
|
+
type: Directive,
|
|
441
|
+
args: [{ selector: '[bsTrack]' }]
|
|
442
|
+
}], propDecorators: { trackClass: [{
|
|
443
|
+
type: HostBinding,
|
|
444
|
+
args: ['class.track']
|
|
445
|
+
}] } });
|
|
446
|
+
|
|
447
|
+
class BsLuminosityStripComponent {
|
|
448
|
+
constructor() {
|
|
449
|
+
//#region HS
|
|
450
|
+
this.hs$ = new BehaviorSubject({ hue: 0, saturation: 0 });
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region Luminosity
|
|
453
|
+
this.luminosity$ = new BehaviorSubject(0.5);
|
|
454
|
+
this.luminosityChange = new EventEmitter();
|
|
455
|
+
//#endregion
|
|
456
|
+
this.canvasContext = null;
|
|
457
|
+
this.hs$.pipe(takeUntilDestroyed()).subscribe((hs) => {
|
|
458
|
+
if (this.canvasContext) {
|
|
459
|
+
const width = this.canvas.nativeElement.width, height = this.canvas.nativeElement.height;
|
|
460
|
+
this.canvasContext.clearRect(0, 0, width, height);
|
|
461
|
+
this.canvasContext.save();
|
|
462
|
+
// HSL
|
|
463
|
+
// - H: 0 - 359
|
|
464
|
+
// - S: "0%" - "100%"
|
|
465
|
+
// - L: "0%" - "50%" - "100%"
|
|
466
|
+
const gradient = this.canvasContext.createLinearGradient(0, 0, width, 0);
|
|
467
|
+
gradient.addColorStop(0, `hsl(${hs.hue}, ${hs.saturation * 100}%, 0%)`);
|
|
468
|
+
gradient.addColorStop(0.5, `hsl(${hs.hue}, ${hs.saturation * 100}%, 50%)`);
|
|
469
|
+
gradient.addColorStop(1, `hsl(${hs.hue}, ${hs.saturation * 100}%, 100%)`);
|
|
470
|
+
this.canvasContext.fillStyle = gradient;
|
|
471
|
+
this.canvasContext.fillRect(0, 0, width, height);
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
this.resultBackground$ = combineLatest([this.hs$, this.luminosity$])
|
|
475
|
+
.pipe(map(([hs, luminosity]) => {
|
|
476
|
+
return `hsl(${hs.hue}, ${hs.saturation * 100}%, ${luminosity * 100}%)`;
|
|
477
|
+
}));
|
|
478
|
+
this.luminosity$.pipe(takeUntilDestroyed())
|
|
479
|
+
.subscribe(luminosity => this.luminosityChange.emit(luminosity));
|
|
480
|
+
}
|
|
481
|
+
get hs() {
|
|
482
|
+
return this.hs$.value;
|
|
483
|
+
}
|
|
484
|
+
set hs(value) {
|
|
485
|
+
this.hs$.next(value);
|
|
486
|
+
}
|
|
487
|
+
get luminosity() {
|
|
488
|
+
return this.luminosity$.value;
|
|
489
|
+
}
|
|
490
|
+
set luminosity(value) {
|
|
491
|
+
this.luminosity$.next(value);
|
|
492
|
+
}
|
|
493
|
+
ngAfterViewInit() {
|
|
494
|
+
this.canvasContext = this.canvas.nativeElement.getContext('2d', { willReadFrequently: true });
|
|
495
|
+
}
|
|
496
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsLuminosityStripComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
497
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: BsLuminosityStripComponent, selector: "bs-luminosity-strip", inputs: { hs: "hs", luminosity: "luminosity" }, outputs: { luminosityChange: "luminosityChange" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["canvas"], descendants: true }], ngImport: i0, template: "<bs-slider [value]=\"(luminosity$ | async)!\" (valueChange)=\"luminosityChange.emit($event)\">\n <canvas bsTrack class=\"position-absolute w-100\" #canvas></canvas>\n <div bsThumb [style.background]=\"resultBackground$ | async\"></div>\n</bs-slider>", 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]" }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] }); }
|
|
498
|
+
}
|
|
499
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsLuminosityStripComponent, decorators: [{
|
|
500
|
+
type: Component,
|
|
501
|
+
args: [{ selector: 'bs-luminosity-strip', template: "<bs-slider [value]=\"(luminosity$ | async)!\" (valueChange)=\"luminosityChange.emit($event)\">\n <canvas bsTrack class=\"position-absolute w-100\" #canvas></canvas>\n <div bsThumb [style.background]=\"resultBackground$ | async\"></div>\n</bs-slider>" }]
|
|
502
|
+
}], ctorParameters: function () { return []; }, propDecorators: { hs: [{
|
|
503
|
+
type: Input
|
|
504
|
+
}], luminosityChange: [{
|
|
505
|
+
type: Output
|
|
506
|
+
}], luminosity: [{
|
|
507
|
+
type: Input
|
|
508
|
+
}], canvas: [{
|
|
509
|
+
type: ViewChild,
|
|
510
|
+
args: ['canvas']
|
|
511
|
+
}] } });
|
|
512
|
+
|
|
513
|
+
class BsAlphaStripComponent {
|
|
514
|
+
constructor() {
|
|
515
|
+
//#region HS
|
|
516
|
+
this.hs$ = new BehaviorSubject({ hue: 0, saturation: 0 });
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region Luminosity
|
|
519
|
+
this.luminosity$ = new BehaviorSubject(0.5);
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region Alpha
|
|
522
|
+
this.alpha$ = new BehaviorSubject(1);
|
|
523
|
+
this.alphaChange = new EventEmitter();
|
|
524
|
+
//#endregion
|
|
525
|
+
this.canvasContext = null;
|
|
526
|
+
combineLatest([this.hs$, this.luminosity$]).pipe(takeUntilDestroyed()).subscribe(([hs, luminosity]) => {
|
|
527
|
+
setTimeout(() => {
|
|
528
|
+
if (this.canvasContext) {
|
|
529
|
+
const width = this.canvas.nativeElement.width, height = this.canvas.nativeElement.height;
|
|
530
|
+
this.canvasContext.clearRect(0, 0, width, height);
|
|
531
|
+
this.canvasContext.save();
|
|
532
|
+
const gradient = this.canvasContext.createLinearGradient(0, 0, width, 0);
|
|
533
|
+
gradient.addColorStop(0, `hsla(${hs.hue}, ${hs.saturation * 100}%, ${luminosity * 100}%, 0)`);
|
|
534
|
+
gradient.addColorStop(1, `hsla(${hs.hue}, ${hs.saturation * 100}%, ${luminosity * 100}%, 1)`);
|
|
535
|
+
this.canvasContext.fillStyle = gradient;
|
|
536
|
+
this.canvasContext.fillRect(0, 0, width, height);
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
this.resultBackground$ = combineLatest([this.hs$, this.luminosity$, this.alpha$])
|
|
541
|
+
.pipe(map(([hs, luminosity, alpha]) => {
|
|
542
|
+
return `hsla(${hs.hue}, ${hs.saturation * 100}%, ${luminosity * 100}%, ${alpha})`;
|
|
543
|
+
}));
|
|
544
|
+
this.alpha$.pipe(takeUntilDestroyed())
|
|
545
|
+
.subscribe((alpha) => this.alphaChange.emit(alpha));
|
|
546
|
+
}
|
|
547
|
+
get hs() {
|
|
548
|
+
return this.hs$.value;
|
|
549
|
+
}
|
|
550
|
+
set hs(value) {
|
|
551
|
+
this.hs$.next(value);
|
|
552
|
+
}
|
|
553
|
+
get luminosity() {
|
|
554
|
+
return this.luminosity$.value;
|
|
555
|
+
}
|
|
556
|
+
set luminosity(value) {
|
|
557
|
+
this.luminosity$.next(value);
|
|
558
|
+
}
|
|
559
|
+
get alpha() {
|
|
560
|
+
return this.alpha$.value;
|
|
561
|
+
}
|
|
562
|
+
set alpha(value) {
|
|
563
|
+
this.alpha$.next(value);
|
|
564
|
+
}
|
|
565
|
+
ngAfterViewInit() {
|
|
566
|
+
this.canvasContext = this.canvas.nativeElement.getContext('2d', { willReadFrequently: true });
|
|
567
|
+
}
|
|
568
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsAlphaStripComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
569
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: BsAlphaStripComponent, selector: "bs-alpha-strip", inputs: { hs: "hs", luminosity: "luminosity", alpha: "alpha" }, outputs: { alphaChange: "alphaChange" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["track"], descendants: true }], ngImport: i0, template: "<bs-slider [value]=\"(alpha$ | async)!\" (valueChange)=\"alphaChange.emit($event)\">\n <canvas bsTrack class=\" track position-absolute w-100\" #track></canvas>\n\n <!-- [style.background]=\"resultBackground$ | async\" -->\n <div bsThumb [style.background]=\"resultBackground$ | async\"></div>\n</bs-slider>", 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]" }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] }); }
|
|
570
|
+
}
|
|
571
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsAlphaStripComponent, decorators: [{
|
|
572
|
+
type: Component,
|
|
573
|
+
args: [{ selector: 'bs-alpha-strip', template: "<bs-slider [value]=\"(alpha$ | async)!\" (valueChange)=\"alphaChange.emit($event)\">\n <canvas bsTrack class=\" track position-absolute w-100\" #track></canvas>\n\n <!-- [style.background]=\"resultBackground$ | async\" -->\n <div bsThumb [style.background]=\"resultBackground$ | async\"></div>\n</bs-slider>", 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"] }]
|
|
574
|
+
}], ctorParameters: function () { return []; }, propDecorators: { hs: [{
|
|
575
|
+
type: Input
|
|
576
|
+
}], luminosity: [{
|
|
577
|
+
type: Input
|
|
578
|
+
}], alphaChange: [{
|
|
579
|
+
type: Output
|
|
580
|
+
}], alpha: [{
|
|
581
|
+
type: Input
|
|
582
|
+
}], canvas: [{
|
|
583
|
+
type: ViewChild,
|
|
584
|
+
args: ['track']
|
|
585
|
+
}] } });
|
|
586
|
+
|
|
587
|
+
class BsColorPickerComponent {
|
|
588
|
+
constructor() {
|
|
589
|
+
this.width$ = new BehaviorSubject(150);
|
|
590
|
+
this.height$ = new BehaviorSubject(150);
|
|
591
|
+
this.disabled$ = new BehaviorSubject(false);
|
|
592
|
+
this.allowAlpha$ = new BehaviorSubject(true);
|
|
593
|
+
this.hs$ = new BehaviorSubject({ hue: 0, saturation: 0 });
|
|
594
|
+
this.luminosity$ = new BehaviorSubject(0);
|
|
595
|
+
//#region Alpha
|
|
596
|
+
this.alpha$ = new BehaviorSubject(1);
|
|
597
|
+
this.alphaChange = new EventEmitter();
|
|
598
|
+
this.alpha$.pipe(takeUntilDestroyed())
|
|
599
|
+
.subscribe((alpha) => this.alphaChange.emit(alpha));
|
|
600
|
+
}
|
|
601
|
+
set width(value) {
|
|
602
|
+
this.width$.next(value);
|
|
603
|
+
}
|
|
604
|
+
set height(value) {
|
|
605
|
+
this.height$.next(value);
|
|
606
|
+
}
|
|
607
|
+
set allowAlpha(value) {
|
|
608
|
+
this.allowAlpha$.next(value);
|
|
609
|
+
}
|
|
610
|
+
get alpha() {
|
|
611
|
+
return this.alpha$.value;
|
|
612
|
+
}
|
|
613
|
+
set alpha(value) {
|
|
614
|
+
this.alpha$.next(value);
|
|
615
|
+
}
|
|
616
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsColorPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
617
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.2", type: BsColorPickerComponent, selector: "bs-color-picker", inputs: { width: "width", height: "height", allowAlpha: "allowAlpha", alpha: "alpha" }, outputs: { alphaChange: "alphaChange" }, viewQueries: [{ propertyName: "colorWheel", first: true, predicate: ["wheel"], descendants: true }], ngImport: i0, template: "<ng-container *bsLet=\"(disabled$ | async)!; let letDisabled\">\n <ng-container *bsLet=\"(hs$ | async)!; let letHS\">\n <ng-container *bsLet=\"(luminosity$ | async)!; let letLuminosity\">\n <ng-container *bsLet=\"(alpha$ | async)!; let letAlpha\">\n <bs-color-wheel [hs]=\"letHS\" (hsChange)=\"hs$.next($event)\" [luminosity]=\"letLuminosity\" #wheel></bs-color-wheel>\n <bs-luminosity-strip [hs]=\"letHS\" [luminosity]=\"letLuminosity\" (luminosityChange)=\"luminosity$.next($event)\" class=\"d-block mt-2\" #strip></bs-luminosity-strip>\n <bs-alpha-strip *ngIf=\"allowAlpha$ | async\" [hs]=\"letHS\" [luminosity]=\"letLuminosity\" [alpha]=\"letAlpha\" (alphaChange)=\"alpha$.next($event)\" class=\"d-block mt-2\" #alpha></bs-alpha-strip>\n </ng-container>\n </ng-container>\n </ng-container>\n</ng-container>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.BsLetDirective, selector: "[bsLet]", inputs: ["bsLet"] }, { kind: "component", type: BsColorWheelComponent, selector: "bs-color-wheel", inputs: ["diameterRatio", "width", "height", "hs", "luminosity"], outputs: ["hsChange"] }, { kind: "component", type: BsLuminosityStripComponent, selector: "bs-luminosity-strip", inputs: ["hs", "luminosity"], outputs: ["luminosityChange"] }, { kind: "component", type: BsAlphaStripComponent, selector: "bs-alpha-strip", inputs: ["hs", "luminosity", "alpha"], outputs: ["alphaChange"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] }); }
|
|
618
|
+
}
|
|
619
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsColorPickerComponent, decorators: [{
|
|
620
|
+
type: Component,
|
|
621
|
+
args: [{ selector: 'bs-color-picker', template: "<ng-container *bsLet=\"(disabled$ | async)!; let letDisabled\">\n <ng-container *bsLet=\"(hs$ | async)!; let letHS\">\n <ng-container *bsLet=\"(luminosity$ | async)!; let letLuminosity\">\n <ng-container *bsLet=\"(alpha$ | async)!; let letAlpha\">\n <bs-color-wheel [hs]=\"letHS\" (hsChange)=\"hs$.next($event)\" [luminosity]=\"letLuminosity\" #wheel></bs-color-wheel>\n <bs-luminosity-strip [hs]=\"letHS\" [luminosity]=\"letLuminosity\" (luminosityChange)=\"luminosity$.next($event)\" class=\"d-block mt-2\" #strip></bs-luminosity-strip>\n <bs-alpha-strip *ngIf=\"allowAlpha$ | async\" [hs]=\"letHS\" [luminosity]=\"letLuminosity\" [alpha]=\"letAlpha\" (alphaChange)=\"alpha$.next($event)\" class=\"d-block mt-2\" #alpha></bs-alpha-strip>\n </ng-container>\n </ng-container>\n </ng-container>\n</ng-container>" }]
|
|
622
|
+
}], ctorParameters: function () { return []; }, propDecorators: { colorWheel: [{
|
|
623
|
+
type: ViewChild,
|
|
624
|
+
args: ['wheel']
|
|
625
|
+
}], width: [{
|
|
626
|
+
type: Input
|
|
627
|
+
}], height: [{
|
|
628
|
+
type: Input
|
|
629
|
+
}], allowAlpha: [{
|
|
630
|
+
type: Input
|
|
631
|
+
}], alphaChange: [{
|
|
632
|
+
type: Output
|
|
633
|
+
}], alpha: [{
|
|
634
|
+
type: Input
|
|
635
|
+
}] } });
|
|
636
|
+
|
|
637
|
+
class BsColorPickerValueAccessor {
|
|
638
|
+
constructor(host, destroy) {
|
|
639
|
+
this.host = host;
|
|
640
|
+
this.destroy = destroy;
|
|
641
|
+
}
|
|
642
|
+
ngAfterViewInit() {
|
|
643
|
+
combineLatest([this.host.hs$, this.host.luminosity$])
|
|
644
|
+
.pipe(takeUntilDestroyed(this.destroy))
|
|
645
|
+
.subscribe(([hs, luminosity]) => {
|
|
646
|
+
const rgb = this.hsl2rgb(hs.hue, hs.saturation, luminosity);
|
|
647
|
+
const hex = this.rgb2hex(rgb);
|
|
648
|
+
setTimeout(() => this.onValueChange && this.onValueChange(hex), 10);
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
hsl2rgb(h, s, l) {
|
|
652
|
+
const k = (n) => (n + h / 30) % 12;
|
|
653
|
+
const a = s * Math.min(l, 1 - l);
|
|
654
|
+
const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
655
|
+
const retValue = { r: 255 * f(0), g: 255 * f(8), b: 255 * f(4) };
|
|
656
|
+
return retValue;
|
|
657
|
+
}
|
|
658
|
+
//#region ControlValueAccessor implementation
|
|
659
|
+
registerOnChange(fn) {
|
|
660
|
+
this.onValueChange = fn;
|
|
661
|
+
}
|
|
662
|
+
registerOnTouched(fn) {
|
|
663
|
+
this.onTouched = fn;
|
|
664
|
+
}
|
|
665
|
+
writeValue(value) {
|
|
666
|
+
if (this.host && this.host.colorWheel) {
|
|
667
|
+
if (value) {
|
|
668
|
+
const rgb = this.hex2rgb(value);
|
|
669
|
+
const hsl = this.rgb2Hsl(rgb);
|
|
670
|
+
this.host.hs$.next({ hue: hsl.h, saturation: hsl.s });
|
|
671
|
+
this.host.luminosity$.next(hsl.l);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
setDisabledState(isDisabled) {
|
|
676
|
+
if (this.host && this.host.colorWheel) {
|
|
677
|
+
this.host.colorWheel.disabled$.next(isDisabled);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region Color Conversion
|
|
682
|
+
rgb2hex(rgb) {
|
|
683
|
+
return '#' + (Math.round((rgb.r << 16) + (rgb.g << 8) + rgb.b)).toString(16).padStart(6, '0');
|
|
684
|
+
}
|
|
685
|
+
hex2rgb(hex) {
|
|
686
|
+
const r = parseInt(hex.slice(1, 3), 16), g = parseInt(hex.slice(3, 5), 16), b = parseInt(hex.slice(5, 7), 16);
|
|
687
|
+
return { r, g, b };
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Divide 1 to n, handling floating point errors.
|
|
691
|
+
* Ensures that the value is in between 0 and 1.
|
|
692
|
+
**/
|
|
693
|
+
bound01(n, max) {
|
|
694
|
+
n = Math.min(max, Math.max(0, n));
|
|
695
|
+
if (Math.abs(n - max) < 0.000001) {
|
|
696
|
+
return 1;
|
|
697
|
+
}
|
|
698
|
+
else {
|
|
699
|
+
return (n % max) / max;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
rgb2Hsl(color) {
|
|
703
|
+
const r01 = this.bound01(color.r, 255);
|
|
704
|
+
const g01 = this.bound01(color.g, 255);
|
|
705
|
+
const b01 = this.bound01(color.b, 255);
|
|
706
|
+
const max = Math.max(r01, g01, b01);
|
|
707
|
+
const min = Math.min(r01, g01, b01);
|
|
708
|
+
let h, s;
|
|
709
|
+
const l = (max + min) / 2;
|
|
710
|
+
if (max === min) {
|
|
711
|
+
h = s = 0;
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
const d = max - min;
|
|
715
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
716
|
+
switch (max) {
|
|
717
|
+
case r01:
|
|
718
|
+
h = (g01 - b01) / d + (g01 < b01 ? 6 : 0);
|
|
719
|
+
break;
|
|
720
|
+
case g01:
|
|
721
|
+
h = (b01 - r01) / d + 2;
|
|
722
|
+
break;
|
|
723
|
+
case b01:
|
|
724
|
+
h = (r01 - g01) / d + 4;
|
|
725
|
+
break;
|
|
726
|
+
default: {
|
|
727
|
+
throw 'Invalid operation';
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
h /= 6;
|
|
731
|
+
}
|
|
732
|
+
h *= 360;
|
|
733
|
+
return { h, s, l };
|
|
734
|
+
}
|
|
735
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsColorPickerValueAccessor, deps: [{ token: forwardRef(() => BsColorPickerComponent) }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
736
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.2", type: BsColorPickerValueAccessor, selector: "bs-color-picker", providers: [{
|
|
737
|
+
provide: NG_VALUE_ACCESSOR,
|
|
738
|
+
// useExisting: BsColorPickerValueAccessor,
|
|
739
|
+
useExisting: forwardRef(() => BsColorPickerValueAccessor),
|
|
740
|
+
multi: true
|
|
741
|
+
}], exportAs: ["bsColorPicker"], ngImport: i0 }); }
|
|
742
|
+
}
|
|
743
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsColorPickerValueAccessor, decorators: [{
|
|
744
|
+
type: Directive,
|
|
745
|
+
args: [{
|
|
746
|
+
selector: 'bs-color-picker',
|
|
747
|
+
providers: [{
|
|
748
|
+
provide: NG_VALUE_ACCESSOR,
|
|
749
|
+
// useExisting: BsColorPickerValueAccessor,
|
|
750
|
+
useExisting: forwardRef(() => BsColorPickerValueAccessor),
|
|
751
|
+
multi: true
|
|
752
|
+
}],
|
|
753
|
+
exportAs: 'bsColorPicker'
|
|
754
|
+
}]
|
|
755
|
+
}], ctorParameters: function () { return [{ type: BsColorPickerComponent, decorators: [{
|
|
756
|
+
type: Inject,
|
|
757
|
+
args: [forwardRef(() => BsColorPickerComponent)]
|
|
758
|
+
}] }, { type: i0.DestroyRef }]; } });
|
|
759
|
+
|
|
760
|
+
class BsColorPickerModule {
|
|
761
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsColorPickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
762
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.2", ngImport: i0, type: BsColorPickerModule, declarations: [BsColorPickerComponent,
|
|
763
|
+
BsColorPickerValueAccessor,
|
|
764
|
+
BsColorWheelComponent,
|
|
765
|
+
BsLuminosityStripComponent,
|
|
766
|
+
BsSliderComponent,
|
|
767
|
+
BsThumbDirective,
|
|
768
|
+
BsTrackDirective,
|
|
769
|
+
BsAlphaStripComponent], imports: [CommonModule,
|
|
770
|
+
FormsModule,
|
|
771
|
+
BsLetModule], exports: [BsColorPickerComponent,
|
|
772
|
+
BsColorPickerValueAccessor,
|
|
773
|
+
BsColorWheelComponent,
|
|
774
|
+
BsLuminosityStripComponent,
|
|
775
|
+
BsSliderComponent,
|
|
776
|
+
BsThumbDirective,
|
|
777
|
+
BsTrackDirective,
|
|
778
|
+
BsAlphaStripComponent] }); }
|
|
779
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsColorPickerModule, imports: [CommonModule,
|
|
780
|
+
FormsModule,
|
|
781
|
+
BsLetModule] }); }
|
|
782
|
+
}
|
|
783
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.2", ngImport: i0, type: BsColorPickerModule, decorators: [{
|
|
784
|
+
type: NgModule,
|
|
785
|
+
args: [{
|
|
786
|
+
declarations: [
|
|
787
|
+
BsColorPickerComponent,
|
|
788
|
+
BsColorPickerValueAccessor,
|
|
789
|
+
BsColorWheelComponent,
|
|
790
|
+
BsLuminosityStripComponent,
|
|
791
|
+
BsSliderComponent,
|
|
792
|
+
BsThumbDirective,
|
|
793
|
+
BsTrackDirective,
|
|
794
|
+
BsAlphaStripComponent
|
|
795
|
+
],
|
|
796
|
+
imports: [
|
|
797
|
+
CommonModule,
|
|
798
|
+
FormsModule,
|
|
799
|
+
BsLetModule
|
|
800
|
+
],
|
|
801
|
+
exports: [
|
|
802
|
+
BsColorPickerComponent,
|
|
803
|
+
BsColorPickerValueAccessor,
|
|
804
|
+
BsColorWheelComponent,
|
|
805
|
+
BsLuminosityStripComponent,
|
|
806
|
+
BsSliderComponent,
|
|
807
|
+
BsThumbDirective,
|
|
808
|
+
BsTrackDirective,
|
|
809
|
+
BsAlphaStripComponent
|
|
810
|
+
]
|
|
811
|
+
}]
|
|
812
|
+
}] });
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Generated bundle index. Do not edit.
|
|
816
|
+
*/
|
|
817
|
+
|
|
818
|
+
export { BsAlphaStripComponent, BsColorPickerComponent, BsColorPickerModule, BsColorPickerValueAccessor, BsColorWheelComponent, BsLuminosityStripComponent, BsSliderComponent, BsThumbDirective, BsTrackDirective };
|
|
819
|
+
//# sourceMappingURL=mintplayer-ng-bootstrap-color-picker.mjs.map
|