wj-elements 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/router-links-e0087f84.js +146 -0
- package/dist/style.css +2 -2365
- package/dist/wj-aside.js +18 -22
- package/dist/wj-avatar.js +32 -49
- package/dist/wj-badge.js +18 -22
- package/dist/wj-breadcrumb.js +53 -103
- package/dist/wj-breadcrumbs.js +21 -36
- package/dist/wj-button-group.js +24 -36
- package/dist/wj-button.js +37 -80
- package/dist/wj-card-content.js +16 -18
- package/dist/wj-card-controls.js +16 -18
- package/dist/wj-card-header.js +16 -20
- package/dist/wj-card-subtitle.js +17 -19
- package/dist/wj-card-title.js +16 -18
- package/dist/wj-card.js +16 -20
- package/dist/wj-checkbox.js +24 -46
- package/dist/wj-chip.js +21 -39
- package/dist/wj-col.js +18 -32
- package/dist/wj-color-picker.js +503 -868
- package/dist/wj-container.js +18 -20
- package/dist/wj-copy-button.js +66 -112
- package/dist/wj-dialog.js +43 -67
- package/dist/wj-divider.js +16 -20
- package/dist/wj-dropdown.js +22 -31
- package/dist/wj-element.js +241 -416
- package/dist/wj-footer.js +16 -18
- package/dist/wj-form.js +16 -18
- package/dist/wj-grid.js +17 -21
- package/dist/wj-header.js +18 -22
- package/dist/wj-icon-picker.js +66 -107
- package/dist/wj-icon.js +67 -142
- package/dist/wj-img-comparer.js +43 -72
- package/dist/wj-img.js +21 -31
- package/dist/wj-infinite-scroll.js +49 -84
- package/dist/wj-input.js +67 -146
- package/dist/wj-item.js +19 -34
- package/dist/wj-label.js +19 -21
- package/dist/wj-list.js +17 -20
- package/dist/wj-main.js +16 -18
- package/dist/wj-master.js +331 -462
- package/dist/wj-menu-button.js +18 -21
- package/dist/wj-menu-item.js +67 -144
- package/dist/wj-menu-label.js +17 -21
- package/dist/wj-menu.js +20 -24
- package/dist/wj-popup.js +714 -1140
- package/dist/wj-progress-bar.js +42 -100
- package/dist/wj-radio-group.js +27 -38
- package/dist/wj-radio.js +24 -46
- package/dist/wj-route.js +8 -11
- package/dist/wj-router-link.js +19 -22
- package/dist/wj-router-outlet.js +71 -135
- package/dist/wj-routerx.js +641 -1121
- package/dist/wj-row.js +20 -22
- package/dist/wj-slider.js +55 -97
- package/dist/wj-split-view.js +45 -81
- package/dist/wj-store.js +110 -195
- package/dist/wj-textarea.js +39 -86
- package/dist/wj-thumbnail.js +17 -19
- package/dist/wj-toast.js +34 -88
- package/dist/wj-toggle.js +24 -42
- package/dist/wj-toolbar-action.js +16 -27
- package/dist/wj-toolbar.js +21 -26
- package/dist/wj-tooltip.js +27 -41
- package/dist/wj-visually-hidden.js +16 -18
- package/package.json +1 -1
- package/dist/router-links-26e4a166.js +0 -204
package/dist/wj-color-picker.js
CHANGED
|
@@ -1,130 +1,94 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import WJElement from "./wj-element.js";
|
|
1
|
+
var N = Object.defineProperty;
|
|
2
|
+
var B = (t, r, e) => r in t ? N(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
|
|
3
|
+
var v = (t, r, e) => (B(t, typeof r != "symbol" ? r + "" : r, e), e);
|
|
4
|
+
import z from "./wj-element.js";
|
|
8
5
|
import "./wj-store.js";
|
|
9
|
-
function
|
|
6
|
+
function S(t) {
|
|
10
7
|
"@babel/helpers - typeof";
|
|
11
|
-
return
|
|
12
|
-
return typeof
|
|
13
|
-
} : function(
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var rgb = inputToRGB(color);
|
|
29
|
-
this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format;
|
|
30
|
-
this._gradientType = opts.gradientType;
|
|
31
|
-
if (this._r < 1)
|
|
32
|
-
this._r = Math.round(this._r);
|
|
33
|
-
if (this._g < 1)
|
|
34
|
-
this._g = Math.round(this._g);
|
|
35
|
-
if (this._b < 1)
|
|
36
|
-
this._b = Math.round(this._b);
|
|
37
|
-
this._ok = rgb.ok;
|
|
38
|
-
}
|
|
39
|
-
tinycolor.prototype = {
|
|
40
|
-
isDark: function isDark() {
|
|
8
|
+
return S = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(r) {
|
|
9
|
+
return typeof r;
|
|
10
|
+
} : function(r) {
|
|
11
|
+
return r && typeof Symbol == "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
|
|
12
|
+
}, S(t);
|
|
13
|
+
}
|
|
14
|
+
var O = /^\s+/, G = /\s+$/;
|
|
15
|
+
function s(t, r) {
|
|
16
|
+
if (t = t || "", r = r || {}, t instanceof s)
|
|
17
|
+
return t;
|
|
18
|
+
if (!(this instanceof s))
|
|
19
|
+
return new s(t, r);
|
|
20
|
+
var e = $(t);
|
|
21
|
+
this._originalInput = t, this._r = e.r, this._g = e.g, this._b = e.b, this._a = e.a, this._roundA = Math.round(100 * this._a) / 100, this._format = r.format || e.format, this._gradientType = r.gradientType, this._r < 1 && (this._r = Math.round(this._r)), this._g < 1 && (this._g = Math.round(this._g)), this._b < 1 && (this._b = Math.round(this._b)), this._ok = e.ok;
|
|
22
|
+
}
|
|
23
|
+
s.prototype = {
|
|
24
|
+
isDark: function() {
|
|
41
25
|
return this.getBrightness() < 128;
|
|
42
26
|
},
|
|
43
|
-
isLight: function
|
|
27
|
+
isLight: function() {
|
|
44
28
|
return !this.isDark();
|
|
45
29
|
},
|
|
46
|
-
isValid: function
|
|
30
|
+
isValid: function() {
|
|
47
31
|
return this._ok;
|
|
48
32
|
},
|
|
49
|
-
getOriginalInput: function
|
|
33
|
+
getOriginalInput: function() {
|
|
50
34
|
return this._originalInput;
|
|
51
35
|
},
|
|
52
|
-
getFormat: function
|
|
36
|
+
getFormat: function() {
|
|
53
37
|
return this._format;
|
|
54
38
|
},
|
|
55
|
-
getAlpha: function
|
|
39
|
+
getAlpha: function() {
|
|
56
40
|
return this._a;
|
|
57
41
|
},
|
|
58
|
-
getBrightness: function
|
|
59
|
-
var
|
|
60
|
-
return (
|
|
42
|
+
getBrightness: function() {
|
|
43
|
+
var r = this.toRgb();
|
|
44
|
+
return (r.r * 299 + r.g * 587 + r.b * 114) / 1e3;
|
|
61
45
|
},
|
|
62
|
-
getLuminance: function
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
RsRGB = rgb.r / 255;
|
|
66
|
-
GsRGB = rgb.g / 255;
|
|
67
|
-
BsRGB = rgb.b / 255;
|
|
68
|
-
if (RsRGB <= 0.03928)
|
|
69
|
-
R = RsRGB / 12.92;
|
|
70
|
-
else
|
|
71
|
-
R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
|
|
72
|
-
if (GsRGB <= 0.03928)
|
|
73
|
-
G = GsRGB / 12.92;
|
|
74
|
-
else
|
|
75
|
-
G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
|
|
76
|
-
if (BsRGB <= 0.03928)
|
|
77
|
-
B = BsRGB / 12.92;
|
|
78
|
-
else
|
|
79
|
-
B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
|
|
80
|
-
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
|
|
46
|
+
getLuminance: function() {
|
|
47
|
+
var r = this.toRgb(), e, a, i, n, o, h;
|
|
48
|
+
return e = r.r / 255, a = r.g / 255, i = r.b / 255, e <= 0.03928 ? n = e / 12.92 : n = Math.pow((e + 0.055) / 1.055, 2.4), a <= 0.03928 ? o = a / 12.92 : o = Math.pow((a + 0.055) / 1.055, 2.4), i <= 0.03928 ? h = i / 12.92 : h = Math.pow((i + 0.055) / 1.055, 2.4), 0.2126 * n + 0.7152 * o + 0.0722 * h;
|
|
81
49
|
},
|
|
82
|
-
setAlpha: function
|
|
83
|
-
this._a =
|
|
84
|
-
this._roundA = Math.round(100 * this._a) / 100;
|
|
85
|
-
return this;
|
|
50
|
+
setAlpha: function(r) {
|
|
51
|
+
return this._a = D(r), this._roundA = Math.round(100 * this._a) / 100, this;
|
|
86
52
|
},
|
|
87
|
-
toHsv: function
|
|
88
|
-
var
|
|
53
|
+
toHsv: function() {
|
|
54
|
+
var r = R(this._r, this._g, this._b);
|
|
89
55
|
return {
|
|
90
|
-
h:
|
|
91
|
-
s:
|
|
92
|
-
v:
|
|
56
|
+
h: r.h * 360,
|
|
57
|
+
s: r.s,
|
|
58
|
+
v: r.v,
|
|
93
59
|
a: this._a
|
|
94
60
|
};
|
|
95
61
|
},
|
|
96
|
-
toHsvString: function
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
|
|
62
|
+
toHsvString: function() {
|
|
63
|
+
var r = R(this._r, this._g, this._b), e = Math.round(r.h * 360), a = Math.round(r.s * 100), i = Math.round(r.v * 100);
|
|
64
|
+
return this._a == 1 ? "hsv(" + e + ", " + a + "%, " + i + "%)" : "hsva(" + e + ", " + a + "%, " + i + "%, " + this._roundA + ")";
|
|
100
65
|
},
|
|
101
|
-
toHsl: function
|
|
102
|
-
var
|
|
66
|
+
toHsl: function() {
|
|
67
|
+
var r = C(this._r, this._g, this._b);
|
|
103
68
|
return {
|
|
104
|
-
h:
|
|
105
|
-
s:
|
|
106
|
-
l:
|
|
69
|
+
h: r.h * 360,
|
|
70
|
+
s: r.s,
|
|
71
|
+
l: r.l,
|
|
107
72
|
a: this._a
|
|
108
73
|
};
|
|
109
74
|
},
|
|
110
|
-
toHslString: function
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
|
|
75
|
+
toHslString: function() {
|
|
76
|
+
var r = C(this._r, this._g, this._b), e = Math.round(r.h * 360), a = Math.round(r.s * 100), i = Math.round(r.l * 100);
|
|
77
|
+
return this._a == 1 ? "hsl(" + e + ", " + a + "%, " + i + "%)" : "hsla(" + e + ", " + a + "%, " + i + "%, " + this._roundA + ")";
|
|
114
78
|
},
|
|
115
|
-
toHex: function
|
|
116
|
-
return
|
|
79
|
+
toHex: function(r) {
|
|
80
|
+
return E(this._r, this._g, this._b, r);
|
|
117
81
|
},
|
|
118
|
-
toHexString: function
|
|
119
|
-
return "#" + this.toHex(
|
|
82
|
+
toHexString: function(r) {
|
|
83
|
+
return "#" + this.toHex(r);
|
|
120
84
|
},
|
|
121
|
-
toHex8: function
|
|
122
|
-
return
|
|
85
|
+
toHex8: function(r) {
|
|
86
|
+
return X(this._r, this._g, this._b, this._a, r);
|
|
123
87
|
},
|
|
124
|
-
toHex8String: function
|
|
125
|
-
return "#" + this.toHex8(
|
|
88
|
+
toHex8String: function(r) {
|
|
89
|
+
return "#" + this.toHex8(r);
|
|
126
90
|
},
|
|
127
|
-
toRgb: function
|
|
91
|
+
toRgb: function() {
|
|
128
92
|
return {
|
|
129
93
|
r: Math.round(this._r),
|
|
130
94
|
g: Math.round(this._g),
|
|
@@ -132,513 +96,339 @@ tinycolor.prototype = {
|
|
|
132
96
|
a: this._a
|
|
133
97
|
};
|
|
134
98
|
},
|
|
135
|
-
toRgbString: function
|
|
99
|
+
toRgbString: function() {
|
|
136
100
|
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 + ")";
|
|
137
101
|
},
|
|
138
|
-
toPercentageRgb: function
|
|
102
|
+
toPercentageRgb: function() {
|
|
139
103
|
return {
|
|
140
|
-
r: Math.round(
|
|
141
|
-
g: Math.round(
|
|
142
|
-
b: Math.round(
|
|
104
|
+
r: Math.round(u(this._r, 255) * 100) + "%",
|
|
105
|
+
g: Math.round(u(this._g, 255) * 100) + "%",
|
|
106
|
+
b: Math.round(u(this._b, 255) * 100) + "%",
|
|
143
107
|
a: this._a
|
|
144
108
|
};
|
|
145
109
|
},
|
|
146
|
-
toPercentageRgbString: function
|
|
147
|
-
return this._a == 1 ? "rgb(" + Math.round(
|
|
110
|
+
toPercentageRgbString: function() {
|
|
111
|
+
return this._a == 1 ? "rgb(" + Math.round(u(this._r, 255) * 100) + "%, " + Math.round(u(this._g, 255) * 100) + "%, " + Math.round(u(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(u(this._r, 255) * 100) + "%, " + Math.round(u(this._g, 255) * 100) + "%, " + Math.round(u(this._b, 255) * 100) + "%, " + this._roundA + ")";
|
|
148
112
|
},
|
|
149
|
-
toName: function
|
|
150
|
-
|
|
151
|
-
return "transparent";
|
|
152
|
-
}
|
|
153
|
-
if (this._a < 1) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
|
|
113
|
+
toName: function() {
|
|
114
|
+
return this._a === 0 ? "transparent" : this._a < 1 ? !1 : ne[E(this._r, this._g, this._b, !0)] || !1;
|
|
157
115
|
},
|
|
158
|
-
toFilter: function
|
|
159
|
-
var
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var s = tinycolor(secondColor);
|
|
164
|
-
secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
|
|
116
|
+
toFilter: function(r) {
|
|
117
|
+
var e = "#" + L(this._r, this._g, this._b, this._a), a = e, i = this._gradientType ? "GradientType = 1, " : "";
|
|
118
|
+
if (r) {
|
|
119
|
+
var n = s(r);
|
|
120
|
+
a = "#" + L(n._r, n._g, n._b, n._a);
|
|
165
121
|
}
|
|
166
|
-
return "progid:DXImageTransform.Microsoft.gradient(" +
|
|
122
|
+
return "progid:DXImageTransform.Microsoft.gradient(" + i + "startColorstr=" + e + ",endColorstr=" + a + ")";
|
|
167
123
|
},
|
|
168
|
-
toString: function
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
var
|
|
172
|
-
|
|
173
|
-
var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
|
|
174
|
-
if (needsAlphaFormat) {
|
|
175
|
-
if (format === "name" && this._a === 0) {
|
|
176
|
-
return this.toName();
|
|
177
|
-
}
|
|
178
|
-
return this.toRgbString();
|
|
179
|
-
}
|
|
180
|
-
if (format === "rgb") {
|
|
181
|
-
formattedString = this.toRgbString();
|
|
182
|
-
}
|
|
183
|
-
if (format === "prgb") {
|
|
184
|
-
formattedString = this.toPercentageRgbString();
|
|
185
|
-
}
|
|
186
|
-
if (format === "hex" || format === "hex6") {
|
|
187
|
-
formattedString = this.toHexString();
|
|
188
|
-
}
|
|
189
|
-
if (format === "hex3") {
|
|
190
|
-
formattedString = this.toHexString(true);
|
|
191
|
-
}
|
|
192
|
-
if (format === "hex4") {
|
|
193
|
-
formattedString = this.toHex8String(true);
|
|
194
|
-
}
|
|
195
|
-
if (format === "hex8") {
|
|
196
|
-
formattedString = this.toHex8String();
|
|
197
|
-
}
|
|
198
|
-
if (format === "name") {
|
|
199
|
-
formattedString = this.toName();
|
|
200
|
-
}
|
|
201
|
-
if (format === "hsl") {
|
|
202
|
-
formattedString = this.toHslString();
|
|
203
|
-
}
|
|
204
|
-
if (format === "hsv") {
|
|
205
|
-
formattedString = this.toHsvString();
|
|
206
|
-
}
|
|
207
|
-
return formattedString || this.toHexString();
|
|
124
|
+
toString: function(r) {
|
|
125
|
+
var e = !!r;
|
|
126
|
+
r = r || this._format;
|
|
127
|
+
var a = !1, i = this._a < 1 && this._a >= 0, n = !e && i && (r === "hex" || r === "hex6" || r === "hex3" || r === "hex4" || r === "hex8" || r === "name");
|
|
128
|
+
return n ? r === "name" && this._a === 0 ? this.toName() : this.toRgbString() : (r === "rgb" && (a = this.toRgbString()), r === "prgb" && (a = this.toPercentageRgbString()), (r === "hex" || r === "hex6") && (a = this.toHexString()), r === "hex3" && (a = this.toHexString(!0)), r === "hex4" && (a = this.toHex8String(!0)), r === "hex8" && (a = this.toHex8String()), r === "name" && (a = this.toName()), r === "hsl" && (a = this.toHslString()), r === "hsv" && (a = this.toHsvString()), a || this.toHexString());
|
|
208
129
|
},
|
|
209
|
-
clone: function
|
|
210
|
-
return
|
|
130
|
+
clone: function() {
|
|
131
|
+
return s(this.toString());
|
|
211
132
|
},
|
|
212
|
-
_applyModification: function
|
|
213
|
-
var
|
|
214
|
-
this._r =
|
|
215
|
-
this._g = color._g;
|
|
216
|
-
this._b = color._b;
|
|
217
|
-
this.setAlpha(color._a);
|
|
218
|
-
return this;
|
|
133
|
+
_applyModification: function(r, e) {
|
|
134
|
+
var a = r.apply(null, [this].concat([].slice.call(e)));
|
|
135
|
+
return this._r = a._r, this._g = a._g, this._b = a._b, this.setAlpha(a._a), this;
|
|
219
136
|
},
|
|
220
|
-
lighten: function
|
|
221
|
-
return this._applyModification(
|
|
137
|
+
lighten: function() {
|
|
138
|
+
return this._applyModification(K, arguments);
|
|
222
139
|
},
|
|
223
|
-
brighten: function
|
|
224
|
-
return this._applyModification(
|
|
140
|
+
brighten: function() {
|
|
141
|
+
return this._applyModification(Z, arguments);
|
|
225
142
|
},
|
|
226
|
-
darken: function
|
|
227
|
-
return this._applyModification(
|
|
143
|
+
darken: function() {
|
|
144
|
+
return this._applyModification(Q, arguments);
|
|
228
145
|
},
|
|
229
|
-
desaturate: function
|
|
230
|
-
return this._applyModification(
|
|
146
|
+
desaturate: function() {
|
|
147
|
+
return this._applyModification(W, arguments);
|
|
231
148
|
},
|
|
232
|
-
saturate: function
|
|
233
|
-
return this._applyModification(
|
|
149
|
+
saturate: function() {
|
|
150
|
+
return this._applyModification(Y, arguments);
|
|
234
151
|
},
|
|
235
|
-
greyscale: function
|
|
236
|
-
return this._applyModification(
|
|
152
|
+
greyscale: function() {
|
|
153
|
+
return this._applyModification(J, arguments);
|
|
237
154
|
},
|
|
238
|
-
spin: function
|
|
239
|
-
return this._applyModification(
|
|
155
|
+
spin: function() {
|
|
156
|
+
return this._applyModification(ee, arguments);
|
|
240
157
|
},
|
|
241
|
-
_applyCombination: function
|
|
242
|
-
return
|
|
158
|
+
_applyCombination: function(r, e) {
|
|
159
|
+
return r.apply(null, [this].concat([].slice.call(e)));
|
|
243
160
|
},
|
|
244
|
-
analogous: function
|
|
245
|
-
return this._applyCombination(
|
|
161
|
+
analogous: function() {
|
|
162
|
+
return this._applyCombination(ae, arguments);
|
|
246
163
|
},
|
|
247
|
-
complement: function
|
|
248
|
-
return this._applyCombination(
|
|
164
|
+
complement: function() {
|
|
165
|
+
return this._applyCombination(te, arguments);
|
|
249
166
|
},
|
|
250
|
-
monochromatic: function
|
|
251
|
-
return this._applyCombination(
|
|
167
|
+
monochromatic: function() {
|
|
168
|
+
return this._applyCombination(ie, arguments);
|
|
252
169
|
},
|
|
253
|
-
splitcomplement: function
|
|
254
|
-
return this._applyCombination(
|
|
170
|
+
splitcomplement: function() {
|
|
171
|
+
return this._applyCombination(re, arguments);
|
|
255
172
|
},
|
|
256
173
|
// Disabled until https://github.com/bgrins/TinyColor/issues/254
|
|
257
174
|
// polyad: function (number) {
|
|
258
175
|
// return this._applyCombination(polyad, [number]);
|
|
259
176
|
// },
|
|
260
|
-
triad: function
|
|
261
|
-
return this._applyCombination(
|
|
177
|
+
triad: function() {
|
|
178
|
+
return this._applyCombination(T, [3]);
|
|
262
179
|
},
|
|
263
|
-
tetrad: function
|
|
264
|
-
return this._applyCombination(
|
|
180
|
+
tetrad: function() {
|
|
181
|
+
return this._applyCombination(T, [4]);
|
|
265
182
|
}
|
|
266
183
|
};
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
var
|
|
270
|
-
for (var
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
newColor[i] = convertToPercentage(color[i]);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
color = newColor;
|
|
280
|
-
}
|
|
281
|
-
return tinycolor(color, opts);
|
|
184
|
+
s.fromRatio = function(t, r) {
|
|
185
|
+
if (S(t) == "object") {
|
|
186
|
+
var e = {};
|
|
187
|
+
for (var a in t)
|
|
188
|
+
t.hasOwnProperty(a) && (a === "a" ? e[a] = t[a] : e[a] = y(t[a]));
|
|
189
|
+
t = e;
|
|
190
|
+
}
|
|
191
|
+
return s(t, r);
|
|
282
192
|
};
|
|
283
|
-
function
|
|
284
|
-
var
|
|
193
|
+
function $(t) {
|
|
194
|
+
var r = {
|
|
285
195
|
r: 0,
|
|
286
196
|
g: 0,
|
|
287
197
|
b: 0
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
color = stringInputToObject(color);
|
|
297
|
-
}
|
|
298
|
-
if (_typeof(color) == "object") {
|
|
299
|
-
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
300
|
-
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
301
|
-
ok = true;
|
|
302
|
-
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
|
|
303
|
-
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
304
|
-
s = convertToPercentage(color.s);
|
|
305
|
-
v = convertToPercentage(color.v);
|
|
306
|
-
rgb = hsvToRgb(color.h, s, v);
|
|
307
|
-
ok = true;
|
|
308
|
-
format = "hsv";
|
|
309
|
-
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
310
|
-
s = convertToPercentage(color.s);
|
|
311
|
-
l = convertToPercentage(color.l);
|
|
312
|
-
rgb = hslToRgb(color.h, s, l);
|
|
313
|
-
ok = true;
|
|
314
|
-
format = "hsl";
|
|
315
|
-
}
|
|
316
|
-
if (color.hasOwnProperty("a")) {
|
|
317
|
-
a = color.a;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
a = boundAlpha(a);
|
|
321
|
-
return {
|
|
322
|
-
ok,
|
|
323
|
-
format: color.format || format,
|
|
324
|
-
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
325
|
-
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
326
|
-
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
327
|
-
a
|
|
198
|
+
}, e = 1, a = null, i = null, n = null, o = !1, h = !1;
|
|
199
|
+
return typeof t == "string" && (t = le(t)), S(t) == "object" && (m(t.r) && m(t.g) && m(t.b) ? (r = U(t.r, t.g, t.b), o = !0, h = String(t.r).substr(-1) === "%" ? "prgb" : "rgb") : m(t.h) && m(t.s) && m(t.v) ? (a = y(t.s), i = y(t.v), r = q(t.h, a, i), o = !0, h = "hsv") : m(t.h) && m(t.s) && m(t.l) && (a = y(t.s), n = y(t.l), r = V(t.h, a, n), o = !0, h = "hsl"), t.hasOwnProperty("a") && (e = t.a)), e = D(e), {
|
|
200
|
+
ok: o,
|
|
201
|
+
format: t.format || h,
|
|
202
|
+
r: Math.min(255, Math.max(r.r, 0)),
|
|
203
|
+
g: Math.min(255, Math.max(r.g, 0)),
|
|
204
|
+
b: Math.min(255, Math.max(r.b, 0)),
|
|
205
|
+
a: e
|
|
328
206
|
};
|
|
329
207
|
}
|
|
330
|
-
function
|
|
208
|
+
function U(t, r, e) {
|
|
331
209
|
return {
|
|
332
|
-
r:
|
|
333
|
-
g:
|
|
334
|
-
b:
|
|
210
|
+
r: u(t, 255) * 255,
|
|
211
|
+
g: u(r, 255) * 255,
|
|
212
|
+
b: u(e, 255) * 255
|
|
335
213
|
};
|
|
336
214
|
}
|
|
337
|
-
function
|
|
338
|
-
r =
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
348
|
-
switch (max) {
|
|
349
|
-
case r:
|
|
350
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
215
|
+
function C(t, r, e) {
|
|
216
|
+
t = u(t, 255), r = u(r, 255), e = u(e, 255);
|
|
217
|
+
var a = Math.max(t, r, e), i = Math.min(t, r, e), n, o, h = (a + i) / 2;
|
|
218
|
+
if (a == i)
|
|
219
|
+
n = o = 0;
|
|
220
|
+
else {
|
|
221
|
+
var l = a - i;
|
|
222
|
+
switch (o = h > 0.5 ? l / (2 - a - i) : l / (a + i), a) {
|
|
223
|
+
case t:
|
|
224
|
+
n = (r - e) / l + (r < e ? 6 : 0);
|
|
351
225
|
break;
|
|
352
|
-
case
|
|
353
|
-
|
|
226
|
+
case r:
|
|
227
|
+
n = (e - t) / l + 2;
|
|
354
228
|
break;
|
|
355
|
-
case
|
|
356
|
-
|
|
229
|
+
case e:
|
|
230
|
+
n = (t - r) / l + 4;
|
|
357
231
|
break;
|
|
358
232
|
}
|
|
359
|
-
|
|
233
|
+
n /= 6;
|
|
360
234
|
}
|
|
361
235
|
return {
|
|
362
|
-
h,
|
|
363
|
-
s,
|
|
364
|
-
l
|
|
236
|
+
h: n,
|
|
237
|
+
s: o,
|
|
238
|
+
l: h
|
|
365
239
|
};
|
|
366
240
|
}
|
|
367
|
-
function
|
|
368
|
-
var
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
function hue2rgb(p2, q2, t) {
|
|
373
|
-
if (t < 0)
|
|
374
|
-
t += 1;
|
|
375
|
-
if (t > 1)
|
|
376
|
-
t -= 1;
|
|
377
|
-
if (t < 1 / 6)
|
|
378
|
-
return p2 + (q2 - p2) * 6 * t;
|
|
379
|
-
if (t < 1 / 2)
|
|
380
|
-
return q2;
|
|
381
|
-
if (t < 2 / 3)
|
|
382
|
-
return p2 + (q2 - p2) * (2 / 3 - t) * 6;
|
|
383
|
-
return p2;
|
|
241
|
+
function V(t, r, e) {
|
|
242
|
+
var a, i, n;
|
|
243
|
+
t = u(t, 360), r = u(r, 100), e = u(e, 100);
|
|
244
|
+
function o(d, g, c) {
|
|
245
|
+
return c < 0 && (c += 1), c > 1 && (c -= 1), c < 1 / 6 ? d + (g - d) * 6 * c : c < 1 / 2 ? g : c < 2 / 3 ? d + (g - d) * (2 / 3 - c) * 6 : d;
|
|
384
246
|
}
|
|
385
|
-
if (
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
var
|
|
389
|
-
|
|
390
|
-
r = hue2rgb(p, q, h + 1 / 3);
|
|
391
|
-
g = hue2rgb(p, q, h);
|
|
392
|
-
b = hue2rgb(p, q, h - 1 / 3);
|
|
247
|
+
if (r === 0)
|
|
248
|
+
a = i = n = e;
|
|
249
|
+
else {
|
|
250
|
+
var h = e < 0.5 ? e * (1 + r) : e + r - e * r, l = 2 * e - h;
|
|
251
|
+
a = o(l, h, t + 1 / 3), i = o(l, h, t), n = o(l, h, t - 1 / 3);
|
|
393
252
|
}
|
|
394
253
|
return {
|
|
395
|
-
r:
|
|
396
|
-
g:
|
|
397
|
-
b:
|
|
254
|
+
r: a * 255,
|
|
255
|
+
g: i * 255,
|
|
256
|
+
b: n * 255
|
|
398
257
|
};
|
|
399
258
|
}
|
|
400
|
-
function
|
|
401
|
-
r =
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
h = 0;
|
|
410
|
-
} else {
|
|
411
|
-
switch (max) {
|
|
412
|
-
case r:
|
|
413
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
259
|
+
function R(t, r, e) {
|
|
260
|
+
t = u(t, 255), r = u(r, 255), e = u(e, 255);
|
|
261
|
+
var a = Math.max(t, r, e), i = Math.min(t, r, e), n, o, h = a, l = a - i;
|
|
262
|
+
if (o = a === 0 ? 0 : l / a, a == i)
|
|
263
|
+
n = 0;
|
|
264
|
+
else {
|
|
265
|
+
switch (a) {
|
|
266
|
+
case t:
|
|
267
|
+
n = (r - e) / l + (r < e ? 6 : 0);
|
|
414
268
|
break;
|
|
415
|
-
case
|
|
416
|
-
|
|
269
|
+
case r:
|
|
270
|
+
n = (e - t) / l + 2;
|
|
417
271
|
break;
|
|
418
|
-
case
|
|
419
|
-
|
|
272
|
+
case e:
|
|
273
|
+
n = (t - r) / l + 4;
|
|
420
274
|
break;
|
|
421
275
|
}
|
|
422
|
-
|
|
276
|
+
n /= 6;
|
|
423
277
|
}
|
|
424
278
|
return {
|
|
425
|
-
h,
|
|
426
|
-
s,
|
|
427
|
-
v
|
|
279
|
+
h: n,
|
|
280
|
+
s: o,
|
|
281
|
+
v: h
|
|
428
282
|
};
|
|
429
283
|
}
|
|
430
|
-
function
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
v = bound01(v, 100);
|
|
434
|
-
var i = Math.floor(h), f = h - i, p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s), mod = i % 6, r = [v, q, p, p, t, v][mod], g = [t, v, v, q, p, p][mod], b = [p, p, t, v, v, q][mod];
|
|
284
|
+
function q(t, r, e) {
|
|
285
|
+
t = u(t, 360) * 6, r = u(r, 100), e = u(e, 100);
|
|
286
|
+
var a = Math.floor(t), i = t - a, n = e * (1 - r), o = e * (1 - i * r), h = e * (1 - (1 - i) * r), l = a % 6, d = [e, o, n, n, h, e][l], g = [h, e, e, o, n, n][l], c = [n, n, h, e, e, o][l];
|
|
435
287
|
return {
|
|
436
|
-
r:
|
|
288
|
+
r: d * 255,
|
|
437
289
|
g: g * 255,
|
|
438
|
-
b:
|
|
290
|
+
b: c * 255
|
|
439
291
|
};
|
|
440
292
|
}
|
|
441
|
-
function
|
|
442
|
-
var
|
|
443
|
-
|
|
444
|
-
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
445
|
-
}
|
|
446
|
-
return hex.join("");
|
|
293
|
+
function E(t, r, e, a) {
|
|
294
|
+
var i = [b(Math.round(t).toString(16)), b(Math.round(r).toString(16)), b(Math.round(e).toString(16))];
|
|
295
|
+
return a && i[0].charAt(0) == i[0].charAt(1) && i[1].charAt(0) == i[1].charAt(1) && i[2].charAt(0) == i[2].charAt(1) ? i[0].charAt(0) + i[1].charAt(0) + i[2].charAt(0) : i.join("");
|
|
447
296
|
}
|
|
448
|
-
function
|
|
449
|
-
var
|
|
450
|
-
|
|
451
|
-
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
|
|
452
|
-
}
|
|
453
|
-
return hex.join("");
|
|
297
|
+
function X(t, r, e, a, i) {
|
|
298
|
+
var n = [b(Math.round(t).toString(16)), b(Math.round(r).toString(16)), b(Math.round(e).toString(16)), b(I(a))];
|
|
299
|
+
return i && n[0].charAt(0) == n[0].charAt(1) && n[1].charAt(0) == n[1].charAt(1) && n[2].charAt(0) == n[2].charAt(1) && n[3].charAt(0) == n[3].charAt(1) ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) + n[3].charAt(0) : n.join("");
|
|
454
300
|
}
|
|
455
|
-
function
|
|
456
|
-
var
|
|
457
|
-
return
|
|
301
|
+
function L(t, r, e, a) {
|
|
302
|
+
var i = [b(I(a)), b(Math.round(t).toString(16)), b(Math.round(r).toString(16)), b(Math.round(e).toString(16))];
|
|
303
|
+
return i.join("");
|
|
458
304
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
return false;
|
|
462
|
-
return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
|
|
305
|
+
s.equals = function(t, r) {
|
|
306
|
+
return !t || !r ? !1 : s(t).toRgbString() == s(r).toRgbString();
|
|
463
307
|
};
|
|
464
|
-
|
|
465
|
-
return
|
|
308
|
+
s.random = function() {
|
|
309
|
+
return s.fromRatio({
|
|
466
310
|
r: Math.random(),
|
|
467
311
|
g: Math.random(),
|
|
468
312
|
b: Math.random()
|
|
469
313
|
});
|
|
470
314
|
};
|
|
471
|
-
function
|
|
472
|
-
|
|
473
|
-
var
|
|
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
|
-
return
|
|
502
|
-
}
|
|
503
|
-
function
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
}
|
|
510
|
-
function _spin(color, amount) {
|
|
511
|
-
var hsl = tinycolor(color).toHsl();
|
|
512
|
-
var hue = (hsl.h + amount) % 360;
|
|
513
|
-
hsl.h = hue < 0 ? 360 + hue : hue;
|
|
514
|
-
return tinycolor(hsl);
|
|
515
|
-
}
|
|
516
|
-
function _complement(color) {
|
|
517
|
-
var hsl = tinycolor(color).toHsl();
|
|
518
|
-
hsl.h = (hsl.h + 180) % 360;
|
|
519
|
-
return tinycolor(hsl);
|
|
520
|
-
}
|
|
521
|
-
function polyad(color, number) {
|
|
522
|
-
if (isNaN(number) || number <= 0) {
|
|
315
|
+
function W(t, r) {
|
|
316
|
+
r = r === 0 ? 0 : r || 10;
|
|
317
|
+
var e = s(t).toHsl();
|
|
318
|
+
return e.s -= r / 100, e.s = M(e.s), s(e);
|
|
319
|
+
}
|
|
320
|
+
function Y(t, r) {
|
|
321
|
+
r = r === 0 ? 0 : r || 10;
|
|
322
|
+
var e = s(t).toHsl();
|
|
323
|
+
return e.s += r / 100, e.s = M(e.s), s(e);
|
|
324
|
+
}
|
|
325
|
+
function J(t) {
|
|
326
|
+
return s(t).desaturate(100);
|
|
327
|
+
}
|
|
328
|
+
function K(t, r) {
|
|
329
|
+
r = r === 0 ? 0 : r || 10;
|
|
330
|
+
var e = s(t).toHsl();
|
|
331
|
+
return e.l += r / 100, e.l = M(e.l), s(e);
|
|
332
|
+
}
|
|
333
|
+
function Z(t, r) {
|
|
334
|
+
r = r === 0 ? 0 : r || 10;
|
|
335
|
+
var e = s(t).toRgb();
|
|
336
|
+
return e.r = Math.max(0, Math.min(255, e.r - Math.round(255 * -(r / 100)))), e.g = Math.max(0, Math.min(255, e.g - Math.round(255 * -(r / 100)))), e.b = Math.max(0, Math.min(255, e.b - Math.round(255 * -(r / 100)))), s(e);
|
|
337
|
+
}
|
|
338
|
+
function Q(t, r) {
|
|
339
|
+
r = r === 0 ? 0 : r || 10;
|
|
340
|
+
var e = s(t).toHsl();
|
|
341
|
+
return e.l -= r / 100, e.l = M(e.l), s(e);
|
|
342
|
+
}
|
|
343
|
+
function ee(t, r) {
|
|
344
|
+
var e = s(t).toHsl(), a = (e.h + r) % 360;
|
|
345
|
+
return e.h = a < 0 ? 360 + a : a, s(e);
|
|
346
|
+
}
|
|
347
|
+
function te(t) {
|
|
348
|
+
var r = s(t).toHsl();
|
|
349
|
+
return r.h = (r.h + 180) % 360, s(r);
|
|
350
|
+
}
|
|
351
|
+
function T(t, r) {
|
|
352
|
+
if (isNaN(r) || r <= 0)
|
|
523
353
|
throw new Error("Argument to polyad must be a positive number");
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
result.push(tinycolor({
|
|
530
|
-
h: (hsl.h + i * step) % 360,
|
|
531
|
-
s: hsl.s,
|
|
532
|
-
l: hsl.l
|
|
354
|
+
for (var e = s(t).toHsl(), a = [s(t)], i = 360 / r, n = 1; n < r; n++)
|
|
355
|
+
a.push(s({
|
|
356
|
+
h: (e.h + n * i) % 360,
|
|
357
|
+
s: e.s,
|
|
358
|
+
l: e.l
|
|
533
359
|
}));
|
|
534
|
-
|
|
535
|
-
return result;
|
|
360
|
+
return a;
|
|
536
361
|
}
|
|
537
|
-
function
|
|
538
|
-
var
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
l: hsl.l
|
|
362
|
+
function re(t) {
|
|
363
|
+
var r = s(t).toHsl(), e = r.h;
|
|
364
|
+
return [s(t), s({
|
|
365
|
+
h: (e + 72) % 360,
|
|
366
|
+
s: r.s,
|
|
367
|
+
l: r.l
|
|
368
|
+
}), s({
|
|
369
|
+
h: (e + 216) % 360,
|
|
370
|
+
s: r.s,
|
|
371
|
+
l: r.l
|
|
548
372
|
})];
|
|
549
373
|
}
|
|
550
|
-
function
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
|
|
557
|
-
hsl.h = (hsl.h + part) % 360;
|
|
558
|
-
ret.push(tinycolor(hsl));
|
|
559
|
-
}
|
|
560
|
-
return ret;
|
|
561
|
-
}
|
|
562
|
-
function _monochromatic(color, results) {
|
|
563
|
-
results = results || 6;
|
|
564
|
-
var hsv = tinycolor(color).toHsv();
|
|
565
|
-
var h = hsv.h, s = hsv.s, v = hsv.v;
|
|
566
|
-
var ret = [];
|
|
567
|
-
var modification = 1 / results;
|
|
568
|
-
while (results--) {
|
|
569
|
-
ret.push(tinycolor({
|
|
570
|
-
h,
|
|
571
|
-
s,
|
|
572
|
-
v
|
|
573
|
-
}));
|
|
574
|
-
v = (v + modification) % 1;
|
|
575
|
-
}
|
|
576
|
-
return ret;
|
|
374
|
+
function ae(t, r, e) {
|
|
375
|
+
r = r || 6, e = e || 30;
|
|
376
|
+
var a = s(t).toHsl(), i = 360 / e, n = [s(t)];
|
|
377
|
+
for (a.h = (a.h - (i * r >> 1) + 720) % 360; --r; )
|
|
378
|
+
a.h = (a.h + i) % 360, n.push(s(a));
|
|
379
|
+
return n;
|
|
577
380
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
var
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
381
|
+
function ie(t, r) {
|
|
382
|
+
r = r || 6;
|
|
383
|
+
for (var e = s(t).toHsv(), a = e.h, i = e.s, n = e.v, o = [], h = 1 / r; r--; )
|
|
384
|
+
o.push(s({
|
|
385
|
+
h: a,
|
|
386
|
+
s: i,
|
|
387
|
+
v: n
|
|
388
|
+
})), n = (n + h) % 1;
|
|
389
|
+
return o;
|
|
390
|
+
}
|
|
391
|
+
s.mix = function(t, r, e) {
|
|
392
|
+
e = e === 0 ? 0 : e || 50;
|
|
393
|
+
var a = s(t).toRgb(), i = s(r).toRgb(), n = e / 100, o = {
|
|
394
|
+
r: (i.r - a.r) * n + a.r,
|
|
395
|
+
g: (i.g - a.g) * n + a.g,
|
|
396
|
+
b: (i.b - a.b) * n + a.b,
|
|
397
|
+
a: (i.a - a.a) * n + a.a
|
|
588
398
|
};
|
|
589
|
-
return
|
|
399
|
+
return s(o);
|
|
590
400
|
};
|
|
591
|
-
|
|
592
|
-
var
|
|
593
|
-
|
|
594
|
-
return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
|
|
401
|
+
s.readability = function(t, r) {
|
|
402
|
+
var e = s(t), a = s(r);
|
|
403
|
+
return (Math.max(e.getLuminance(), a.getLuminance()) + 0.05) / (Math.min(e.getLuminance(), a.getLuminance()) + 0.05);
|
|
595
404
|
};
|
|
596
|
-
|
|
597
|
-
var
|
|
598
|
-
|
|
599
|
-
out = false;
|
|
600
|
-
wcag2Parms = validateWCAG2Parms(wcag2);
|
|
601
|
-
switch (wcag2Parms.level + wcag2Parms.size) {
|
|
405
|
+
s.isReadable = function(t, r, e) {
|
|
406
|
+
var a = s.readability(t, r), i, n;
|
|
407
|
+
switch (n = !1, i = ue(e), i.level + i.size) {
|
|
602
408
|
case "AAsmall":
|
|
603
409
|
case "AAAlarge":
|
|
604
|
-
|
|
410
|
+
n = a >= 4.5;
|
|
605
411
|
break;
|
|
606
412
|
case "AAlarge":
|
|
607
|
-
|
|
413
|
+
n = a >= 3;
|
|
608
414
|
break;
|
|
609
415
|
case "AAAsmall":
|
|
610
|
-
|
|
416
|
+
n = a >= 7;
|
|
611
417
|
break;
|
|
612
418
|
}
|
|
613
|
-
return
|
|
419
|
+
return n;
|
|
614
420
|
};
|
|
615
|
-
|
|
616
|
-
var
|
|
617
|
-
|
|
618
|
-
var
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
for (var i = 0; i < colorList.length; i++) {
|
|
625
|
-
readability = tinycolor.readability(baseColor, colorList[i]);
|
|
626
|
-
if (readability > bestScore) {
|
|
627
|
-
bestScore = readability;
|
|
628
|
-
bestColor = tinycolor(colorList[i]);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
if (tinycolor.isReadable(baseColor, bestColor, {
|
|
632
|
-
level,
|
|
633
|
-
size
|
|
634
|
-
}) || !includeFallbackColors) {
|
|
635
|
-
return bestColor;
|
|
636
|
-
} else {
|
|
637
|
-
args.includeFallbackColors = false;
|
|
638
|
-
return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
|
|
639
|
-
}
|
|
421
|
+
s.mostReadable = function(t, r, e) {
|
|
422
|
+
var a = null, i = 0, n, o, h, l;
|
|
423
|
+
e = e || {}, o = e.includeFallbackColors, h = e.level, l = e.size;
|
|
424
|
+
for (var d = 0; d < r.length; d++)
|
|
425
|
+
n = s.readability(t, r[d]), n > i && (i = n, a = s(r[d]));
|
|
426
|
+
return s.isReadable(t, a, {
|
|
427
|
+
level: h,
|
|
428
|
+
size: l
|
|
429
|
+
}) || !o ? a : (e.includeFallbackColors = !1, s.mostReadable(t, ["#fff", "#000"], e));
|
|
640
430
|
};
|
|
641
|
-
var
|
|
431
|
+
var j = s.names = {
|
|
642
432
|
aliceblue: "f0f8ff",
|
|
643
433
|
antiquewhite: "faebd7",
|
|
644
434
|
aqua: "0ff",
|
|
@@ -788,94 +578,70 @@ var names = tinycolor.names = {
|
|
|
788
578
|
whitesmoke: "f5f5f5",
|
|
789
579
|
yellow: "ff0",
|
|
790
580
|
yellowgreen: "9acd32"
|
|
791
|
-
};
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
var
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
flipped[o[i]] = i;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
return flipped;
|
|
581
|
+
}, ne = s.hexNames = se(j);
|
|
582
|
+
function se(t) {
|
|
583
|
+
var r = {};
|
|
584
|
+
for (var e in t)
|
|
585
|
+
t.hasOwnProperty(e) && (r[t[e]] = e);
|
|
586
|
+
return r;
|
|
801
587
|
}
|
|
802
|
-
function
|
|
803
|
-
|
|
804
|
-
if (isNaN(a) || a < 0 || a > 1) {
|
|
805
|
-
a = 1;
|
|
806
|
-
}
|
|
807
|
-
return a;
|
|
588
|
+
function D(t) {
|
|
589
|
+
return t = parseFloat(t), (isNaN(t) || t < 0 || t > 1) && (t = 1), t;
|
|
808
590
|
}
|
|
809
|
-
function
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
n = Math.min(max, Math.max(0, parseFloat(n)));
|
|
814
|
-
if (processPercent) {
|
|
815
|
-
n = parseInt(n * max, 10) / 100;
|
|
816
|
-
}
|
|
817
|
-
if (Math.abs(n - max) < 1e-6) {
|
|
818
|
-
return 1;
|
|
819
|
-
}
|
|
820
|
-
return n % max / parseFloat(max);
|
|
591
|
+
function u(t, r) {
|
|
592
|
+
oe(t) && (t = "100%");
|
|
593
|
+
var e = he(t);
|
|
594
|
+
return t = Math.min(r, Math.max(0, parseFloat(t))), e && (t = parseInt(t * r, 10) / 100), Math.abs(t - r) < 1e-6 ? 1 : t % r / parseFloat(r);
|
|
821
595
|
}
|
|
822
|
-
function
|
|
823
|
-
return Math.min(1, Math.max(0,
|
|
596
|
+
function M(t) {
|
|
597
|
+
return Math.min(1, Math.max(0, t));
|
|
824
598
|
}
|
|
825
|
-
function
|
|
826
|
-
return parseInt(
|
|
599
|
+
function f(t) {
|
|
600
|
+
return parseInt(t, 16);
|
|
827
601
|
}
|
|
828
|
-
function
|
|
829
|
-
return typeof
|
|
602
|
+
function oe(t) {
|
|
603
|
+
return typeof t == "string" && t.indexOf(".") != -1 && parseFloat(t) === 1;
|
|
830
604
|
}
|
|
831
|
-
function
|
|
832
|
-
return typeof
|
|
605
|
+
function he(t) {
|
|
606
|
+
return typeof t == "string" && t.indexOf("%") != -1;
|
|
833
607
|
}
|
|
834
|
-
function
|
|
835
|
-
return
|
|
608
|
+
function b(t) {
|
|
609
|
+
return t.length == 1 ? "0" + t : "" + t;
|
|
836
610
|
}
|
|
837
|
-
function
|
|
838
|
-
|
|
839
|
-
n = n * 100 + "%";
|
|
840
|
-
}
|
|
841
|
-
return n;
|
|
611
|
+
function y(t) {
|
|
612
|
+
return t <= 1 && (t = t * 100 + "%"), t;
|
|
842
613
|
}
|
|
843
|
-
function
|
|
844
|
-
return Math.round(parseFloat(
|
|
614
|
+
function I(t) {
|
|
615
|
+
return Math.round(parseFloat(t) * 255).toString(16);
|
|
845
616
|
}
|
|
846
|
-
function
|
|
847
|
-
return
|
|
617
|
+
function F(t) {
|
|
618
|
+
return f(t) / 255;
|
|
848
619
|
}
|
|
849
|
-
var
|
|
850
|
-
var
|
|
851
|
-
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
|
|
852
|
-
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
|
853
|
-
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
854
|
-
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
620
|
+
var p = function() {
|
|
621
|
+
var t = "[-\\+]?\\d+%?", r = "[-\\+]?\\d*\\.\\d+%?", e = "(?:" + r + ")|(?:" + t + ")", a = "[\\s|\\(]+(" + e + ")[,|\\s]+(" + e + ")[,|\\s]+(" + e + ")\\s*\\)?", i = "[\\s|\\(]+(" + e + ")[,|\\s]+(" + e + ")[,|\\s]+(" + e + ")[,|\\s]+(" + e + ")\\s*\\)?";
|
|
855
622
|
return {
|
|
856
|
-
CSS_UNIT: new RegExp(
|
|
857
|
-
rgb: new RegExp("rgb" +
|
|
858
|
-
rgba: new RegExp("rgba" +
|
|
859
|
-
hsl: new RegExp("hsl" +
|
|
860
|
-
hsla: new RegExp("hsla" +
|
|
861
|
-
hsv: new RegExp("hsv" +
|
|
862
|
-
hsva: new RegExp("hsva" +
|
|
623
|
+
CSS_UNIT: new RegExp(e),
|
|
624
|
+
rgb: new RegExp("rgb" + a),
|
|
625
|
+
rgba: new RegExp("rgba" + i),
|
|
626
|
+
hsl: new RegExp("hsl" + a),
|
|
627
|
+
hsla: new RegExp("hsla" + i),
|
|
628
|
+
hsv: new RegExp("hsv" + a),
|
|
629
|
+
hsva: new RegExp("hsva" + i),
|
|
863
630
|
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
864
631
|
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
865
632
|
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
866
633
|
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
867
634
|
};
|
|
868
635
|
}();
|
|
869
|
-
function
|
|
870
|
-
return !!
|
|
871
|
-
}
|
|
872
|
-
function
|
|
873
|
-
|
|
874
|
-
var
|
|
875
|
-
if (
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
} else if (color == "transparent") {
|
|
636
|
+
function m(t) {
|
|
637
|
+
return !!p.CSS_UNIT.exec(t);
|
|
638
|
+
}
|
|
639
|
+
function le(t) {
|
|
640
|
+
t = t.replace(O, "").replace(G, "").toLowerCase();
|
|
641
|
+
var r = !1;
|
|
642
|
+
if (j[t])
|
|
643
|
+
t = j[t], r = !0;
|
|
644
|
+
else if (t == "transparent")
|
|
879
645
|
return {
|
|
880
646
|
r: 0,
|
|
881
647
|
g: 0,
|
|
@@ -883,203 +649,130 @@ function stringInputToObject(color) {
|
|
|
883
649
|
a: 0,
|
|
884
650
|
format: "name"
|
|
885
651
|
};
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
if (match = matchers.hex6.exec(color)) {
|
|
943
|
-
return {
|
|
944
|
-
r: parseIntFromHex(match[1]),
|
|
945
|
-
g: parseIntFromHex(match[2]),
|
|
946
|
-
b: parseIntFromHex(match[3]),
|
|
947
|
-
format: named ? "name" : "hex"
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
if (match = matchers.hex4.exec(color)) {
|
|
951
|
-
return {
|
|
952
|
-
r: parseIntFromHex(match[1] + "" + match[1]),
|
|
953
|
-
g: parseIntFromHex(match[2] + "" + match[2]),
|
|
954
|
-
b: parseIntFromHex(match[3] + "" + match[3]),
|
|
955
|
-
a: convertHexToDecimal(match[4] + "" + match[4]),
|
|
956
|
-
format: named ? "name" : "hex8"
|
|
957
|
-
};
|
|
958
|
-
}
|
|
959
|
-
if (match = matchers.hex3.exec(color)) {
|
|
960
|
-
return {
|
|
961
|
-
r: parseIntFromHex(match[1] + "" + match[1]),
|
|
962
|
-
g: parseIntFromHex(match[2] + "" + match[2]),
|
|
963
|
-
b: parseIntFromHex(match[3] + "" + match[3]),
|
|
964
|
-
format: named ? "name" : "hex"
|
|
965
|
-
};
|
|
966
|
-
}
|
|
967
|
-
return false;
|
|
968
|
-
}
|
|
969
|
-
function validateWCAG2Parms(parms) {
|
|
970
|
-
var level, size;
|
|
971
|
-
parms = parms || {
|
|
652
|
+
var e;
|
|
653
|
+
return (e = p.rgb.exec(t)) ? {
|
|
654
|
+
r: e[1],
|
|
655
|
+
g: e[2],
|
|
656
|
+
b: e[3]
|
|
657
|
+
} : (e = p.rgba.exec(t)) ? {
|
|
658
|
+
r: e[1],
|
|
659
|
+
g: e[2],
|
|
660
|
+
b: e[3],
|
|
661
|
+
a: e[4]
|
|
662
|
+
} : (e = p.hsl.exec(t)) ? {
|
|
663
|
+
h: e[1],
|
|
664
|
+
s: e[2],
|
|
665
|
+
l: e[3]
|
|
666
|
+
} : (e = p.hsla.exec(t)) ? {
|
|
667
|
+
h: e[1],
|
|
668
|
+
s: e[2],
|
|
669
|
+
l: e[3],
|
|
670
|
+
a: e[4]
|
|
671
|
+
} : (e = p.hsv.exec(t)) ? {
|
|
672
|
+
h: e[1],
|
|
673
|
+
s: e[2],
|
|
674
|
+
v: e[3]
|
|
675
|
+
} : (e = p.hsva.exec(t)) ? {
|
|
676
|
+
h: e[1],
|
|
677
|
+
s: e[2],
|
|
678
|
+
v: e[3],
|
|
679
|
+
a: e[4]
|
|
680
|
+
} : (e = p.hex8.exec(t)) ? {
|
|
681
|
+
r: f(e[1]),
|
|
682
|
+
g: f(e[2]),
|
|
683
|
+
b: f(e[3]),
|
|
684
|
+
a: F(e[4]),
|
|
685
|
+
format: r ? "name" : "hex8"
|
|
686
|
+
} : (e = p.hex6.exec(t)) ? {
|
|
687
|
+
r: f(e[1]),
|
|
688
|
+
g: f(e[2]),
|
|
689
|
+
b: f(e[3]),
|
|
690
|
+
format: r ? "name" : "hex"
|
|
691
|
+
} : (e = p.hex4.exec(t)) ? {
|
|
692
|
+
r: f(e[1] + "" + e[1]),
|
|
693
|
+
g: f(e[2] + "" + e[2]),
|
|
694
|
+
b: f(e[3] + "" + e[3]),
|
|
695
|
+
a: F(e[4] + "" + e[4]),
|
|
696
|
+
format: r ? "name" : "hex8"
|
|
697
|
+
} : (e = p.hex3.exec(t)) ? {
|
|
698
|
+
r: f(e[1] + "" + e[1]),
|
|
699
|
+
g: f(e[2] + "" + e[2]),
|
|
700
|
+
b: f(e[3] + "" + e[3]),
|
|
701
|
+
format: r ? "name" : "hex"
|
|
702
|
+
} : !1;
|
|
703
|
+
}
|
|
704
|
+
function ue(t) {
|
|
705
|
+
var r, e;
|
|
706
|
+
return t = t || {
|
|
972
707
|
level: "AA",
|
|
973
708
|
size: "small"
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
if (level !== "AA" && level !== "AAA") {
|
|
978
|
-
level = "AA";
|
|
979
|
-
}
|
|
980
|
-
if (size !== "small" && size !== "large") {
|
|
981
|
-
size = "small";
|
|
982
|
-
}
|
|
983
|
-
return {
|
|
984
|
-
level,
|
|
985
|
-
size
|
|
709
|
+
}, r = (t.level || "AA").toUpperCase(), e = (t.size || "small").toLowerCase(), r !== "AA" && r !== "AAA" && (r = "AA"), e !== "small" && e !== "large" && (e = "small"), {
|
|
710
|
+
level: r,
|
|
711
|
+
size: e
|
|
986
712
|
};
|
|
987
713
|
}
|
|
988
|
-
const
|
|
989
|
-
|
|
714
|
+
const ce = `/*!
|
|
715
|
+
* direction.scss
|
|
716
|
+
*/:host{--wj-color-picker-value: #ff0000;--wj-color-picker-radius: 4px}.anchor{width:1rem;height:1rem;background:var(--wj-color-picker-value)}.picker{width:200px;min-height:90px;box-shadow:0 0 5px #0000000d,0 5px 20px #0000001a;border-radius:var(--wj-color-picker-radius)}.color-area{display:block;position:relative;height:100px;color:var(--wj-color-picker-area);background-image:linear-gradient(rgba(0,0,0,0),#000),linear-gradient(90deg,#fff,currentColor);cursor:crosshair;border-radius:var(--wj-color-picker-radius) var(--wj-color-picker-radius) 0 0}.wrapper{display:inline-table;width:calc(100% - 2rem);margin:1rem}.hue{border-radius:.25rem;background-image:linear-gradient(to right,rgb(255,0,0) 0%,rgb(255,255,0) 17%,rgb(0,255,0) 33%,rgb(0,255,255) 50%,rgb(0,0,255) 67%,rgb(255,0,255) 83%,rgb(255,0,0) 100%);width:100%;height:8px;margin:.75rem 0 1rem}.hue::part(slider){--wj-slider-color: transparent;--wj-slider-thumb-color: white;--wj-slider-thumb-shadow: 0 0 0 1px rgba(33, 33, 33, .14);--wj-slider-thumb-shadow-active: var(--wj-slider-thumb-shadow);--wj-slider-track-color: transparent}.alpha-wrapper{border-radius:.25rem;width:100%;height:8px;margin:.75rem 0 1rem;background-image:repeating-linear-gradient(45deg,#aaa 25%,transparent 25%,transparent 75%,#aaa 75%,#aaa),repeating-linear-gradient(45deg,#aaa 25%,#fff 25%,#fff 75%,#aaa 75%,#aaa);background-position:0 0,4px 4px;background-size:8px 8px}.alpha{color:var(--wj-color-picker-value);display:block;height:100%;width:100%;border-radius:inherit;background-image:linear-gradient(90deg,rgba(0,0,0,0),currentColor)}.alpha::part(slider){--wj-slider-color: transparent;--wj-slider-thumb-color: white;--wj-slider-thumb-shadow: 0 0 0 1px rgba(33, 33, 33, .14);--wj-slider-thumb-shadow-active: var(--wj-slider-thumb-shadow);--wj-slider-track-color: transparent;--wj-slider-track-height: 8px}.input-wrapper{display:grid;align-items:center;grid-template-columns:1fr auto}.color-preview{width:30px!important;height:30px!important;border-radius:50%;position:relative;margin-right:1rem}.color-preview:before,.color-preview:after{content:"";position:absolute;height:100%;width:100%;left:0;top:0;border:1px solid #fff;border-radius:50%}.color-preview:before{background-image:repeating-linear-gradient(45deg,#aaa 25%,transparent 25%,transparent 75%,#aaa 75%,#aaa),repeating-linear-gradient(45deg,#aaa 25%,#fff 25%,#fff 75%,#aaa 75%,#aaa);background-position:0 0,4px 4px;background-size:8px 8px}.color-preview:after{background:var(--wj-color-picker-value)}wj-input{--wj-input-border-radius: 1rem;--wj-input-margin-bottom: 0}wj-input::part(input){text-align:center}.swatches{margin-top:1rem;display:flex;justify-content:center;flex-wrap:wrap}.swatch{background:var(--wj-color-picker-swatch);position:relative;width:20px;height:20px;margin:0 4px 6px;padding:0;border:0;border-radius:50%;color:inherit;white-space:nowrap;overflow:hidden;cursor:pointer}.marker{position:absolute;width:12px;height:12px;margin:-6px 0 0 -6px;border:1px solid #fff;border-radius:50%;background-color:var(--wj-color-picker-value);cursor:pointer}
|
|
717
|
+
`;
|
|
718
|
+
class de extends z {
|
|
990
719
|
constructor() {
|
|
991
720
|
super();
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
const
|
|
721
|
+
v(this, "className", "ColorPicker");
|
|
722
|
+
v(this, "moveMarker", (e) => {
|
|
723
|
+
const a = this.getPointerPosition(e);
|
|
995
724
|
console.log("colorAreaDimension", this.colorAreaDimension);
|
|
996
|
-
let
|
|
997
|
-
|
|
998
|
-
this.setColor(this.setColorAtPosition(x, y), "marker");
|
|
999
|
-
this.setMarkerPosition(x, y);
|
|
725
|
+
let i = a.pageX - this.colorAreaDimension.x, n = a.pageY - this.colorAreaDimension.y;
|
|
726
|
+
this.setColor(this.setColorAtPosition(i, n), "marker"), this.setMarkerPosition(i, n);
|
|
1000
727
|
});
|
|
1001
728
|
/*
|
|
1002
729
|
* @desc nanstavenie pozicie markera podla farby
|
|
1003
730
|
* @param color
|
|
1004
731
|
* @returns {{x: number, y: number}}
|
|
1005
732
|
*/
|
|
1006
|
-
|
|
1007
|
-
let
|
|
733
|
+
v(this, "setMarkerPositionByColor", (e = "red") => {
|
|
734
|
+
let a = s(e).toHsv();
|
|
1008
735
|
return {
|
|
1009
|
-
x: this.colorAreaDimension.width *
|
|
1010
|
-
y: this.colorAreaDimension.height - this.colorAreaDimension.height *
|
|
736
|
+
x: this.colorAreaDimension.width * a.s,
|
|
737
|
+
y: this.colorAreaDimension.height - this.colorAreaDimension.height * a.v
|
|
1011
738
|
};
|
|
1012
739
|
});
|
|
1013
740
|
/*
|
|
1014
741
|
* Set css variable color value
|
|
1015
742
|
*/
|
|
1016
|
-
|
|
1017
|
-
let
|
|
1018
|
-
if (
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
this.colorArea.style.setProperty("--wj-color-picker-area", currentColor.toHexString());
|
|
1022
|
-
}
|
|
1023
|
-
if (type === "marker") {
|
|
1024
|
-
console.log("SOM MARKER");
|
|
1025
|
-
this.alphaSlider.value = 100;
|
|
1026
|
-
this.alphaSlider.style.setProperty("--wj-color-picker-value", currentColor.toHexString());
|
|
1027
|
-
this.colorPreview.style.setProperty("--wj-color-picker-value", currentColor.toHex8String());
|
|
1028
|
-
this.picker.style.setProperty("--wj-color-picker-value", currentColor.toHexString());
|
|
1029
|
-
this.marker.style.setProperty("--wj-color-picker-value", currentColor.toHex8String());
|
|
743
|
+
v(this, "setColor", (e = null, a = "") => {
|
|
744
|
+
let i = e;
|
|
745
|
+
if (i === null && a === "" && (console.log("SOM NULL"), i = s(this.input.value), this.colorArea.style.setProperty("--wj-color-picker-area", i.toHexString())), a === "marker" && (console.log("SOM MARKER"), this.alphaSlider.value = 100, this.alphaSlider.style.setProperty("--wj-color-picker-value", i.toHexString()), this.colorPreview.style.setProperty("--wj-color-picker-value", i.toHex8String()), this.picker.style.setProperty("--wj-color-picker-value", i.toHexString()), this.marker.style.setProperty("--wj-color-picker-value", i.toHex8String())), a === "hue") {
|
|
746
|
+
let n = this.setColorAtPosition(this.markerPosition.x, this.markerPosition.y, this.alphaSlider.value);
|
|
747
|
+
i = s(this.getHSVA(this.hueSlider.value, this.alphaSlider.value)), this.colorPreview.style.setProperty("--wj-color-picker-value", n.toHex8String()), this.marker.style.setProperty("--wj-color-picker-value", n.toHexString()), this.alphaSlider.style.setProperty("--wj-color-picker-value", i.toHexString()), this.colorArea.style.setProperty("--wj-color-picker-area", i.toHexString()), this.input.value = n.toHex8String();
|
|
1030
748
|
}
|
|
1031
|
-
if (
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
this.colorPreview.style.setProperty("--wj-color-picker-value",
|
|
1035
|
-
this.marker.style.setProperty("--wj-color-picker-value", markerColorByPosition.toHexString());
|
|
1036
|
-
this.alphaSlider.style.setProperty("--wj-color-picker-value", currentColor.toHexString());
|
|
1037
|
-
this.colorArea.style.setProperty("--wj-color-picker-area", currentColor.toHexString());
|
|
1038
|
-
this.input.value = markerColorByPosition.toHex8String();
|
|
749
|
+
if (a === "alpha") {
|
|
750
|
+
i = s(this.input.value);
|
|
751
|
+
let n = i.toHsv();
|
|
752
|
+
n.a = this.alphaSlider.value / 100, i = s(n), this.colorPreview.style.setProperty("--wj-color-picker-value", i.toHex8String());
|
|
1039
753
|
}
|
|
1040
|
-
|
|
1041
|
-
currentColor = tinycolor(this.input.value);
|
|
1042
|
-
let hsv = currentColor.toHsv();
|
|
1043
|
-
hsv.a = this.alphaSlider.value / 100;
|
|
1044
|
-
currentColor = tinycolor(hsv);
|
|
1045
|
-
this.colorPreview.style.setProperty("--wj-color-picker-value", currentColor.toHex8String());
|
|
1046
|
-
}
|
|
1047
|
-
if (type === "swatch") {
|
|
1048
|
-
this.colorPreview.style.setProperty("--wj-color-picker-value", currentColor.toHex8String());
|
|
1049
|
-
this.marker.style.setProperty("--wj-color-picker-value", currentColor.toHexString());
|
|
1050
|
-
this.alphaSlider.style.setProperty("--wj-color-picker-value", currentColor.toHexString());
|
|
1051
|
-
this.colorArea.style.setProperty("--wj-color-picker-area", currentColor.toHex8String());
|
|
1052
|
-
this.markerPosition = this.setMarkerPositionByColor(currentColor.toHex8String());
|
|
1053
|
-
this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y);
|
|
1054
|
-
}
|
|
1055
|
-
this.input.value = currentColor.toHex8String();
|
|
1056
|
-
this.anchor.style.setProperty("--wj-color-picker-value", currentColor.toHexString());
|
|
754
|
+
a === "swatch" && (this.colorPreview.style.setProperty("--wj-color-picker-value", i.toHex8String()), this.marker.style.setProperty("--wj-color-picker-value", i.toHexString()), this.alphaSlider.style.setProperty("--wj-color-picker-value", i.toHexString()), this.colorArea.style.setProperty("--wj-color-picker-area", i.toHex8String()), this.markerPosition = this.setMarkerPositionByColor(i.toHex8String()), this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y)), this.input.value = i.toHex8String(), this.anchor.style.setProperty("--wj-color-picker-value", i.toHexString());
|
|
1057
755
|
});
|
|
1058
756
|
/*
|
|
1059
757
|
* Set hue sliders
|
|
1060
758
|
*/
|
|
1061
|
-
|
|
1062
|
-
this.hueSlider.value = e.detail.value;
|
|
1063
|
-
this.setColor(null, "hue");
|
|
759
|
+
v(this, "setHue", (e) => {
|
|
760
|
+
this.hueSlider.value = e.detail.value, this.setColor(null, "hue");
|
|
1064
761
|
});
|
|
1065
762
|
/*
|
|
1066
763
|
* Set alpha sliders
|
|
1067
764
|
*/
|
|
1068
|
-
|
|
1069
|
-
this.alphaSlider.value = e.detail.value;
|
|
1070
|
-
this.setColor(null, "alpha");
|
|
765
|
+
v(this, "setAlpha", (e) => {
|
|
766
|
+
this.alphaSlider.value = e.detail.value, this.setColor(null, "alpha");
|
|
1071
767
|
});
|
|
1072
768
|
/*
|
|
1073
769
|
* Get HSVA color order by hue and alpha
|
|
1074
770
|
*/
|
|
1075
|
-
|
|
1076
|
-
return `hsva(${hue}, 100%, 100%, ${alpha / 100})`;
|
|
1077
|
-
});
|
|
771
|
+
v(this, "getHSVA", (e, a) => `hsva(${e}, 100%, 100%, ${a / 100})`);
|
|
1078
772
|
this._markerPosition = {
|
|
1079
773
|
markerX: "0",
|
|
1080
774
|
markerY: "0"
|
|
1081
|
-
}
|
|
1082
|
-
this._swatches = [
|
|
775
|
+
}, this._swatches = [
|
|
1083
776
|
"#264653",
|
|
1084
777
|
"#2a9d8f",
|
|
1085
778
|
"#e9c46a",
|
|
@@ -1093,20 +786,20 @@ class ColorPicker extends WJElement {
|
|
|
1093
786
|
"rgba(0,119,182,0.8)"
|
|
1094
787
|
];
|
|
1095
788
|
}
|
|
1096
|
-
set markerPosition(
|
|
1097
|
-
this._markerPosition =
|
|
789
|
+
set markerPosition(e) {
|
|
790
|
+
this._markerPosition = e;
|
|
1098
791
|
}
|
|
1099
792
|
get markerPosition() {
|
|
1100
793
|
return this._markerPosition;
|
|
1101
794
|
}
|
|
1102
|
-
set swatches(
|
|
1103
|
-
this.setAttribute("swatches",
|
|
795
|
+
set swatches(e) {
|
|
796
|
+
this.setAttribute("swatches", e.split(","));
|
|
1104
797
|
}
|
|
1105
798
|
get swatches() {
|
|
1106
799
|
return this._swatches;
|
|
1107
800
|
}
|
|
1108
801
|
static get cssStyleSheet() {
|
|
1109
|
-
return
|
|
802
|
+
return ce;
|
|
1110
803
|
}
|
|
1111
804
|
static get observedAttributes() {
|
|
1112
805
|
return [];
|
|
@@ -1114,120 +807,66 @@ class ColorPicker extends WJElement {
|
|
|
1114
807
|
setupAttributes() {
|
|
1115
808
|
this.isShadowRoot = "open";
|
|
1116
809
|
}
|
|
1117
|
-
draw(
|
|
1118
|
-
let
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
let
|
|
1125
|
-
|
|
1126
|
-
let
|
|
1127
|
-
|
|
1128
|
-
let
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
let
|
|
1139
|
-
|
|
1140
|
-
let
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
let inputWrapper = document.createElement("div");
|
|
1147
|
-
inputWrapper.classList.add("input-wrapper");
|
|
1148
|
-
let colorPreview = document.createElement("div");
|
|
1149
|
-
colorPreview.classList.add("color-preview");
|
|
1150
|
-
let input = document.createElement("wj-input");
|
|
1151
|
-
input.classList.add("input");
|
|
1152
|
-
input.setAttribute("variant", "standard");
|
|
1153
|
-
input.value = "#ff0000";
|
|
1154
|
-
colorArea.appendChild(marker);
|
|
1155
|
-
alphaWrapper.appendChild(alphaSlider);
|
|
1156
|
-
inputWrapper.appendChild(colorPreview);
|
|
1157
|
-
inputWrapper.appendChild(input);
|
|
1158
|
-
wrapper.appendChild(hueSlider);
|
|
1159
|
-
wrapper.appendChild(alphaWrapper);
|
|
1160
|
-
wrapper.appendChild(inputWrapper);
|
|
1161
|
-
picker.appendChild(colorArea);
|
|
1162
|
-
picker.appendChild(wrapper);
|
|
1163
|
-
this.createSwatches(wrapper);
|
|
1164
|
-
let popup = document.createElement("wj-popup");
|
|
1165
|
-
popup.setAttribute("placement", this.placement || "bottom-start");
|
|
1166
|
-
popup.setAttribute("offset", this.offset);
|
|
1167
|
-
popup.setAttribute("manual", "");
|
|
1168
|
-
popup.appendChild(anchor);
|
|
1169
|
-
popup.appendChild(picker);
|
|
1170
|
-
native.appendChild(popup);
|
|
1171
|
-
fragment.appendChild(native);
|
|
1172
|
-
this.popup = popup;
|
|
1173
|
-
this.anchor = anchor;
|
|
1174
|
-
this.picker = picker;
|
|
1175
|
-
this.marker = marker;
|
|
1176
|
-
this.colorArea = colorArea;
|
|
1177
|
-
this.hueSlider = hueSlider;
|
|
1178
|
-
this.alphaSlider = alphaSlider;
|
|
1179
|
-
this.colorPreview = colorPreview;
|
|
1180
|
-
this.input = input;
|
|
1181
|
-
return fragment;
|
|
1182
|
-
}
|
|
1183
|
-
createSwatches(node) {
|
|
810
|
+
draw(e, a, i) {
|
|
811
|
+
let n = document.createDocumentFragment(), o = document.createElement("div");
|
|
812
|
+
o.classList.add("native-color-picker");
|
|
813
|
+
let h = document.createElement("div");
|
|
814
|
+
h.setAttribute("slot", "anchor"), h.classList.add("anchor");
|
|
815
|
+
let l = document.createElement("div");
|
|
816
|
+
l.classList.add("picker");
|
|
817
|
+
let d = document.createElement("div");
|
|
818
|
+
d.classList.add("marker");
|
|
819
|
+
let g = document.createElement("div");
|
|
820
|
+
g.classList.add("color-area"), g.addEventListener("click", this.moveMarker);
|
|
821
|
+
let c = document.createElement("div");
|
|
822
|
+
c.classList.add("wrapper");
|
|
823
|
+
let x = document.createElement("wj-slider");
|
|
824
|
+
x.setAttribute("min", "0"), x.setAttribute("max", "360"), x.classList.add("hue"), x.addEventListener("wj:slider-move", this.setHue);
|
|
825
|
+
let H = document.createElement("div");
|
|
826
|
+
H.classList.add("alpha-wrapper");
|
|
827
|
+
let w = document.createElement("wj-slider");
|
|
828
|
+
w.setAttribute("min", "0"), w.setAttribute("max", "100"), w.setAttribute("value", "50"), w.classList.add("alpha"), w.addEventListener("wj:slider-move", this.setAlpha);
|
|
829
|
+
let A = document.createElement("div");
|
|
830
|
+
A.classList.add("input-wrapper");
|
|
831
|
+
let P = document.createElement("div");
|
|
832
|
+
P.classList.add("color-preview");
|
|
833
|
+
let _ = document.createElement("wj-input");
|
|
834
|
+
_.classList.add("input"), _.setAttribute("variant", "standard"), _.value = "#ff0000", g.appendChild(d), H.appendChild(w), A.appendChild(P), A.appendChild(_), c.appendChild(x), c.appendChild(H), c.appendChild(A), l.appendChild(g), l.appendChild(c), this.createSwatches(c);
|
|
835
|
+
let k = document.createElement("wj-popup");
|
|
836
|
+
return k.setAttribute("placement", this.placement || "bottom-start"), k.setAttribute("offset", this.offset), k.setAttribute("manual", ""), k.appendChild(h), k.appendChild(l), o.appendChild(k), n.appendChild(o), this.popup = k, this.anchor = h, this.picker = l, this.marker = d, this.colorArea = g, this.hueSlider = x, this.alphaSlider = w, this.colorPreview = P, this.input = _, n;
|
|
837
|
+
}
|
|
838
|
+
createSwatches(e) {
|
|
1184
839
|
if (this.swatches.length === 0)
|
|
1185
840
|
return;
|
|
1186
|
-
let
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
});
|
|
1198
|
-
node.appendChild(swatches);
|
|
1199
|
-
}
|
|
1200
|
-
setSliders(color) {
|
|
1201
|
-
let hsva = tinycolor(color).toHsv();
|
|
1202
|
-
this.hueSlider.value = hsva.h;
|
|
1203
|
-
this.alphaSlider.value = hsva.a * 100;
|
|
841
|
+
let a = document.createElement("div");
|
|
842
|
+
a.classList.add("swatches"), this.swatches.forEach((i) => {
|
|
843
|
+
let n = document.createElement("button");
|
|
844
|
+
n.classList.add("swatch"), n.style.setProperty("--wj-color-picker-swatch", i), n.addEventListener("click", (o) => {
|
|
845
|
+
this.setSliders(i), this.setColor(s(i), "swatch");
|
|
846
|
+
}), a.appendChild(n);
|
|
847
|
+
}), e.appendChild(a);
|
|
848
|
+
}
|
|
849
|
+
setSliders(e) {
|
|
850
|
+
let a = s(e).toHsv();
|
|
851
|
+
this.hueSlider.value = a.h, this.alphaSlider.value = a.a * 100;
|
|
1204
852
|
}
|
|
1205
853
|
afterDraw() {
|
|
1206
|
-
this.init =
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
this.
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
y: this.colorArea.offsetTop
|
|
1214
|
-
};
|
|
1215
|
-
this.markerPosition = this.setMarkerPositionByColor(this.input.value);
|
|
1216
|
-
this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y);
|
|
1217
|
-
if (this.input.value != "")
|
|
1218
|
-
this.alphaSlider.value = 100;
|
|
1219
|
-
this.setColor();
|
|
1220
|
-
this.init = true;
|
|
1221
|
-
}
|
|
854
|
+
this.init = !1, this.addEventListener("wj:popup-show", (e) => {
|
|
855
|
+
this.init || (this.colorAreaDimension = {
|
|
856
|
+
width: this.colorArea.offsetWidth,
|
|
857
|
+
height: this.colorArea.offsetHeight,
|
|
858
|
+
x: this.colorArea.offsetLeft,
|
|
859
|
+
y: this.colorArea.offsetTop
|
|
860
|
+
}, this.markerPosition = this.setMarkerPositionByColor(this.input.value), this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y), this.input.value != "" && (this.alphaSlider.value = 100), this.setColor(), this.init = !0);
|
|
1222
861
|
});
|
|
1223
862
|
}
|
|
1224
863
|
disconnectedCallback() {
|
|
1225
|
-
this.init =
|
|
864
|
+
this.init = !1;
|
|
1226
865
|
}
|
|
1227
|
-
getPointerPosition(
|
|
866
|
+
getPointerPosition(e) {
|
|
1228
867
|
return {
|
|
1229
|
-
pageX:
|
|
1230
|
-
pageY:
|
|
868
|
+
pageX: e.changedTouches ? e.changedTouches[0].pageX : e.pageX,
|
|
869
|
+
pageY: e.changedTouches ? e.changedTouches[0].pageY : e.pageY
|
|
1231
870
|
};
|
|
1232
871
|
}
|
|
1233
872
|
/*
|
|
@@ -1235,15 +874,11 @@ class ColorPicker extends WJElement {
|
|
|
1235
874
|
* @param x
|
|
1236
875
|
* @param y
|
|
1237
876
|
*/
|
|
1238
|
-
setMarkerPosition(
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
y
|
|
1244
|
-
};
|
|
1245
|
-
this.marker.style.left = `${x}px`;
|
|
1246
|
-
this.marker.style.top = `${y}px`;
|
|
877
|
+
setMarkerPosition(e, a) {
|
|
878
|
+
e = e < 0 ? 0 : e > this.colorAreaDimension.width ? this.colorAreaDimension.width : e, a = a < 0 ? 0 : a > this.colorAreaDimension.height ? this.colorAreaDimension.height : a, this.markerPosition = {
|
|
879
|
+
x: e,
|
|
880
|
+
y: a
|
|
881
|
+
}, this.marker.style.left = `${e}px`, this.marker.style.top = `${a}px`;
|
|
1247
882
|
}
|
|
1248
883
|
/*
|
|
1249
884
|
* nastavenie farby podla pozicie markera
|
|
@@ -1251,18 +886,18 @@ class ColorPicker extends WJElement {
|
|
|
1251
886
|
* @param y
|
|
1252
887
|
* @returns {tinycolor}
|
|
1253
888
|
*/
|
|
1254
|
-
setColorAtPosition(
|
|
1255
|
-
console.log("x",
|
|
1256
|
-
const
|
|
889
|
+
setColorAtPosition(e, a, i = 100) {
|
|
890
|
+
console.log("x", e, "y", a, "alpha", i);
|
|
891
|
+
const n = {
|
|
1257
892
|
h: this.hueSlider.value * 1,
|
|
1258
|
-
s:
|
|
1259
|
-
v: 100 -
|
|
1260
|
-
a:
|
|
893
|
+
s: e / this.colorAreaDimension.width * 100,
|
|
894
|
+
v: 100 - a / this.colorAreaDimension.height * 100,
|
|
895
|
+
a: i / 100
|
|
1261
896
|
};
|
|
1262
|
-
return
|
|
897
|
+
return s(n);
|
|
1263
898
|
}
|
|
1264
899
|
}
|
|
1265
|
-
customElements.get("wj-color-picker") || window.customElements.define("wj-color-picker",
|
|
900
|
+
customElements.get("wj-color-picker") || window.customElements.define("wj-color-picker", de);
|
|
1266
901
|
export {
|
|
1267
|
-
ColorPicker
|
|
902
|
+
de as ColorPicker
|
|
1268
903
|
};
|