@ngx-mce/color-picker 22.2.8 → 22.2.9
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/fesm2022/ngx-mce-color-picker.mjs +1752 -1325
- package/fesm2022/ngx-mce-color-picker.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ngx-mce-color-picker.d.ts +450 -364
|
@@ -1,1364 +1,1791 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import * as i3 from
|
|
4
|
-
import { FormGroup,
|
|
5
|
-
import * as i1 from
|
|
6
|
-
import {
|
|
7
|
-
import * as i2 from
|
|
8
|
-
import {
|
|
9
|
-
import { Subject,
|
|
10
|
-
import {
|
|
11
|
-
import { NgClass } from
|
|
12
|
-
import * as i1
|
|
13
|
-
import { MatButtonModule } from
|
|
14
|
-
import { Directionality } from
|
|
15
|
-
import { coerceBooleanProperty } from
|
|
16
|
-
import { ESCAPE, UP_ARROW
|
|
17
|
-
import { Overlay, OverlayConfig } from
|
|
18
|
-
import { ComponentPortal } from
|
|
19
|
-
import { MatDialog } from
|
|
20
|
-
import * as i2
|
|
21
|
-
import { MatIconModule } from
|
|
22
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DOCUMENT, Directive, ElementRef, EventEmitter, HostBinding, HostListener, Injectable, InjectionToken, Input, NgZone, Output, ViewContainerRef, ViewEncapsulation, effect, forwardRef, inject, input, output, signal, untracked, viewChild } from "@angular/core";
|
|
3
|
+
import * as i3 from "@angular/forms";
|
|
4
|
+
import { FormControl, FormGroup, NG_VALIDATORS, NG_VALUE_ACCESSOR, ReactiveFormsModule, Validators } from "@angular/forms";
|
|
5
|
+
import * as i1$1 from "@angular/material/form-field";
|
|
6
|
+
import { MatFormField, MatFormFieldModule } from "@angular/material/form-field";
|
|
7
|
+
import * as i2$1 from "@angular/material/input";
|
|
8
|
+
import { MAT_INPUT_VALUE_ACCESSOR, MatInputModule } from "@angular/material/input";
|
|
9
|
+
import { Subject, Subscription, merge, of } from "rxjs";
|
|
10
|
+
import { debounceTime, distinctUntilChanged, filter, take, takeUntil } from "rxjs/operators";
|
|
11
|
+
import { NgClass } from "@angular/common";
|
|
12
|
+
import * as i1 from "@angular/material/button";
|
|
13
|
+
import { MatButtonModule } from "@angular/material/button";
|
|
14
|
+
import { Directionality } from "@angular/cdk/bidi";
|
|
15
|
+
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
|
16
|
+
import { DOWN_ARROW, ESCAPE, UP_ARROW } from "@angular/cdk/keycodes";
|
|
17
|
+
import { Overlay, OverlayConfig } from "@angular/cdk/overlay";
|
|
18
|
+
import { ComponentPortal } from "@angular/cdk/portal";
|
|
19
|
+
import { MatDialog } from "@angular/material/dialog";
|
|
20
|
+
import * as i2 from "@angular/material/icon";
|
|
21
|
+
import { MatIconModule } from "@angular/material/icon";
|
|
23
22
|
const trimLeft = /^\s+/;
|
|
24
23
|
const trimRight = /\s+$/;
|
|
25
24
|
const mathRound = Math.round;
|
|
26
25
|
const NUMERIC_REGEX = /[^0-9]/g;
|
|
27
26
|
const MAX_RGB = 255;
|
|
28
27
|
const MIN_RGB = 0;
|
|
29
|
-
/** List basic colors */
|
|
30
28
|
const BASIC_COLORS = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
"#ffffff",
|
|
30
|
+
"#ffff00",
|
|
31
|
+
"#ff00ff",
|
|
32
|
+
"#ff0000",
|
|
33
|
+
"#c0c0c0",
|
|
34
|
+
"#808080",
|
|
35
|
+
"#808000",
|
|
36
|
+
"#800080",
|
|
37
|
+
"#800000",
|
|
38
|
+
"#00ffff",
|
|
39
|
+
"#00ff00",
|
|
40
|
+
"#008080",
|
|
41
|
+
"#008000",
|
|
42
|
+
"#0000ff",
|
|
43
|
+
"#000080",
|
|
44
|
+
"#000000"
|
|
47
45
|
];
|
|
48
|
-
/**
|
|
49
|
-
* Get color at position
|
|
50
|
-
* @param ctx
|
|
51
|
-
* @param x
|
|
52
|
-
* @param y
|
|
53
|
-
*/
|
|
54
46
|
function getColorAtPosition(ctx, x, y) {
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
const imageData = ctx.getImageData(x, y, 1, 1).data;
|
|
48
|
+
return {
|
|
49
|
+
r: imageData[0],
|
|
50
|
+
g: imageData[1],
|
|
51
|
+
b: imageData[2]
|
|
52
|
+
};
|
|
57
53
|
}
|
|
58
|
-
// `rgbaToHex`
|
|
59
|
-
// Converts an RGBA color plus alpha transparency to hex
|
|
60
|
-
// Assumes r, g, b are contained in the set [0, 255] and
|
|
61
|
-
// a in [0, 1]. Returns a 4 or 8 character rgba hex
|
|
62
54
|
function rgbaToHex(r, g, b, a, allow4Char) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
hex[0].charAt(0) == hex[0].charAt(1) &&
|
|
72
|
-
hex[1].charAt(0) == hex[1].charAt(1) &&
|
|
73
|
-
hex[2].charAt(0) == hex[2].charAt(1) &&
|
|
74
|
-
hex[3].charAt(0) == hex[3].charAt(1)) {
|
|
75
|
-
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
|
|
76
|
-
}
|
|
77
|
-
return hex.join('');
|
|
55
|
+
const hex = [
|
|
56
|
+
pad2(mathRound(r).toString(16)),
|
|
57
|
+
pad2(mathRound(g).toString(16)),
|
|
58
|
+
pad2(mathRound(b).toString(16)),
|
|
59
|
+
pad2(convertDecimalToHex(a.toString(16)))
|
|
60
|
+
];
|
|
61
|
+
if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
|
|
62
|
+
return hex.join("");
|
|
78
63
|
}
|
|
79
|
-
// Force a hex value to have 2 characters
|
|
80
64
|
function pad2(c) {
|
|
81
|
-
|
|
65
|
+
return c.length == 1 ? "0" + c : "" + c;
|
|
82
66
|
}
|
|
83
|
-
// Converts a decimal to a hex value
|
|
84
67
|
function convertDecimalToHex(d) {
|
|
85
|
-
|
|
68
|
+
return Math.round(parseFloat(d) * 255).toString(16);
|
|
86
69
|
}
|
|
87
|
-
// Converts a hex value to a decimal
|
|
88
70
|
function convertHexToDecimal(h) {
|
|
89
|
-
|
|
71
|
+
return parseIntFromHex(h) / 255;
|
|
90
72
|
}
|
|
91
|
-
// Parse a base-16 hex value into a base-10 integer
|
|
92
73
|
function parseIntFromHex(val) {
|
|
93
|
-
|
|
74
|
+
return parseInt(val, 16);
|
|
94
75
|
}
|
|
95
|
-
// `rgbToHex`
|
|
96
|
-
// Converts an RGB color to hex
|
|
97
|
-
// Assumes r, g, and b are contained in the set [0, 255]
|
|
98
|
-
// Returns a 3 or 6 character hex
|
|
99
76
|
function rgbToHex(r, g, b, allow3Char) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
hex[0].charAt(0) == hex[0].charAt(1) &&
|
|
108
|
-
hex[1].charAt(0) == hex[1].charAt(1) &&
|
|
109
|
-
hex[2].charAt(0) == hex[2].charAt(1)) {
|
|
110
|
-
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
111
|
-
}
|
|
112
|
-
return hex.join('');
|
|
77
|
+
const hex = [
|
|
78
|
+
pad2(mathRound(r).toString(16)),
|
|
79
|
+
pad2(mathRound(g).toString(16)),
|
|
80
|
+
pad2(mathRound(b).toString(16))
|
|
81
|
+
];
|
|
82
|
+
if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
83
|
+
return hex.join("");
|
|
113
84
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const CSS_INTEGER = '[-\\+]?\\d+%?';
|
|
118
|
-
const CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
|
|
119
|
-
const CSS_UNIT = '(?:' + CSS_NUMBER + ')|(?:' + CSS_INTEGER + ')';
|
|
120
|
-
const PERMISSIVE_MATCH3 = '[\\s|\\(]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')\\s*\\)?';
|
|
121
|
-
const PERMISSIVE_MATCH4 = '[\\s|\\(]+(' +
|
|
122
|
-
CSS_UNIT +
|
|
123
|
-
')[,|\\s]+(' +
|
|
124
|
-
CSS_UNIT +
|
|
125
|
-
')[,|\\s]+(' +
|
|
126
|
-
CSS_UNIT +
|
|
127
|
-
')[,|\\s]+(' +
|
|
128
|
-
CSS_UNIT +
|
|
129
|
-
')\\s*\\)?';
|
|
85
|
+
const CSS_UNIT = "(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)";
|
|
86
|
+
const PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
87
|
+
const PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
130
88
|
const matchers = {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
89
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
90
|
+
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
|
|
91
|
+
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
|
|
92
|
+
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
|
|
93
|
+
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
|
|
94
|
+
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
|
|
95
|
+
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
|
|
96
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
97
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
98
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
99
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
142
100
|
};
|
|
143
|
-
// `stringInputToObject`
|
|
144
|
-
// Permissive string parsing. Take in a number of formats, and output an object
|
|
145
|
-
// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
146
101
|
function stringInputToObject(color) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
r: parseIntFromHex(match[1] + '' + match[1]),
|
|
188
|
-
g: parseIntFromHex(match[2] + '' + match[2]),
|
|
189
|
-
b: parseIntFromHex(match[3] + '' + match[3]),
|
|
190
|
-
a: convertHexToDecimal(match[4] + '' + match[4]),
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
if ((match = matchers.hex3.exec(color))) {
|
|
194
|
-
return {
|
|
195
|
-
r: parseIntFromHex(match[1] + '' + match[1]),
|
|
196
|
-
g: parseIntFromHex(match[2] + '' + match[2]),
|
|
197
|
-
b: parseIntFromHex(match[3] + '' + match[3]),
|
|
198
|
-
a: 1,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
return null;
|
|
102
|
+
color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
|
|
103
|
+
let match;
|
|
104
|
+
if (match = matchers.rgb.exec(color)) return {
|
|
105
|
+
r: parseFloat(match[1]),
|
|
106
|
+
g: parseFloat(match[2]),
|
|
107
|
+
b: parseFloat(match[3]),
|
|
108
|
+
a: 1
|
|
109
|
+
};
|
|
110
|
+
if (match = matchers.rgba.exec(color)) return {
|
|
111
|
+
r: parseFloat(match[1]),
|
|
112
|
+
g: parseFloat(match[2]),
|
|
113
|
+
b: parseFloat(match[3]),
|
|
114
|
+
a: parseFloat(match[4])
|
|
115
|
+
};
|
|
116
|
+
if (match = matchers.hex8.exec(color)) return {
|
|
117
|
+
r: parseIntFromHex(match[1]),
|
|
118
|
+
g: parseIntFromHex(match[2]),
|
|
119
|
+
b: parseIntFromHex(match[3]),
|
|
120
|
+
a: convertHexToDecimal(match[4])
|
|
121
|
+
};
|
|
122
|
+
if (match = matchers.hex6.exec(color)) return {
|
|
123
|
+
r: parseIntFromHex(match[1]),
|
|
124
|
+
g: parseIntFromHex(match[2]),
|
|
125
|
+
b: parseIntFromHex(match[3]),
|
|
126
|
+
a: 1
|
|
127
|
+
};
|
|
128
|
+
if (match = matchers.hex4.exec(color)) return {
|
|
129
|
+
r: parseIntFromHex(match[1] + "" + match[1]),
|
|
130
|
+
g: parseIntFromHex(match[2] + "" + match[2]),
|
|
131
|
+
b: parseIntFromHex(match[3] + "" + match[3]),
|
|
132
|
+
a: convertHexToDecimal(match[4] + "" + match[4])
|
|
133
|
+
};
|
|
134
|
+
if (match = matchers.hex3.exec(color)) return {
|
|
135
|
+
r: parseIntFromHex(match[1] + "" + match[1]),
|
|
136
|
+
g: parseIntFromHex(match[2] + "" + match[2]),
|
|
137
|
+
b: parseIntFromHex(match[3] + "" + match[3]),
|
|
138
|
+
a: 1
|
|
139
|
+
};
|
|
140
|
+
return null;
|
|
202
141
|
}
|
|
203
142
|
function createMissingDateImplError(provider) {
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
class Color {
|
|
208
|
-
r;
|
|
209
|
-
g;
|
|
210
|
-
b;
|
|
211
|
-
a;
|
|
212
|
-
roundA;
|
|
213
|
-
hex;
|
|
214
|
-
rgba;
|
|
215
|
-
constructor(_r, _g, _b, _a) {
|
|
216
|
-
this.r = _r > MAX_RGB ? MAX_RGB : _r;
|
|
217
|
-
this.g = _g > MAX_RGB ? MAX_RGB : _g;
|
|
218
|
-
this.b = _b > MAX_RGB ? MAX_RGB : _b;
|
|
219
|
-
if (_a != null) {
|
|
220
|
-
this.a = _a > 1 ? 1 : _a;
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
this.a = 1;
|
|
224
|
-
}
|
|
225
|
-
this.roundA = Math.round(this.a);
|
|
226
|
-
this.hex = rgbToHex(this.r, this.g, this.b);
|
|
227
|
-
this.rgba = this.toRgba();
|
|
228
|
-
}
|
|
229
|
-
toHex(allow3Char) {
|
|
230
|
-
return rgbToHex(this.r, this.g, this.b, allow3Char);
|
|
231
|
-
}
|
|
232
|
-
toRgba() {
|
|
233
|
-
return `rgba(${this.r},${this.g},${this.b},${this.a})`;
|
|
234
|
-
}
|
|
235
|
-
toHexString(allow3Char) {
|
|
236
|
-
return '#' + this.toHex(allow3Char);
|
|
237
|
-
}
|
|
238
|
-
toRgbString() {
|
|
239
|
-
return this.a === 1
|
|
240
|
-
? 'rgb(' + Math.round(this.r) + ', ' + Math.round(this.g) + ', ' + Math.round(this.b) + ')'
|
|
241
|
-
: 'rgba(' +
|
|
242
|
-
Math.round(this.r) +
|
|
243
|
-
', ' +
|
|
244
|
-
Math.round(this.g) +
|
|
245
|
-
', ' +
|
|
246
|
-
Math.round(this.b) +
|
|
247
|
-
', ' +
|
|
248
|
-
this.roundA +
|
|
249
|
-
')';
|
|
250
|
-
}
|
|
251
|
-
toHex8(allow4Char) {
|
|
252
|
-
return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
|
|
253
|
-
}
|
|
254
|
-
toHex8String(allow4Char) {
|
|
255
|
-
return '#' + this.toHex8(allow4Char);
|
|
256
|
-
}
|
|
257
|
-
toString(format) {
|
|
258
|
-
const formatSet = !!format;
|
|
259
|
-
let formattedString;
|
|
260
|
-
const hasAlpha = this.a < 1 && this.a >= 0;
|
|
261
|
-
const needsAlphaFormat = !formatSet &&
|
|
262
|
-
hasAlpha &&
|
|
263
|
-
(format === 'hex' ||
|
|
264
|
-
format === 'hex6' ||
|
|
265
|
-
format === 'hex3' ||
|
|
266
|
-
format === 'hex4' ||
|
|
267
|
-
format === 'hex8');
|
|
268
|
-
if (needsAlphaFormat) {
|
|
269
|
-
return this.toRgbString();
|
|
270
|
-
}
|
|
271
|
-
if (format === 'rgb') {
|
|
272
|
-
formattedString = this.toRgbString();
|
|
273
|
-
}
|
|
274
|
-
if (format === 'hex' || format === 'hex6') {
|
|
275
|
-
formattedString = this.toHexString();
|
|
276
|
-
}
|
|
277
|
-
if (format === 'hex3') {
|
|
278
|
-
formattedString = this.toHexString(true);
|
|
279
|
-
}
|
|
280
|
-
if (format === 'hex4') {
|
|
281
|
-
formattedString = this.toHex8String(true);
|
|
282
|
-
}
|
|
283
|
-
if (format === 'hex8') {
|
|
284
|
-
formattedString = this.toHex8String();
|
|
285
|
-
}
|
|
286
|
-
return formattedString || this.toHexString();
|
|
287
|
-
}
|
|
143
|
+
return Error(`NgxMatColorPicker: No provider found for ${provider}. You must define MAT_COLOR_FORMATS in your module`);
|
|
288
144
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
145
|
+
var Color = class {
|
|
146
|
+
r;
|
|
147
|
+
g;
|
|
148
|
+
b;
|
|
149
|
+
a;
|
|
150
|
+
roundA;
|
|
151
|
+
hex;
|
|
152
|
+
rgba;
|
|
153
|
+
constructor(_r, _g, _b, _a) {
|
|
154
|
+
this.r = _r > 255 ? 255 : _r;
|
|
155
|
+
this.g = _g > 255 ? 255 : _g;
|
|
156
|
+
this.b = _b > 255 ? 255 : _b;
|
|
157
|
+
if (_a != null) this.a = _a > 1 ? 1 : _a;
|
|
158
|
+
else this.a = 1;
|
|
159
|
+
this.roundA = Math.round(this.a);
|
|
160
|
+
this.hex = rgbToHex(this.r, this.g, this.b);
|
|
161
|
+
this.rgba = this.toRgba();
|
|
162
|
+
}
|
|
163
|
+
toHex(allow3Char) {
|
|
164
|
+
return rgbToHex(this.r, this.g, this.b, allow3Char);
|
|
165
|
+
}
|
|
166
|
+
toRgba() {
|
|
167
|
+
return `rgba(${this.r},${this.g},${this.b},${this.a})`;
|
|
168
|
+
}
|
|
169
|
+
toHexString(allow3Char) {
|
|
170
|
+
return "#" + this.toHex(allow3Char);
|
|
171
|
+
}
|
|
172
|
+
toRgbString() {
|
|
173
|
+
return this.a === 1 ? "rgb(" + Math.round(this.r) + ", " + Math.round(this.g) + ", " + Math.round(this.b) + ")" : "rgba(" + Math.round(this.r) + ", " + Math.round(this.g) + ", " + Math.round(this.b) + ", " + this.roundA + ")";
|
|
174
|
+
}
|
|
175
|
+
toHex8(allow4Char) {
|
|
176
|
+
return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
|
|
177
|
+
}
|
|
178
|
+
toHex8String(allow4Char) {
|
|
179
|
+
return "#" + this.toHex8(allow4Char);
|
|
180
|
+
}
|
|
181
|
+
toString(format) {
|
|
182
|
+
const formatSet = !!format;
|
|
183
|
+
let formattedString;
|
|
184
|
+
const hasAlpha = this.a < 1 && this.a >= 0;
|
|
185
|
+
if (!formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8")) return this.toRgbString();
|
|
186
|
+
if (format === "rgb") formattedString = this.toRgbString();
|
|
187
|
+
if (format === "hex" || format === "hex6") formattedString = this.toHexString();
|
|
188
|
+
if (format === "hex3") formattedString = this.toHexString(true);
|
|
189
|
+
if (format === "hex4") formattedString = this.toHex8String(true);
|
|
190
|
+
if (format === "hex8") formattedString = this.toHex8String();
|
|
191
|
+
return formattedString || this.toHexString();
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var NgxMatBaseColorCanvas = class NgxMatBaseColorCanvas {
|
|
195
|
+
colorChanged = output();
|
|
196
|
+
theme = input(...ngDevMode ? [void 0, { debugName: "theme" }] : /* istanbul ignore next */ []);
|
|
197
|
+
color = signal(null, ...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
|
|
198
|
+
set setColor(color) {
|
|
199
|
+
this.color.set(color);
|
|
200
|
+
}
|
|
201
|
+
canvas = null;
|
|
202
|
+
elementId;
|
|
203
|
+
ctx = null;
|
|
204
|
+
width = 0;
|
|
205
|
+
height = 0;
|
|
206
|
+
x = 0;
|
|
207
|
+
y = 0;
|
|
208
|
+
drag = false;
|
|
209
|
+
_destroyed = new Subject();
|
|
210
|
+
zone = null;
|
|
211
|
+
constructor(elementId) {
|
|
212
|
+
this.elementId = elementId;
|
|
213
|
+
}
|
|
214
|
+
ngOnDestroy() {
|
|
215
|
+
this._destroyed.next();
|
|
216
|
+
this._destroyed.complete();
|
|
217
|
+
}
|
|
218
|
+
ngAfterViewInit() {
|
|
219
|
+
this.canvas = document.getElementById(this.elementId);
|
|
220
|
+
this.ctx = this.canvas.getContext("2d");
|
|
221
|
+
this.width = this.canvas.width;
|
|
222
|
+
this.height = this.canvas.height;
|
|
223
|
+
this.draw();
|
|
224
|
+
}
|
|
225
|
+
draw() {
|
|
226
|
+
this.ctx?.clearRect(0, 0, this.width, this.height);
|
|
227
|
+
this.ctx?.rect(0, 0, this.width, this.height);
|
|
228
|
+
this.fillGradient();
|
|
229
|
+
if (this.y != 0) this.redrawIndicator(this.x, this.y);
|
|
230
|
+
}
|
|
231
|
+
onMousedown(e) {
|
|
232
|
+
this.drag = true;
|
|
233
|
+
this.changeColor(e);
|
|
234
|
+
this.zone?.runOutsideAngular(() => {
|
|
235
|
+
this.canvas?.addEventListener("mousemove", this.onMousemove.bind(this));
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
onMousemove(e) {
|
|
239
|
+
if (this.drag) this.zone?.run(() => {
|
|
240
|
+
this.changeColor(e);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
onMouseup(_) {
|
|
244
|
+
this.drag = false;
|
|
245
|
+
this.canvas?.removeEventListener("mousemove", this.onMousemove);
|
|
246
|
+
}
|
|
247
|
+
emitChange(color) {
|
|
248
|
+
this.colorChanged.emit(color);
|
|
249
|
+
}
|
|
250
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
251
|
+
minVersion: "12.0.0",
|
|
252
|
+
version: "22.2.0",
|
|
253
|
+
ngImport: i0,
|
|
254
|
+
type: NgxMatBaseColorCanvas,
|
|
255
|
+
deps: "invalid",
|
|
256
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
257
|
+
});
|
|
258
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
259
|
+
minVersion: "17.1.0",
|
|
260
|
+
version: "22.2.0",
|
|
261
|
+
type: NgxMatBaseColorCanvas,
|
|
262
|
+
isStandalone: true,
|
|
263
|
+
inputs: {
|
|
264
|
+
theme: {
|
|
265
|
+
classPropertyName: "theme",
|
|
266
|
+
publicName: "theme",
|
|
267
|
+
isSignal: true,
|
|
268
|
+
isRequired: false,
|
|
269
|
+
transformFunction: null
|
|
270
|
+
},
|
|
271
|
+
setColor: {
|
|
272
|
+
classPropertyName: "setColor",
|
|
273
|
+
publicName: "color",
|
|
274
|
+
isSignal: false,
|
|
275
|
+
isRequired: false,
|
|
276
|
+
transformFunction: null
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
outputs: { colorChanged: "colorChanged" },
|
|
280
|
+
ngImport: i0
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
284
|
+
minVersion: "12.0.0",
|
|
285
|
+
version: "22.2.0",
|
|
286
|
+
ngImport: i0,
|
|
287
|
+
type: NgxMatBaseColorCanvas,
|
|
288
|
+
decorators: [{ type: Directive }],
|
|
289
|
+
ctorParameters: () => [{ type: void 0 }],
|
|
290
|
+
propDecorators: {
|
|
291
|
+
colorChanged: [{
|
|
292
|
+
type: i0.Output,
|
|
293
|
+
args: ["colorChanged"]
|
|
294
|
+
}],
|
|
295
|
+
theme: [{
|
|
296
|
+
type: i0.Input,
|
|
297
|
+
args: [{
|
|
298
|
+
isSignal: true,
|
|
299
|
+
alias: "theme",
|
|
300
|
+
required: false
|
|
301
|
+
}]
|
|
302
|
+
}],
|
|
303
|
+
setColor: [{
|
|
304
|
+
type: Input,
|
|
305
|
+
args: [{ alias: "color" }]
|
|
306
|
+
}]
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
var NgxMatColorSliderComponent = class NgxMatColorSliderComponent extends NgxMatBaseColorCanvas {
|
|
310
|
+
zone = inject(NgZone);
|
|
311
|
+
constructor() {
|
|
312
|
+
super("color-strip");
|
|
313
|
+
}
|
|
314
|
+
ngAfterViewInit() {
|
|
315
|
+
super.ngAfterViewInit();
|
|
316
|
+
}
|
|
317
|
+
fillGradient() {
|
|
318
|
+
const grd = this.ctx?.createLinearGradient(0, 0, 0, this.height);
|
|
319
|
+
grd?.addColorStop(0, "rgba(255, 0, 0, 1)");
|
|
320
|
+
grd?.addColorStop(.17, "rgba(255, 255, 0, 1)");
|
|
321
|
+
grd?.addColorStop(.34, "rgba(0, 255, 0, 1)");
|
|
322
|
+
grd?.addColorStop(.51, "rgba(0, 255, 255, 1)");
|
|
323
|
+
grd?.addColorStop(.68, "rgba(0, 0, 255, 1)");
|
|
324
|
+
grd?.addColorStop(.85, "rgba(255, 0, 255, 1)");
|
|
325
|
+
grd?.addColorStop(1, "rgba(255, 0, 0, 1)");
|
|
326
|
+
this.ctx.fillStyle = grd;
|
|
327
|
+
this.ctx?.fill();
|
|
328
|
+
}
|
|
329
|
+
redrawIndicator(x, y) {
|
|
330
|
+
this.ctx?.beginPath();
|
|
331
|
+
this.ctx.strokeStyle = "white";
|
|
332
|
+
this.ctx.lineWidth = 2;
|
|
333
|
+
this.ctx?.arc(7.5, y, 7.5, 0, 2 * Math.PI, false);
|
|
334
|
+
this.ctx?.stroke();
|
|
335
|
+
this.ctx?.closePath();
|
|
336
|
+
}
|
|
337
|
+
changeColor(e) {
|
|
338
|
+
this.x = e.offsetX;
|
|
339
|
+
this.y = e.offsetY;
|
|
340
|
+
this.draw();
|
|
341
|
+
const { r, g, b } = getColorAtPosition(this.ctx, e.offsetX, e.offsetY);
|
|
342
|
+
this.emitChange(new Color(r, g, b));
|
|
343
|
+
}
|
|
344
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
345
|
+
minVersion: "12.0.0",
|
|
346
|
+
version: "22.2.0",
|
|
347
|
+
ngImport: i0,
|
|
348
|
+
type: NgxMatColorSliderComponent,
|
|
349
|
+
deps: [],
|
|
350
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
351
|
+
});
|
|
352
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
353
|
+
minVersion: "14.0.0",
|
|
354
|
+
version: "22.2.0",
|
|
355
|
+
type: NgxMatColorSliderComponent,
|
|
356
|
+
isStandalone: true,
|
|
357
|
+
selector: "ngx-mat-color-slider",
|
|
358
|
+
usesInheritance: true,
|
|
359
|
+
ngImport: i0,
|
|
360
|
+
template: "<canvas\n id=\"color-strip\"\n class=\"zone-strip\"\n (mousedown)=\"onMousedown($event)\"\n (mouseup)=\"onMouseup($event)\"\n width=\"15\"\n height=\"234\"\n></canvas>\n",
|
|
361
|
+
styles: [""],
|
|
362
|
+
changeDetection: i0.ChangeDetectionStrategy.Eager
|
|
363
|
+
});
|
|
364
|
+
};
|
|
365
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
366
|
+
minVersion: "12.0.0",
|
|
367
|
+
version: "22.2.0",
|
|
368
|
+
ngImport: i0,
|
|
369
|
+
type: NgxMatColorSliderComponent,
|
|
370
|
+
decorators: [{
|
|
371
|
+
type: Component,
|
|
372
|
+
args: [{
|
|
373
|
+
selector: "ngx-mat-color-slider",
|
|
374
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
375
|
+
template: "<canvas\n id=\"color-strip\"\n class=\"zone-strip\"\n (mousedown)=\"onMousedown($event)\"\n (mouseup)=\"onMouseup($event)\"\n width=\"15\"\n height=\"234\"\n></canvas>\n"
|
|
376
|
+
}]
|
|
377
|
+
}],
|
|
378
|
+
ctorParameters: () => []
|
|
379
|
+
});
|
|
407
380
|
const RADIUS_NOB = 5;
|
|
408
|
-
class NgxMatColorCanvasComponent extends NgxMatBaseColorCanvas {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
class
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
381
|
+
var NgxMatColorCanvasComponent = class NgxMatColorCanvasComponent extends NgxMatBaseColorCanvas {
|
|
382
|
+
_baseColor = null;
|
|
383
|
+
get rCtrl() {
|
|
384
|
+
return this.formGroup.get("r");
|
|
385
|
+
}
|
|
386
|
+
get gCtrl() {
|
|
387
|
+
return this.formGroup.get("g");
|
|
388
|
+
}
|
|
389
|
+
get bCtrl() {
|
|
390
|
+
return this.formGroup.get("b");
|
|
391
|
+
}
|
|
392
|
+
get aCtrl() {
|
|
393
|
+
return this.formGroup.get("a");
|
|
394
|
+
}
|
|
395
|
+
get hexCtrl() {
|
|
396
|
+
return this.formGroup.get("hex");
|
|
397
|
+
}
|
|
398
|
+
_resetBaseColor = true;
|
|
399
|
+
formGroup;
|
|
400
|
+
rgba = "";
|
|
401
|
+
zone = inject(NgZone);
|
|
402
|
+
constructor() {
|
|
403
|
+
super("color-block");
|
|
404
|
+
this.formGroup = new FormGroup({
|
|
405
|
+
r: new FormControl(null, [Validators.required]),
|
|
406
|
+
g: new FormControl(null, [Validators.required]),
|
|
407
|
+
b: new FormControl(null, [Validators.required]),
|
|
408
|
+
a: new FormControl(null, [Validators.required]),
|
|
409
|
+
hex: new FormControl(null, [Validators.required, Validators.pattern(matchers.hex6)])
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
ngOnInit() {
|
|
413
|
+
merge(this.rCtrl.valueChanges, this.gCtrl.valueChanges, this.bCtrl.valueChanges, this.aCtrl.valueChanges).pipe(takeUntil(this._destroyed), debounceTime(400)).subscribe((_) => {
|
|
414
|
+
const color = new Color(Number(this.rCtrl.value), Number(this.gCtrl.value), Number(this.bCtrl.value), Number(this.aCtrl.value));
|
|
415
|
+
this.emitChange(color);
|
|
416
|
+
});
|
|
417
|
+
this.hexCtrl.valueChanges.pipe(takeUntil(this._destroyed), debounceTime(400), distinctUntilChanged()).subscribe((hex) => {
|
|
418
|
+
const obj = stringInputToObject(hex);
|
|
419
|
+
if (obj != null) {
|
|
420
|
+
const color = new Color(obj.r, obj.g, obj.b, obj.a);
|
|
421
|
+
this.emitChange(color);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
ngOnChanges(changes) {
|
|
426
|
+
const key = "setColor";
|
|
427
|
+
if (changes[key] && changes[key].currentValue) {
|
|
428
|
+
this.updateForm(changes[key].currentValue);
|
|
429
|
+
if (this._resetBaseColor) this._baseColor = changes[key].currentValue;
|
|
430
|
+
this._resetBaseColor = true;
|
|
431
|
+
if (!changes[key].firstChange) this.draw();
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
updateForm(val) {
|
|
435
|
+
const config = { emitEvent: false };
|
|
436
|
+
this.rCtrl?.setValue(val.r, config);
|
|
437
|
+
this.gCtrl?.setValue(val.g, config);
|
|
438
|
+
this.bCtrl?.setValue(val.b, config);
|
|
439
|
+
this.aCtrl?.setValue(val.a, config);
|
|
440
|
+
this.hexCtrl?.setValue(val.hex, config);
|
|
441
|
+
}
|
|
442
|
+
redrawIndicator(x, y) {
|
|
443
|
+
this.ctx?.beginPath();
|
|
444
|
+
this.ctx.strokeStyle = "white";
|
|
445
|
+
this.ctx?.arc(x, y, RADIUS_NOB, 0, 2 * Math.PI, false);
|
|
446
|
+
this.ctx?.stroke();
|
|
447
|
+
this.ctx?.closePath();
|
|
448
|
+
}
|
|
449
|
+
fillGradient() {
|
|
450
|
+
this.ctx.fillStyle = this._baseColor ? this._baseColor.rgba : "rgba(255,255,255,1)";
|
|
451
|
+
this.ctx?.fillRect(0, 0, this.width, this.height);
|
|
452
|
+
const grdWhite = this.ctx?.createLinearGradient(0, 0, this.width, 0);
|
|
453
|
+
grdWhite?.addColorStop(0, "rgba(255,255,255,1)");
|
|
454
|
+
grdWhite?.addColorStop(1, "rgba(255,255,255,0)");
|
|
455
|
+
this.ctx.fillStyle = grdWhite;
|
|
456
|
+
this.ctx?.fillRect(0, 0, this.width, this.height);
|
|
457
|
+
const grdBlack = this.ctx?.createLinearGradient(0, 0, 0, this.height);
|
|
458
|
+
grdBlack?.addColorStop(0, "rgba(0,0,0,0)");
|
|
459
|
+
grdBlack?.addColorStop(1, "rgba(0,0,0,1)");
|
|
460
|
+
this.ctx.fillStyle = grdBlack;
|
|
461
|
+
this.ctx?.fillRect(0, 0, this.width, this.height);
|
|
462
|
+
}
|
|
463
|
+
onSliderColorChanged(c) {
|
|
464
|
+
this._baseColor = c;
|
|
465
|
+
this.color.set(c);
|
|
466
|
+
this.fillGradient();
|
|
467
|
+
this.emitChange(c);
|
|
468
|
+
}
|
|
469
|
+
changeColor(e) {
|
|
470
|
+
this.x = e.offsetX;
|
|
471
|
+
this.y = e.offsetY;
|
|
472
|
+
this._resetBaseColor = false;
|
|
473
|
+
this.draw();
|
|
474
|
+
const { r, g, b } = getColorAtPosition(this.ctx, e.offsetX, e.offsetY);
|
|
475
|
+
this.emitChange(new Color(r, g, b));
|
|
476
|
+
}
|
|
477
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
478
|
+
minVersion: "12.0.0",
|
|
479
|
+
version: "22.2.0",
|
|
480
|
+
ngImport: i0,
|
|
481
|
+
type: NgxMatColorCanvasComponent,
|
|
482
|
+
deps: [],
|
|
483
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
484
|
+
});
|
|
485
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
486
|
+
minVersion: "14.0.0",
|
|
487
|
+
version: "22.2.0",
|
|
488
|
+
type: NgxMatColorCanvasComponent,
|
|
489
|
+
isStandalone: true,
|
|
490
|
+
selector: "ngx-mat-color-canvas",
|
|
491
|
+
host: { classAttribute: "ngx-mat-color-canvas" },
|
|
492
|
+
usesInheritance: true,
|
|
493
|
+
usesOnChanges: true,
|
|
494
|
+
ngImport: i0,
|
|
495
|
+
template: "<form [formGroup]=\"formGroup\">\n <div class=\"color-canvas-row\">\n <div class=\"zone-canvas\">\n <canvas\n id=\"color-block\"\n class=\"zone-block\"\n (mousedown)=\"onMousedown($event)\"\n (mouseup)=\"onMouseup($event)\"\n width=\"200\"\n height=\"235\"\n ></canvas>\n <ngx-mat-color-slider (colorChanged)=\"onSliderColorChanged($event)\" />\n </div>\n\n <div class=\"zone-inputs\">\n <mat-form-field [color]=\"theme()\">\n <mat-label>R</mat-label>\n <input\n matInput\n formControlName=\"r\"\n ngxMatNumericColorInput\n autocomplete=\"off\"\n />\n </mat-form-field>\n\n <mat-form-field [color]=\"theme()\">\n <mat-label>G</mat-label>\n <input\n matInput\n formControlName=\"g\"\n ngxMatNumericColorInput\n autocomplete=\"off\"\n />\n </mat-form-field>\n\n <mat-form-field [color]=\"theme()\">\n <mat-label>B</mat-label>\n <input\n matInput\n formControlName=\"b\"\n ngxMatNumericColorInput\n autocomplete=\"off\"\n />\n </mat-form-field>\n </div>\n </div>\n\n <div class=\"color-canvas-row\">\n <button\n mat-mini-fab\n [style.background-color]=\"color()?.rgba || 'transparent'\"\n class=\"preview\"\n ></button>\n <mat-form-field [color]=\"theme()\">\n <mat-label>HEX6</mat-label>\n <mat-label matPrefix class=\"symbol\"># </mat-label>\n <input matInput formControlName=\"hex\" autocomplete=\"off\" />\n </mat-form-field>\n <mat-form-field class=\"input-opacity\" [color]=\"theme()\">\n <mat-label>A</mat-label>\n <input\n matInput\n formControlName=\"a\"\n type=\"number\"\n min=\"0\"\n max=\"1\"\n step=\"0.1\"\n autocomplete=\"off\"\n />\n </mat-form-field>\n </div>\n</form>\n",
|
|
496
|
+
styles: [".ngx-mat-color-canvas .color-canvas-row{display:flex}.ngx-mat-color-canvas .color-canvas-row:first-of-type{height:235px;margin-bottom:12px}.ngx-mat-color-canvas .color-canvas-row:first-of-type .card{height:180px}.ngx-mat-color-canvas .color-canvas-row canvas:hover{cursor:crosshair}.ngx-mat-color-canvas .color-canvas-row .zone{display:flex}.ngx-mat-color-canvas .color-canvas-row .zone-canvas{height:235px}.ngx-mat-color-canvas .color-canvas-row .zone-canvas .zone-block{border:1px solid rgba(0,0,0,.12)}.ngx-mat-color-canvas .color-canvas-row .zone-strip{flex-basis:auto;margin-left:10px}.ngx-mat-color-canvas .color-canvas-row .zone-inputs{display:flex;width:60px;height:235px;flex-direction:column;margin-left:16px;margin-top:12px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2){display:flex}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .preview{min-width:40px;min-height:40px;height:40px;width:40px;margin-top:12px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field{margin-left:16px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field:first-of-type{width:170px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field:first-of-type .symbol{font-weight:700;color:#0000008a}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field:last-of-type{width:60px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field:last-of-type .mat-mdc-text-field-wrapper{padding:0 8px}.ngx-mat-color-canvas .mat-mdc-form-field-label{font-weight:700}.ngx-mat-color-canvas .mat-mdc-form-field .mdc-text-field--filled:not(.mdc-text-field--disabled){background-color:transparent}\n"],
|
|
497
|
+
dependencies: [
|
|
498
|
+
{
|
|
499
|
+
kind: "ngmodule",
|
|
500
|
+
type: MatFormFieldModule
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
kind: "component",
|
|
504
|
+
type: i1$1.MatFormField,
|
|
505
|
+
selector: "mat-form-field",
|
|
506
|
+
inputs: [
|
|
507
|
+
"hideRequiredMarker",
|
|
508
|
+
"color",
|
|
509
|
+
"floatLabel",
|
|
510
|
+
"appearance",
|
|
511
|
+
"subscriptSizing",
|
|
512
|
+
"hintLabel"
|
|
513
|
+
],
|
|
514
|
+
exportAs: ["matFormField"]
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
kind: "directive",
|
|
518
|
+
type: i1$1.MatLabel,
|
|
519
|
+
selector: "mat-label"
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
kind: "directive",
|
|
523
|
+
type: i1$1.MatPrefix,
|
|
524
|
+
selector: "[matPrefix], [matIconPrefix], [matTextPrefix]",
|
|
525
|
+
inputs: ["matTextPrefix"]
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
kind: "ngmodule",
|
|
529
|
+
type: MatInputModule
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
kind: "directive",
|
|
533
|
+
type: i2$1.MatInput,
|
|
534
|
+
selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
|
|
535
|
+
inputs: [
|
|
536
|
+
"disabled",
|
|
537
|
+
"id",
|
|
538
|
+
"placeholder",
|
|
539
|
+
"name",
|
|
540
|
+
"required",
|
|
541
|
+
"type",
|
|
542
|
+
"errorStateMatcher",
|
|
543
|
+
"aria-describedby",
|
|
544
|
+
"value",
|
|
545
|
+
"readonly",
|
|
546
|
+
"disabledInteractive"
|
|
547
|
+
],
|
|
548
|
+
exportAs: ["matInput"]
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
kind: "component",
|
|
552
|
+
type: NgxMatColorSliderComponent,
|
|
553
|
+
selector: "ngx-mat-color-slider"
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
kind: "ngmodule",
|
|
557
|
+
type: ReactiveFormsModule
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
kind: "directive",
|
|
561
|
+
type: i3.ɵNgNoValidate,
|
|
562
|
+
selector: "form:not([ngNoForm]):not([ngNativeValidate])"
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
kind: "directive",
|
|
566
|
+
type: i3.DefaultValueAccessor,
|
|
567
|
+
selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
kind: "directive",
|
|
571
|
+
type: i3.NumberValueAccessor,
|
|
572
|
+
selector: "input[type=number]:not([ngNoCva])[formControlName],input[type=number]:not([ngNoCva])[formControl],input[type=number]:not([ngNoCva])[ngModel]"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
kind: "directive",
|
|
576
|
+
type: i3.NgControlStatus,
|
|
577
|
+
selector: "[formControlName],[ngModel],[formControl]"
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
kind: "directive",
|
|
581
|
+
type: i3.NgControlStatusGroup,
|
|
582
|
+
selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
kind: "directive",
|
|
586
|
+
type: i3.MinValidator,
|
|
587
|
+
selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]",
|
|
588
|
+
inputs: ["min"]
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
kind: "directive",
|
|
592
|
+
type: i3.MaxValidator,
|
|
593
|
+
selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]",
|
|
594
|
+
inputs: ["max"]
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
kind: "directive",
|
|
598
|
+
type: i3.FormGroupDirective,
|
|
599
|
+
selector: "[formGroup]",
|
|
600
|
+
inputs: ["formGroup"],
|
|
601
|
+
outputs: ["ngSubmit"],
|
|
602
|
+
exportAs: ["ngForm"]
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
kind: "directive",
|
|
606
|
+
type: i3.FormControlName,
|
|
607
|
+
selector: "[formControlName]",
|
|
608
|
+
inputs: [
|
|
609
|
+
"formControlName",
|
|
610
|
+
"disabled",
|
|
611
|
+
"ngModel"
|
|
612
|
+
],
|
|
613
|
+
outputs: ["ngModelChange"]
|
|
614
|
+
}
|
|
615
|
+
],
|
|
616
|
+
changeDetection: i0.ChangeDetectionStrategy.Eager,
|
|
617
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
618
|
+
});
|
|
600
619
|
};
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
620
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
621
|
+
minVersion: "12.0.0",
|
|
622
|
+
version: "22.2.0",
|
|
623
|
+
ngImport: i0,
|
|
624
|
+
type: NgxMatColorCanvasComponent,
|
|
625
|
+
decorators: [{
|
|
626
|
+
type: Component,
|
|
627
|
+
args: [{
|
|
628
|
+
selector: "ngx-mat-color-canvas",
|
|
629
|
+
encapsulation: ViewEncapsulation.None,
|
|
630
|
+
host: { class: "ngx-mat-color-canvas" },
|
|
631
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
632
|
+
imports: [
|
|
633
|
+
MatFormFieldModule,
|
|
634
|
+
MatInputModule,
|
|
635
|
+
NgxMatColorSliderComponent,
|
|
636
|
+
ReactiveFormsModule
|
|
637
|
+
],
|
|
638
|
+
template: "<form [formGroup]=\"formGroup\">\n <div class=\"color-canvas-row\">\n <div class=\"zone-canvas\">\n <canvas\n id=\"color-block\"\n class=\"zone-block\"\n (mousedown)=\"onMousedown($event)\"\n (mouseup)=\"onMouseup($event)\"\n width=\"200\"\n height=\"235\"\n ></canvas>\n <ngx-mat-color-slider (colorChanged)=\"onSliderColorChanged($event)\" />\n </div>\n\n <div class=\"zone-inputs\">\n <mat-form-field [color]=\"theme()\">\n <mat-label>R</mat-label>\n <input\n matInput\n formControlName=\"r\"\n ngxMatNumericColorInput\n autocomplete=\"off\"\n />\n </mat-form-field>\n\n <mat-form-field [color]=\"theme()\">\n <mat-label>G</mat-label>\n <input\n matInput\n formControlName=\"g\"\n ngxMatNumericColorInput\n autocomplete=\"off\"\n />\n </mat-form-field>\n\n <mat-form-field [color]=\"theme()\">\n <mat-label>B</mat-label>\n <input\n matInput\n formControlName=\"b\"\n ngxMatNumericColorInput\n autocomplete=\"off\"\n />\n </mat-form-field>\n </div>\n </div>\n\n <div class=\"color-canvas-row\">\n <button\n mat-mini-fab\n [style.background-color]=\"color()?.rgba || 'transparent'\"\n class=\"preview\"\n ></button>\n <mat-form-field [color]=\"theme()\">\n <mat-label>HEX6</mat-label>\n <mat-label matPrefix class=\"symbol\"># </mat-label>\n <input matInput formControlName=\"hex\" autocomplete=\"off\" />\n </mat-form-field>\n <mat-form-field class=\"input-opacity\" [color]=\"theme()\">\n <mat-label>A</mat-label>\n <input\n matInput\n formControlName=\"a\"\n type=\"number\"\n min=\"0\"\n max=\"1\"\n step=\"0.1\"\n autocomplete=\"off\"\n />\n </mat-form-field>\n </div>\n</form>\n",
|
|
639
|
+
styles: [".ngx-mat-color-canvas .color-canvas-row{display:flex}.ngx-mat-color-canvas .color-canvas-row:first-of-type{height:235px;margin-bottom:12px}.ngx-mat-color-canvas .color-canvas-row:first-of-type .card{height:180px}.ngx-mat-color-canvas .color-canvas-row canvas:hover{cursor:crosshair}.ngx-mat-color-canvas .color-canvas-row .zone{display:flex}.ngx-mat-color-canvas .color-canvas-row .zone-canvas{height:235px}.ngx-mat-color-canvas .color-canvas-row .zone-canvas .zone-block{border:1px solid rgba(0,0,0,.12)}.ngx-mat-color-canvas .color-canvas-row .zone-strip{flex-basis:auto;margin-left:10px}.ngx-mat-color-canvas .color-canvas-row .zone-inputs{display:flex;width:60px;height:235px;flex-direction:column;margin-left:16px;margin-top:12px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2){display:flex}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .preview{min-width:40px;min-height:40px;height:40px;width:40px;margin-top:12px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field{margin-left:16px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field:first-of-type{width:170px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field:first-of-type .symbol{font-weight:700;color:#0000008a}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field:last-of-type{width:60px}.ngx-mat-color-canvas .color-canvas-row:nth-of-type(2) .mat-mdc-form-field:last-of-type .mat-mdc-text-field-wrapper{padding:0 8px}.ngx-mat-color-canvas .mat-mdc-form-field-label{font-weight:700}.ngx-mat-color-canvas .mat-mdc-form-field .mdc-text-field--filled:not(.mdc-text-field--disabled){background-color:transparent}\n"]
|
|
640
|
+
}]
|
|
641
|
+
}],
|
|
642
|
+
ctorParameters: () => []
|
|
643
|
+
});
|
|
644
|
+
var NgxMatColorCollectionComponent = class NgxMatColorCollectionComponent {
|
|
645
|
+
colorChanged = output();
|
|
646
|
+
set color(c) {
|
|
647
|
+
if (c) this.selectedColor.set(c.toHexString());
|
|
648
|
+
}
|
|
649
|
+
selectedColor = signal("", ...ngDevMode ? [{ debugName: "selectedColor" }] : /* istanbul ignore next */ []);
|
|
650
|
+
colors1 = BASIC_COLORS.slice(0, 8);
|
|
651
|
+
colors2 = BASIC_COLORS.slice(8, 16);
|
|
652
|
+
select(hex) {
|
|
653
|
+
this.selectedColor.set(hex);
|
|
654
|
+
const rgba = stringInputToObject(hex);
|
|
655
|
+
if (rgba != null) this.colorChanged.emit(new Color(rgba.r, rgba.g, rgba.b, rgba.a));
|
|
656
|
+
}
|
|
657
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
658
|
+
minVersion: "12.0.0",
|
|
659
|
+
version: "22.2.0",
|
|
660
|
+
ngImport: i0,
|
|
661
|
+
type: NgxMatColorCollectionComponent,
|
|
662
|
+
deps: [],
|
|
663
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
664
|
+
});
|
|
665
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
666
|
+
minVersion: "17.0.0",
|
|
667
|
+
version: "22.2.0",
|
|
668
|
+
type: NgxMatColorCollectionComponent,
|
|
669
|
+
isStandalone: true,
|
|
670
|
+
selector: "ngx-mat-color-collection",
|
|
671
|
+
inputs: { color: "color" },
|
|
672
|
+
outputs: { colorChanged: "colorChanged" },
|
|
673
|
+
host: { classAttribute: "ngx-mat-color-collection" },
|
|
674
|
+
ngImport: i0,
|
|
675
|
+
template: "<div class=\"color-collection-row\">\n @for (c of colors1; track c) {\n <button\n mat-mini-fab\n [style.background-color]=\"c\"\n class=\"btn-color\"\n (click)=\"select(c)\"\n [ngClass]=\"{ active: selectedColor() === c }\"\n [disableRipple]=\"true\"></button>\n }\n</div>\n<div class=\"color-collection-row\">\n @for (c of colors2; track c) {\n <button\n mat-mini-fab\n [style.background-color]=\"c\"\n class=\"btn-color\"\n (click)=\"select(c)\"\n [ngClass]=\"{ active: selectedColor() === c }\"\n [disableRipple]=\"true\"></button>\n }\n</div>\n",
|
|
676
|
+
styles: [".ngx-mat-color-collection .btn-color{height:20px;width:20px;margin-right:11px;box-shadow:none;opacity:.3;will-change:opacity;transition:opacity .3s linear}.ngx-mat-color-collection .btn-color.active{box-shadow:0 3px 5px -1px #0003,0 6px 10px #00000024,0 1px 18px #0000001f;opacity:1}.ngx-mat-color-collection .btn-color .mat-mdc-button-touch-target{display:none!important}\n"],
|
|
677
|
+
dependencies: [
|
|
678
|
+
{
|
|
679
|
+
kind: "ngmodule",
|
|
680
|
+
type: MatButtonModule
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
kind: "component",
|
|
684
|
+
type: i1.MatMiniFabButton,
|
|
685
|
+
selector: "button[mat-mini-fab], a[mat-mini-fab], button[matMiniFab], a[matMiniFab]",
|
|
686
|
+
exportAs: ["matButton", "matAnchor"]
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
kind: "directive",
|
|
690
|
+
type: NgClass,
|
|
691
|
+
selector: "[ngClass]",
|
|
692
|
+
inputs: ["class", "ngClass"]
|
|
693
|
+
}
|
|
694
|
+
],
|
|
695
|
+
changeDetection: i0.ChangeDetectionStrategy.Eager,
|
|
696
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
697
|
+
});
|
|
698
|
+
};
|
|
699
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
700
|
+
minVersion: "12.0.0",
|
|
701
|
+
version: "22.2.0",
|
|
702
|
+
ngImport: i0,
|
|
703
|
+
type: NgxMatColorCollectionComponent,
|
|
704
|
+
decorators: [{
|
|
705
|
+
type: Component,
|
|
706
|
+
args: [{
|
|
707
|
+
selector: "ngx-mat-color-collection",
|
|
708
|
+
encapsulation: ViewEncapsulation.None,
|
|
709
|
+
host: { class: "ngx-mat-color-collection" },
|
|
710
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
711
|
+
imports: [MatButtonModule, NgClass],
|
|
712
|
+
template: "<div class=\"color-collection-row\">\n @for (c of colors1; track c) {\n <button\n mat-mini-fab\n [style.background-color]=\"c\"\n class=\"btn-color\"\n (click)=\"select(c)\"\n [ngClass]=\"{ active: selectedColor() === c }\"\n [disableRipple]=\"true\"></button>\n }\n</div>\n<div class=\"color-collection-row\">\n @for (c of colors2; track c) {\n <button\n mat-mini-fab\n [style.background-color]=\"c\"\n class=\"btn-color\"\n (click)=\"select(c)\"\n [ngClass]=\"{ active: selectedColor() === c }\"\n [disableRipple]=\"true\"></button>\n }\n</div>\n",
|
|
713
|
+
styles: [".ngx-mat-color-collection .btn-color{height:20px;width:20px;margin-right:11px;box-shadow:none;opacity:.3;will-change:opacity;transition:opacity .3s linear}.ngx-mat-color-collection .btn-color.active{box-shadow:0 3px 5px -1px #0003,0 6px 10px #00000024,0 1px 18px #0000001f;opacity:1}.ngx-mat-color-collection .btn-color .mat-mdc-button-touch-target{display:none!important}\n"]
|
|
714
|
+
}]
|
|
715
|
+
}],
|
|
716
|
+
propDecorators: {
|
|
717
|
+
colorChanged: [{
|
|
718
|
+
type: i0.Output,
|
|
719
|
+
args: ["colorChanged"]
|
|
720
|
+
}],
|
|
721
|
+
color: [{ type: Input }]
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
var NgxMatColorPaletteComponent = class NgxMatColorPaletteComponent {
|
|
725
|
+
colorChanged = output();
|
|
726
|
+
color = input(...ngDevMode ? [void 0, { debugName: "color" }] : /* istanbul ignore next */ []);
|
|
727
|
+
theme = input(...ngDevMode ? [void 0, { debugName: "theme" }] : /* istanbul ignore next */ []);
|
|
728
|
+
handleColorChanged(color) {
|
|
729
|
+
this.colorChanged.emit(color);
|
|
730
|
+
}
|
|
731
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
732
|
+
minVersion: "12.0.0",
|
|
733
|
+
version: "22.2.0",
|
|
734
|
+
ngImport: i0,
|
|
735
|
+
type: NgxMatColorPaletteComponent,
|
|
736
|
+
deps: [],
|
|
737
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
738
|
+
});
|
|
739
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
740
|
+
minVersion: "17.1.0",
|
|
741
|
+
version: "22.2.0",
|
|
742
|
+
type: NgxMatColorPaletteComponent,
|
|
743
|
+
isStandalone: true,
|
|
744
|
+
selector: "ngx-mat-color-palette",
|
|
745
|
+
inputs: {
|
|
746
|
+
color: {
|
|
747
|
+
classPropertyName: "color",
|
|
748
|
+
publicName: "color",
|
|
749
|
+
isSignal: true,
|
|
750
|
+
isRequired: false,
|
|
751
|
+
transformFunction: null
|
|
752
|
+
},
|
|
753
|
+
theme: {
|
|
754
|
+
classPropertyName: "theme",
|
|
755
|
+
publicName: "theme",
|
|
756
|
+
isSignal: true,
|
|
757
|
+
isRequired: false,
|
|
758
|
+
transformFunction: null
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
outputs: { colorChanged: "colorChanged" },
|
|
762
|
+
host: { classAttribute: "ngx-mat-color-palette" },
|
|
763
|
+
ngImport: i0,
|
|
764
|
+
template: "<ngx-mat-color-canvas\n (colorChanged)=\"handleColorChanged($event)\"\n [color]=\"color()\"\n [theme]=\"theme()\"\n/>\n\n<ngx-mat-color-collection\n (colorChanged)=\"handleColorChanged($event)\"\n [color]=\"color()\"\n/>\n",
|
|
765
|
+
styles: [".ngx-mat-color-palette .actions{margin-top:10px;display:flex}.ngx-mat-color-palette .actions .left{display:flex;flex-direction:column;margin-right:15px}.ngx-mat-color-palette .actions .left .preview{flex:2 1 auto;margin-bottom:10px}.ngx-mat-color-palette .actions .right{display:flex;width:60px;flex-direction:column}\n"],
|
|
766
|
+
dependencies: [{
|
|
767
|
+
kind: "component",
|
|
768
|
+
type: NgxMatColorCollectionComponent,
|
|
769
|
+
selector: "ngx-mat-color-collection",
|
|
770
|
+
inputs: ["color"],
|
|
771
|
+
outputs: ["colorChanged"]
|
|
772
|
+
}, {
|
|
773
|
+
kind: "component",
|
|
774
|
+
type: NgxMatColorCanvasComponent,
|
|
775
|
+
selector: "ngx-mat-color-canvas"
|
|
776
|
+
}],
|
|
777
|
+
changeDetection: i0.ChangeDetectionStrategy.Eager,
|
|
778
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
779
|
+
});
|
|
780
|
+
};
|
|
781
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
782
|
+
minVersion: "12.0.0",
|
|
783
|
+
version: "22.2.0",
|
|
784
|
+
ngImport: i0,
|
|
785
|
+
type: NgxMatColorPaletteComponent,
|
|
786
|
+
decorators: [{
|
|
787
|
+
type: Component,
|
|
788
|
+
args: [{
|
|
789
|
+
selector: "ngx-mat-color-palette",
|
|
790
|
+
encapsulation: ViewEncapsulation.None,
|
|
791
|
+
host: { class: "ngx-mat-color-palette" },
|
|
792
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
793
|
+
imports: [NgxMatColorCollectionComponent, NgxMatColorCanvasComponent],
|
|
794
|
+
template: "<ngx-mat-color-canvas\n (colorChanged)=\"handleColorChanged($event)\"\n [color]=\"color()\"\n [theme]=\"theme()\"\n/>\n\n<ngx-mat-color-collection\n (colorChanged)=\"handleColorChanged($event)\"\n [color]=\"color()\"\n/>\n",
|
|
795
|
+
styles: [".ngx-mat-color-palette .actions{margin-top:10px;display:flex}.ngx-mat-color-palette .actions .left{display:flex;flex-direction:column;margin-right:15px}.ngx-mat-color-palette .actions .left .preview{flex:2 1 auto;margin-bottom:10px}.ngx-mat-color-palette .actions .right{display:flex;width:60px;flex-direction:column}\n"]
|
|
796
|
+
}]
|
|
797
|
+
}],
|
|
798
|
+
propDecorators: {
|
|
799
|
+
colorChanged: [{
|
|
800
|
+
type: i0.Output,
|
|
801
|
+
args: ["colorChanged"]
|
|
802
|
+
}],
|
|
803
|
+
color: [{
|
|
804
|
+
type: i0.Input,
|
|
805
|
+
args: [{
|
|
806
|
+
isSignal: true,
|
|
807
|
+
alias: "color",
|
|
808
|
+
required: false
|
|
809
|
+
}]
|
|
810
|
+
}],
|
|
811
|
+
theme: [{
|
|
812
|
+
type: i0.Input,
|
|
813
|
+
args: [{
|
|
814
|
+
isSignal: true,
|
|
815
|
+
alias: "theme",
|
|
816
|
+
required: false
|
|
817
|
+
}]
|
|
818
|
+
}]
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
var ColorAdapter = class ColorAdapter {
|
|
822
|
+
sameColor(a, b) {
|
|
823
|
+
if (a == null && b == null) return true;
|
|
824
|
+
if (a != null && b != null) return a.rgba === b.rgba;
|
|
825
|
+
return false;
|
|
826
|
+
}
|
|
827
|
+
format(c, format) {
|
|
828
|
+
return c.toString(format);
|
|
829
|
+
}
|
|
830
|
+
parse(value) {
|
|
831
|
+
const obj = stringInputToObject(value);
|
|
832
|
+
if (obj) return new Color(obj.r, obj.g, obj.b, obj.a);
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
835
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
836
|
+
minVersion: "12.0.0",
|
|
837
|
+
version: "22.2.0",
|
|
838
|
+
ngImport: i0,
|
|
839
|
+
type: ColorAdapter,
|
|
840
|
+
deps: [],
|
|
841
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
842
|
+
});
|
|
843
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
844
|
+
minVersion: "12.0.0",
|
|
845
|
+
version: "22.2.0",
|
|
846
|
+
ngImport: i0,
|
|
847
|
+
type: ColorAdapter
|
|
848
|
+
});
|
|
849
|
+
};
|
|
850
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
851
|
+
minVersion: "12.0.0",
|
|
852
|
+
version: "22.2.0",
|
|
853
|
+
ngImport: i0,
|
|
854
|
+
type: ColorAdapter,
|
|
855
|
+
decorators: [{ type: Injectable }]
|
|
856
|
+
});
|
|
857
|
+
const NGX_MAT_COLOR_FORMATS = { display: { colorInput: "hex" } };
|
|
858
|
+
const MAT_COLOR_FORMATS = new InjectionToken("mat-color-formats");
|
|
859
|
+
const NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY = new InjectionToken("ngx-mat-colorpicker-scroll-strategy");
|
|
605
860
|
function NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY_FACTORY(overlay) {
|
|
606
|
-
|
|
861
|
+
return () => overlay.scrollStrategies.reposition();
|
|
607
862
|
}
|
|
608
863
|
const NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY_FACTORY_PROVIDER = {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
864
|
+
provide: NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY,
|
|
865
|
+
deps: [Overlay],
|
|
866
|
+
useFactory: NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY_FACTORY
|
|
867
|
+
};
|
|
868
|
+
var NgxMatColorPickerContentComponent = class NgxMatColorPickerContentComponent {
|
|
869
|
+
_palette = viewChild(NgxMatColorPaletteComponent, ...ngDevMode ? [{ debugName: "_palette" }] : /* istanbul ignore next */ []);
|
|
870
|
+
picker = null;
|
|
871
|
+
color;
|
|
872
|
+
_isLeaving = false;
|
|
873
|
+
_panelEnterClass = null;
|
|
874
|
+
_animationDone = new Subject();
|
|
875
|
+
_cdr = inject(ChangeDetectorRef);
|
|
876
|
+
get isEnterDropdown() {
|
|
877
|
+
return !this._isLeaving && this._panelEnterClass === "enter-dropdown";
|
|
878
|
+
}
|
|
879
|
+
get isEnterDialog() {
|
|
880
|
+
return !this._isLeaving && this._panelEnterClass === "enter-dialog";
|
|
881
|
+
}
|
|
882
|
+
get isLeaving() {
|
|
883
|
+
return this._isLeaving;
|
|
884
|
+
}
|
|
885
|
+
ngOnInit() {
|
|
886
|
+
this._panelEnterClass = this.picker?.touchUi ? "enter-dialog" : "enter-dropdown";
|
|
887
|
+
this._cdr.markForCheck();
|
|
888
|
+
}
|
|
889
|
+
_startExitAnimation() {
|
|
890
|
+
this._isLeaving = true;
|
|
891
|
+
this._cdr.markForCheck();
|
|
892
|
+
}
|
|
893
|
+
_onAnimationEnd(event) {
|
|
894
|
+
if (event.animationName === "panelLeave") this._animationDone.next();
|
|
895
|
+
}
|
|
896
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
897
|
+
minVersion: "12.0.0",
|
|
898
|
+
version: "22.2.0",
|
|
899
|
+
ngImport: i0,
|
|
900
|
+
type: NgxMatColorPickerContentComponent,
|
|
901
|
+
deps: [],
|
|
902
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
903
|
+
});
|
|
904
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
905
|
+
minVersion: "17.2.0",
|
|
906
|
+
version: "22.2.0",
|
|
907
|
+
type: NgxMatColorPickerContentComponent,
|
|
908
|
+
isStandalone: true,
|
|
909
|
+
selector: "ngx-mat-color-picker-content",
|
|
910
|
+
inputs: { color: "color" },
|
|
911
|
+
outputs: { _animationDone: "_animationDone" },
|
|
912
|
+
host: {
|
|
913
|
+
listeners: { "animationend": "_onAnimationEnd($event)" },
|
|
914
|
+
properties: {
|
|
915
|
+
"class.ngx-mat-colorpicker-content-touch": "picker?.touchUi",
|
|
916
|
+
"class.panel-enter-dropdown": "this.isEnterDropdown",
|
|
917
|
+
"class.panel-enter-dialog": "this.isEnterDialog",
|
|
918
|
+
"class.panel-leave": "this.isLeaving"
|
|
919
|
+
},
|
|
920
|
+
classAttribute: "ngx-mat-colorpicker-content"
|
|
921
|
+
},
|
|
922
|
+
viewQueries: [{
|
|
923
|
+
propertyName: "_palette",
|
|
924
|
+
first: true,
|
|
925
|
+
predicate: NgxMatColorPaletteComponent,
|
|
926
|
+
descendants: true,
|
|
927
|
+
isSignal: true
|
|
928
|
+
}],
|
|
929
|
+
exportAs: ["ngxMatColorPickerContent"],
|
|
930
|
+
ngImport: i0,
|
|
931
|
+
template: "<ngx-mat-color-palette\n (colorChanged)=\"picker?.select($event)\"\n [color]=\"picker!._selected\"\n [theme]=\"color\"></ngx-mat-color-palette>\n",
|
|
932
|
+
styles: ["@keyframes panelDropdownEnter{0%{opacity:0;transform:scaleY(.8)}to{opacity:1;transform:scale(1)}}@keyframes panelDialogEnter{0%{opacity:0;transform:scale(.7)}to{opacity:1;transform:none}}@keyframes panelLeave{0%{opacity:1}to{opacity:0}}.panel-enter-dropdown{animation:panelDropdownEnter .12s cubic-bezier(0,0,.2,1)}.panel-enter-dialog{animation:panelDialogEnter .15s cubic-bezier(0,0,.2,1)}.panel-leave{animation:panelLeave .1s linear forwards;pointer-events:none}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.calendar-fade-enter{animation:fadeIn .12s .1s cubic-bezier(.55,0,.55,.2) forwards}\n", ".ngx-mat-colorpicker-content{display:block;border-radius:4px;box-shadow:0 2px 4px -1px #0003,0 4px 5px #00000024,0 1px 10px #0000001f;background-color:#fff;color:#000000de;padding:16px}.ngx-mat-colorpicker-content .ngx-mat-color-palette{width:296px;height:354px}.ngx-mat-colorpicker-content-touch{display:block;max-height:80vh;overflow:auto}.ngx-mat-colorpicker-content-touch .ngx-mat-color-palette{min-width:250px;min-height:312px;max-width:750px;max-height:788px}@media all and (orientation:landscape){.mat-colorpicker-content-touch .ngx-mat-color-palette{width:64vh;height:80vh}}@media all and (orientation:portrait){.mat-colorpicker-content-touch .ngx-mat-color-palette{width:80vw;height:100vw}}\n"],
|
|
933
|
+
dependencies: [{
|
|
934
|
+
kind: "component",
|
|
935
|
+
type: NgxMatColorPaletteComponent,
|
|
936
|
+
selector: "ngx-mat-color-palette",
|
|
937
|
+
inputs: ["color", "theme"],
|
|
938
|
+
outputs: ["colorChanged"]
|
|
939
|
+
}],
|
|
940
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
941
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
942
|
+
});
|
|
943
|
+
};
|
|
944
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
945
|
+
minVersion: "12.0.0",
|
|
946
|
+
version: "22.2.0",
|
|
947
|
+
ngImport: i0,
|
|
948
|
+
type: NgxMatColorPickerContentComponent,
|
|
949
|
+
decorators: [{
|
|
950
|
+
type: Component,
|
|
951
|
+
args: [{
|
|
952
|
+
selector: "ngx-mat-color-picker-content",
|
|
953
|
+
host: {
|
|
954
|
+
class: "ngx-mat-colorpicker-content",
|
|
955
|
+
"[class.ngx-mat-colorpicker-content-touch]": "picker?.touchUi",
|
|
956
|
+
"(animationend)": "_onAnimationEnd($event)"
|
|
957
|
+
},
|
|
958
|
+
exportAs: "ngxMatColorPickerContent",
|
|
959
|
+
encapsulation: ViewEncapsulation.None,
|
|
960
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
961
|
+
imports: [NgxMatColorPaletteComponent],
|
|
962
|
+
template: "<ngx-mat-color-palette\n (colorChanged)=\"picker?.select($event)\"\n [color]=\"picker!._selected\"\n [theme]=\"color\"></ngx-mat-color-palette>\n",
|
|
963
|
+
styles: ["@keyframes panelDropdownEnter{0%{opacity:0;transform:scaleY(.8)}to{opacity:1;transform:scale(1)}}@keyframes panelDialogEnter{0%{opacity:0;transform:scale(.7)}to{opacity:1;transform:none}}@keyframes panelLeave{0%{opacity:1}to{opacity:0}}.panel-enter-dropdown{animation:panelDropdownEnter .12s cubic-bezier(0,0,.2,1)}.panel-enter-dialog{animation:panelDialogEnter .15s cubic-bezier(0,0,.2,1)}.panel-leave{animation:panelLeave .1s linear forwards;pointer-events:none}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.calendar-fade-enter{animation:fadeIn .12s .1s cubic-bezier(.55,0,.55,.2) forwards}\n", ".ngx-mat-colorpicker-content{display:block;border-radius:4px;box-shadow:0 2px 4px -1px #0003,0 4px 5px #00000024,0 1px 10px #0000001f;background-color:#fff;color:#000000de;padding:16px}.ngx-mat-colorpicker-content .ngx-mat-color-palette{width:296px;height:354px}.ngx-mat-colorpicker-content-touch{display:block;max-height:80vh;overflow:auto}.ngx-mat-colorpicker-content-touch .ngx-mat-color-palette{min-width:250px;min-height:312px;max-width:750px;max-height:788px}@media all and (orientation:landscape){.mat-colorpicker-content-touch .ngx-mat-color-palette{width:64vh;height:80vh}}@media all and (orientation:portrait){.mat-colorpicker-content-touch .ngx-mat-color-palette{width:80vw;height:100vw}}\n"]
|
|
964
|
+
}]
|
|
965
|
+
}],
|
|
966
|
+
propDecorators: {
|
|
967
|
+
_palette: [{
|
|
968
|
+
type: i0.ViewChild,
|
|
969
|
+
args: [i0.forwardRef(() => NgxMatColorPaletteComponent), { isSignal: true }]
|
|
970
|
+
}],
|
|
971
|
+
color: [{ type: Input }],
|
|
972
|
+
_animationDone: [{ type: Output }],
|
|
973
|
+
isEnterDropdown: [{
|
|
974
|
+
type: HostBinding,
|
|
975
|
+
args: ["class.panel-enter-dropdown"]
|
|
976
|
+
}],
|
|
977
|
+
isEnterDialog: [{
|
|
978
|
+
type: HostBinding,
|
|
979
|
+
args: ["class.panel-enter-dialog"]
|
|
980
|
+
}],
|
|
981
|
+
isLeaving: [{
|
|
982
|
+
type: HostBinding,
|
|
983
|
+
args: ["class.panel-leave"]
|
|
984
|
+
}]
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
var NgxMatColorPickerComponent = class NgxMatColorPickerComponent {
|
|
988
|
+
id = `ngx-mat-color-picker-${Math.floor(Math.random() * 1e6)}`;
|
|
989
|
+
openedStream = new EventEmitter();
|
|
990
|
+
closedStream = new EventEmitter();
|
|
991
|
+
get disabled() {
|
|
992
|
+
return this._disabled === void 0 && this._pickerInput ? this._pickerInput.disabled : !!this._disabled;
|
|
993
|
+
}
|
|
994
|
+
set disabled(value) {
|
|
995
|
+
const newValue = coerceBooleanProperty(value);
|
|
996
|
+
if (newValue !== this._disabled) {
|
|
997
|
+
this._disabled = newValue;
|
|
998
|
+
this._disabledChange.next(newValue);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
_disabled = false;
|
|
1002
|
+
get touchUi() {
|
|
1003
|
+
return this._touchUi;
|
|
1004
|
+
}
|
|
1005
|
+
set touchUi(value) {
|
|
1006
|
+
this._touchUi = coerceBooleanProperty(value);
|
|
1007
|
+
}
|
|
1008
|
+
_touchUi = false;
|
|
1009
|
+
get opened() {
|
|
1010
|
+
return this._opened;
|
|
1011
|
+
}
|
|
1012
|
+
set opened(value) {
|
|
1013
|
+
if (value) this.open();
|
|
1014
|
+
else this.close();
|
|
1015
|
+
}
|
|
1016
|
+
_opened = false;
|
|
1017
|
+
get defaultColor() {
|
|
1018
|
+
return this._defaultColor;
|
|
1019
|
+
}
|
|
1020
|
+
set defaultColor(value) {
|
|
1021
|
+
this._defaultColor = value;
|
|
1022
|
+
}
|
|
1023
|
+
_defaultColor = "primary";
|
|
1024
|
+
get color() {
|
|
1025
|
+
return this._color || (this._pickerInput ? this._pickerInput.getThemePalette() : void 0);
|
|
1026
|
+
}
|
|
1027
|
+
set color(value) {
|
|
1028
|
+
this._color = value;
|
|
1029
|
+
}
|
|
1030
|
+
_color;
|
|
1031
|
+
get isPrimary() {
|
|
1032
|
+
return this.color === "primary";
|
|
1033
|
+
}
|
|
1034
|
+
get isAccent() {
|
|
1035
|
+
return this.color === "accent";
|
|
1036
|
+
}
|
|
1037
|
+
get isWarn() {
|
|
1038
|
+
return this.color === "warn";
|
|
1039
|
+
}
|
|
1040
|
+
get _selected() {
|
|
1041
|
+
return this._validSelected;
|
|
1042
|
+
}
|
|
1043
|
+
set _selected(value) {
|
|
1044
|
+
this._validSelected = value;
|
|
1045
|
+
}
|
|
1046
|
+
_validSelected = null;
|
|
1047
|
+
_pickerInput = null;
|
|
1048
|
+
_popupRef = null;
|
|
1049
|
+
_dialogRef = null;
|
|
1050
|
+
_popupComponentRef = null;
|
|
1051
|
+
_portal = null;
|
|
1052
|
+
_disabledChange = new EventEmitter();
|
|
1053
|
+
_focusedElementBeforeOpen = null;
|
|
1054
|
+
_inputSubscription = Subscription.EMPTY;
|
|
1055
|
+
_selectedChanged = new Subject();
|
|
1056
|
+
_isAnimating = false;
|
|
1057
|
+
_dialog = inject(MatDialog);
|
|
1058
|
+
_overlay = inject(Overlay);
|
|
1059
|
+
_zone = inject(NgZone);
|
|
1060
|
+
_adapter = inject(ColorAdapter);
|
|
1061
|
+
_dir = inject(Directionality, { optional: true });
|
|
1062
|
+
_scrollStrategy = inject(NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY);
|
|
1063
|
+
_document = inject(DOCUMENT, { optional: true });
|
|
1064
|
+
_viewContainerRef = inject(ViewContainerRef);
|
|
1065
|
+
ngOnDestroy() {
|
|
1066
|
+
this.close();
|
|
1067
|
+
this._inputSubscription.unsubscribe();
|
|
1068
|
+
this._disabledChange.complete();
|
|
1069
|
+
if (this._popupRef) {
|
|
1070
|
+
this._popupRef.dispose();
|
|
1071
|
+
this._popupComponentRef = null;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
select(nextVal) {
|
|
1075
|
+
const oldValue = this._selected;
|
|
1076
|
+
this._selected = nextVal;
|
|
1077
|
+
if (!this._adapter.sameColor(oldValue, this._selected)) this._selectedChanged.next(nextVal);
|
|
1078
|
+
}
|
|
1079
|
+
registerInput(input) {
|
|
1080
|
+
if (this._pickerInput) throw Error("A ColorPicker can only be associated with a single input.");
|
|
1081
|
+
this._pickerInput = input;
|
|
1082
|
+
this._inputSubscription = this._pickerInput._valueChange.subscribe((value) => this._selected = value);
|
|
1083
|
+
}
|
|
1084
|
+
open() {
|
|
1085
|
+
if (this._opened || this.disabled || this._isAnimating) return;
|
|
1086
|
+
if (!this._pickerInput) throw Error("Attempted to open an ColorPicker with no associated input.");
|
|
1087
|
+
if (this._document) this._focusedElementBeforeOpen = this._document.activeElement;
|
|
1088
|
+
if (this.touchUi) this._openAsDialog();
|
|
1089
|
+
else this._openAsPopup();
|
|
1090
|
+
this._opened = true;
|
|
1091
|
+
this.openedStream.emit();
|
|
1092
|
+
}
|
|
1093
|
+
_openAsDialog() {
|
|
1094
|
+
if (this._dialogRef) this._dialogRef.close();
|
|
1095
|
+
this._dialogRef = this._dialog.open(NgxMatColorPickerContentComponent, {
|
|
1096
|
+
direction: this._dir ? this._dir.value : "ltr",
|
|
1097
|
+
viewContainerRef: this._viewContainerRef,
|
|
1098
|
+
panelClass: "ngx-mat-colorpicker-dialog"
|
|
1099
|
+
});
|
|
1100
|
+
this._dialogRef.afterClosed().subscribe(() => this._handleDialogClosed());
|
|
1101
|
+
this._dialogRef.componentInstance.picker = this;
|
|
1102
|
+
this._setColor();
|
|
1103
|
+
}
|
|
1104
|
+
_handleDialogClosed() {
|
|
1105
|
+
this._opened = false;
|
|
1106
|
+
this._isAnimating = false;
|
|
1107
|
+
this.closedStream.emit();
|
|
1108
|
+
if (this._focusedElementBeforeOpen) {
|
|
1109
|
+
this._focusedElementBeforeOpen.focus();
|
|
1110
|
+
this._focusedElementBeforeOpen = null;
|
|
1111
|
+
}
|
|
1112
|
+
this._dialogRef = null;
|
|
1113
|
+
}
|
|
1114
|
+
_openAsPopup() {
|
|
1115
|
+
if (!this._portal) this._portal = new ComponentPortal(NgxMatColorPickerContentComponent, this._viewContainerRef);
|
|
1116
|
+
if (!this._popupRef) this._createPopup();
|
|
1117
|
+
if (!this._popupRef?.hasAttached()) {
|
|
1118
|
+
this._popupComponentRef = this._popupRef?.attach(this._portal);
|
|
1119
|
+
this._popupComponentRef.instance.picker = this;
|
|
1120
|
+
this._setColor();
|
|
1121
|
+
this._zone.onStable.asObservable().pipe(take(1)).subscribe(() => {
|
|
1122
|
+
this._popupRef?.updatePosition();
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
_createPopup() {
|
|
1127
|
+
const overlayConfig = new OverlayConfig({
|
|
1128
|
+
positionStrategy: this._createPopupPositionStrategy(),
|
|
1129
|
+
hasBackdrop: true,
|
|
1130
|
+
backdropClass: "mat-overlay-transparent-backdrop",
|
|
1131
|
+
direction: this._dir ?? "ltr",
|
|
1132
|
+
scrollStrategy: this._scrollStrategy(),
|
|
1133
|
+
panelClass: "mat-colorpicker-popup"
|
|
1134
|
+
});
|
|
1135
|
+
this._popupRef = this._overlay.create(overlayConfig);
|
|
1136
|
+
this._popupRef.overlayElement.setAttribute("role", "dialog");
|
|
1137
|
+
merge(this._popupRef.backdropClick(), this._popupRef.detachments(), this._popupRef.keydownEvents().pipe(filter((event) => {
|
|
1138
|
+
return event.keyCode === ESCAPE || this._pickerInput && event.altKey && event.keyCode === UP_ARROW;
|
|
1139
|
+
}))).subscribe((event) => {
|
|
1140
|
+
if (event) event.preventDefault();
|
|
1141
|
+
this.close();
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
close() {
|
|
1145
|
+
if (!this._opened || this._isAnimating) return;
|
|
1146
|
+
if (this.touchUi) {
|
|
1147
|
+
if (this._dialogRef) this._dialogRef.close();
|
|
1148
|
+
} else {
|
|
1149
|
+
let contentInstance = null;
|
|
1150
|
+
if (this._popupComponentRef) contentInstance = this._popupComponentRef.instance;
|
|
1151
|
+
const canRestoreFocus = this._focusedElementBeforeOpen && typeof this._focusedElementBeforeOpen.focus === "function";
|
|
1152
|
+
const completeClose = () => {
|
|
1153
|
+
if (this._popupRef && this._popupRef.hasAttached()) this._popupRef.detach();
|
|
1154
|
+
if (this._portal && this._portal.isAttached) this._portal.detach();
|
|
1155
|
+
this._opened = false;
|
|
1156
|
+
this._isAnimating = false;
|
|
1157
|
+
this.closedStream.emit();
|
|
1158
|
+
if (canRestoreFocus) this._focusedElementBeforeOpen.focus();
|
|
1159
|
+
this._focusedElementBeforeOpen = null;
|
|
1160
|
+
};
|
|
1161
|
+
if (contentInstance) {
|
|
1162
|
+
this._isAnimating = true;
|
|
1163
|
+
contentInstance._startExitAnimation();
|
|
1164
|
+
contentInstance._animationDone.pipe(take(1)).subscribe(() => {
|
|
1165
|
+
if (canRestoreFocus) this._focusedElementBeforeOpen.focus();
|
|
1166
|
+
setTimeout(completeClose);
|
|
1167
|
+
});
|
|
1168
|
+
} else if (canRestoreFocus) {
|
|
1169
|
+
this._focusedElementBeforeOpen.focus();
|
|
1170
|
+
setTimeout(completeClose);
|
|
1171
|
+
} else completeClose();
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
_setColor() {
|
|
1175
|
+
const color = this.color;
|
|
1176
|
+
if (this._popupComponentRef) this._popupComponentRef.instance.color = color;
|
|
1177
|
+
if (this._dialogRef) this._dialogRef.componentInstance.color = color;
|
|
1178
|
+
}
|
|
1179
|
+
_createPopupPositionStrategy() {
|
|
1180
|
+
return this._overlay.position().flexibleConnectedTo(this._pickerInput.getConnectedOverlayOrigin()).withTransformOriginOn(".ngx-mat-colorpicker-content").withFlexibleDimensions(false).withViewportMargin(8).withLockedPosition().withPositions([
|
|
1181
|
+
{
|
|
1182
|
+
originX: "start",
|
|
1183
|
+
originY: "bottom",
|
|
1184
|
+
overlayX: "start",
|
|
1185
|
+
overlayY: "top"
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
originX: "start",
|
|
1189
|
+
originY: "top",
|
|
1190
|
+
overlayX: "start",
|
|
1191
|
+
overlayY: "bottom"
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
originX: "end",
|
|
1195
|
+
originY: "bottom",
|
|
1196
|
+
overlayX: "end",
|
|
1197
|
+
overlayY: "top"
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
originX: "end",
|
|
1201
|
+
originY: "top",
|
|
1202
|
+
overlayX: "end",
|
|
1203
|
+
overlayY: "bottom"
|
|
1204
|
+
}
|
|
1205
|
+
]);
|
|
1206
|
+
}
|
|
1207
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1208
|
+
minVersion: "12.0.0",
|
|
1209
|
+
version: "22.2.0",
|
|
1210
|
+
ngImport: i0,
|
|
1211
|
+
type: NgxMatColorPickerComponent,
|
|
1212
|
+
deps: [],
|
|
1213
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1214
|
+
});
|
|
1215
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1216
|
+
minVersion: "14.0.0",
|
|
1217
|
+
version: "22.2.0",
|
|
1218
|
+
type: NgxMatColorPickerComponent,
|
|
1219
|
+
isStandalone: true,
|
|
1220
|
+
selector: "ngx-mat-color-picker",
|
|
1221
|
+
inputs: {
|
|
1222
|
+
id: "id",
|
|
1223
|
+
disabled: "disabled",
|
|
1224
|
+
touchUi: "touchUi",
|
|
1225
|
+
opened: "opened",
|
|
1226
|
+
defaultColor: "defaultColor",
|
|
1227
|
+
color: "color"
|
|
1228
|
+
},
|
|
1229
|
+
outputs: {
|
|
1230
|
+
openedStream: "opened",
|
|
1231
|
+
closedStream: "closed"
|
|
1232
|
+
},
|
|
1233
|
+
host: { properties: {
|
|
1234
|
+
"class.mat-primary": "this.isPrimary",
|
|
1235
|
+
"class.mat-accent": "this.isAccent",
|
|
1236
|
+
"class.mat-warn": "this.isWarn"
|
|
1237
|
+
} },
|
|
1238
|
+
providers: [ColorAdapter, NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY_FACTORY_PROVIDER],
|
|
1239
|
+
exportAs: ["ngxMatColorPicker"],
|
|
1240
|
+
ngImport: i0,
|
|
1241
|
+
template: "",
|
|
1242
|
+
isInline: true,
|
|
1243
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
1244
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
1245
|
+
});
|
|
1246
|
+
};
|
|
1247
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1248
|
+
minVersion: "12.0.0",
|
|
1249
|
+
version: "22.2.0",
|
|
1250
|
+
ngImport: i0,
|
|
1251
|
+
type: NgxMatColorPickerComponent,
|
|
1252
|
+
decorators: [{
|
|
1253
|
+
type: Component,
|
|
1254
|
+
args: [{
|
|
1255
|
+
selector: "ngx-mat-color-picker",
|
|
1256
|
+
template: "",
|
|
1257
|
+
exportAs: "ngxMatColorPicker",
|
|
1258
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1259
|
+
encapsulation: ViewEncapsulation.None,
|
|
1260
|
+
providers: [ColorAdapter, NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY_FACTORY_PROVIDER]
|
|
1261
|
+
}]
|
|
1262
|
+
}],
|
|
1263
|
+
propDecorators: {
|
|
1264
|
+
id: [{ type: Input }],
|
|
1265
|
+
openedStream: [{
|
|
1266
|
+
type: Output,
|
|
1267
|
+
args: ["opened"]
|
|
1268
|
+
}],
|
|
1269
|
+
closedStream: [{
|
|
1270
|
+
type: Output,
|
|
1271
|
+
args: ["closed"]
|
|
1272
|
+
}],
|
|
1273
|
+
disabled: [{ type: Input }],
|
|
1274
|
+
touchUi: [{ type: Input }],
|
|
1275
|
+
opened: [{ type: Input }],
|
|
1276
|
+
defaultColor: [{ type: Input }],
|
|
1277
|
+
color: [{ type: Input }],
|
|
1278
|
+
isPrimary: [{
|
|
1279
|
+
type: HostBinding,
|
|
1280
|
+
args: ["class.mat-primary"]
|
|
1281
|
+
}],
|
|
1282
|
+
isAccent: [{
|
|
1283
|
+
type: HostBinding,
|
|
1284
|
+
args: ["class.mat-accent"]
|
|
1285
|
+
}],
|
|
1286
|
+
isWarn: [{
|
|
1287
|
+
type: HostBinding,
|
|
1288
|
+
args: ["class.mat-warn"]
|
|
1289
|
+
}]
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
var NgxMatColorPickerInputEvent = class {
|
|
1293
|
+
target;
|
|
1294
|
+
targetElement;
|
|
1295
|
+
value;
|
|
1296
|
+
constructor(target, targetElement) {
|
|
1297
|
+
this.target = target;
|
|
1298
|
+
this.targetElement = targetElement;
|
|
1299
|
+
this.value = this.target.value;
|
|
1300
|
+
}
|
|
612
1301
|
};
|
|
613
|
-
class NgxMatColorPickerContentComponent {
|
|
614
|
-
/** Reference to the internal calendar component. */
|
|
615
|
-
_palette = viewChild(NgxMatColorPaletteComponent, /* @ts-ignore */
|
|
616
|
-
...(ngDevMode ? [{ debugName: "_palette" }] : /* istanbul ignore next */ []));
|
|
617
|
-
picker = null;
|
|
618
|
-
color;
|
|
619
|
-
_isLeaving = false;
|
|
620
|
-
_panelEnterClass = null;
|
|
621
|
-
_animationDone = new Subject();
|
|
622
|
-
_cdr = inject(ChangeDetectorRef);
|
|
623
|
-
get isEnterDropdown() {
|
|
624
|
-
return !this._isLeaving && this._panelEnterClass === 'enter-dropdown';
|
|
625
|
-
}
|
|
626
|
-
get isEnterDialog() {
|
|
627
|
-
return !this._isLeaving && this._panelEnterClass === 'enter-dialog';
|
|
628
|
-
}
|
|
629
|
-
get isLeaving() {
|
|
630
|
-
return this._isLeaving;
|
|
631
|
-
}
|
|
632
|
-
ngOnInit() {
|
|
633
|
-
this._panelEnterClass = this.picker?.touchUi ? 'enter-dialog' : 'enter-dropdown';
|
|
634
|
-
this._cdr.markForCheck(); // ensure initial class is applied
|
|
635
|
-
}
|
|
636
|
-
_startExitAnimation() {
|
|
637
|
-
this._isLeaving = true;
|
|
638
|
-
this._cdr.markForCheck(); // trigger class update
|
|
639
|
-
}
|
|
640
|
-
_onAnimationEnd(event) {
|
|
641
|
-
if (event.animationName === 'panelLeave') {
|
|
642
|
-
this._animationDone.next();
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: NgxMatColorPickerContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
646
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.7", type: NgxMatColorPickerContentComponent, isStandalone: true, selector: "ngx-mat-color-picker-content", inputs: { color: "color" }, outputs: { _animationDone: "_animationDone" }, host: { listeners: { "animationend": "_onAnimationEnd($event)" }, properties: { "class.ngx-mat-colorpicker-content-touch": "picker?.touchUi", "class.panel-enter-dropdown": "this.isEnterDropdown", "class.panel-enter-dialog": "this.isEnterDialog", "class.panel-leave": "this.isLeaving" }, classAttribute: "ngx-mat-colorpicker-content" }, viewQueries: [{ propertyName: "_palette", first: true, predicate: NgxMatColorPaletteComponent, descendants: true, isSignal: true }], exportAs: ["ngxMatColorPickerContent"], ngImport: i0, template: "<ngx-mat-color-palette\n (colorChanged)=\"picker?.select($event)\"\n [color]=\"picker!._selected\"\n [theme]=\"color\"></ngx-mat-color-palette>\n", styles: ["@keyframes panelDropdownEnter{0%{opacity:0;transform:scaleY(.8)}to{opacity:1;transform:scale(1)}}@keyframes panelDialogEnter{0%{opacity:0;transform:scale(.7)}to{opacity:1;transform:none}}@keyframes panelLeave{0%{opacity:1}to{opacity:0}}.panel-enter-dropdown{animation:panelDropdownEnter .12s cubic-bezier(0,0,.2,1)}.panel-enter-dialog{animation:panelDialogEnter .15s cubic-bezier(0,0,.2,1)}.panel-leave{animation:panelLeave .1s linear forwards;pointer-events:none}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.calendar-fade-enter{animation:fadeIn .12s .1s cubic-bezier(.55,0,.55,.2) forwards}\n", ".ngx-mat-colorpicker-content{display:block;border-radius:4px;box-shadow:0 2px 4px -1px #0003,0 4px 5px #00000024,0 1px 10px #0000001f;background-color:#fff;color:#000000de;padding:16px}.ngx-mat-colorpicker-content .ngx-mat-color-palette{width:296px;height:354px}.ngx-mat-colorpicker-content-touch{display:block;max-height:80vh;overflow:auto}.ngx-mat-colorpicker-content-touch .ngx-mat-color-palette{min-width:250px;min-height:312px;max-width:750px;max-height:788px}@media all and (orientation:landscape){.mat-colorpicker-content-touch .ngx-mat-color-palette{width:64vh;height:80vh}}@media all and (orientation:portrait){.mat-colorpicker-content-touch .ngx-mat-color-palette{width:80vw;height:100vw}}\n"], dependencies: [{ kind: "component", type: NgxMatColorPaletteComponent, selector: "ngx-mat-color-palette", inputs: ["color", "theme"], outputs: ["colorChanged"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
647
|
-
}
|
|
648
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: NgxMatColorPickerContentComponent, decorators: [{
|
|
649
|
-
type: Component,
|
|
650
|
-
args: [{ selector: 'ngx-mat-color-picker-content', host: {
|
|
651
|
-
class: 'ngx-mat-colorpicker-content',
|
|
652
|
-
'[class.ngx-mat-colorpicker-content-touch]': 'picker?.touchUi',
|
|
653
|
-
'(animationend)': '_onAnimationEnd($event)',
|
|
654
|
-
}, exportAs: 'ngxMatColorPickerContent', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgxMatColorPaletteComponent], template: "<ngx-mat-color-palette\n (colorChanged)=\"picker?.select($event)\"\n [color]=\"picker!._selected\"\n [theme]=\"color\"></ngx-mat-color-palette>\n", styles: ["@keyframes panelDropdownEnter{0%{opacity:0;transform:scaleY(.8)}to{opacity:1;transform:scale(1)}}@keyframes panelDialogEnter{0%{opacity:0;transform:scale(.7)}to{opacity:1;transform:none}}@keyframes panelLeave{0%{opacity:1}to{opacity:0}}.panel-enter-dropdown{animation:panelDropdownEnter .12s cubic-bezier(0,0,.2,1)}.panel-enter-dialog{animation:panelDialogEnter .15s cubic-bezier(0,0,.2,1)}.panel-leave{animation:panelLeave .1s linear forwards;pointer-events:none}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.calendar-fade-enter{animation:fadeIn .12s .1s cubic-bezier(.55,0,.55,.2) forwards}\n", ".ngx-mat-colorpicker-content{display:block;border-radius:4px;box-shadow:0 2px 4px -1px #0003,0 4px 5px #00000024,0 1px 10px #0000001f;background-color:#fff;color:#000000de;padding:16px}.ngx-mat-colorpicker-content .ngx-mat-color-palette{width:296px;height:354px}.ngx-mat-colorpicker-content-touch{display:block;max-height:80vh;overflow:auto}.ngx-mat-colorpicker-content-touch .ngx-mat-color-palette{min-width:250px;min-height:312px;max-width:750px;max-height:788px}@media all and (orientation:landscape){.mat-colorpicker-content-touch .ngx-mat-color-palette{width:64vh;height:80vh}}@media all and (orientation:portrait){.mat-colorpicker-content-touch .ngx-mat-color-palette{width:80vw;height:100vw}}\n"] }]
|
|
655
|
-
}], propDecorators: { _palette: [{ type: i0.ViewChild, args: [i0.forwardRef(() => NgxMatColorPaletteComponent), { isSignal: true }] }], color: [{
|
|
656
|
-
type: Input
|
|
657
|
-
}], _animationDone: [{
|
|
658
|
-
type: Output
|
|
659
|
-
}], isEnterDropdown: [{
|
|
660
|
-
type: HostBinding,
|
|
661
|
-
args: ['class.panel-enter-dropdown']
|
|
662
|
-
}], isEnterDialog: [{
|
|
663
|
-
type: HostBinding,
|
|
664
|
-
args: ['class.panel-enter-dialog']
|
|
665
|
-
}], isLeaving: [{
|
|
666
|
-
type: HostBinding,
|
|
667
|
-
args: ['class.panel-leave']
|
|
668
|
-
}] } });
|
|
669
|
-
class NgxMatColorPickerComponent {
|
|
670
|
-
id = `ngx-mat-color-picker-${Math.floor(Math.random() * 1000000)}`;
|
|
671
|
-
/** Emits when the datepicker has been opened. */
|
|
672
|
-
openedStream = new EventEmitter();
|
|
673
|
-
/** Emits when the datepicker has been closed. */
|
|
674
|
-
closedStream = new EventEmitter();
|
|
675
|
-
get disabled() {
|
|
676
|
-
return this._disabled === undefined && this._pickerInput
|
|
677
|
-
? this._pickerInput.disabled
|
|
678
|
-
: !!this._disabled;
|
|
679
|
-
}
|
|
680
|
-
set disabled(value) {
|
|
681
|
-
const newValue = coerceBooleanProperty(value);
|
|
682
|
-
if (newValue !== this._disabled) {
|
|
683
|
-
this._disabled = newValue;
|
|
684
|
-
this._disabledChange.next(newValue);
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
_disabled = false;
|
|
688
|
-
get touchUi() {
|
|
689
|
-
return this._touchUi;
|
|
690
|
-
}
|
|
691
|
-
set touchUi(value) {
|
|
692
|
-
this._touchUi = coerceBooleanProperty(value);
|
|
693
|
-
}
|
|
694
|
-
_touchUi = false;
|
|
695
|
-
/** Whether the calendar is open. */
|
|
696
|
-
get opened() {
|
|
697
|
-
return this._opened;
|
|
698
|
-
}
|
|
699
|
-
set opened(value) {
|
|
700
|
-
if (value)
|
|
701
|
-
this.open();
|
|
702
|
-
else
|
|
703
|
-
this.close();
|
|
704
|
-
}
|
|
705
|
-
_opened = false;
|
|
706
|
-
/** Default Color palette to use on the datepicker's calendar. */
|
|
707
|
-
get defaultColor() {
|
|
708
|
-
return this._defaultColor;
|
|
709
|
-
}
|
|
710
|
-
set defaultColor(value) {
|
|
711
|
-
this._defaultColor = value;
|
|
712
|
-
}
|
|
713
|
-
_defaultColor = 'primary';
|
|
714
|
-
/** Color palette to use on the datepicker's calendar. */
|
|
715
|
-
get color() {
|
|
716
|
-
return this._color || (this._pickerInput ? this._pickerInput.getThemePalette() : undefined);
|
|
717
|
-
}
|
|
718
|
-
set color(value) {
|
|
719
|
-
this._color = value;
|
|
720
|
-
}
|
|
721
|
-
_color;
|
|
722
|
-
get isPrimary() {
|
|
723
|
-
return this.color === 'primary';
|
|
724
|
-
}
|
|
725
|
-
get isAccent() {
|
|
726
|
-
return this.color === 'accent';
|
|
727
|
-
}
|
|
728
|
-
get isWarn() {
|
|
729
|
-
return this.color === 'warn';
|
|
730
|
-
}
|
|
731
|
-
/** The currently selected date. */
|
|
732
|
-
get _selected() {
|
|
733
|
-
return this._validSelected;
|
|
734
|
-
}
|
|
735
|
-
set _selected(value) {
|
|
736
|
-
this._validSelected = value;
|
|
737
|
-
}
|
|
738
|
-
_validSelected = null;
|
|
739
|
-
_pickerInput = null;
|
|
740
|
-
/** A reference to the overlay when the picker is opened as a popup. */
|
|
741
|
-
_popupRef = null;
|
|
742
|
-
/** A reference to the dialog when the picker is opened as a dialog. */
|
|
743
|
-
_dialogRef = null;
|
|
744
|
-
/** Reference to the component instantiated in popup mode. */
|
|
745
|
-
_popupComponentRef = null;
|
|
746
|
-
/** A portal containing the content for this picker. */
|
|
747
|
-
_portal = null;
|
|
748
|
-
/** Emits when the datepicker is disabled. */
|
|
749
|
-
_disabledChange = new EventEmitter();
|
|
750
|
-
/** The element that was focused before the datepicker was opened. */
|
|
751
|
-
_focusedElementBeforeOpen = null;
|
|
752
|
-
/** Subscription to value changes in the associated input element. */
|
|
753
|
-
_inputSubscription = Subscription.EMPTY;
|
|
754
|
-
/** Emits new selected date when selected date changes. */
|
|
755
|
-
_selectedChanged = new Subject();
|
|
756
|
-
/** Whether an animation is currently in progress. */
|
|
757
|
-
_isAnimating = false;
|
|
758
|
-
_dialog = inject(MatDialog);
|
|
759
|
-
_overlay = inject(Overlay);
|
|
760
|
-
_zone = inject(NgZone);
|
|
761
|
-
_adapter = inject(ColorAdapter);
|
|
762
|
-
_dir = inject(Directionality, { optional: true });
|
|
763
|
-
_scrollStrategy = inject(NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY);
|
|
764
|
-
_document = inject(DOCUMENT, { optional: true });
|
|
765
|
-
_viewContainerRef = inject(ViewContainerRef);
|
|
766
|
-
ngOnDestroy() {
|
|
767
|
-
this.close();
|
|
768
|
-
this._inputSubscription.unsubscribe();
|
|
769
|
-
this._disabledChange.complete();
|
|
770
|
-
if (this._popupRef) {
|
|
771
|
-
this._popupRef.dispose();
|
|
772
|
-
this._popupComponentRef = null;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
/** Selects the given date */
|
|
776
|
-
select(nextVal) {
|
|
777
|
-
const oldValue = this._selected;
|
|
778
|
-
this._selected = nextVal;
|
|
779
|
-
if (!this._adapter.sameColor(oldValue, this._selected)) {
|
|
780
|
-
this._selectedChanged.next(nextVal);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
/**
|
|
784
|
-
* Register an input with this datepicker.
|
|
785
|
-
* @param input The datepicker input to register with this datepicker.
|
|
786
|
-
*/
|
|
787
|
-
registerInput(input) {
|
|
788
|
-
if (this._pickerInput) {
|
|
789
|
-
throw Error('A ColorPicker can only be associated with a single input.');
|
|
790
|
-
}
|
|
791
|
-
this._pickerInput = input;
|
|
792
|
-
this._inputSubscription = this._pickerInput._valueChange.subscribe((value) => (this._selected = value));
|
|
793
|
-
}
|
|
794
|
-
open() {
|
|
795
|
-
if (this._opened || this.disabled || this._isAnimating) {
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
if (!this._pickerInput) {
|
|
799
|
-
throw Error('Attempted to open an ColorPicker with no associated input.');
|
|
800
|
-
}
|
|
801
|
-
if (this._document) {
|
|
802
|
-
this._focusedElementBeforeOpen = this._document.activeElement;
|
|
803
|
-
}
|
|
804
|
-
if (this.touchUi)
|
|
805
|
-
this._openAsDialog();
|
|
806
|
-
else
|
|
807
|
-
this._openAsPopup();
|
|
808
|
-
this._opened = true;
|
|
809
|
-
this.openedStream.emit();
|
|
810
|
-
}
|
|
811
|
-
/** Open the calendar as a dialog. */
|
|
812
|
-
_openAsDialog() {
|
|
813
|
-
if (this._dialogRef) {
|
|
814
|
-
this._dialogRef.close();
|
|
815
|
-
}
|
|
816
|
-
this._dialogRef = this._dialog.open(NgxMatColorPickerContentComponent, {
|
|
817
|
-
direction: this._dir ? this._dir.value : 'ltr',
|
|
818
|
-
viewContainerRef: this._viewContainerRef,
|
|
819
|
-
panelClass: 'ngx-mat-colorpicker-dialog',
|
|
820
|
-
});
|
|
821
|
-
this._dialogRef.afterClosed().subscribe(() => this._handleDialogClosed());
|
|
822
|
-
this._dialogRef.componentInstance.picker = this;
|
|
823
|
-
this._setColor();
|
|
824
|
-
}
|
|
825
|
-
_handleDialogClosed() {
|
|
826
|
-
this._opened = false;
|
|
827
|
-
this._isAnimating = false;
|
|
828
|
-
this.closedStream.emit();
|
|
829
|
-
if (this._focusedElementBeforeOpen) {
|
|
830
|
-
this._focusedElementBeforeOpen.focus();
|
|
831
|
-
this._focusedElementBeforeOpen = null;
|
|
832
|
-
}
|
|
833
|
-
this._dialogRef = null;
|
|
834
|
-
}
|
|
835
|
-
/** Open the calendar as a popup. */
|
|
836
|
-
_openAsPopup() {
|
|
837
|
-
if (!this._portal) {
|
|
838
|
-
this._portal = new ComponentPortal(NgxMatColorPickerContentComponent, this._viewContainerRef);
|
|
839
|
-
}
|
|
840
|
-
if (!this._popupRef) {
|
|
841
|
-
this._createPopup();
|
|
842
|
-
}
|
|
843
|
-
if (!this._popupRef?.hasAttached()) {
|
|
844
|
-
this._popupComponentRef = this._popupRef?.attach(this._portal);
|
|
845
|
-
this._popupComponentRef.instance.picker = this;
|
|
846
|
-
this._setColor();
|
|
847
|
-
// Update the position once the calendar has rendered.
|
|
848
|
-
this._zone.onStable
|
|
849
|
-
.asObservable()
|
|
850
|
-
.pipe(take(1))
|
|
851
|
-
.subscribe(() => {
|
|
852
|
-
this._popupRef?.updatePosition();
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
/** Create the popup. */
|
|
857
|
-
_createPopup() {
|
|
858
|
-
const overlayConfig = new OverlayConfig({
|
|
859
|
-
positionStrategy: this._createPopupPositionStrategy(),
|
|
860
|
-
hasBackdrop: true,
|
|
861
|
-
backdropClass: 'mat-overlay-transparent-backdrop',
|
|
862
|
-
direction: this._dir ?? "ltr",
|
|
863
|
-
scrollStrategy: this._scrollStrategy(),
|
|
864
|
-
panelClass: 'mat-colorpicker-popup',
|
|
865
|
-
});
|
|
866
|
-
this._popupRef = this._overlay.create(overlayConfig);
|
|
867
|
-
this._popupRef.overlayElement.setAttribute('role', 'dialog');
|
|
868
|
-
merge(this._popupRef.backdropClick(), this._popupRef.detachments(), this._popupRef.keydownEvents().pipe(filter((event) => {
|
|
869
|
-
// Closing on alt + up is only valid when there's an input associated with the datepicker.
|
|
870
|
-
return (event.keyCode === ESCAPE ||
|
|
871
|
-
(this._pickerInput && event.altKey && event.keyCode === UP_ARROW));
|
|
872
|
-
}))).subscribe((event) => {
|
|
873
|
-
if (event) {
|
|
874
|
-
event.preventDefault();
|
|
875
|
-
}
|
|
876
|
-
this.close();
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
close() {
|
|
880
|
-
if (!this._opened || this._isAnimating) {
|
|
881
|
-
return;
|
|
882
|
-
}
|
|
883
|
-
if (this.touchUi) {
|
|
884
|
-
// Dialog mode – close the dialog, state reset happens in afterClosed
|
|
885
|
-
if (this._dialogRef) {
|
|
886
|
-
this._dialogRef.close();
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
else {
|
|
890
|
-
// Popup mode – animate out then clean up
|
|
891
|
-
let contentInstance = null;
|
|
892
|
-
if (this._popupComponentRef) {
|
|
893
|
-
contentInstance = this._popupComponentRef.instance;
|
|
894
|
-
}
|
|
895
|
-
const canRestoreFocus = this._focusedElementBeforeOpen &&
|
|
896
|
-
typeof this._focusedElementBeforeOpen.focus === 'function';
|
|
897
|
-
const completeClose = () => {
|
|
898
|
-
if (this._popupRef && this._popupRef.hasAttached()) {
|
|
899
|
-
this._popupRef.detach();
|
|
900
|
-
}
|
|
901
|
-
if (this._portal && this._portal.isAttached) {
|
|
902
|
-
this._portal.detach();
|
|
903
|
-
}
|
|
904
|
-
this._opened = false;
|
|
905
|
-
this._isAnimating = false;
|
|
906
|
-
this.closedStream.emit();
|
|
907
|
-
if (canRestoreFocus) {
|
|
908
|
-
this._focusedElementBeforeOpen.focus();
|
|
909
|
-
}
|
|
910
|
-
this._focusedElementBeforeOpen = null;
|
|
911
|
-
};
|
|
912
|
-
if (contentInstance) {
|
|
913
|
-
this._isAnimating = true;
|
|
914
|
-
contentInstance._startExitAnimation();
|
|
915
|
-
contentInstance._animationDone.pipe(take(1)).subscribe(() => {
|
|
916
|
-
// Restore focus before the timeout to ensure it happens even if the
|
|
917
|
-
// overlay is removed synchronously.
|
|
918
|
-
if (canRestoreFocus) {
|
|
919
|
-
this._focusedElementBeforeOpen.focus();
|
|
920
|
-
}
|
|
921
|
-
setTimeout(completeClose);
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
else {
|
|
925
|
-
// No content to animate – close immediately
|
|
926
|
-
if (canRestoreFocus) {
|
|
927
|
-
this._focusedElementBeforeOpen.focus();
|
|
928
|
-
setTimeout(completeClose);
|
|
929
|
-
}
|
|
930
|
-
else {
|
|
931
|
-
completeClose();
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
/** Passes the current theme color along to the calendar overlay. */
|
|
937
|
-
_setColor() {
|
|
938
|
-
const color = this.color;
|
|
939
|
-
if (this._popupComponentRef) {
|
|
940
|
-
this._popupComponentRef.instance.color = color;
|
|
941
|
-
}
|
|
942
|
-
if (this._dialogRef) {
|
|
943
|
-
this._dialogRef.componentInstance.color = color;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
/** Create the popup PositionStrategy. */
|
|
947
|
-
_createPopupPositionStrategy() {
|
|
948
|
-
return this._overlay
|
|
949
|
-
.position()
|
|
950
|
-
.flexibleConnectedTo(this._pickerInput.getConnectedOverlayOrigin())
|
|
951
|
-
.withTransformOriginOn('.ngx-mat-colorpicker-content')
|
|
952
|
-
.withFlexibleDimensions(false)
|
|
953
|
-
.withViewportMargin(8)
|
|
954
|
-
.withLockedPosition()
|
|
955
|
-
.withPositions([
|
|
956
|
-
{
|
|
957
|
-
originX: 'start',
|
|
958
|
-
originY: 'bottom',
|
|
959
|
-
overlayX: 'start',
|
|
960
|
-
overlayY: 'top',
|
|
961
|
-
},
|
|
962
|
-
{
|
|
963
|
-
originX: 'start',
|
|
964
|
-
originY: 'top',
|
|
965
|
-
overlayX: 'start',
|
|
966
|
-
overlayY: 'bottom',
|
|
967
|
-
},
|
|
968
|
-
{
|
|
969
|
-
originX: 'end',
|
|
970
|
-
originY: 'bottom',
|
|
971
|
-
overlayX: 'end',
|
|
972
|
-
overlayY: 'top',
|
|
973
|
-
},
|
|
974
|
-
{
|
|
975
|
-
originX: 'end',
|
|
976
|
-
originY: 'top',
|
|
977
|
-
overlayX: 'end',
|
|
978
|
-
overlayY: 'bottom',
|
|
979
|
-
},
|
|
980
|
-
]);
|
|
981
|
-
}
|
|
982
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: NgxMatColorPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
983
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.7", type: NgxMatColorPickerComponent, isStandalone: true, selector: "ngx-mat-color-picker", inputs: { id: "id", disabled: "disabled", touchUi: "touchUi", opened: "opened", defaultColor: "defaultColor", color: "color" }, outputs: { openedStream: "opened", closedStream: "closed" }, host: { properties: { "class.mat-primary": "this.isPrimary", "class.mat-accent": "this.isAccent", "class.mat-warn": "this.isWarn" } }, providers: [ColorAdapter, NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY_FACTORY_PROVIDER], exportAs: ["ngxMatColorPicker"], ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
984
|
-
}
|
|
985
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: NgxMatColorPickerComponent, decorators: [{
|
|
986
|
-
type: Component,
|
|
987
|
-
args: [{
|
|
988
|
-
selector: 'ngx-mat-color-picker',
|
|
989
|
-
template: '',
|
|
990
|
-
exportAs: 'ngxMatColorPicker',
|
|
991
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
992
|
-
encapsulation: ViewEncapsulation.None,
|
|
993
|
-
providers: [ColorAdapter, NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY_FACTORY_PROVIDER],
|
|
994
|
-
}]
|
|
995
|
-
}], propDecorators: { id: [{
|
|
996
|
-
type: Input
|
|
997
|
-
}], openedStream: [{
|
|
998
|
-
type: Output,
|
|
999
|
-
args: ['opened']
|
|
1000
|
-
}], closedStream: [{
|
|
1001
|
-
type: Output,
|
|
1002
|
-
args: ['closed']
|
|
1003
|
-
}], disabled: [{
|
|
1004
|
-
type: Input
|
|
1005
|
-
}], touchUi: [{
|
|
1006
|
-
type: Input
|
|
1007
|
-
}], opened: [{
|
|
1008
|
-
type: Input
|
|
1009
|
-
}], defaultColor: [{
|
|
1010
|
-
type: Input
|
|
1011
|
-
}], color: [{
|
|
1012
|
-
type: Input
|
|
1013
|
-
}], isPrimary: [{
|
|
1014
|
-
type: HostBinding,
|
|
1015
|
-
args: ['class.mat-primary']
|
|
1016
|
-
}], isAccent: [{
|
|
1017
|
-
type: HostBinding,
|
|
1018
|
-
args: ['class.mat-accent']
|
|
1019
|
-
}], isWarn: [{
|
|
1020
|
-
type: HostBinding,
|
|
1021
|
-
args: ['class.mat-warn']
|
|
1022
|
-
}] } });
|
|
1023
|
-
|
|
1024
|
-
class NgxMatColorPickerInputEvent {
|
|
1025
|
-
target;
|
|
1026
|
-
targetElement;
|
|
1027
|
-
/** The new value for the target colorpicker input. */
|
|
1028
|
-
value;
|
|
1029
|
-
constructor(
|
|
1030
|
-
/** Reference to the colorpicker input component that emitted the event. */
|
|
1031
|
-
target,
|
|
1032
|
-
/** Reference to the native input element associated with the colorpicker input. */
|
|
1033
|
-
targetElement) {
|
|
1034
|
-
this.target = target;
|
|
1035
|
-
this.targetElement = targetElement;
|
|
1036
|
-
this.value = this.target.value;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
1302
|
const MAT_COLORPICKER_VALUE_ACCESSOR = {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1303
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1304
|
+
useExisting: forwardRef(() => NgxMatColorPickerInput),
|
|
1305
|
+
multi: true
|
|
1043
1306
|
};
|
|
1044
1307
|
const MAT_COLORPICKER_VALIDATORS = {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1308
|
+
provide: NG_VALIDATORS,
|
|
1309
|
+
useExisting: forwardRef(() => NgxMatColorPickerInput),
|
|
1310
|
+
multi: true
|
|
1048
1311
|
};
|
|
1049
|
-
class NgxMatColorPickerInput {
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1312
|
+
var NgxMatColorPickerInput = class NgxMatColorPickerInput {
|
|
1313
|
+
set ngxMatColorPicker(value) {
|
|
1314
|
+
if (!value) return;
|
|
1315
|
+
this._picker = value;
|
|
1316
|
+
this._picker.registerInput(this);
|
|
1317
|
+
this._pickerSubscription.unsubscribe();
|
|
1318
|
+
this._pickerSubscription = this._picker._selectedChanged.subscribe((selected) => {
|
|
1319
|
+
this.value = selected;
|
|
1320
|
+
this._cvaOnChange(selected);
|
|
1321
|
+
this._onTouched();
|
|
1322
|
+
this.colorInput.emit(new NgxMatColorPickerInputEvent(this, this._elementRef.nativeElement));
|
|
1323
|
+
this.colorChange.emit(new NgxMatColorPickerInputEvent(this, this._elementRef.nativeElement));
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
_picker = null;
|
|
1327
|
+
get disabled() {
|
|
1328
|
+
return !!this._disabled;
|
|
1329
|
+
}
|
|
1330
|
+
set disabled(value) {
|
|
1331
|
+
const newValue = coerceBooleanProperty(value);
|
|
1332
|
+
const element = this._elementRef.nativeElement;
|
|
1333
|
+
if (this._disabled !== newValue) {
|
|
1334
|
+
this._disabled = newValue;
|
|
1335
|
+
this._disabledChange.emit(newValue);
|
|
1336
|
+
}
|
|
1337
|
+
if (newValue && element.blur) element.blur();
|
|
1338
|
+
}
|
|
1339
|
+
_disabled = false;
|
|
1340
|
+
get value() {
|
|
1341
|
+
return this._value;
|
|
1342
|
+
}
|
|
1343
|
+
set value(value) {
|
|
1344
|
+
const oldValue = this.value;
|
|
1345
|
+
this._value = value;
|
|
1346
|
+
this._formatValue(value);
|
|
1347
|
+
if (!this._adapter.sameColor(oldValue, value)) this._valueChange.emit(value);
|
|
1348
|
+
}
|
|
1349
|
+
_value = null;
|
|
1350
|
+
colorChange = output();
|
|
1351
|
+
colorInput = output();
|
|
1352
|
+
_disabledChange = new EventEmitter();
|
|
1353
|
+
_valueChange = new EventEmitter();
|
|
1354
|
+
_onTouched = () => {};
|
|
1355
|
+
_cvaOnChange = () => {};
|
|
1356
|
+
_validatorOnChange = () => {};
|
|
1357
|
+
_pickerSubscription = Subscription.EMPTY;
|
|
1358
|
+
_validator = Validators.compose([]);
|
|
1359
|
+
_lastValueValid = false;
|
|
1360
|
+
_elementRef = inject(ElementRef);
|
|
1361
|
+
_formField = inject(MatFormField, { optional: true });
|
|
1362
|
+
_colorFormats = inject(MAT_COLOR_FORMATS, { optional: true });
|
|
1363
|
+
_adapter = inject(ColorAdapter);
|
|
1364
|
+
constructor() {
|
|
1365
|
+
if (!this._colorFormats) throw createMissingDateImplError("MAT_COLOR_FORMATS");
|
|
1366
|
+
}
|
|
1367
|
+
getThemePalette() {
|
|
1368
|
+
return this._formField ? this._formField.color : void 0;
|
|
1369
|
+
}
|
|
1370
|
+
registerOnValidatorChange(fn) {
|
|
1371
|
+
this._validatorOnChange = fn;
|
|
1372
|
+
}
|
|
1373
|
+
validate(c) {
|
|
1374
|
+
return this._validator ? this._validator(c) : null;
|
|
1375
|
+
}
|
|
1376
|
+
getPopupConnectionElementRef() {
|
|
1377
|
+
return this.getConnectedOverlayOrigin();
|
|
1378
|
+
}
|
|
1379
|
+
getConnectedOverlayOrigin() {
|
|
1380
|
+
return this._formField ? this._formField.getConnectedOverlayOrigin() : this._elementRef;
|
|
1381
|
+
}
|
|
1382
|
+
ngOnDestroy() {
|
|
1383
|
+
this._pickerSubscription.unsubscribe();
|
|
1384
|
+
this._valueChange.complete();
|
|
1385
|
+
this._disabledChange.complete();
|
|
1386
|
+
}
|
|
1387
|
+
writeValue(value) {
|
|
1388
|
+
this.value = value;
|
|
1389
|
+
}
|
|
1390
|
+
registerOnChange(fn) {
|
|
1391
|
+
this._cvaOnChange = fn;
|
|
1392
|
+
}
|
|
1393
|
+
registerOnTouched(fn) {
|
|
1394
|
+
this._onTouched = fn;
|
|
1395
|
+
}
|
|
1396
|
+
setDisabledState(isDisabled) {
|
|
1397
|
+
this.disabled = isDisabled;
|
|
1398
|
+
}
|
|
1399
|
+
_onChange() {
|
|
1400
|
+
this.colorChange.emit(new NgxMatColorPickerInputEvent(this, this._elementRef.nativeElement));
|
|
1401
|
+
}
|
|
1402
|
+
_onKeydown(event) {
|
|
1403
|
+
const isAltDownArrow = event.altKey && event.keyCode === DOWN_ARROW;
|
|
1404
|
+
if (this._picker && isAltDownArrow && !this._elementRef.nativeElement.readOnly) {
|
|
1405
|
+
this._picker.open();
|
|
1406
|
+
event.preventDefault();
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
_onBlur() {
|
|
1410
|
+
if (this.value) this._formatValue(this.value);
|
|
1411
|
+
this._onTouched();
|
|
1412
|
+
}
|
|
1413
|
+
_formatValue(value) {
|
|
1414
|
+
this._elementRef.nativeElement.value = this._colorFormats && value ? this._adapter.format(value, this._colorFormats.display.colorInput) : "";
|
|
1415
|
+
}
|
|
1416
|
+
_onInput(event) {
|
|
1417
|
+
const lastValueWasValid = this._lastValueValid;
|
|
1418
|
+
const target = event?.target;
|
|
1419
|
+
const nextValue = this._adapter.parse(target.value);
|
|
1420
|
+
if (!this._adapter.sameColor(nextValue, this._value)) {
|
|
1421
|
+
this._value = nextValue;
|
|
1422
|
+
this._cvaOnChange(nextValue);
|
|
1423
|
+
this._valueChange.emit(nextValue);
|
|
1424
|
+
this.colorInput.emit(new NgxMatColorPickerInputEvent(this, this._elementRef.nativeElement));
|
|
1425
|
+
} else if (lastValueWasValid !== this._lastValueValid) this._validatorOnChange();
|
|
1426
|
+
}
|
|
1427
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1428
|
+
minVersion: "12.0.0",
|
|
1429
|
+
version: "22.2.0",
|
|
1430
|
+
ngImport: i0,
|
|
1431
|
+
type: NgxMatColorPickerInput,
|
|
1432
|
+
deps: [],
|
|
1433
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1434
|
+
});
|
|
1435
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1436
|
+
minVersion: "14.0.0",
|
|
1437
|
+
version: "22.2.0",
|
|
1438
|
+
type: NgxMatColorPickerInput,
|
|
1439
|
+
isStandalone: true,
|
|
1440
|
+
selector: "input[ngxMatColorPicker]",
|
|
1441
|
+
inputs: {
|
|
1442
|
+
ngxMatColorPicker: "ngxMatColorPicker",
|
|
1443
|
+
disabled: "disabled",
|
|
1444
|
+
value: "value"
|
|
1445
|
+
},
|
|
1446
|
+
outputs: {
|
|
1447
|
+
colorChange: "colorChange",
|
|
1448
|
+
colorInput: "colorInput"
|
|
1449
|
+
},
|
|
1450
|
+
host: {
|
|
1451
|
+
listeners: {
|
|
1452
|
+
"input": "_onInput($event)",
|
|
1453
|
+
"change": "_onChange()",
|
|
1454
|
+
"blur": "_onBlur()",
|
|
1455
|
+
"keydown": "_onKeydown($event)"
|
|
1456
|
+
},
|
|
1457
|
+
properties: {
|
|
1458
|
+
"attr.aria-haspopup": "_picker ? \"dialog\" : null",
|
|
1459
|
+
"attr.aria-owns": "(_picker?.opened && _picker?.id) || null",
|
|
1460
|
+
"disabled": "disabled"
|
|
1461
|
+
}
|
|
1462
|
+
},
|
|
1463
|
+
providers: [
|
|
1464
|
+
{
|
|
1465
|
+
provide: MAT_INPUT_VALUE_ACCESSOR,
|
|
1466
|
+
useExisting: NgxMatColorPickerInput
|
|
1467
|
+
},
|
|
1468
|
+
ColorAdapter,
|
|
1469
|
+
MAT_COLORPICKER_VALIDATORS,
|
|
1470
|
+
MAT_COLORPICKER_VALUE_ACCESSOR
|
|
1471
|
+
],
|
|
1472
|
+
exportAs: ["ngxMatColorPickerInput"],
|
|
1473
|
+
ngImport: i0
|
|
1474
|
+
});
|
|
1475
|
+
};
|
|
1476
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1477
|
+
minVersion: "12.0.0",
|
|
1478
|
+
version: "22.2.0",
|
|
1479
|
+
ngImport: i0,
|
|
1480
|
+
type: NgxMatColorPickerInput,
|
|
1481
|
+
decorators: [{
|
|
1482
|
+
type: Directive,
|
|
1483
|
+
args: [{
|
|
1484
|
+
selector: "input[ngxMatColorPicker]",
|
|
1485
|
+
providers: [
|
|
1486
|
+
{
|
|
1487
|
+
provide: MAT_INPUT_VALUE_ACCESSOR,
|
|
1488
|
+
useExisting: NgxMatColorPickerInput
|
|
1489
|
+
},
|
|
1490
|
+
ColorAdapter,
|
|
1491
|
+
MAT_COLORPICKER_VALIDATORS,
|
|
1492
|
+
MAT_COLORPICKER_VALUE_ACCESSOR
|
|
1493
|
+
],
|
|
1494
|
+
host: {
|
|
1495
|
+
"[attr.aria-haspopup]": "_picker ? \"dialog\" : null",
|
|
1496
|
+
"[attr.aria-owns]": "(_picker?.opened && _picker?.id) || null",
|
|
1497
|
+
"[disabled]": "disabled",
|
|
1498
|
+
"(input)": "_onInput($event)",
|
|
1499
|
+
"(change)": "_onChange()",
|
|
1500
|
+
"(blur)": "_onBlur()",
|
|
1501
|
+
"(keydown)": "_onKeydown($event)"
|
|
1502
|
+
},
|
|
1503
|
+
exportAs: "ngxMatColorPickerInput"
|
|
1504
|
+
}]
|
|
1505
|
+
}],
|
|
1506
|
+
ctorParameters: () => [],
|
|
1507
|
+
propDecorators: {
|
|
1508
|
+
ngxMatColorPicker: [{ type: Input }],
|
|
1509
|
+
disabled: [{ type: Input }],
|
|
1510
|
+
value: [{ type: Input }],
|
|
1511
|
+
colorChange: [{
|
|
1512
|
+
type: i0.Output,
|
|
1513
|
+
args: ["colorChange"]
|
|
1514
|
+
}],
|
|
1515
|
+
colorInput: [{
|
|
1516
|
+
type: i0.Output,
|
|
1517
|
+
args: ["colorInput"]
|
|
1518
|
+
}]
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
var NgxMatColorpickerToggleIcon = class NgxMatColorpickerToggleIcon {
|
|
1522
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1523
|
+
minVersion: "12.0.0",
|
|
1524
|
+
version: "22.2.0",
|
|
1525
|
+
ngImport: i0,
|
|
1526
|
+
type: NgxMatColorpickerToggleIcon,
|
|
1527
|
+
deps: [],
|
|
1528
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1529
|
+
});
|
|
1530
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1531
|
+
minVersion: "14.0.0",
|
|
1532
|
+
version: "22.2.0",
|
|
1533
|
+
type: NgxMatColorpickerToggleIcon,
|
|
1534
|
+
isStandalone: true,
|
|
1535
|
+
selector: "[ngxMatColorpickerToggleIcon]",
|
|
1536
|
+
ngImport: i0
|
|
1537
|
+
});
|
|
1538
|
+
};
|
|
1539
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1540
|
+
minVersion: "12.0.0",
|
|
1541
|
+
version: "22.2.0",
|
|
1542
|
+
ngImport: i0,
|
|
1543
|
+
type: NgxMatColorpickerToggleIcon,
|
|
1544
|
+
decorators: [{
|
|
1545
|
+
type: Directive,
|
|
1546
|
+
args: [{ selector: "[ngxMatColorpickerToggleIcon]" }]
|
|
1547
|
+
}]
|
|
1548
|
+
});
|
|
1549
|
+
var NgxMatColorToggleComponent = class NgxMatColorToggleComponent {
|
|
1550
|
+
_stateChanges = Subscription.EMPTY;
|
|
1551
|
+
picker = input(void 0, {
|
|
1552
|
+
...ngDevMode ? { debugName: "picker" } : /* istanbul ignore next */ {},
|
|
1553
|
+
alias: "for"
|
|
1554
|
+
});
|
|
1555
|
+
tabIndex = input(...ngDevMode ? [void 0, { debugName: "tabIndex" }] : /* istanbul ignore next */ []);
|
|
1556
|
+
get disabled() {
|
|
1557
|
+
if (this._disabled == null && this.picker()) return this.picker()?.disabled;
|
|
1558
|
+
}
|
|
1559
|
+
set disabled(value) {
|
|
1560
|
+
this._disabled = value;
|
|
1561
|
+
}
|
|
1562
|
+
_disabled = false;
|
|
1563
|
+
disableRipple = input(...ngDevMode ? [void 0, { debugName: "disableRipple" }] : /* istanbul ignore next */ []);
|
|
1564
|
+
_button = viewChild("button", ...ngDevMode ? [{ debugName: "_button" }] : /* istanbul ignore next */ []);
|
|
1565
|
+
_cd = inject(ChangeDetectorRef);
|
|
1566
|
+
constructor() {
|
|
1567
|
+
effect(() => {
|
|
1568
|
+
this.picker();
|
|
1569
|
+
untracked(() => this._watchStateChanges());
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
ngOnDestroy() {
|
|
1573
|
+
this._stateChanges.unsubscribe();
|
|
1574
|
+
}
|
|
1575
|
+
ngAfterContentInit() {
|
|
1576
|
+
this._watchStateChanges();
|
|
1577
|
+
}
|
|
1578
|
+
open(event) {
|
|
1579
|
+
if (this.picker() && !this.disabled) {
|
|
1580
|
+
this.picker()?.open();
|
|
1581
|
+
event.stopPropagation();
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
_watchStateChanges() {
|
|
1585
|
+
const disabled$ = this.picker()?._disabledChange ?? new EventEmitter();
|
|
1586
|
+
const inputDisabled$ = this.picker()?._pickerInput?._disabledChange ?? new EventEmitter();
|
|
1587
|
+
const pickerToggled$ = this.picker() ? merge(this.picker().openedStream, this.picker().closedStream) : of();
|
|
1588
|
+
this._stateChanges.unsubscribe();
|
|
1589
|
+
this._stateChanges = merge(disabled$, inputDisabled$, pickerToggled$).subscribe(() => this._cd.markForCheck());
|
|
1590
|
+
}
|
|
1591
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1592
|
+
minVersion: "12.0.0",
|
|
1593
|
+
version: "22.2.0",
|
|
1594
|
+
ngImport: i0,
|
|
1595
|
+
type: NgxMatColorToggleComponent,
|
|
1596
|
+
deps: [],
|
|
1597
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1598
|
+
});
|
|
1599
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1600
|
+
minVersion: "17.2.0",
|
|
1601
|
+
version: "22.2.0",
|
|
1602
|
+
type: NgxMatColorToggleComponent,
|
|
1603
|
+
isStandalone: true,
|
|
1604
|
+
selector: "ngx-mat-color-toggle",
|
|
1605
|
+
inputs: {
|
|
1606
|
+
picker: {
|
|
1607
|
+
classPropertyName: "picker",
|
|
1608
|
+
publicName: "for",
|
|
1609
|
+
isSignal: true,
|
|
1610
|
+
isRequired: false,
|
|
1611
|
+
transformFunction: null
|
|
1612
|
+
},
|
|
1613
|
+
tabIndex: {
|
|
1614
|
+
classPropertyName: "tabIndex",
|
|
1615
|
+
publicName: "tabIndex",
|
|
1616
|
+
isSignal: true,
|
|
1617
|
+
isRequired: false,
|
|
1618
|
+
transformFunction: null
|
|
1619
|
+
},
|
|
1620
|
+
disabled: {
|
|
1621
|
+
classPropertyName: "disabled",
|
|
1622
|
+
publicName: "disabled",
|
|
1623
|
+
isSignal: false,
|
|
1624
|
+
isRequired: false,
|
|
1625
|
+
transformFunction: null
|
|
1626
|
+
},
|
|
1627
|
+
disableRipple: {
|
|
1628
|
+
classPropertyName: "disableRipple",
|
|
1629
|
+
publicName: "disableRipple",
|
|
1630
|
+
isSignal: true,
|
|
1631
|
+
isRequired: false,
|
|
1632
|
+
transformFunction: null
|
|
1633
|
+
}
|
|
1634
|
+
},
|
|
1635
|
+
host: {
|
|
1636
|
+
listeners: { "focus": "_button()?.focus()" },
|
|
1637
|
+
properties: {
|
|
1638
|
+
"attr.tabindex": "-1",
|
|
1639
|
+
"class.ngx-mat-color-toggle-active": "picker()?.opened",
|
|
1640
|
+
"class.mat-accent": "picker()?.color === \"accent\"",
|
|
1641
|
+
"class.mat-warn": "picker()?.color === \"warn\""
|
|
1642
|
+
},
|
|
1643
|
+
classAttribute: "ngx-mat-color-toggle"
|
|
1644
|
+
},
|
|
1645
|
+
viewQueries: [{
|
|
1646
|
+
propertyName: "_button",
|
|
1647
|
+
first: true,
|
|
1648
|
+
predicate: ["button"],
|
|
1649
|
+
descendants: true,
|
|
1650
|
+
isSignal: true
|
|
1651
|
+
}],
|
|
1652
|
+
exportAs: ["ngxMatColorPickerToggle"],
|
|
1653
|
+
ngImport: i0,
|
|
1654
|
+
template: "<button\n #button\n mat-icon-button\n type=\"button\"\n [attr.aria-haspopup]=\"picker() ? 'dialog' : null\"\n [attr.tabindex]=\"disabled ? -1 : tabIndex()\"\n [disabled]=\"disabled\"\n (click)=\"open($event)\"\n [disableRipple]=\"disableRipple()\"\n>\n <ng-content select=\"[ngxMatColorpickerToggleIcon]\">\n <mat-icon [style.color]=\"picker()?._selected?.rgba\">palette</mat-icon>\n </ng-content>\n</button>\n",
|
|
1655
|
+
styles: [".mat-form-field-appearance .mat-form-field-prefix .ngx-mat-color-toggle-default-icon,.mat-form-field-appearance .mat-form-field-suffix .ngx-mat-color-toggle-default-icon{width:1em}.mat-form-field:not(.mat-form-field-appearance) .mat-form-field-prefix .ngx-mat-color-toggle-default-icon,.mat-form-field:not(.mat-form-field-appearance) .mat-form-field-suffix .ngx-mat-color-toggle-default-icon{display:block;width:1.5em;height:1.5em}.mat-form-field:not(.mat-form-field-appearance) .mat-form-field-prefix .mat-icon-button .ngx-mat-color-toggle-default-icon,.mat-form-field:not(.mat-form-field-appearance) .mat-form-field-suffix .mat-icon-button .ngx-mat-color-toggle-default-icon{margin:auto}\n"],
|
|
1656
|
+
dependencies: [
|
|
1657
|
+
{
|
|
1658
|
+
kind: "ngmodule",
|
|
1659
|
+
type: MatButtonModule
|
|
1660
|
+
},
|
|
1661
|
+
{
|
|
1662
|
+
kind: "component",
|
|
1663
|
+
type: i1.MatIconButton,
|
|
1664
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
1665
|
+
exportAs: ["matButton", "matAnchor"]
|
|
1666
|
+
},
|
|
1667
|
+
{
|
|
1668
|
+
kind: "ngmodule",
|
|
1669
|
+
type: MatIconModule
|
|
1670
|
+
},
|
|
1671
|
+
{
|
|
1672
|
+
kind: "component",
|
|
1673
|
+
type: i2.MatIcon,
|
|
1674
|
+
selector: "mat-icon",
|
|
1675
|
+
inputs: [
|
|
1676
|
+
"color",
|
|
1677
|
+
"inline",
|
|
1678
|
+
"svgIcon",
|
|
1679
|
+
"fontSet",
|
|
1680
|
+
"fontIcon"
|
|
1681
|
+
],
|
|
1682
|
+
exportAs: ["matIcon"]
|
|
1683
|
+
}
|
|
1684
|
+
],
|
|
1685
|
+
changeDetection: i0.ChangeDetectionStrategy.Eager,
|
|
1686
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
1687
|
+
});
|
|
1688
|
+
};
|
|
1689
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1690
|
+
minVersion: "12.0.0",
|
|
1691
|
+
version: "22.2.0",
|
|
1692
|
+
ngImport: i0,
|
|
1693
|
+
type: NgxMatColorToggleComponent,
|
|
1694
|
+
decorators: [{
|
|
1695
|
+
type: Component,
|
|
1696
|
+
args: [{
|
|
1697
|
+
selector: "ngx-mat-color-toggle",
|
|
1698
|
+
host: {
|
|
1699
|
+
class: "ngx-mat-color-toggle",
|
|
1700
|
+
"[attr.tabindex]": "-1",
|
|
1701
|
+
"[class.ngx-mat-color-toggle-active]": "picker()?.opened",
|
|
1702
|
+
"[class.mat-accent]": "picker()?.color === \"accent\"",
|
|
1703
|
+
"[class.mat-warn]": "picker()?.color === \"warn\"",
|
|
1704
|
+
"(focus)": "_button()?.focus()"
|
|
1705
|
+
},
|
|
1706
|
+
exportAs: "ngxMatColorPickerToggle",
|
|
1707
|
+
encapsulation: ViewEncapsulation.None,
|
|
1708
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
1709
|
+
imports: [MatButtonModule, MatIconModule],
|
|
1710
|
+
template: "<button\n #button\n mat-icon-button\n type=\"button\"\n [attr.aria-haspopup]=\"picker() ? 'dialog' : null\"\n [attr.tabindex]=\"disabled ? -1 : tabIndex()\"\n [disabled]=\"disabled\"\n (click)=\"open($event)\"\n [disableRipple]=\"disableRipple()\"\n>\n <ng-content select=\"[ngxMatColorpickerToggleIcon]\">\n <mat-icon [style.color]=\"picker()?._selected?.rgba\">palette</mat-icon>\n </ng-content>\n</button>\n",
|
|
1711
|
+
styles: [".mat-form-field-appearance .mat-form-field-prefix .ngx-mat-color-toggle-default-icon,.mat-form-field-appearance .mat-form-field-suffix .ngx-mat-color-toggle-default-icon{width:1em}.mat-form-field:not(.mat-form-field-appearance) .mat-form-field-prefix .ngx-mat-color-toggle-default-icon,.mat-form-field:not(.mat-form-field-appearance) .mat-form-field-suffix .ngx-mat-color-toggle-default-icon{display:block;width:1.5em;height:1.5em}.mat-form-field:not(.mat-form-field-appearance) .mat-form-field-prefix .mat-icon-button .ngx-mat-color-toggle-default-icon,.mat-form-field:not(.mat-form-field-appearance) .mat-form-field-suffix .mat-icon-button .ngx-mat-color-toggle-default-icon{margin:auto}\n"]
|
|
1712
|
+
}]
|
|
1713
|
+
}],
|
|
1714
|
+
ctorParameters: () => [],
|
|
1715
|
+
propDecorators: {
|
|
1716
|
+
picker: [{
|
|
1717
|
+
type: i0.Input,
|
|
1718
|
+
args: [{
|
|
1719
|
+
isSignal: true,
|
|
1720
|
+
alias: "for",
|
|
1721
|
+
required: false
|
|
1722
|
+
}]
|
|
1723
|
+
}],
|
|
1724
|
+
tabIndex: [{
|
|
1725
|
+
type: i0.Input,
|
|
1726
|
+
args: [{
|
|
1727
|
+
isSignal: true,
|
|
1728
|
+
alias: "tabIndex",
|
|
1729
|
+
required: false
|
|
1730
|
+
}]
|
|
1731
|
+
}],
|
|
1732
|
+
disabled: [{ type: Input }],
|
|
1733
|
+
disableRipple: [{
|
|
1734
|
+
type: i0.Input,
|
|
1735
|
+
args: [{
|
|
1736
|
+
isSignal: true,
|
|
1737
|
+
alias: "disableRipple",
|
|
1738
|
+
required: false
|
|
1739
|
+
}]
|
|
1740
|
+
}],
|
|
1741
|
+
_button: [{
|
|
1742
|
+
type: i0.ViewChild,
|
|
1743
|
+
args: ["button", { isSignal: true }]
|
|
1744
|
+
}]
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
var NumericColorInputDirective = class NumericColorInputDirective {
|
|
1748
|
+
onInput($event) {
|
|
1749
|
+
this._formatInput($event.target);
|
|
1750
|
+
}
|
|
1751
|
+
_formatInput(input) {
|
|
1752
|
+
if (!input) return;
|
|
1753
|
+
let val = Number(input.value.replace(NUMERIC_REGEX, ""));
|
|
1754
|
+
val = isNaN(val) ? 0 : val;
|
|
1755
|
+
input.value = val.toString();
|
|
1756
|
+
}
|
|
1757
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1758
|
+
minVersion: "12.0.0",
|
|
1759
|
+
version: "22.2.0",
|
|
1760
|
+
ngImport: i0,
|
|
1761
|
+
type: NumericColorInputDirective,
|
|
1762
|
+
deps: [],
|
|
1763
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1764
|
+
});
|
|
1765
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1766
|
+
minVersion: "14.0.0",
|
|
1767
|
+
version: "22.2.0",
|
|
1768
|
+
type: NumericColorInputDirective,
|
|
1769
|
+
isStandalone: true,
|
|
1770
|
+
selector: "[ngxMatNumericColorInput]",
|
|
1771
|
+
host: { listeners: { "input": "onInput($event)" } },
|
|
1772
|
+
ngImport: i0
|
|
1773
|
+
});
|
|
1774
|
+
};
|
|
1775
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1776
|
+
minVersion: "12.0.0",
|
|
1777
|
+
version: "22.2.0",
|
|
1778
|
+
ngImport: i0,
|
|
1779
|
+
type: NumericColorInputDirective,
|
|
1780
|
+
decorators: [{
|
|
1781
|
+
type: Directive,
|
|
1782
|
+
args: [{ selector: "[ngxMatNumericColorInput]" }]
|
|
1783
|
+
}],
|
|
1784
|
+
propDecorators: { onInput: [{
|
|
1785
|
+
type: HostListener,
|
|
1786
|
+
args: ["input", ["$event"]]
|
|
1787
|
+
}] }
|
|
1788
|
+
});
|
|
1363
1789
|
export { BASIC_COLORS, Color, ColorAdapter, MAT_COLORPICKER_VALIDATORS, MAT_COLORPICKER_VALUE_ACCESSOR, MAT_COLOR_FORMATS, MAX_RGB, MIN_RGB, NGX_MAT_COLOR_FORMATS, NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY, NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY_FACTORY, NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY_FACTORY_PROVIDER, NUMERIC_REGEX, NgxMatColorCanvasComponent, NgxMatColorCollectionComponent, NgxMatColorPaletteComponent, NgxMatColorPickerComponent, NgxMatColorPickerContentComponent, NgxMatColorPickerInput, NgxMatColorPickerInputEvent, NgxMatColorSliderComponent, NgxMatColorToggleComponent, NgxMatColorpickerToggleIcon, NumericColorInputDirective, convertDecimalToHex, createMissingDateImplError, getColorAtPosition, matchers, pad2, rgbToHex, rgbaToHex, stringInputToObject };
|
|
1364
|
-
|
|
1790
|
+
|
|
1791
|
+
//# sourceMappingURL=ngx-mce-color-picker.mjs.map
|