wj-elements 0.0.11 → 0.0.13

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