@libs-ui/components-color-picker 0.2.10
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/README.md +3 -0
- package/color-picker.component.d.ts +53 -0
- package/esm2022/color-picker.component.mjs +322 -0
- package/esm2022/index.mjs +3 -0
- package/esm2022/interfaces/index.mjs +2 -0
- package/esm2022/interfaces/picker.interface.mjs +2 -0
- package/esm2022/libs-ui-components-color-picker.mjs +5 -0
- package/esm2022/utils/picker.mjs +261 -0
- package/fesm2022/libs-ui-components-color-picker.mjs +589 -0
- package/fesm2022/libs-ui-components-color-picker.mjs.map +1 -0
- package/index.d.ts +2 -0
- package/interfaces/index.d.ts +1 -0
- package/interfaces/picker.interface.d.ts +41 -0
- package/package.json +25 -0
- package/utils/picker.d.ts +175 -0
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, inject, input, output, viewChild, Component, ChangeDetectionStrategy } from '@angular/core';
|
|
3
|
+
import { LibsUiComponentsInputsValidComponent } from '@libs-ui/components-inputs-valid';
|
|
4
|
+
import { LibsUiNotificationService } from '@libs-ui/services-notification';
|
|
5
|
+
import { get, isNil, set } from '@libs-ui/utils';
|
|
6
|
+
|
|
7
|
+
const ColorNames = { 'aliceblue': '#F0F8FF', 'antiquewhite': '#FAEBD7', 'aqua': '#00FFFF', 'aquamarine': '#7FFFD4', 'azure': '#F0FFFF', 'beige': '#F5F5DC', 'bisque': '#FFE4C4', 'black': '#000000', 'blanchedalmond': '#FFEBCD', 'blue': '#0000FF', 'blueviolet': '#8A2BE2', 'brown': '#A52A2A', 'burlywood': '#DEB887', 'cadetblue': '#5F9EA0', 'chartreuse': '#7FFF00', 'chocolate': '#D2691E', 'coral': '#FF7F50', 'cornflowerblue': '#6495ED', 'cornsilk': '#FFF8DC', 'crimson': '#DC143C', 'cyan': '#00FFFF', 'darkblue': '#00008B', 'darkcyan': '#008B8B', 'darkgoldenrod': '#B8860B', 'darkgray': '#A9A9A9', 'darkgrey': '#A9A9A9', 'darkgreen': '#006400', 'darkkhaki': '#BDB76B', 'darkmagenta': '#8B008B', 'darkolivegreen': '#556B2F', 'darkorange': '#FF8C00', 'darkorchid': '#9932CC', 'darkred': '#8B0000', 'darksalmon': '#E9967A', 'darkseagreen': '#8FBC8F', 'darkslateblue': '#483D8B', 'darkslategray': '#2F4F4F', 'darkslategrey': '#2F4F4F', 'darkturquoise': '#00CED1', 'darkviolet': '#9400D3', 'deeppink': '#FF1493', 'deepskyblue': '#00BFFF', 'dimgray': '#696969', 'dimgrey': '#696969', 'dodgerblue': '#1E90FF', 'firebrick': '#B22222', 'floralwhite': '#FFFAF0', 'forestgreen': '#228B22', 'fuchsia': '#FF00FF', 'gainsboro': '#DCDCDC', 'ghostwhite': '#F8F8FF', 'gold': '#FFD700', 'goldenrod': '#DAA520', 'gray': '#808080', 'grey': '#808080', 'green': '#008000', 'greenyellow': '#ADFF2F', 'honeydew': '#F0FFF0', 'hotpink': '#FF69B4', 'indianred ': '#CD5C5C', 'indigo ': '#4B0082', 'ivory': '#FFFFF0', 'khaki': '#F0E68C', 'lavender': '#E6E6FA', 'lavenderblush': '#FFF0F5', 'lawngreen': '#7CFC00', 'lemonchiffon': '#FFFACD', 'lightblue': '#ADD8E6', 'lightcoral': '#F08080', 'lightcyan': '#E0FFFF', 'lightgoldenrodyellow': '#FAFAD2', 'lightgray': '#D3D3D3', 'lightgrey': '#D3D3D3', 'lightgreen': '#90EE90', 'lightpink': '#FFB6C1', 'lightsalmon': '#FFA07A', 'lightseagreen': '#20B2AA', 'lightskyblue': '#87CEFA', 'lightslategray': '#778899', 'lightslategrey': '#778899', 'lightsteelblue': '#B0C4DE', 'lightyellow': '#FFFFE0', 'lime': '#00FF00', 'limegreen': '#32CD32', 'linen': '#FAF0E6', 'magenta': '#FF00FF', 'maroon': '#800000', 'mediumaquamarine': '#66CDAA', 'mediumblue': '#0000CD', 'mediumorchid': '#BA55D3', 'mediumpurple': '#9370DB', 'mediumseagreen': '#3CB371', 'mediumslateblue': '#7B68EE', 'mediumspringgreen': '#00FA9A', 'mediumturquoise': '#48D1CC', 'mediumvioletred': '#C71585', 'midnightblue': '#191970', 'mintcream': '#F5FFFA', 'mistyrose': '#FFE4E1', 'moccasin': '#FFE4B5', 'navajowhite': '#FFDEAD', 'navy': '#000080', 'oldlace': '#FDF5E6', 'olive': '#808000', 'olivedrab': '#6B8E23', 'orange': '#FFA500', 'orangered': '#FF4500', 'orchid': '#DA70D6', 'palegoldenrod': '#EEE8AA', 'palegreen': '#98FB98', 'paleturquoise': '#AFEEEE', 'palevioletred': '#DB7093', 'papayawhip': '#FFEFD5', 'peachpuff': '#FFDAB9', 'peru': '#CD853F', 'pink': '#FFC0CB', 'plum': '#DDA0DD', 'powderblue': '#B0E0E6', 'purple': '#800080', 'rebeccapurple': '#663399', 'red': '#FF0000', 'rosybrown': '#BC8F8F', 'royalblue': '#4169E1', 'saddlebrown': '#8B4513', 'salmon': '#FA8072', 'sandybrown': '#F4A460', 'seagreen': '#2E8B57', 'seashell': '#FFF5EE', 'sienna': '#A0522D', 'silver': '#C0C0C0', 'skyblue': '#87CEEB', 'slateblue': '#6A5ACD', 'slategray': '#708090', 'slategrey': '#708090', 'snow': '#FFFAFA', 'springgreen': '#00FF7F', 'steelblue': '#4682B4', 'tan': '#D2B48C', 'teal': '#008080', 'thistle': '#D8BFD8', 'tomato': '#FF6347', 'turquoise': '#40E0D0', 'violet': '#EE82EE', 'wheat': '#F5DEB3', 'white': '#FFFFFF', 'whitesmoke': '#F5F5F5', 'yellow': '#FFFF00', 'yellowgreen': '#9ACD32' };
|
|
8
|
+
const optionsDefault = () => {
|
|
9
|
+
return {
|
|
10
|
+
showHsl: false,
|
|
11
|
+
showRgb: true,
|
|
12
|
+
showHex: true,
|
|
13
|
+
showAlpha: false,
|
|
14
|
+
color: '#ff0000',
|
|
15
|
+
format: 'color',
|
|
16
|
+
slBarSize: [316, 200],
|
|
17
|
+
hueBarSize: [316, 20],
|
|
18
|
+
alphaBarSize: [316, 20]
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const limit = (value, min, max) => {
|
|
22
|
+
value = +value;
|
|
23
|
+
return isNaN(value) ? min : (value < min ? min : (value > max ? max : value));
|
|
24
|
+
};
|
|
25
|
+
const hslToRgb = (h, s, l) => {
|
|
26
|
+
let r, g, b;
|
|
27
|
+
[h, s, l] = [limit(h, 0, 360) / 360, limit(s, 0, 100) / 100, limit(l, 0, 100) / 100];
|
|
28
|
+
if (s == 0) {
|
|
29
|
+
r = g = b = l; // achromatic
|
|
30
|
+
return [r * 255, g * 255, b * 255].map(Math.round);
|
|
31
|
+
}
|
|
32
|
+
const hueToRgb = (p, q, t) => {
|
|
33
|
+
if (t < 0)
|
|
34
|
+
t += 1;
|
|
35
|
+
if (t > 1)
|
|
36
|
+
t -= 1;
|
|
37
|
+
if (t < 1 / 6)
|
|
38
|
+
return p + (q - p) * 6 * t;
|
|
39
|
+
if (t < 1 / 2)
|
|
40
|
+
return q;
|
|
41
|
+
if (t < 2 / 3)
|
|
42
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
43
|
+
return p;
|
|
44
|
+
};
|
|
45
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
46
|
+
const p = (2 * l) - q;
|
|
47
|
+
r = hueToRgb(p, q, h + (1 / 3));
|
|
48
|
+
g = hueToRgb(p, q, h);
|
|
49
|
+
b = hueToRgb(p, q, h - (1 / 3));
|
|
50
|
+
return [r * 255, g * 255, b * 255].map(Math.round);
|
|
51
|
+
};
|
|
52
|
+
const cssColorToRgba = (color) => {
|
|
53
|
+
if (color) {
|
|
54
|
+
const colorByName = get(ColorNames, color.toLowerCase());
|
|
55
|
+
const [, , , r, g, b, a, , rr, gg, bb, aa] = /^\s*#?((([0-9A-F])([0-9A-F])([0-9A-F])([0-9A-F])?)|(([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})?))\s*$/i.exec(colorByName || color) || [];
|
|
56
|
+
if (!isNil(r)) {
|
|
57
|
+
return [
|
|
58
|
+
parseInt(r + r, 16),
|
|
59
|
+
parseInt(g + g, 16),
|
|
60
|
+
parseInt(b + b, 16),
|
|
61
|
+
a ? +((parseInt(a + a, 16)) / 255).toFixed(2) : 1
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
if (!isNil(rr)) {
|
|
65
|
+
return [
|
|
66
|
+
parseInt(rr, 16),
|
|
67
|
+
parseInt(gg, 16),
|
|
68
|
+
parseInt(bb, 16),
|
|
69
|
+
aa ? +((parseInt(aa, 16)) / 255).toFixed(2) : 1
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
};
|
|
75
|
+
const parseColorToRgba = (color) => {
|
|
76
|
+
if (Array.isArray(color)) {
|
|
77
|
+
return [
|
|
78
|
+
limit(color[0], 0, 255),
|
|
79
|
+
limit(color[1], 0, 255),
|
|
80
|
+
limit(color[2], 0, 255),
|
|
81
|
+
limit(color[3] ?? 1, 0, 1)
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
const parsed = cssColorToRgba(color) || cssRgbaToRgba(color);
|
|
85
|
+
if (parsed && parsed.length === 3) {
|
|
86
|
+
parsed.push(1);
|
|
87
|
+
}
|
|
88
|
+
return parsed;
|
|
89
|
+
};
|
|
90
|
+
const cssRgbaToRgba = (rgba) => {
|
|
91
|
+
if (rgba) {
|
|
92
|
+
const [m, r, g, b, , a] = /^rgba?\((\d+)\s*[\s,]\s*(\d+)\s*[\s,]\s*(\d+)(\s*[\s,]\s*(\d*(.\d+)?))?\)/i.exec(rgba) || [];
|
|
93
|
+
return m ? [limit(r, 0, 255), limit(g, 0, 255), limit(b, 0, 255), limit(a ?? 1, 0, 1)] : undefined;
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
};
|
|
97
|
+
const cssHslaToHsla = (hsla) => {
|
|
98
|
+
if (hsla) {
|
|
99
|
+
const [m, h, s, l, , a] = /^hsla?\((\d+)\s*[\s,]\s*(\d+)\s*[\s,]\s*(\d+)(\s*[\s,]\s*(\d*(.\d+)?))?\)/i.exec(hsla) || [];
|
|
100
|
+
return m ? [limit(h, 0, 255), limit(s, 0, 255), limit(l, 0, 255), limit(a ?? 1, 0, 1)] : undefined;
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
};
|
|
104
|
+
const parseColorToHsla = (color) => {
|
|
105
|
+
if (Array.isArray(color)) {
|
|
106
|
+
return [
|
|
107
|
+
limit(color[0], 0, 360),
|
|
108
|
+
limit(color[1], 0, 100),
|
|
109
|
+
limit(color[2], 0, 100),
|
|
110
|
+
limit(color[3] ?? 1, 0, 1)
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
const parsed = cssHslaToHsla(color);
|
|
114
|
+
if (parsed && parsed.length === 3) {
|
|
115
|
+
parsed.push(1);
|
|
116
|
+
}
|
|
117
|
+
return parsed;
|
|
118
|
+
};
|
|
119
|
+
const rgbToHsl = (r, g, b) => {
|
|
120
|
+
[r, g, b] = [limit(r, 0, 255) / 255, limit(g, 0, 255) / 255, limit(b, 0, 255) / 255];
|
|
121
|
+
const max = Math.max(r, g, b);
|
|
122
|
+
const min = Math.min(r, g, b);
|
|
123
|
+
let h, s = (max + min) / 2;
|
|
124
|
+
const l = (max + min) / 2;
|
|
125
|
+
if (max == min) {
|
|
126
|
+
h = s = 0; // achromatic
|
|
127
|
+
return [h * 360, s * 100, l * 100].map(Math.round);
|
|
128
|
+
}
|
|
129
|
+
const d = max - min;
|
|
130
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
131
|
+
switch (max) {
|
|
132
|
+
case r:
|
|
133
|
+
h = ((g - b) / d) + (g < b ? 6 : 0);
|
|
134
|
+
break;
|
|
135
|
+
case g:
|
|
136
|
+
h = ((b - r) / d) + 2;
|
|
137
|
+
break;
|
|
138
|
+
case b:
|
|
139
|
+
h = ((r - g) / d) + 4;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
h = (h || 0) / 6;
|
|
143
|
+
return [h * 360, s * 100, l * 100].map(Math.round);
|
|
144
|
+
};
|
|
145
|
+
const rgbToHex = (r, g, b) => {
|
|
146
|
+
[r, g, b] = [limit(r, 0, 255), limit(g, 0, 255), limit(b, 0, 255)];
|
|
147
|
+
return "#" + ("000000" + ((r << 16) | (g << 8) | b).toString(16)).slice(-6);
|
|
148
|
+
};
|
|
149
|
+
const rgbToInt = (r, g, b) => {
|
|
150
|
+
return (r << 16) | (g << 8) | b;
|
|
151
|
+
};
|
|
152
|
+
const rgbToHsv = (r, g, b) => {
|
|
153
|
+
[r, g, b] = [limit(r, 0, 255) / 255, limit(g, 0, 255) / 255, limit(b, 0, 255) / 255];
|
|
154
|
+
const max = Math.max(r, g, b);
|
|
155
|
+
const min = Math.min(r, g, b);
|
|
156
|
+
let h, s = max;
|
|
157
|
+
const v = max;
|
|
158
|
+
const d = max - min;
|
|
159
|
+
s = max === 0 ? 0 : d / max;
|
|
160
|
+
if (max == min) {
|
|
161
|
+
h = 0;
|
|
162
|
+
return [h, s, v];
|
|
163
|
+
}
|
|
164
|
+
switch (max) {
|
|
165
|
+
case r:
|
|
166
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
167
|
+
break;
|
|
168
|
+
case g:
|
|
169
|
+
h = (b - r) / d + 2;
|
|
170
|
+
break;
|
|
171
|
+
case b:
|
|
172
|
+
h = (r - g) / d + 4;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
h = (h || 0) / 6;
|
|
176
|
+
return [h, s, v];
|
|
177
|
+
};
|
|
178
|
+
const formatColor = (data, format) => {
|
|
179
|
+
switch (format) {
|
|
180
|
+
case 'rgb':
|
|
181
|
+
default:
|
|
182
|
+
return data.slice(0, 3);
|
|
183
|
+
case 'rgbcss':
|
|
184
|
+
return `rgb(${data[0]}, ${data[1]}, ${data[2]})`;
|
|
185
|
+
case 'rgbcss4':
|
|
186
|
+
return `rgb(${data[0]}, ${data[1]}, ${data[2]}, ${data[3]})`;
|
|
187
|
+
case 'rgba':
|
|
188
|
+
return data;
|
|
189
|
+
case 'rgbacss':
|
|
190
|
+
return `rgba(${data[0]}, ${data[1]}, ${data[2]}, ${data[3]})`;
|
|
191
|
+
case 'hsl':
|
|
192
|
+
return rgbToHsl(data[0], data[1], data[2]);
|
|
193
|
+
case 'hslcss':
|
|
194
|
+
data = rgbToHsl(data[0], data[1], data[2]);
|
|
195
|
+
return `hsl(${data[0]}, ${data[1]}, ${data[2]})`;
|
|
196
|
+
case 'hslcss4': {
|
|
197
|
+
const hh = rgbToHsl(data[0], data[1], data[2]);
|
|
198
|
+
return `hsl(${hh[0]}, ${hh[1]}, ${hh[2]}, ${data[3]})`;
|
|
199
|
+
}
|
|
200
|
+
case 'hsla':
|
|
201
|
+
return [...rgbToHsl(data[0], data[1], data[2]), data[3]];
|
|
202
|
+
case 'hslacss': {
|
|
203
|
+
const ha = rgbToHsl(data[0], data[1], data[2]);
|
|
204
|
+
return `hsla(${ha[0]}, ${ha[1]}, ${ha[2]}, ${data[3]})`;
|
|
205
|
+
}
|
|
206
|
+
case 'hex':
|
|
207
|
+
return rgbToHex(data[0], data[1], data[2]);
|
|
208
|
+
case 'hexcss4':
|
|
209
|
+
return rgbToHex(data[0], data[1], data[2]) + ('00' + parseInt((data[3] * 255).toString()).toString(16)).slice(-2);
|
|
210
|
+
case 'int':
|
|
211
|
+
return rgbToInt(data[0], data[1], data[2]);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const parseColor = (color, format) => {
|
|
215
|
+
if (!isNil(color)) {
|
|
216
|
+
let data = [];
|
|
217
|
+
data = parseColorToRgba(color) || (parseColorToHsla(color) && [...hslToRgb(data[0], data[1], data[2]), data[3]]);
|
|
218
|
+
if (data) {
|
|
219
|
+
if (typeof format === 'object') {
|
|
220
|
+
return ['rgb', 'rgbcss', 'rgbcss4', 'rgba', 'rgbacss', 'hsl', 'hslcss', 'hslcss4', 'hsla', 'hslacss', 'hex', 'hexcss4', 'int'].reduce((m, f) => {
|
|
221
|
+
set(m, f, formatColor(data, f));
|
|
222
|
+
return m;
|
|
223
|
+
}, format);
|
|
224
|
+
}
|
|
225
|
+
return formatColor(data, format);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
};
|
|
230
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
231
|
+
const canvasHelper = (canvas) => {
|
|
232
|
+
const ctx = canvas.getContext('2d');
|
|
233
|
+
const width = +canvas.width;
|
|
234
|
+
const height = +canvas.height;
|
|
235
|
+
const whiteBlackGradient = ctx.createLinearGradient(1, 1, 1, height - 1);
|
|
236
|
+
whiteBlackGradient.addColorStop(0, 'white');
|
|
237
|
+
whiteBlackGradient.addColorStop(1, 'black');
|
|
238
|
+
return {
|
|
239
|
+
setHue: (hue) => {
|
|
240
|
+
const colorGradient = ctx.createLinearGradient(1, 0, width - 1, 0);
|
|
241
|
+
colorGradient.addColorStop(0, `hsla(${hue}, 100%, 50%, 0)`);
|
|
242
|
+
colorGradient.addColorStop(1, `hsla(${hue}, 100%, 50%, 1)`);
|
|
243
|
+
ctx.fillStyle = whiteBlackGradient;
|
|
244
|
+
ctx.fillRect(0, 0, width, height);
|
|
245
|
+
ctx.fillStyle = colorGradient;
|
|
246
|
+
ctx.globalCompositeOperation = 'multiply';
|
|
247
|
+
ctx.fillRect(0, 0, width, height);
|
|
248
|
+
ctx.globalCompositeOperation = 'source-over';
|
|
249
|
+
},
|
|
250
|
+
grabColor: (x, y) => ctx.getImageData(x, y, 1, 1).data,
|
|
251
|
+
findColor: (r, g, b) => {
|
|
252
|
+
const [, s, v] = rgbToHsv(r, g, b);
|
|
253
|
+
const x = s * width;
|
|
254
|
+
const y = height - (v * height);
|
|
255
|
+
return [x, y];
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
const defaultHelper = () => {
|
|
260
|
+
return {
|
|
261
|
+
setHue: () => { return; },
|
|
262
|
+
grabColor: () => [],
|
|
263
|
+
findColor: () => []
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
class LibsUiComponentsColorPickerComponent {
|
|
268
|
+
/* PROPERTY */
|
|
269
|
+
hDisplay = signal({ value: 0 });
|
|
270
|
+
sDisplay = signal({ value: 0 });
|
|
271
|
+
lDisplay = signal({ value: 0 });
|
|
272
|
+
rDisplay = signal({ value: 0 });
|
|
273
|
+
gDisplay = signal({ value: 0 });
|
|
274
|
+
bDisplay = signal({ value: 0 });
|
|
275
|
+
hexDisplay = signal({ value: '' });
|
|
276
|
+
options = signal(optionsDefault());
|
|
277
|
+
focus = signal(undefined);
|
|
278
|
+
s = signal(0);
|
|
279
|
+
h = signal(0);
|
|
280
|
+
l = signal(0);
|
|
281
|
+
r = signal(0);
|
|
282
|
+
g = signal(0);
|
|
283
|
+
b = signal(0);
|
|
284
|
+
a = signal(1);
|
|
285
|
+
slBarHelper = signal(defaultHelper());
|
|
286
|
+
notificationService = inject(LibsUiNotificationService);
|
|
287
|
+
/* INPUT */
|
|
288
|
+
customOptions = input();
|
|
289
|
+
/* OUTPUT */
|
|
290
|
+
outColorChange = output();
|
|
291
|
+
/* VIEW CHILD */
|
|
292
|
+
hueEl = viewChild.required('hueEl');
|
|
293
|
+
huePointerEl = viewChild.required('huePointerEl');
|
|
294
|
+
slEl = viewChild.required('slEl');
|
|
295
|
+
slPointerEl = viewChild.required('slPointerEl');
|
|
296
|
+
alphaEl = viewChild.required('alphaEl');
|
|
297
|
+
alphaPointerEl = viewChild.required('alphaPointerEl');
|
|
298
|
+
previewEl = viewChild.required('previewEl');
|
|
299
|
+
/* FUNCTIONS */
|
|
300
|
+
ngOnInit() {
|
|
301
|
+
if (this.customOptions()) {
|
|
302
|
+
this.options.update(options => ({ ...options, ...this.customOptions() }));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
ngAfterViewInit() {
|
|
306
|
+
this.setupHueCanvas(this.hueEl().nativeElement);
|
|
307
|
+
this.setupSlCanvas(this.slEl().nativeElement);
|
|
308
|
+
this.slBarHelper.set(canvasHelper(this.slEl().nativeElement));
|
|
309
|
+
if (this.options().showAlpha) {
|
|
310
|
+
this.setupAlphaCanvas(this.alphaEl().nativeElement);
|
|
311
|
+
}
|
|
312
|
+
this.handlerColorChange(this.options().format, this.options().color);
|
|
313
|
+
}
|
|
314
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
315
|
+
setupHueCanvas(canvas) {
|
|
316
|
+
canvas.width = this.options().hueBarSize[0];
|
|
317
|
+
canvas.height = this.options().hueBarSize[1];
|
|
318
|
+
const ctx = canvas.getContext('2d');
|
|
319
|
+
const gradient = ctx.createLinearGradient(0, 0, this.options().hueBarSize[0], 0);
|
|
320
|
+
const step = 1 / 360;
|
|
321
|
+
for (let ii = 0; ii <= 1; ii += step) {
|
|
322
|
+
gradient.addColorStop(ii, `hsl(${360 * ii}, 100%, 50%)`);
|
|
323
|
+
}
|
|
324
|
+
console.log(gradient);
|
|
325
|
+
ctx.fillStyle = gradient;
|
|
326
|
+
ctx.fillRect(0, 0, this.options().hueBarSize[0], this.options().hueBarSize[1]);
|
|
327
|
+
const onMouseMove = (event) => {
|
|
328
|
+
const x = limit(event.clientX - canvas.getBoundingClientRect().left, 0, this.options().hueBarSize[0]);
|
|
329
|
+
const hue = Math.round(x * 360 / this.options().hueBarSize[0]);
|
|
330
|
+
this.huePointerEl().nativeElement.style.left = `${x - 7}px`;
|
|
331
|
+
this.handlerColorChange('h', hue);
|
|
332
|
+
};
|
|
333
|
+
const onMouseUp = () => {
|
|
334
|
+
document.removeEventListener('mousemove', onMouseMove);
|
|
335
|
+
document.removeEventListener('mouseup', onMouseUp);
|
|
336
|
+
};
|
|
337
|
+
canvas.addEventListener('mousedown', (event) => {
|
|
338
|
+
onMouseMove(event);
|
|
339
|
+
document.addEventListener('mousemove', onMouseMove);
|
|
340
|
+
document.addEventListener('mouseup', onMouseUp);
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
344
|
+
setupSlCanvas(canvas) {
|
|
345
|
+
canvas.width = this.options().slBarSize[0];
|
|
346
|
+
canvas.height = this.options().slBarSize[1];
|
|
347
|
+
const onMouseMove = (event) => {
|
|
348
|
+
const x = limit(event.clientX - canvas.getBoundingClientRect().left, 0, this.options().slBarSize[0] - 1);
|
|
349
|
+
const y = limit(event.clientY - canvas.getBoundingClientRect().top, 0, this.options().slBarSize[1] - 1);
|
|
350
|
+
const c = this.slBarHelper().grabColor(x, y);
|
|
351
|
+
this.slPointerEl().nativeElement.style.left = `${x - 7}px`;
|
|
352
|
+
this.slPointerEl().nativeElement.style.top = `${y - 7}px`;
|
|
353
|
+
this.handlerColorChange('rgb', c);
|
|
354
|
+
};
|
|
355
|
+
const onMouseUp = () => {
|
|
356
|
+
document.removeEventListener('mousemove', onMouseMove);
|
|
357
|
+
document.removeEventListener('mouseup', onMouseUp);
|
|
358
|
+
};
|
|
359
|
+
canvas.addEventListener('mousedown', (event) => {
|
|
360
|
+
onMouseMove(event);
|
|
361
|
+
document.addEventListener('mousemove', onMouseMove);
|
|
362
|
+
document.addEventListener('mouseup', onMouseUp);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
366
|
+
setupAlphaCanvas(canvas) {
|
|
367
|
+
canvas.width = this.options().alphaBarSize[0];
|
|
368
|
+
canvas.height = this.options().alphaBarSize[1];
|
|
369
|
+
const ctx = canvas.getContext('2d');
|
|
370
|
+
const gradient = ctx.createLinearGradient(0, 0, canvas.width - 1, 0);
|
|
371
|
+
gradient.addColorStop(0, `hsla(0, 0%, 50%, 0)`);
|
|
372
|
+
gradient.addColorStop(1, `hsla(0, 0%, 50%, 1)`);
|
|
373
|
+
ctx.fillStyle = gradient;
|
|
374
|
+
ctx.fillRect(0, 0, this.options().alphaBarSize[0], this.options().alphaBarSize[1]);
|
|
375
|
+
const onMouseMove = (event) => {
|
|
376
|
+
const x = limit(event.clientX - canvas.getBoundingClientRect().left, 0, this.options().alphaBarSize[0]);
|
|
377
|
+
const alpha = +(x / this.options().alphaBarSize[0]).toFixed(2);
|
|
378
|
+
this.alphaPointerEl().nativeElement.style.left = `${x - 7}px`;
|
|
379
|
+
this.handlerColorChange('alpha', alpha);
|
|
380
|
+
};
|
|
381
|
+
const onMouseUp = () => {
|
|
382
|
+
document.removeEventListener('mousemove', onMouseMove);
|
|
383
|
+
document.removeEventListener('mouseup', onMouseUp);
|
|
384
|
+
};
|
|
385
|
+
canvas.addEventListener('mousedown', (event) => {
|
|
386
|
+
onMouseMove(event);
|
|
387
|
+
document.addEventListener('mousemove', onMouseMove);
|
|
388
|
+
document.addEventListener('mouseup', onMouseUp);
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
handlerCopyColor(event) {
|
|
392
|
+
event.stopPropagation();
|
|
393
|
+
window.navigator.clipboard.writeText(this.hexDisplay().value);
|
|
394
|
+
this.notificationService.showCompTypeTextSuccess('i18n_copy_successfully');
|
|
395
|
+
}
|
|
396
|
+
updatePointerH(h) {
|
|
397
|
+
const x = this.options().hueBarSize[0] * h / 360;
|
|
398
|
+
this.huePointerEl().nativeElement.style.left = `${x - 7}px`;
|
|
399
|
+
}
|
|
400
|
+
updatePointerSl(h, s, l) {
|
|
401
|
+
const [r, g, b] = hslToRgb(h, s, l);
|
|
402
|
+
const [x, y] = this.slBarHelper().findColor(r, g, b);
|
|
403
|
+
if (x >= 0) {
|
|
404
|
+
this.slPointerEl().nativeElement.style.left = `${x - 7}px`;
|
|
405
|
+
this.slPointerEl().nativeElement.style.top = `${y - 7}px`;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
updatePointerA(a) {
|
|
409
|
+
if (!this.options().showAlpha) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const x = this.options().alphaBarSize[0] * a;
|
|
413
|
+
this.alphaPointerEl().nativeElement.style.left = `${x - 7}px`;
|
|
414
|
+
}
|
|
415
|
+
updateHslDisplay(h, s, l) {
|
|
416
|
+
if (!this.options().showHsl) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
this.hDisplay.set({ value: h });
|
|
420
|
+
this.sDisplay.set({ value: s });
|
|
421
|
+
this.lDisplay.set({ value: l });
|
|
422
|
+
}
|
|
423
|
+
updateRgbDisplay(r, g, b) {
|
|
424
|
+
if (!this.options().showRgb) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
;
|
|
428
|
+
this.rDisplay.set({ value: r });
|
|
429
|
+
this.gDisplay.set({ value: g });
|
|
430
|
+
this.bDisplay.set({ value: b });
|
|
431
|
+
}
|
|
432
|
+
updateRgbHexDisplay(r, g, b, a) {
|
|
433
|
+
if (!this.options().showHex) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
;
|
|
437
|
+
if (this.options().showAlpha) {
|
|
438
|
+
this.hexDisplay.set({ value: parseColor([r, g, b, a], 'hexcss4') });
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
this.hexDisplay.set({ value: rgbToHex(r, g, b) });
|
|
442
|
+
}
|
|
443
|
+
updateRgb() {
|
|
444
|
+
const rgb = hslToRgb(this.h(), this.s(), this.l());
|
|
445
|
+
this.r.set(rgb[0]);
|
|
446
|
+
this.g.set(rgb[1]);
|
|
447
|
+
this.b.set(rgb[2]);
|
|
448
|
+
}
|
|
449
|
+
updateHsl() {
|
|
450
|
+
const hsl = rgbToHsl(this.r(), this.g(), this.b());
|
|
451
|
+
this.h.set(hsl[0]);
|
|
452
|
+
this.s.set(hsl[1]);
|
|
453
|
+
this.l.set(hsl[2]);
|
|
454
|
+
}
|
|
455
|
+
updateValuesAndPointer(config) {
|
|
456
|
+
if (config.rgb) {
|
|
457
|
+
this.updateRgb();
|
|
458
|
+
}
|
|
459
|
+
if (config.hsl) {
|
|
460
|
+
this.updateHsl();
|
|
461
|
+
}
|
|
462
|
+
if (config.hue) {
|
|
463
|
+
this.slBarHelper().setHue(this.h());
|
|
464
|
+
}
|
|
465
|
+
if (config.hPoint) {
|
|
466
|
+
this.updatePointerH(this.h());
|
|
467
|
+
}
|
|
468
|
+
if (config.slPoint) {
|
|
469
|
+
this.updatePointerSl(this.h(), this.s(), this.l());
|
|
470
|
+
}
|
|
471
|
+
if (config.hslDisplay) {
|
|
472
|
+
this.updateHslDisplay(this.h(), this.s(), this.l());
|
|
473
|
+
}
|
|
474
|
+
if (config.rgbDisplay) {
|
|
475
|
+
this.updateRgbDisplay(this.r(), this.g(), this.b());
|
|
476
|
+
}
|
|
477
|
+
if (config.hexDisplay) {
|
|
478
|
+
this.updateRgbHexDisplay(this.r(), this.g(), this.b(), this.a());
|
|
479
|
+
}
|
|
480
|
+
if (config.aPoint) {
|
|
481
|
+
this.updatePointerA(this.a());
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
handlerColorChange(key, value, silent = false) {
|
|
485
|
+
let config = {};
|
|
486
|
+
switch (key) {
|
|
487
|
+
case 'h': {
|
|
488
|
+
this.h.set(value);
|
|
489
|
+
config = { hPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, rgb: true, hue: true };
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
case 's':
|
|
493
|
+
this.s.set(value);
|
|
494
|
+
config = { slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, rgb: true };
|
|
495
|
+
break;
|
|
496
|
+
case 'l':
|
|
497
|
+
this.l.set(value);
|
|
498
|
+
config = { slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, rgb: true };
|
|
499
|
+
break;
|
|
500
|
+
case 'r':
|
|
501
|
+
this.r.set(value);
|
|
502
|
+
config = { hPoint: true, slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, hsl: true, hue: true };
|
|
503
|
+
break;
|
|
504
|
+
case 'g':
|
|
505
|
+
this.g.set(value);
|
|
506
|
+
config = { hPoint: true, slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, hsl: true, hue: true };
|
|
507
|
+
break;
|
|
508
|
+
case 'b':
|
|
509
|
+
this.b.set(value);
|
|
510
|
+
config = { hPoint: true, slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, hsl: true, hue: true };
|
|
511
|
+
break;
|
|
512
|
+
case 'rgb':
|
|
513
|
+
this.r.set(value[0]);
|
|
514
|
+
this.g.set(value[1]);
|
|
515
|
+
this.b.set(value[2]);
|
|
516
|
+
config = { hPoint: true, slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, aPoint: true, hsl: true, hue: true };
|
|
517
|
+
break;
|
|
518
|
+
case 'rgba':
|
|
519
|
+
this.r.set(value[0]);
|
|
520
|
+
this.g.set(value[1]);
|
|
521
|
+
this.b.set(value[2]);
|
|
522
|
+
this.a.set(value[3]);
|
|
523
|
+
config = { hPoint: true, slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, aPoint: true, hsl: true, hue: true };
|
|
524
|
+
break;
|
|
525
|
+
case 'hsl':
|
|
526
|
+
this.h.set(value[0]);
|
|
527
|
+
this.s.set(value[1]);
|
|
528
|
+
this.l.set(value[2]);
|
|
529
|
+
config = { hPoint: true, slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, aPoint: true, rgb: true, hue: true };
|
|
530
|
+
break;
|
|
531
|
+
case 'hsla':
|
|
532
|
+
this.h.set(value[0]);
|
|
533
|
+
this.s.set(value[1]);
|
|
534
|
+
this.l.set(value[2]);
|
|
535
|
+
this.a.set(value[3]);
|
|
536
|
+
config = { hPoint: true, slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, aPoint: true, rgb: true, hue: true };
|
|
537
|
+
break;
|
|
538
|
+
case 'hex': {
|
|
539
|
+
const rgba = cssColorToRgba(value) || [this.r(), this.g(), this.b(), this.a()];
|
|
540
|
+
this.hexDisplay.set({ value: value });
|
|
541
|
+
this.r.set(rgba[0]);
|
|
542
|
+
this.g.set(rgba[1]);
|
|
543
|
+
this.b.set(rgba[2]);
|
|
544
|
+
this.a.set(rgba[3]);
|
|
545
|
+
config = { hPoint: true, slPoint: true, hslDisplay: true, rgbDisplay: true, aPoint: true, hsl: true, hue: true };
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
case 'color': {
|
|
549
|
+
const rgba = (parseColor(value, 'rgba') || [0, 0, 0, 1]);
|
|
550
|
+
this.r.set(rgba[0]);
|
|
551
|
+
this.g.set(rgba[1]);
|
|
552
|
+
this.b.set(rgba[2]);
|
|
553
|
+
this.a.set(rgba[3]);
|
|
554
|
+
config = { hPoint: true, slPoint: true, hslDisplay: true, hexDisplay: true, rgbDisplay: true, aPoint: true, hsl: true, hue: true };
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
case 'alpha':
|
|
558
|
+
this.a.set(value);
|
|
559
|
+
this.updateRgbHexDisplay(this.r(), this.g(), this.b(), this.a());
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
this.updateValuesAndPointer(config);
|
|
563
|
+
this.previewEl().nativeElement.style.backgroundColor = this.a() === 1 ? `rgb(${this.r()},${this.g()},${this.b()})` : `rgba(${this.r()},${this.g()},${this.b()},${this.a()})`;
|
|
564
|
+
if (!silent) {
|
|
565
|
+
this.outColorChange.emit(this.hexDisplay().value);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
handlerFocusAndBlur(event, key) {
|
|
569
|
+
this.focus.set(event.name === 'blur' ? undefined : key);
|
|
570
|
+
}
|
|
571
|
+
handlerValueChange(event, key) {
|
|
572
|
+
this.handlerColorChange(key, event);
|
|
573
|
+
}
|
|
574
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiComponentsColorPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
575
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: LibsUiComponentsColorPickerComponent, isStandalone: true, selector: "libs_ui-components-color_picker", inputs: { customOptions: { classPropertyName: "customOptions", publicName: "customOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { outColorChange: "outColorChange" }, viewQueries: [{ propertyName: "hueEl", first: true, predicate: ["hueEl"], descendants: true, isSignal: true }, { propertyName: "huePointerEl", first: true, predicate: ["huePointerEl"], descendants: true, isSignal: true }, { propertyName: "slEl", first: true, predicate: ["slEl"], descendants: true, isSignal: true }, { propertyName: "slPointerEl", first: true, predicate: ["slPointerEl"], descendants: true, isSignal: true }, { propertyName: "alphaEl", first: true, predicate: ["alphaEl"], descendants: true, isSignal: true }, { propertyName: "alphaPointerEl", first: true, predicate: ["alphaPointerEl"], descendants: true, isSignal: true }, { propertyName: "previewEl", first: true, predicate: ["previewEl"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"relative\"\n [style.width.px]=\"options().slBarSize[0]\">\n <div class=\"cursor-pointer\">\n <canvas #slEl\n class=\"rounded-tl-[4px] rounded-tr-[4px] libs-ui-color-picker-background-transparent\"></canvas>\n <div #slPointerEl\n class=\"libs-ui-color-picker-dot\"></div>\n </div>\n <div class=\"relative\">\n <canvas #hueEl\n class=\"libs-ui-color-picker-background-transparent\"\n [class.rounded-bl-[4px]]=\"!options().showAlpha\"\n [class.rounded-br-[4px]]=\"!options().showAlpha\"></canvas>\n <div #huePointerEl\n class=\"libs-ui-color-picker-dot\"></div>\n </div>\n @if (options().showAlpha) {\n <div class=\"relative\">\n <canvas #alphaEl\n class=\"rounded-bl-[4px] rounded-br-[4px] libs-ui-color-picker-background-transparent\"></canvas>\n <div #alphaPointerEl\n class=\"libs-ui-color-picker-dot\"></div>\n </div>\n }\n <div class=\"flex items-end\">\n <div class=\"text-center mr-[16px]\">\n <div class=\"libs-ui-color-picker-background-transparent rounded-[4px]\">\n <div #previewEl\n class=\"w-[32px] h-[32px] rounded-[4px] cursor-pointer\"\n (click)=\"handlerCopyColor($event)\"></div>\n </div>\n </div>\n @if (options().showHex) {\n <div class=\"text-center mr-[12px]\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">HEX</span>\n <div class=\"w-[88px]\">\n <libs_ui-components-inputs-valid [item]=\"hexDisplay()\"\n [fieldNameBind]=\"'value'\"\n [classIncludeInput]=\"'text-center !p-0'\"\n (outValueChange)=\"handlerValueChange($event, 'hex')\" />\n </div>\n </div>\n }\n <div>\n @if (options().showHsl) {\n <div class=\"flex\">\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">H</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"hDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"360\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-tr-none !rounded-br-none ' + (focus() === 's' ? '!border-r-transparent' : '')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'h')\"\n (outValueChange)=\"handlerValueChange($event, 'h')\" />\n </div>\n </div>\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">S</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"sDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"100\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-none ' + (focus() === 's' ? '' : '!border-x-transparent')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 's')\"\n (outValueChange)=\"handlerValueChange($event, 's')\" />\n </div>\n </div>\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">L</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"lDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"100\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-tl-none !rounded-bl-none ' + (focus() === 's' ? '!border-l-transparent' : '')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'l')\"\n (outValueChange)=\"handlerValueChange($event, 'l')\" />\n </div>\n </div>\n </div>\n }\n @if (options().showRgb) {\n <div class=\"flex\">\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">R</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"rDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"255\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-tr-none !rounded-br-none ' + (focus() === 'g' ? '!border-r-transparent' : '')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'r')\"\n (outValueChange)=\"handlerValueChange($event, 'r')\" />\n </div>\n </div>\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">G</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"gDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"255\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-none ' + (focus() === 'g' ? '' : '!border-x-transparent')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'g')\"\n (outValueChange)=\"handlerValueChange($event, 'g')\" />\n </div>\n </div>\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">B</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"bDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"255\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-tl-none !rounded-bl-none ' + (focus() === 'g' ? '!border-l-transparent' : '')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'b')\"\n (outValueChange)=\"handlerValueChange($event, 'b')\" />\n </div>\n </div>\n </div>\n }\n </div>\n </div>\n</div>\n", styles: [".libs-ui-color-picker-background-transparent{background-image:linear-gradient(-45deg,#cdcdcd 25%,transparent 25%),linear-gradient(45deg,#cdcdcd 25%,transparent 25%),linear-gradient(-45deg,transparent 75%,#cdcdcd 75%),linear-gradient(45deg,transparent 75%,#cdcdcd 75%);background-size:11px 11px;background-position:0 0,0 -5.5px,-5.5px 5.5px,5.5px 0px}.libs-ui-color-picker-dot{position:absolute;width:14px;height:14px;top:3px;left:0;background:#fff;pointer-events:none;border-radius:50px;z-index:1;box-shadow:0 1px 2px #000000bf}\n"], dependencies: [{ kind: "component", type: LibsUiComponentsInputsValidComponent, selector: "libs_ui-components-inputs-valid", inputs: ["item", "labelConfig", "emitEmptyInDataTypeNumber", "ignoreBlockInputMaxValue", "fieldNameBind", "showCount", "typeComponentSelectItem", "valueComponentSelectItem", "disableComponentSelectItem", "tagInput", "dataType", "resetAutoCompletePassword", "textAreaEnterNotNewLine", "hiddenContent", "fixedFloat", "acceptNegativeValue", "valueUpDownNumber", "ignoreWidthInput100", "classIncludeInput", "classContainerInput", "readonly", "disable", "noBorder", "backgroundNone", "useColorModeExist", "placeholder", "keepPlaceholderOnly", "classContainerBottomInput", "autoRemoveEmoji", "defaultHeight", "maxHeightTextArea", "minHeightTextArea", "ignoreShowError", "borderError", "iconLeftClass", "popoverContentIconLeft", "iconRightClass", "popoverContentIconRight", "zIndexPopoverContent", "unitsLeft", "configUnitLeft", "keySelectedUnitLeft", "unitsRight", "configUnitRight", "keySelectedUnitRight", "maxValueNumber", "minValueNumber", "ignoreContentLeft", "ignoreContentRight", "isBaselineStyle", "valuePatternShowError", "validPattern", "validRequired", "validMinLength", "validMinValue", "validMaxValue", "validMaxLength", "functionValid", "maxLength", "positionMessageErrorStartInput", "classInclude", "resize", "templateLeftBottomInput", "templateRightBottomInput", "onlyAcceptNegativeValue", "autoAddZeroLessThan10InTypeInt", "maxLengthNumberCount", "classMessageErrorInclude", "ignoreStopPropagationEvent", "ignoreUnitRightClassReadOnly", "paddingRightCustomSpecific", "focusTimeOut"], outputs: ["itemChange", "outValueChange", "outSelect", "outIconLeft", "outIconRight", "outClickButtonLabel", "outToggleEventLabel", "outLabelRightClick", "outEnterInputEvent", "outHeightAreaChange", "outFunctionsControl", "outFocusAndBlur", "outChangeValueByButtonUpDown"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
576
|
+
}
|
|
577
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiComponentsColorPickerComponent, decorators: [{
|
|
578
|
+
type: Component,
|
|
579
|
+
args: [{ selector: 'libs_ui-components-color_picker', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
580
|
+
LibsUiComponentsInputsValidComponent
|
|
581
|
+
], template: "<div class=\"relative\"\n [style.width.px]=\"options().slBarSize[0]\">\n <div class=\"cursor-pointer\">\n <canvas #slEl\n class=\"rounded-tl-[4px] rounded-tr-[4px] libs-ui-color-picker-background-transparent\"></canvas>\n <div #slPointerEl\n class=\"libs-ui-color-picker-dot\"></div>\n </div>\n <div class=\"relative\">\n <canvas #hueEl\n class=\"libs-ui-color-picker-background-transparent\"\n [class.rounded-bl-[4px]]=\"!options().showAlpha\"\n [class.rounded-br-[4px]]=\"!options().showAlpha\"></canvas>\n <div #huePointerEl\n class=\"libs-ui-color-picker-dot\"></div>\n </div>\n @if (options().showAlpha) {\n <div class=\"relative\">\n <canvas #alphaEl\n class=\"rounded-bl-[4px] rounded-br-[4px] libs-ui-color-picker-background-transparent\"></canvas>\n <div #alphaPointerEl\n class=\"libs-ui-color-picker-dot\"></div>\n </div>\n }\n <div class=\"flex items-end\">\n <div class=\"text-center mr-[16px]\">\n <div class=\"libs-ui-color-picker-background-transparent rounded-[4px]\">\n <div #previewEl\n class=\"w-[32px] h-[32px] rounded-[4px] cursor-pointer\"\n (click)=\"handlerCopyColor($event)\"></div>\n </div>\n </div>\n @if (options().showHex) {\n <div class=\"text-center mr-[12px]\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">HEX</span>\n <div class=\"w-[88px]\">\n <libs_ui-components-inputs-valid [item]=\"hexDisplay()\"\n [fieldNameBind]=\"'value'\"\n [classIncludeInput]=\"'text-center !p-0'\"\n (outValueChange)=\"handlerValueChange($event, 'hex')\" />\n </div>\n </div>\n }\n <div>\n @if (options().showHsl) {\n <div class=\"flex\">\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">H</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"hDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"360\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-tr-none !rounded-br-none ' + (focus() === 's' ? '!border-r-transparent' : '')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'h')\"\n (outValueChange)=\"handlerValueChange($event, 'h')\" />\n </div>\n </div>\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">S</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"sDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"100\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-none ' + (focus() === 's' ? '' : '!border-x-transparent')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 's')\"\n (outValueChange)=\"handlerValueChange($event, 's')\" />\n </div>\n </div>\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">L</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"lDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"100\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-tl-none !rounded-bl-none ' + (focus() === 's' ? '!border-l-transparent' : '')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'l')\"\n (outValueChange)=\"handlerValueChange($event, 'l')\" />\n </div>\n </div>\n </div>\n }\n @if (options().showRgb) {\n <div class=\"flex\">\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">R</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"rDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"255\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-tr-none !rounded-br-none ' + (focus() === 'g' ? '!border-r-transparent' : '')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'r')\"\n (outValueChange)=\"handlerValueChange($event, 'r')\" />\n </div>\n </div>\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">G</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"gDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"255\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-none ' + (focus() === 'g' ? '' : '!border-x-transparent')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'g')\"\n (outValueChange)=\"handlerValueChange($event, 'g')\" />\n </div>\n </div>\n <div class=\"text-center\">\n <span class=\"libs-ui-font-h7r text-[#6a7383]\">B</span>\n <div class=\"w-[56px]\">\n <libs_ui-components-inputs-valid [item]=\"bDisplay()\"\n [fieldNameBind]=\"'value'\"\n [dataType]=\"'int'\"\n [minValueNumber]=\"0\"\n [maxValueNumber]=\"255\"\n [classIncludeInput]=\"'text-center !p-0 !rounded-tl-none !rounded-bl-none ' + (focus() === 'g' ? '!border-l-transparent' : '')\"\n (outFocusAndBlur)=\"handlerFocusAndBlur($event, 'b')\"\n (outValueChange)=\"handlerValueChange($event, 'b')\" />\n </div>\n </div>\n </div>\n }\n </div>\n </div>\n</div>\n", styles: [".libs-ui-color-picker-background-transparent{background-image:linear-gradient(-45deg,#cdcdcd 25%,transparent 25%),linear-gradient(45deg,#cdcdcd 25%,transparent 25%),linear-gradient(-45deg,transparent 75%,#cdcdcd 75%),linear-gradient(45deg,transparent 75%,#cdcdcd 75%);background-size:11px 11px;background-position:0 0,0 -5.5px,-5.5px 5.5px,5.5px 0px}.libs-ui-color-picker-dot{position:absolute;width:14px;height:14px;top:3px;left:0;background:#fff;pointer-events:none;border-radius:50px;z-index:1;box-shadow:0 1px 2px #000000bf}\n"] }]
|
|
582
|
+
}] });
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Generated bundle index. Do not edit.
|
|
586
|
+
*/
|
|
587
|
+
|
|
588
|
+
export { LibsUiComponentsColorPickerComponent };
|
|
589
|
+
//# sourceMappingURL=libs-ui-components-color-picker.mjs.map
|