wj-elements 0.1.136 → 0.1.137

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 (202) hide show
  1. package/dist/dark.css +223 -0
  2. package/dist/infinite-scroll.element-XVJukzjy.js +272 -0
  3. package/dist/infinite-scroll.element-XVJukzjy.js.map +1 -0
  4. package/dist/light.css +534 -0
  5. package/dist/list.element-Ce1vIm1O.js +50 -0
  6. package/dist/list.element-Ce1vIm1O.js.map +1 -0
  7. package/dist/localize.js +70 -0
  8. package/dist/localize.js.map +1 -0
  9. package/dist/popup.element-tyYxow0p.js +1623 -0
  10. package/dist/popup.element-tyYxow0p.js.map +1 -0
  11. package/dist/router-links-CJnOdbas.js +150 -0
  12. package/dist/router-links-CJnOdbas.js.map +1 -0
  13. package/dist/styles.css +849 -0
  14. package/dist/wje-accordion-item.js +113 -0
  15. package/dist/wje-accordion-item.js.map +1 -0
  16. package/dist/wje-accordion.js +122 -0
  17. package/dist/wje-accordion.js.map +1 -0
  18. package/dist/wje-animation.js +4326 -0
  19. package/dist/wje-animation.js.map +1 -0
  20. package/dist/wje-aside.js +55 -0
  21. package/dist/wje-aside.js.map +1 -0
  22. package/dist/wje-avatar.js +90 -0
  23. package/dist/wje-avatar.js.map +1 -0
  24. package/dist/wje-badge.js +71 -0
  25. package/dist/wje-badge.js.map +1 -0
  26. package/dist/wje-breadcrumb.js +195 -0
  27. package/dist/wje-breadcrumb.js.map +1 -0
  28. package/dist/wje-breadcrumbs.js +140 -0
  29. package/dist/wje-breadcrumbs.js.map +1 -0
  30. package/dist/wje-button-group.js +85 -0
  31. package/dist/wje-button-group.js.map +1 -0
  32. package/dist/wje-button.js +352 -0
  33. package/dist/wje-button.js.map +1 -0
  34. package/dist/wje-card-content.js +48 -0
  35. package/dist/wje-card-content.js.map +1 -0
  36. package/dist/wje-card-controls.js +48 -0
  37. package/dist/wje-card-controls.js.map +1 -0
  38. package/dist/wje-card-header.js +48 -0
  39. package/dist/wje-card-header.js.map +1 -0
  40. package/dist/wje-card-subtitle.js +55 -0
  41. package/dist/wje-card-subtitle.js.map +1 -0
  42. package/dist/wje-card-title.js +55 -0
  43. package/dist/wje-card-title.js.map +1 -0
  44. package/dist/wje-card.js +56 -0
  45. package/dist/wje-card.js.map +1 -0
  46. package/dist/wje-carousel-item.js +63 -0
  47. package/dist/wje-carousel-item.js.map +1 -0
  48. package/dist/wje-carousel.js +380 -0
  49. package/dist/wje-carousel.js.map +1 -0
  50. package/dist/wje-checkbox.js +540 -0
  51. package/dist/wje-checkbox.js.map +1 -0
  52. package/dist/wje-chip.js +76 -0
  53. package/dist/wje-chip.js.map +1 -0
  54. package/dist/wje-col.js +38 -0
  55. package/dist/wje-col.js.map +1 -0
  56. package/dist/wje-color-picker.js +1339 -0
  57. package/dist/wje-color-picker.js.map +1 -0
  58. package/dist/wje-container.js +56 -0
  59. package/dist/wje-container.js.map +1 -0
  60. package/dist/wje-copy-button.js +218 -0
  61. package/dist/wje-copy-button.js.map +1 -0
  62. package/dist/wje-dialog.js +249 -0
  63. package/dist/wje-dialog.js.map +1 -0
  64. package/dist/wje-divider.js +55 -0
  65. package/dist/wje-divider.js.map +1 -0
  66. package/dist/wje-dropdown.js +194 -0
  67. package/dist/wje-dropdown.js.map +1 -0
  68. package/dist/wje-element.js +967 -0
  69. package/dist/wje-element.js.map +1 -0
  70. package/dist/wje-fetchAndParseCSS.js +60 -0
  71. package/dist/wje-fetchAndParseCSS.js.map +1 -0
  72. package/dist/wje-file-upload-item.js +140 -0
  73. package/dist/wje-file-upload-item.js.map +1 -0
  74. package/dist/wje-file-upload.js +552 -0
  75. package/dist/wje-file-upload.js.map +1 -0
  76. package/dist/wje-footer.js +52 -0
  77. package/dist/wje-footer.js.map +1 -0
  78. package/dist/wje-form.js +53 -0
  79. package/dist/wje-form.js.map +1 -0
  80. package/dist/wje-format-digital.js +146 -0
  81. package/dist/wje-format-digital.js.map +1 -0
  82. package/dist/wje-grid.js +54 -0
  83. package/dist/wje-grid.js.map +1 -0
  84. package/dist/wje-header.js +56 -0
  85. package/dist/wje-header.js.map +1 -0
  86. package/dist/wje-icon-picker.js +349 -0
  87. package/dist/wje-icon-picker.js.map +1 -0
  88. package/dist/wje-icon.js +191 -0
  89. package/dist/wje-icon.js.map +1 -0
  90. package/dist/wje-img-comparer.js +131 -0
  91. package/dist/wje-img-comparer.js.map +1 -0
  92. package/dist/wje-img.js +80 -0
  93. package/dist/wje-img.js.map +1 -0
  94. package/dist/wje-infinite-scroll.js +6 -0
  95. package/dist/wje-infinite-scroll.js.map +1 -0
  96. package/dist/wje-input-file.js +111 -0
  97. package/dist/wje-input-file.js.map +1 -0
  98. package/dist/wje-input.js +452 -0
  99. package/dist/wje-input.js.map +1 -0
  100. package/dist/wje-item.js +88 -0
  101. package/dist/wje-item.js.map +1 -0
  102. package/dist/wje-kanban.js +462 -0
  103. package/dist/wje-kanban.js.map +1 -0
  104. package/dist/wje-label.js +53 -0
  105. package/dist/wje-label.js.map +1 -0
  106. package/dist/wje-list.js +6 -0
  107. package/dist/wje-list.js.map +1 -0
  108. package/dist/wje-main.js +52 -0
  109. package/dist/wje-main.js.map +1 -0
  110. package/dist/wje-masonry.js +267 -0
  111. package/dist/wje-masonry.js.map +1 -0
  112. package/dist/wje-master.js +687 -0
  113. package/dist/wje-master.js.map +1 -0
  114. package/dist/wje-menu-button.js +60 -0
  115. package/dist/wje-menu-button.js.map +1 -0
  116. package/dist/wje-menu-item.js +545 -0
  117. package/dist/wje-menu-item.js.map +1 -0
  118. package/dist/wje-menu-label.js +55 -0
  119. package/dist/wje-menu-label.js.map +1 -0
  120. package/dist/wje-menu.js +72 -0
  121. package/dist/wje-menu.js.map +1 -0
  122. package/dist/wje-option.js +112 -0
  123. package/dist/wje-option.js.map +1 -0
  124. package/dist/wje-options.js +355 -0
  125. package/dist/wje-options.js.map +1 -0
  126. package/dist/wje-orgchart-group.js +72 -0
  127. package/dist/wje-orgchart-group.js.map +1 -0
  128. package/dist/wje-orgchart-item.js +98 -0
  129. package/dist/wje-orgchart-item.js.map +1 -0
  130. package/dist/wje-orgchart.js +49 -0
  131. package/dist/wje-orgchart.js.map +1 -0
  132. package/dist/wje-popup.js +6 -0
  133. package/dist/wje-popup.js.map +1 -0
  134. package/dist/wje-progress-bar.js +213 -0
  135. package/dist/wje-progress-bar.js.map +1 -0
  136. package/dist/wje-qr-code.js +2892 -0
  137. package/dist/wje-qr-code.js.map +1 -0
  138. package/dist/wje-radio-group.js +228 -0
  139. package/dist/wje-radio-group.js.map +1 -0
  140. package/dist/wje-radio.js +106 -0
  141. package/dist/wje-radio.js.map +1 -0
  142. package/dist/wje-rate.js +300 -0
  143. package/dist/wje-rate.js.map +1 -0
  144. package/dist/wje-relative-time.js +115 -0
  145. package/dist/wje-relative-time.js.map +1 -0
  146. package/dist/wje-reorder-dropzone.js +49 -0
  147. package/dist/wje-reorder-dropzone.js.map +1 -0
  148. package/dist/wje-reorder-handle.js +218 -0
  149. package/dist/wje-reorder-handle.js.map +1 -0
  150. package/dist/wje-reorder-item.js +61 -0
  151. package/dist/wje-reorder-item.js.map +1 -0
  152. package/dist/wje-reorder.js +281 -0
  153. package/dist/wje-reorder.js.map +1 -0
  154. package/dist/wje-route.js +43 -0
  155. package/dist/wje-route.js.map +1 -0
  156. package/dist/wje-router-link.js +64 -0
  157. package/dist/wje-router-link.js.map +1 -0
  158. package/dist/wje-router-outlet.js +192 -0
  159. package/dist/wje-router-outlet.js.map +1 -0
  160. package/dist/wje-routerx.js +1437 -0
  161. package/dist/wje-routerx.js.map +1 -0
  162. package/dist/wje-row.js +49 -0
  163. package/dist/wje-row.js.map +1 -0
  164. package/dist/wje-select.js +630 -0
  165. package/dist/wje-select.js.map +1 -0
  166. package/dist/wje-slider.js +221 -0
  167. package/dist/wje-slider.js.map +1 -0
  168. package/dist/wje-sliding-container.js +474 -0
  169. package/dist/wje-sliding-container.js.map +1 -0
  170. package/dist/wje-split-view.js +153 -0
  171. package/dist/wje-split-view.js.map +1 -0
  172. package/dist/wje-status.js +61 -0
  173. package/dist/wje-status.js.map +1 -0
  174. package/dist/wje-step.js +50 -0
  175. package/dist/wje-step.js.map +1 -0
  176. package/dist/wje-stepper.js +231 -0
  177. package/dist/wje-stepper.js.map +1 -0
  178. package/dist/wje-store.js +401 -0
  179. package/dist/wje-store.js.map +1 -0
  180. package/dist/wje-tab-group.js +137 -0
  181. package/dist/wje-tab-group.js.map +1 -0
  182. package/dist/wje-tab-panel.js +46 -0
  183. package/dist/wje-tab-panel.js.map +1 -0
  184. package/dist/wje-tab.js +59 -0
  185. package/dist/wje-tab.js.map +1 -0
  186. package/dist/wje-textarea.js +373 -0
  187. package/dist/wje-textarea.js.map +1 -0
  188. package/dist/wje-thumbnail.js +54 -0
  189. package/dist/wje-thumbnail.js.map +1 -0
  190. package/dist/wje-toast.js +334 -0
  191. package/dist/wje-toast.js.map +1 -0
  192. package/dist/wje-toggle.js +125 -0
  193. package/dist/wje-toggle.js.map +1 -0
  194. package/dist/wje-toolbar-action.js +72 -0
  195. package/dist/wje-toolbar-action.js.map +1 -0
  196. package/dist/wje-toolbar.js +63 -0
  197. package/dist/wje-toolbar.js.map +1 -0
  198. package/dist/wje-tooltip.js +166 -0
  199. package/dist/wje-tooltip.js.map +1 -0
  200. package/dist/wje-visually-hidden.js +55 -0
  201. package/dist/wje-visually-hidden.js.map +1 -0
  202. package/package.json +1 -1
@@ -0,0 +1,1339 @@
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) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import WJElement, { event } from "./wje-element.js";
5
+ function _typeof(obj) {
6
+ "@babel/helpers - typeof";
7
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
8
+ return typeof obj2;
9
+ } : function(obj2) {
10
+ return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
11
+ }, _typeof(obj);
12
+ }
13
+ var trimLeft = /^\s+/;
14
+ var trimRight = /\s+$/;
15
+ function tinycolor(color, opts) {
16
+ color = color ? color : "";
17
+ opts = opts || {};
18
+ if (color instanceof tinycolor) {
19
+ return color;
20
+ }
21
+ if (!(this instanceof tinycolor)) {
22
+ return new tinycolor(color, opts);
23
+ }
24
+ var rgb = inputToRGB(color);
25
+ 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;
26
+ this._gradientType = opts.gradientType;
27
+ if (this._r < 1) this._r = Math.round(this._r);
28
+ if (this._g < 1) this._g = Math.round(this._g);
29
+ if (this._b < 1) this._b = Math.round(this._b);
30
+ this._ok = rgb.ok;
31
+ }
32
+ tinycolor.prototype = {
33
+ isDark: function isDark() {
34
+ return this.getBrightness() < 128;
35
+ },
36
+ isLight: function isLight() {
37
+ return !this.isDark();
38
+ },
39
+ isValid: function isValid() {
40
+ return this._ok;
41
+ },
42
+ getOriginalInput: function getOriginalInput() {
43
+ return this._originalInput;
44
+ },
45
+ getFormat: function getFormat() {
46
+ return this._format;
47
+ },
48
+ getAlpha: function getAlpha() {
49
+ return this._a;
50
+ },
51
+ getBrightness: function getBrightness() {
52
+ var rgb = this.toRgb();
53
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
54
+ },
55
+ getLuminance: function getLuminance() {
56
+ var rgb = this.toRgb();
57
+ var RsRGB, GsRGB, BsRGB, R, G, B;
58
+ RsRGB = rgb.r / 255;
59
+ GsRGB = rgb.g / 255;
60
+ BsRGB = rgb.b / 255;
61
+ if (RsRGB <= 0.03928) R = RsRGB / 12.92;
62
+ else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
63
+ if (GsRGB <= 0.03928) G = GsRGB / 12.92;
64
+ else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
65
+ if (BsRGB <= 0.03928) B = BsRGB / 12.92;
66
+ else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
67
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
68
+ },
69
+ setAlpha: function setAlpha(value) {
70
+ this._a = boundAlpha(value);
71
+ this._roundA = Math.round(100 * this._a) / 100;
72
+ return this;
73
+ },
74
+ toHsv: function toHsv() {
75
+ var hsv = rgbToHsv(this._r, this._g, this._b);
76
+ return {
77
+ h: hsv.h * 360,
78
+ s: hsv.s,
79
+ v: hsv.v,
80
+ a: this._a
81
+ };
82
+ },
83
+ toHsvString: function toHsvString() {
84
+ var hsv = rgbToHsv(this._r, this._g, this._b);
85
+ var h = Math.round(hsv.h * 360), s = Math.round(hsv.s * 100), v = Math.round(hsv.v * 100);
86
+ return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
87
+ },
88
+ toHsl: function toHsl() {
89
+ var hsl = rgbToHsl(this._r, this._g, this._b);
90
+ return {
91
+ h: hsl.h * 360,
92
+ s: hsl.s,
93
+ l: hsl.l,
94
+ a: this._a
95
+ };
96
+ },
97
+ toHslString: function toHslString() {
98
+ var hsl = rgbToHsl(this._r, this._g, this._b);
99
+ var h = Math.round(hsl.h * 360), s = Math.round(hsl.s * 100), l = Math.round(hsl.l * 100);
100
+ return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
101
+ },
102
+ toHex: function toHex(allow3Char) {
103
+ return rgbToHex(this._r, this._g, this._b, allow3Char);
104
+ },
105
+ toHexString: function toHexString(allow3Char) {
106
+ return "#" + this.toHex(allow3Char);
107
+ },
108
+ toHex8: function toHex8(allow4Char) {
109
+ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
110
+ },
111
+ toHex8String: function toHex8String(allow4Char) {
112
+ return "#" + this.toHex8(allow4Char);
113
+ },
114
+ toRgb: function toRgb() {
115
+ return {
116
+ r: Math.round(this._r),
117
+ g: Math.round(this._g),
118
+ b: Math.round(this._b),
119
+ a: this._a
120
+ };
121
+ },
122
+ toRgbString: function toRgbString() {
123
+ 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 + ")";
124
+ },
125
+ toPercentageRgb: function toPercentageRgb() {
126
+ return {
127
+ r: Math.round(bound01(this._r, 255) * 100) + "%",
128
+ g: Math.round(bound01(this._g, 255) * 100) + "%",
129
+ b: Math.round(bound01(this._b, 255) * 100) + "%",
130
+ a: this._a
131
+ };
132
+ },
133
+ toPercentageRgbString: function toPercentageRgbString() {
134
+ 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 + ")";
135
+ },
136
+ toName: function toName() {
137
+ if (this._a === 0) {
138
+ return "transparent";
139
+ }
140
+ if (this._a < 1) {
141
+ return false;
142
+ }
143
+ return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
144
+ },
145
+ toFilter: function toFilter(secondColor) {
146
+ var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
147
+ var secondHex8String = hex8String;
148
+ var gradientType = this._gradientType ? "GradientType = 1, " : "";
149
+ if (secondColor) {
150
+ var s = tinycolor(secondColor);
151
+ secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
152
+ }
153
+ return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
154
+ },
155
+ toString: function toString(format) {
156
+ var formatSet = !!format;
157
+ format = format || this._format;
158
+ var formattedString = false;
159
+ var hasAlpha = this._a < 1 && this._a >= 0;
160
+ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
161
+ if (needsAlphaFormat) {
162
+ if (format === "name" && this._a === 0) {
163
+ return this.toName();
164
+ }
165
+ return this.toRgbString();
166
+ }
167
+ if (format === "rgb") {
168
+ formattedString = this.toRgbString();
169
+ }
170
+ if (format === "prgb") {
171
+ formattedString = this.toPercentageRgbString();
172
+ }
173
+ if (format === "hex" || format === "hex6") {
174
+ formattedString = this.toHexString();
175
+ }
176
+ if (format === "hex3") {
177
+ formattedString = this.toHexString(true);
178
+ }
179
+ if (format === "hex4") {
180
+ formattedString = this.toHex8String(true);
181
+ }
182
+ if (format === "hex8") {
183
+ formattedString = this.toHex8String();
184
+ }
185
+ if (format === "name") {
186
+ formattedString = this.toName();
187
+ }
188
+ if (format === "hsl") {
189
+ formattedString = this.toHslString();
190
+ }
191
+ if (format === "hsv") {
192
+ formattedString = this.toHsvString();
193
+ }
194
+ return formattedString || this.toHexString();
195
+ },
196
+ clone: function clone() {
197
+ return tinycolor(this.toString());
198
+ },
199
+ _applyModification: function _applyModification(fn, args) {
200
+ var color = fn.apply(null, [this].concat([].slice.call(args)));
201
+ this._r = color._r;
202
+ this._g = color._g;
203
+ this._b = color._b;
204
+ this.setAlpha(color._a);
205
+ return this;
206
+ },
207
+ lighten: function lighten() {
208
+ return this._applyModification(_lighten, arguments);
209
+ },
210
+ brighten: function brighten() {
211
+ return this._applyModification(_brighten, arguments);
212
+ },
213
+ darken: function darken() {
214
+ return this._applyModification(_darken, arguments);
215
+ },
216
+ desaturate: function desaturate() {
217
+ return this._applyModification(_desaturate, arguments);
218
+ },
219
+ saturate: function saturate() {
220
+ return this._applyModification(_saturate, arguments);
221
+ },
222
+ greyscale: function greyscale() {
223
+ return this._applyModification(_greyscale, arguments);
224
+ },
225
+ spin: function spin() {
226
+ return this._applyModification(_spin, arguments);
227
+ },
228
+ _applyCombination: function _applyCombination(fn, args) {
229
+ return fn.apply(null, [this].concat([].slice.call(args)));
230
+ },
231
+ analogous: function analogous() {
232
+ return this._applyCombination(_analogous, arguments);
233
+ },
234
+ complement: function complement() {
235
+ return this._applyCombination(_complement, arguments);
236
+ },
237
+ monochromatic: function monochromatic() {
238
+ return this._applyCombination(_monochromatic, arguments);
239
+ },
240
+ splitcomplement: function splitcomplement() {
241
+ return this._applyCombination(_splitcomplement, arguments);
242
+ },
243
+ // Disabled until https://github.com/bgrins/TinyColor/issues/254
244
+ // polyad: function (number) {
245
+ // return this._applyCombination(polyad, [number]);
246
+ // },
247
+ triad: function triad() {
248
+ return this._applyCombination(polyad, [3]);
249
+ },
250
+ tetrad: function tetrad() {
251
+ return this._applyCombination(polyad, [4]);
252
+ }
253
+ };
254
+ tinycolor.fromRatio = function(color, opts) {
255
+ if (_typeof(color) == "object") {
256
+ var newColor = {};
257
+ for (var i in color) {
258
+ if (color.hasOwnProperty(i)) {
259
+ if (i === "a") {
260
+ newColor[i] = color[i];
261
+ } else {
262
+ newColor[i] = convertToPercentage(color[i]);
263
+ }
264
+ }
265
+ }
266
+ color = newColor;
267
+ }
268
+ return tinycolor(color, opts);
269
+ };
270
+ function inputToRGB(color) {
271
+ var rgb = {
272
+ r: 0,
273
+ g: 0,
274
+ b: 0
275
+ };
276
+ var a = 1;
277
+ var s = null;
278
+ var v = null;
279
+ var l = null;
280
+ var ok = false;
281
+ var format = false;
282
+ if (typeof color == "string") {
283
+ color = stringInputToObject(color);
284
+ }
285
+ if (_typeof(color) == "object") {
286
+ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
287
+ rgb = rgbToRgb(color.r, color.g, color.b);
288
+ ok = true;
289
+ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
290
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
291
+ s = convertToPercentage(color.s);
292
+ v = convertToPercentage(color.v);
293
+ rgb = hsvToRgb(color.h, s, v);
294
+ ok = true;
295
+ format = "hsv";
296
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
297
+ s = convertToPercentage(color.s);
298
+ l = convertToPercentage(color.l);
299
+ rgb = hslToRgb(color.h, s, l);
300
+ ok = true;
301
+ format = "hsl";
302
+ }
303
+ if (color.hasOwnProperty("a")) {
304
+ a = color.a;
305
+ }
306
+ }
307
+ a = boundAlpha(a);
308
+ return {
309
+ ok,
310
+ format: color.format || format,
311
+ r: Math.min(255, Math.max(rgb.r, 0)),
312
+ g: Math.min(255, Math.max(rgb.g, 0)),
313
+ b: Math.min(255, Math.max(rgb.b, 0)),
314
+ a
315
+ };
316
+ }
317
+ function rgbToRgb(r, g, b) {
318
+ return {
319
+ r: bound01(r, 255) * 255,
320
+ g: bound01(g, 255) * 255,
321
+ b: bound01(b, 255) * 255
322
+ };
323
+ }
324
+ function rgbToHsl(r, g, b) {
325
+ r = bound01(r, 255);
326
+ g = bound01(g, 255);
327
+ b = bound01(b, 255);
328
+ var max = Math.max(r, g, b), min = Math.min(r, g, b);
329
+ var h, s, l = (max + min) / 2;
330
+ if (max == min) {
331
+ h = s = 0;
332
+ } else {
333
+ var d = max - min;
334
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
335
+ switch (max) {
336
+ case r:
337
+ h = (g - b) / d + (g < b ? 6 : 0);
338
+ break;
339
+ case g:
340
+ h = (b - r) / d + 2;
341
+ break;
342
+ case b:
343
+ h = (r - g) / d + 4;
344
+ break;
345
+ }
346
+ h /= 6;
347
+ }
348
+ return {
349
+ h,
350
+ s,
351
+ l
352
+ };
353
+ }
354
+ function hslToRgb(h, s, l) {
355
+ var r, g, b;
356
+ h = bound01(h, 360);
357
+ s = bound01(s, 100);
358
+ l = bound01(l, 100);
359
+ function hue2rgb(p2, q2, t) {
360
+ if (t < 0) t += 1;
361
+ if (t > 1) t -= 1;
362
+ if (t < 1 / 6) return p2 + (q2 - p2) * 6 * t;
363
+ if (t < 1 / 2) return q2;
364
+ if (t < 2 / 3) return p2 + (q2 - p2) * (2 / 3 - t) * 6;
365
+ return p2;
366
+ }
367
+ if (s === 0) {
368
+ r = g = b = l;
369
+ } else {
370
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
371
+ var p = 2 * l - q;
372
+ r = hue2rgb(p, q, h + 1 / 3);
373
+ g = hue2rgb(p, q, h);
374
+ b = hue2rgb(p, q, h - 1 / 3);
375
+ }
376
+ return {
377
+ r: r * 255,
378
+ g: g * 255,
379
+ b: b * 255
380
+ };
381
+ }
382
+ function rgbToHsv(r, g, b) {
383
+ r = bound01(r, 255);
384
+ g = bound01(g, 255);
385
+ b = bound01(b, 255);
386
+ var max = Math.max(r, g, b), min = Math.min(r, g, b);
387
+ var h, s, v = max;
388
+ var d = max - min;
389
+ s = max === 0 ? 0 : d / max;
390
+ if (max == min) {
391
+ h = 0;
392
+ } else {
393
+ switch (max) {
394
+ case r:
395
+ h = (g - b) / d + (g < b ? 6 : 0);
396
+ break;
397
+ case g:
398
+ h = (b - r) / d + 2;
399
+ break;
400
+ case b:
401
+ h = (r - g) / d + 4;
402
+ break;
403
+ }
404
+ h /= 6;
405
+ }
406
+ return {
407
+ h,
408
+ s,
409
+ v
410
+ };
411
+ }
412
+ function hsvToRgb(h, s, v) {
413
+ h = bound01(h, 360) * 6;
414
+ s = bound01(s, 100);
415
+ v = bound01(v, 100);
416
+ 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];
417
+ return {
418
+ r: r * 255,
419
+ g: g * 255,
420
+ b: b * 255
421
+ };
422
+ }
423
+ function rgbToHex(r, g, b, allow3Char) {
424
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
425
+ 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)) {
426
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
427
+ }
428
+ return hex.join("");
429
+ }
430
+ function rgbaToHex(r, g, b, a, allow4Char) {
431
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
432
+ 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)) {
433
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
434
+ }
435
+ return hex.join("");
436
+ }
437
+ function rgbaToArgbHex(r, g, b, a) {
438
+ var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
439
+ return hex.join("");
440
+ }
441
+ tinycolor.equals = function(color1, color2) {
442
+ if (!color1 || !color2) return false;
443
+ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
444
+ };
445
+ tinycolor.random = function() {
446
+ return tinycolor.fromRatio({
447
+ r: Math.random(),
448
+ g: Math.random(),
449
+ b: Math.random()
450
+ });
451
+ };
452
+ function _desaturate(color, amount) {
453
+ amount = amount === 0 ? 0 : amount || 10;
454
+ var hsl = tinycolor(color).toHsl();
455
+ hsl.s -= amount / 100;
456
+ hsl.s = clamp01(hsl.s);
457
+ return tinycolor(hsl);
458
+ }
459
+ function _saturate(color, amount) {
460
+ amount = amount === 0 ? 0 : amount || 10;
461
+ var hsl = tinycolor(color).toHsl();
462
+ hsl.s += amount / 100;
463
+ hsl.s = clamp01(hsl.s);
464
+ return tinycolor(hsl);
465
+ }
466
+ function _greyscale(color) {
467
+ return tinycolor(color).desaturate(100);
468
+ }
469
+ function _lighten(color, amount) {
470
+ amount = amount === 0 ? 0 : amount || 10;
471
+ var hsl = tinycolor(color).toHsl();
472
+ hsl.l += amount / 100;
473
+ hsl.l = clamp01(hsl.l);
474
+ return tinycolor(hsl);
475
+ }
476
+ function _brighten(color, amount) {
477
+ amount = amount === 0 ? 0 : amount || 10;
478
+ var rgb = tinycolor(color).toRgb();
479
+ rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
480
+ rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
481
+ rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
482
+ return tinycolor(rgb);
483
+ }
484
+ function _darken(color, amount) {
485
+ amount = amount === 0 ? 0 : amount || 10;
486
+ var hsl = tinycolor(color).toHsl();
487
+ hsl.l -= amount / 100;
488
+ hsl.l = clamp01(hsl.l);
489
+ return tinycolor(hsl);
490
+ }
491
+ function _spin(color, amount) {
492
+ var hsl = tinycolor(color).toHsl();
493
+ var hue = (hsl.h + amount) % 360;
494
+ hsl.h = hue < 0 ? 360 + hue : hue;
495
+ return tinycolor(hsl);
496
+ }
497
+ function _complement(color) {
498
+ var hsl = tinycolor(color).toHsl();
499
+ hsl.h = (hsl.h + 180) % 360;
500
+ return tinycolor(hsl);
501
+ }
502
+ function polyad(color, number) {
503
+ if (isNaN(number) || number <= 0) {
504
+ throw new Error("Argument to polyad must be a positive number");
505
+ }
506
+ var hsl = tinycolor(color).toHsl();
507
+ var result = [tinycolor(color)];
508
+ var step = 360 / number;
509
+ for (var i = 1; i < number; i++) {
510
+ result.push(tinycolor({
511
+ h: (hsl.h + i * step) % 360,
512
+ s: hsl.s,
513
+ l: hsl.l
514
+ }));
515
+ }
516
+ return result;
517
+ }
518
+ function _splitcomplement(color) {
519
+ var hsl = tinycolor(color).toHsl();
520
+ var h = hsl.h;
521
+ return [tinycolor(color), tinycolor({
522
+ h: (h + 72) % 360,
523
+ s: hsl.s,
524
+ l: hsl.l
525
+ }), tinycolor({
526
+ h: (h + 216) % 360,
527
+ s: hsl.s,
528
+ l: hsl.l
529
+ })];
530
+ }
531
+ function _analogous(color, results, slices) {
532
+ results = results || 6;
533
+ slices = slices || 30;
534
+ var hsl = tinycolor(color).toHsl();
535
+ var part = 360 / slices;
536
+ var ret = [tinycolor(color)];
537
+ for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
538
+ hsl.h = (hsl.h + part) % 360;
539
+ ret.push(tinycolor(hsl));
540
+ }
541
+ return ret;
542
+ }
543
+ function _monochromatic(color, results) {
544
+ results = results || 6;
545
+ var hsv = tinycolor(color).toHsv();
546
+ var h = hsv.h, s = hsv.s, v = hsv.v;
547
+ var ret = [];
548
+ var modification = 1 / results;
549
+ while (results--) {
550
+ ret.push(tinycolor({
551
+ h,
552
+ s,
553
+ v
554
+ }));
555
+ v = (v + modification) % 1;
556
+ }
557
+ return ret;
558
+ }
559
+ tinycolor.mix = function(color1, color2, amount) {
560
+ amount = amount === 0 ? 0 : amount || 50;
561
+ var rgb1 = tinycolor(color1).toRgb();
562
+ var rgb2 = tinycolor(color2).toRgb();
563
+ var p = amount / 100;
564
+ var rgba = {
565
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
566
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
567
+ b: (rgb2.b - rgb1.b) * p + rgb1.b,
568
+ a: (rgb2.a - rgb1.a) * p + rgb1.a
569
+ };
570
+ return tinycolor(rgba);
571
+ };
572
+ tinycolor.readability = function(color1, color2) {
573
+ var c1 = tinycolor(color1);
574
+ var c2 = tinycolor(color2);
575
+ return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
576
+ };
577
+ tinycolor.isReadable = function(color1, color2, wcag2) {
578
+ var readability = tinycolor.readability(color1, color2);
579
+ var wcag2Parms, out;
580
+ out = false;
581
+ wcag2Parms = validateWCAG2Parms(wcag2);
582
+ switch (wcag2Parms.level + wcag2Parms.size) {
583
+ case "AAsmall":
584
+ case "AAAlarge":
585
+ out = readability >= 4.5;
586
+ break;
587
+ case "AAlarge":
588
+ out = readability >= 3;
589
+ break;
590
+ case "AAAsmall":
591
+ out = readability >= 7;
592
+ break;
593
+ }
594
+ return out;
595
+ };
596
+ tinycolor.mostReadable = function(baseColor, colorList, args) {
597
+ var bestColor = null;
598
+ var bestScore = 0;
599
+ var readability;
600
+ var includeFallbackColors, level, size;
601
+ args = args || {};
602
+ includeFallbackColors = args.includeFallbackColors;
603
+ level = args.level;
604
+ size = args.size;
605
+ for (var i = 0; i < colorList.length; i++) {
606
+ readability = tinycolor.readability(baseColor, colorList[i]);
607
+ if (readability > bestScore) {
608
+ bestScore = readability;
609
+ bestColor = tinycolor(colorList[i]);
610
+ }
611
+ }
612
+ if (tinycolor.isReadable(baseColor, bestColor, {
613
+ level,
614
+ size
615
+ }) || !includeFallbackColors) {
616
+ return bestColor;
617
+ } else {
618
+ args.includeFallbackColors = false;
619
+ return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
620
+ }
621
+ };
622
+ var names = tinycolor.names = {
623
+ aliceblue: "f0f8ff",
624
+ antiquewhite: "faebd7",
625
+ aqua: "0ff",
626
+ aquamarine: "7fffd4",
627
+ azure: "f0ffff",
628
+ beige: "f5f5dc",
629
+ bisque: "ffe4c4",
630
+ black: "000",
631
+ blanchedalmond: "ffebcd",
632
+ blue: "00f",
633
+ blueviolet: "8a2be2",
634
+ brown: "a52a2a",
635
+ burlywood: "deb887",
636
+ burntsienna: "ea7e5d",
637
+ cadetblue: "5f9ea0",
638
+ chartreuse: "7fff00",
639
+ chocolate: "d2691e",
640
+ coral: "ff7f50",
641
+ cornflowerblue: "6495ed",
642
+ cornsilk: "fff8dc",
643
+ crimson: "dc143c",
644
+ cyan: "0ff",
645
+ darkblue: "00008b",
646
+ darkcyan: "008b8b",
647
+ darkgoldenrod: "b8860b",
648
+ darkgray: "a9a9a9",
649
+ darkgreen: "006400",
650
+ darkgrey: "a9a9a9",
651
+ darkkhaki: "bdb76b",
652
+ darkmagenta: "8b008b",
653
+ darkolivegreen: "556b2f",
654
+ darkorange: "ff8c00",
655
+ darkorchid: "9932cc",
656
+ darkred: "8b0000",
657
+ darksalmon: "e9967a",
658
+ darkseagreen: "8fbc8f",
659
+ darkslateblue: "483d8b",
660
+ darkslategray: "2f4f4f",
661
+ darkslategrey: "2f4f4f",
662
+ darkturquoise: "00ced1",
663
+ darkviolet: "9400d3",
664
+ deeppink: "ff1493",
665
+ deepskyblue: "00bfff",
666
+ dimgray: "696969",
667
+ dimgrey: "696969",
668
+ dodgerblue: "1e90ff",
669
+ firebrick: "b22222",
670
+ floralwhite: "fffaf0",
671
+ forestgreen: "228b22",
672
+ fuchsia: "f0f",
673
+ gainsboro: "dcdcdc",
674
+ ghostwhite: "f8f8ff",
675
+ gold: "ffd700",
676
+ goldenrod: "daa520",
677
+ gray: "808080",
678
+ green: "008000",
679
+ greenyellow: "adff2f",
680
+ grey: "808080",
681
+ honeydew: "f0fff0",
682
+ hotpink: "ff69b4",
683
+ indianred: "cd5c5c",
684
+ indigo: "4b0082",
685
+ ivory: "fffff0",
686
+ khaki: "f0e68c",
687
+ lavender: "e6e6fa",
688
+ lavenderblush: "fff0f5",
689
+ lawngreen: "7cfc00",
690
+ lemonchiffon: "fffacd",
691
+ lightblue: "add8e6",
692
+ lightcoral: "f08080",
693
+ lightcyan: "e0ffff",
694
+ lightgoldenrodyellow: "fafad2",
695
+ lightgray: "d3d3d3",
696
+ lightgreen: "90ee90",
697
+ lightgrey: "d3d3d3",
698
+ lightpink: "ffb6c1",
699
+ lightsalmon: "ffa07a",
700
+ lightseagreen: "20b2aa",
701
+ lightskyblue: "87cefa",
702
+ lightslategray: "789",
703
+ lightslategrey: "789",
704
+ lightsteelblue: "b0c4de",
705
+ lightyellow: "ffffe0",
706
+ lime: "0f0",
707
+ limegreen: "32cd32",
708
+ linen: "faf0e6",
709
+ magenta: "f0f",
710
+ maroon: "800000",
711
+ mediumaquamarine: "66cdaa",
712
+ mediumblue: "0000cd",
713
+ mediumorchid: "ba55d3",
714
+ mediumpurple: "9370db",
715
+ mediumseagreen: "3cb371",
716
+ mediumslateblue: "7b68ee",
717
+ mediumspringgreen: "00fa9a",
718
+ mediumturquoise: "48d1cc",
719
+ mediumvioletred: "c71585",
720
+ midnightblue: "191970",
721
+ mintcream: "f5fffa",
722
+ mistyrose: "ffe4e1",
723
+ moccasin: "ffe4b5",
724
+ navajowhite: "ffdead",
725
+ navy: "000080",
726
+ oldlace: "fdf5e6",
727
+ olive: "808000",
728
+ olivedrab: "6b8e23",
729
+ orange: "ffa500",
730
+ orangered: "ff4500",
731
+ orchid: "da70d6",
732
+ palegoldenrod: "eee8aa",
733
+ palegreen: "98fb98",
734
+ paleturquoise: "afeeee",
735
+ palevioletred: "db7093",
736
+ papayawhip: "ffefd5",
737
+ peachpuff: "ffdab9",
738
+ peru: "cd853f",
739
+ pink: "ffc0cb",
740
+ plum: "dda0dd",
741
+ powderblue: "b0e0e6",
742
+ purple: "800080",
743
+ rebeccapurple: "663399",
744
+ red: "f00",
745
+ rosybrown: "bc8f8f",
746
+ royalblue: "4169e1",
747
+ saddlebrown: "8b4513",
748
+ salmon: "fa8072",
749
+ sandybrown: "f4a460",
750
+ seagreen: "2e8b57",
751
+ seashell: "fff5ee",
752
+ sienna: "a0522d",
753
+ silver: "c0c0c0",
754
+ skyblue: "87ceeb",
755
+ slateblue: "6a5acd",
756
+ slategray: "708090",
757
+ slategrey: "708090",
758
+ snow: "fffafa",
759
+ springgreen: "00ff7f",
760
+ steelblue: "4682b4",
761
+ tan: "d2b48c",
762
+ teal: "008080",
763
+ thistle: "d8bfd8",
764
+ tomato: "ff6347",
765
+ turquoise: "40e0d0",
766
+ violet: "ee82ee",
767
+ wheat: "f5deb3",
768
+ white: "fff",
769
+ whitesmoke: "f5f5f5",
770
+ yellow: "ff0",
771
+ yellowgreen: "9acd32"
772
+ };
773
+ var hexNames = tinycolor.hexNames = flip(names);
774
+ function flip(o) {
775
+ var flipped = {};
776
+ for (var i in o) {
777
+ if (o.hasOwnProperty(i)) {
778
+ flipped[o[i]] = i;
779
+ }
780
+ }
781
+ return flipped;
782
+ }
783
+ function boundAlpha(a) {
784
+ a = parseFloat(a);
785
+ if (isNaN(a) || a < 0 || a > 1) {
786
+ a = 1;
787
+ }
788
+ return a;
789
+ }
790
+ function bound01(n, max) {
791
+ if (isOnePointZero(n)) n = "100%";
792
+ var processPercent = isPercentage(n);
793
+ n = Math.min(max, Math.max(0, parseFloat(n)));
794
+ if (processPercent) {
795
+ n = parseInt(n * max, 10) / 100;
796
+ }
797
+ if (Math.abs(n - max) < 1e-6) {
798
+ return 1;
799
+ }
800
+ return n % max / parseFloat(max);
801
+ }
802
+ function clamp01(val) {
803
+ return Math.min(1, Math.max(0, val));
804
+ }
805
+ function parseIntFromHex(val) {
806
+ return parseInt(val, 16);
807
+ }
808
+ function isOnePointZero(n) {
809
+ return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
810
+ }
811
+ function isPercentage(n) {
812
+ return typeof n === "string" && n.indexOf("%") != -1;
813
+ }
814
+ function pad2(c) {
815
+ return c.length == 1 ? "0" + c : "" + c;
816
+ }
817
+ function convertToPercentage(n) {
818
+ if (n <= 1) {
819
+ n = n * 100 + "%";
820
+ }
821
+ return n;
822
+ }
823
+ function convertDecimalToHex(d) {
824
+ return Math.round(parseFloat(d) * 255).toString(16);
825
+ }
826
+ function convertHexToDecimal(h) {
827
+ return parseIntFromHex(h) / 255;
828
+ }
829
+ var matchers = function() {
830
+ var CSS_INTEGER = "[-\\+]?\\d+%?";
831
+ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
832
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
833
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
834
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
835
+ return {
836
+ CSS_UNIT: new RegExp(CSS_UNIT),
837
+ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
838
+ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
839
+ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
840
+ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
841
+ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
842
+ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
843
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
844
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
845
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
846
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
847
+ };
848
+ }();
849
+ function isValidCSSUnit(color) {
850
+ return !!matchers.CSS_UNIT.exec(color);
851
+ }
852
+ function stringInputToObject(color) {
853
+ color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
854
+ var named = false;
855
+ if (names[color]) {
856
+ color = names[color];
857
+ named = true;
858
+ } else if (color == "transparent") {
859
+ return {
860
+ r: 0,
861
+ g: 0,
862
+ b: 0,
863
+ a: 0,
864
+ format: "name"
865
+ };
866
+ }
867
+ var match;
868
+ if (match = matchers.rgb.exec(color)) {
869
+ return {
870
+ r: match[1],
871
+ g: match[2],
872
+ b: match[3]
873
+ };
874
+ }
875
+ if (match = matchers.rgba.exec(color)) {
876
+ return {
877
+ r: match[1],
878
+ g: match[2],
879
+ b: match[3],
880
+ a: match[4]
881
+ };
882
+ }
883
+ if (match = matchers.hsl.exec(color)) {
884
+ return {
885
+ h: match[1],
886
+ s: match[2],
887
+ l: match[3]
888
+ };
889
+ }
890
+ if (match = matchers.hsla.exec(color)) {
891
+ return {
892
+ h: match[1],
893
+ s: match[2],
894
+ l: match[3],
895
+ a: match[4]
896
+ };
897
+ }
898
+ if (match = matchers.hsv.exec(color)) {
899
+ return {
900
+ h: match[1],
901
+ s: match[2],
902
+ v: match[3]
903
+ };
904
+ }
905
+ if (match = matchers.hsva.exec(color)) {
906
+ return {
907
+ h: match[1],
908
+ s: match[2],
909
+ v: match[3],
910
+ a: match[4]
911
+ };
912
+ }
913
+ if (match = matchers.hex8.exec(color)) {
914
+ return {
915
+ r: parseIntFromHex(match[1]),
916
+ g: parseIntFromHex(match[2]),
917
+ b: parseIntFromHex(match[3]),
918
+ a: convertHexToDecimal(match[4]),
919
+ format: named ? "name" : "hex8"
920
+ };
921
+ }
922
+ if (match = matchers.hex6.exec(color)) {
923
+ return {
924
+ r: parseIntFromHex(match[1]),
925
+ g: parseIntFromHex(match[2]),
926
+ b: parseIntFromHex(match[3]),
927
+ format: named ? "name" : "hex"
928
+ };
929
+ }
930
+ if (match = matchers.hex4.exec(color)) {
931
+ return {
932
+ r: parseIntFromHex(match[1] + "" + match[1]),
933
+ g: parseIntFromHex(match[2] + "" + match[2]),
934
+ b: parseIntFromHex(match[3] + "" + match[3]),
935
+ a: convertHexToDecimal(match[4] + "" + match[4]),
936
+ format: named ? "name" : "hex8"
937
+ };
938
+ }
939
+ if (match = matchers.hex3.exec(color)) {
940
+ return {
941
+ r: parseIntFromHex(match[1] + "" + match[1]),
942
+ g: parseIntFromHex(match[2] + "" + match[2]),
943
+ b: parseIntFromHex(match[3] + "" + match[3]),
944
+ format: named ? "name" : "hex"
945
+ };
946
+ }
947
+ return false;
948
+ }
949
+ function validateWCAG2Parms(parms) {
950
+ var level, size;
951
+ parms = parms || {
952
+ level: "AA",
953
+ size: "small"
954
+ };
955
+ level = (parms.level || "AA").toUpperCase();
956
+ size = (parms.size || "small").toLowerCase();
957
+ if (level !== "AA" && level !== "AAA") {
958
+ level = "AA";
959
+ }
960
+ if (size !== "small" && size !== "large") {
961
+ size = "small";
962
+ }
963
+ return {
964
+ level,
965
+ size
966
+ };
967
+ }
968
+ const styles = "/*\n[ Wj Color Picker ]\n*/\n\n.anchor {\n width: var(--wje-color-picker-size);\n height: var(--wje-color-picker-size);\n background: var(--wje-color-picker-value);\n}\n\n.picker {\n width: 200px;\n min-height: 90px;\n box-shadow:\n 0 0 5px rgba(0, 0, 0, 0.05),\n 0 5px 20px rgba(0, 0, 0, 0.1);\n border-radius: var(--wje-border-radius-small);\n border-width: 1px;\n border-style: var(--wje-border-style);\n border-color: var(--wje-border-color);\n background: var(--wje-background);\n}\n\n.color-area {\n display: block;\n position: relative;\n height: 100px;\n color: var(--wje-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(--wje-color-picker-radius) var(--wje-color-picker-radius) 0 0;\n border-bottom: 1px solid var(--wje-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(\n to right,\n rgb(255, 0, 0) 0%,\n rgb(255, 255, 0) 17%,\n rgb(0, 255, 0) 33%,\n rgb(0, 255, 255) 50%,\n rgb(0, 0, 255) 67%,\n rgb(255, 0, 255) 83%,\n rgb(255, 0, 0) 100%\n );\n width: 100%;\n height: 8px;\n margin: 0.75rem 0 1rem;\n}\n\n.hue::part(slider) {\n --wje-slider-color: transparent;\n --wje-slider-thumb-color: white;\n --wje-slider-thumb-shadow: 0 0 0 1px var(--wje-border-color);\n --wje-slider-thumb-shadow-active: var(--wje-slider-thumb-shadow);\n --wje-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),\n repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa);\n background-position:\n 0 0,\n 4px 4px;\n background-size: 8px 8px;\n}\n\n.alpha {\n color: var(--wje-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 --wje-slider-color: transparent;\n --wje-slider-thumb-color: white;\n --wje-slider-thumb-shadow: 0 0 0 1px var(--wje-border-color);\n --wje-slider-thumb-shadow-active: var(--wje-slider-thumb-shadow);\n --wje-slider-track-color: transparent;\n --wje-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 &:before,\n &: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 &:before {\n background-image: repeating-linear-gradient(45deg, #aaa 25%, transparent 25%, transparent 75%, #aaa 75%, #aaa),\n repeating-linear-gradient(45deg, #aaa 25%, #fff 25%, #fff 75%, #aaa 75%, #aaa);\n background-position:\n 0 0,\n 4px 4px;\n background-size: 8px 8px;\n }\n &:after {\n background: var(--wje-color-picker-value, transparent);\n }\n}\n\nwje-input {\n --wje-input-border-radius: 1rem;\n --wje-input-margin-bottom: 0;\n}\n\nwje-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(--wje-color-picker-swatch, transparent);\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(--wje-color-picker-value, transparent);\n cursor: pointer;\n}\n";
969
+ class ColorPicker extends WJElement {
970
+ /**
971
+ * ColorPicker constructor method.
972
+ */
973
+ constructor() {
974
+ super();
975
+ __publicField(this, "className", "ColorPicker");
976
+ /**
977
+ * Moves the marker to the given position.
978
+ * @param e
979
+ */
980
+ __publicField(this, "moveMarker", (e) => {
981
+ this.colorAreaDimension = this.dimension();
982
+ const pointer = this.getPointerPosition(e);
983
+ let x = pointer.pageX - this.colorAreaDimension.x;
984
+ let y = pointer.pageY - this.colorAreaDimension.y;
985
+ this.setColor(this.setColorAtPosition(x, y), "marker");
986
+ this.setMarkerPosition(x, y);
987
+ });
988
+ /**
989
+ * Sets the marker position by color.
990
+ * @param color
991
+ * @returns {{x: number, y: number}}
992
+ */
993
+ __publicField(this, "setMarkerPositionByColor", (color = "red") => {
994
+ let hsva = tinycolor(color).toHsv();
995
+ return {
996
+ x: this.colorAreaDimension.width * hsva.s,
997
+ y: this.colorAreaDimension.height - this.colorAreaDimension.height * hsva.v
998
+ };
999
+ });
1000
+ /**
1001
+ * Updates the color picker's current color and its associated UI elements.
1002
+ * @param {tinycolor.Instance|null} [color] The color value to set. If null, the current value from the input field is used.
1003
+ * @param {string} [type] The type of action determining which UI element to update. Possible values: "marker", "hue", "alpha", "swatch".
1004
+ */
1005
+ __publicField(this, "setColor", (color = null, type = "") => {
1006
+ let currentColor = color;
1007
+ if (currentColor === null && type === "") {
1008
+ currentColor = tinycolor(this.input.value);
1009
+ this.colorArea.style.setProperty("--wje-color-picker-area", currentColor.toHexString());
1010
+ }
1011
+ if (type === "marker") {
1012
+ this.alphaSlider.value = 100;
1013
+ this.alphaSlider.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1014
+ this.colorPreview.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
1015
+ this.picker.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1016
+ this.marker.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
1017
+ }
1018
+ if (type === "hue") {
1019
+ let markerColorByPosition = this.setColorAtPosition(
1020
+ this.markerPosition.x,
1021
+ this.markerPosition.y,
1022
+ this.alphaSlider.value
1023
+ );
1024
+ currentColor = tinycolor(this.getHSVA(this.hueSlider.value, this.alphaSlider.value));
1025
+ this.colorPreview.style.setProperty("--wje-color-picker-value", markerColorByPosition.toHex8String());
1026
+ this.marker.style.setProperty("--wje-color-picker-value", markerColorByPosition.toHexString());
1027
+ this.alphaSlider.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1028
+ this.colorArea.style.setProperty("--wje-color-picker-area", currentColor.toHexString());
1029
+ this.input.value = markerColorByPosition.toHex8String();
1030
+ }
1031
+ if (type === "alpha") {
1032
+ currentColor = tinycolor(this.input.value);
1033
+ let hsv = currentColor.toHsv();
1034
+ hsv.a = this.alphaSlider.value / 100;
1035
+ currentColor = tinycolor(hsv);
1036
+ this.colorPreview.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
1037
+ }
1038
+ if (type === "swatch") {
1039
+ this.colorPreview.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
1040
+ this.marker.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1041
+ this.alphaSlider.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1042
+ this.colorArea.style.setProperty("--wje-color-picker-area", currentColor.toHex8String());
1043
+ this.markerPosition = this.setMarkerPositionByColor(currentColor.toHex8String());
1044
+ this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y);
1045
+ }
1046
+ this.input.value = currentColor.toHex8String();
1047
+ this.anchor.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
1048
+ this.value = {
1049
+ hex8: currentColor.toHex8String(),
1050
+ hex: currentColor.toHexString(),
1051
+ rgb: currentColor.toRgbString(),
1052
+ rgba: currentColor.toRgbString(),
1053
+ hsl: currentColor.toHslString(),
1054
+ hsla: currentColor.toHslString(),
1055
+ hsv: currentColor.toHsvString(),
1056
+ hsva: currentColor.toHsvString(),
1057
+ name: currentColor.toName(),
1058
+ format: currentColor.getFormat()
1059
+ };
1060
+ event.dispatchCustomEvent(this, "wje-color-picker:select", this.value);
1061
+ });
1062
+ /**
1063
+ * Sets the hue.
1064
+ * @param {object} e The event object.
1065
+ */
1066
+ __publicField(this, "setHue", (e) => {
1067
+ this.hueSlider.value = e.detail.value;
1068
+ this.setColor(null, "hue");
1069
+ });
1070
+ /**
1071
+ * Sets the alpha.
1072
+ * @param {object} e The event object.
1073
+ */
1074
+ __publicField(this, "setAlpha", (e) => {
1075
+ this.alphaSlider.value = e.detail.value;
1076
+ this.setColor(null, "alpha");
1077
+ });
1078
+ /**
1079
+ * Converts hue and alpha values into an HSVA color string.
1080
+ * @param {number} hue The hue value, typically between 0 and 360.
1081
+ * @param {number} alpha The alpha value, typically between 0 and 100, representing the opacity percentage.
1082
+ * @returns {string} - The HSVA color string in the format `hsva(h, 100%, 100%, a)`.
1083
+ */
1084
+ __publicField(this, "getH");
1085
+ __publicField(this, "getHSVA", (hue, alpha) => {
1086
+ return `hsva(${hue}, 100%, 100%, ${alpha / 100})`;
1087
+ });
1088
+ this._markerPosition = {
1089
+ markerX: "0",
1090
+ markerY: "0"
1091
+ };
1092
+ this._swatches = [
1093
+ "#264653",
1094
+ "#2a9d8f",
1095
+ "#e9c46a",
1096
+ "rgb(244,162,97)",
1097
+ "#e76f51",
1098
+ "#d62828",
1099
+ "navy",
1100
+ "#07b",
1101
+ "#0096c7",
1102
+ "#00b4d880",
1103
+ "rgba(0,119,182,0.8)"
1104
+ ];
1105
+ }
1106
+ /**
1107
+ * Setter for the marker position.
1108
+ * @param {object} value The new marker position.
1109
+ */
1110
+ set markerPosition(value) {
1111
+ this._markerPosition = value;
1112
+ }
1113
+ /**
1114
+ * Getter for the marker position.
1115
+ * @returns {object} The current marker position.
1116
+ */
1117
+ get markerPosition() {
1118
+ return this._markerPosition;
1119
+ }
1120
+ /**
1121
+ * Setter for the color swatches.
1122
+ * @param {string} value The new color swatches.
1123
+ */
1124
+ set swatches(value) {
1125
+ this.setAttribute("swatches", value.split(","));
1126
+ }
1127
+ /**
1128
+ * Getter for the color swatches.
1129
+ * @returns {Array} The current color swatches.
1130
+ */
1131
+ get swatches() {
1132
+ return this._swatches;
1133
+ }
1134
+ /**
1135
+ * Getter for the CSS stylesheet.
1136
+ * @returns {object} The styles object.
1137
+ * @static
1138
+ */
1139
+ static get cssStyleSheet() {
1140
+ return styles;
1141
+ }
1142
+ /**
1143
+ * Getter for the observed attributes.
1144
+ * @returns {Array} An empty array.
1145
+ * @static
1146
+ */
1147
+ static get observedAttributes() {
1148
+ return [];
1149
+ }
1150
+ /**
1151
+ * Sets up the attributes for the ColorPicker.
1152
+ */
1153
+ setupAttributes() {
1154
+ this.isShadowRoot = "open";
1155
+ }
1156
+ /**
1157
+ * Draws the ColorPicker element.
1158
+ * @returns {DocumentFragment} The created document fragment.
1159
+ */
1160
+ draw() {
1161
+ let fragment = document.createDocumentFragment();
1162
+ let native = document.createElement("div");
1163
+ native.classList.add("native-color-picker");
1164
+ let anchor = document.createElement("div");
1165
+ anchor.setAttribute("slot", "anchor");
1166
+ anchor.setAttribute("part", "anchor");
1167
+ anchor.classList.add("anchor");
1168
+ let picker = document.createElement("div");
1169
+ picker.classList.add("picker");
1170
+ let marker = document.createElement("div");
1171
+ marker.classList.add("marker");
1172
+ let colorArea = document.createElement("div");
1173
+ colorArea.classList.add("color-area");
1174
+ colorArea.addEventListener("click", this.moveMarker);
1175
+ let wrapper = document.createElement("div");
1176
+ wrapper.classList.add("wrapper");
1177
+ let hueSlider = document.createElement("wje-slider");
1178
+ hueSlider.setAttribute("min", "0");
1179
+ hueSlider.setAttribute("max", "360");
1180
+ hueSlider.classList.add("hue");
1181
+ hueSlider.addEventListener("wje-slider:move", this.setHue);
1182
+ let alphaWrapper = document.createElement("div");
1183
+ alphaWrapper.classList.add("alpha-wrapper");
1184
+ let alphaSlider = document.createElement("wje-slider");
1185
+ alphaSlider.setAttribute("min", "0");
1186
+ alphaSlider.setAttribute("max", "100");
1187
+ alphaSlider.setAttribute("value", "50");
1188
+ alphaSlider.classList.add("alpha");
1189
+ alphaSlider.addEventListener("wje-slider:move", this.setAlpha);
1190
+ let inputWrapper = document.createElement("div");
1191
+ inputWrapper.classList.add("input-wrapper");
1192
+ let colorPreview = document.createElement("div");
1193
+ colorPreview.classList.add("color-preview");
1194
+ let input = document.createElement("wje-input");
1195
+ input.classList.add("input");
1196
+ input.setAttribute("variant", "standard");
1197
+ input.value = "#ff0000";
1198
+ colorArea.appendChild(marker);
1199
+ alphaWrapper.appendChild(alphaSlider);
1200
+ inputWrapper.appendChild(colorPreview);
1201
+ inputWrapper.appendChild(input);
1202
+ wrapper.appendChild(hueSlider);
1203
+ wrapper.appendChild(alphaWrapper);
1204
+ wrapper.appendChild(inputWrapper);
1205
+ picker.appendChild(colorArea);
1206
+ picker.appendChild(wrapper);
1207
+ this.createSwatches(wrapper);
1208
+ let popup = document.createElement("wje-popup");
1209
+ popup.setAttribute("placement", this.placement || "bottom-start");
1210
+ popup.setAttribute("offset", this.offset);
1211
+ popup.setAttribute("manual", "");
1212
+ popup.appendChild(anchor);
1213
+ popup.appendChild(picker);
1214
+ native.appendChild(popup);
1215
+ fragment.appendChild(native);
1216
+ this.popup = popup;
1217
+ this.anchor = anchor;
1218
+ this.picker = picker;
1219
+ this.marker = marker;
1220
+ this.colorArea = colorArea;
1221
+ this.hueSlider = hueSlider;
1222
+ this.alphaSlider = alphaSlider;
1223
+ this.colorPreview = colorPreview;
1224
+ this.input = input;
1225
+ return fragment;
1226
+ }
1227
+ /**
1228
+ * Sets the hue.
1229
+ * @param node
1230
+ */
1231
+ createSwatches(node) {
1232
+ if (this.swatches.length === 0) return;
1233
+ let swatches = document.createElement("div");
1234
+ swatches.classList.add("swatches");
1235
+ this.swatches.forEach((swatch) => {
1236
+ let button = document.createElement("button");
1237
+ button.classList.add("swatch");
1238
+ button.style.setProperty("--wje-color-picker-swatch", swatch);
1239
+ button.addEventListener("click", (e) => {
1240
+ this.setSliders(swatch);
1241
+ this.setColor(tinycolor(swatch), "swatch");
1242
+ });
1243
+ swatches.appendChild(button);
1244
+ });
1245
+ node.appendChild(swatches);
1246
+ }
1247
+ /**
1248
+ * Sets up the event listeners for the ColorPicker.
1249
+ */
1250
+ afterDraw() {
1251
+ this.init = false;
1252
+ this.addEventListener("wje-popup:show", (e) => {
1253
+ if (!this.init) {
1254
+ window.setTimeout(() => {
1255
+ this.colorAreaDimension = this.dimension();
1256
+ this.markerPosition = this.setMarkerPositionByColor(this.input.value);
1257
+ this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y);
1258
+ if (this.input.value !== "") this.alphaSlider.value = 100;
1259
+ this.setColor();
1260
+ }, 0);
1261
+ this.init = true;
1262
+ }
1263
+ });
1264
+ }
1265
+ /**
1266
+ * Sets the sliders to the given color.
1267
+ * @param color
1268
+ */
1269
+ setSliders(color) {
1270
+ let hsva = tinycolor(color).toHsv();
1271
+ this.hueSlider.value = hsva.h;
1272
+ this.alphaSlider.value = hsva.a * 100;
1273
+ }
1274
+ /**
1275
+ * Gets the dimensions of the color area.
1276
+ * @returns {{width: *, x: *, y: *, height: *}}
1277
+ */
1278
+ dimension() {
1279
+ return {
1280
+ width: this.colorArea.offsetWidth,
1281
+ height: this.colorArea.offsetHeight,
1282
+ x: this.colorArea.offsetLeft,
1283
+ y: this.colorArea.offsetTop
1284
+ };
1285
+ }
1286
+ /**
1287
+ * Disconnects the ColorPicker.
1288
+ */
1289
+ beforeDisconnect() {
1290
+ this.init = false;
1291
+ }
1292
+ /**
1293
+ * Sets the hue.
1294
+ * @param e
1295
+ * @returns {{pageY: (*|number), pageX: (*|number)}}
1296
+ */
1297
+ getPointerPosition(e) {
1298
+ return {
1299
+ pageX: e.changedTouches ? e.changedTouches[0].pageX : e.clientX,
1300
+ pageY: e.changedTouches ? e.changedTouches[0].pageY : e.clientY
1301
+ };
1302
+ }
1303
+ /**
1304
+ * Sets the position of the marker.
1305
+ * @param x
1306
+ * @param y
1307
+ */
1308
+ setMarkerPosition(x, y) {
1309
+ x = x < 0 ? 0 : x > this.colorAreaDimension.width ? this.colorAreaDimension.width : x;
1310
+ y = y < 0 ? 0 : y > this.colorAreaDimension.height ? this.colorAreaDimension.height : y;
1311
+ this.markerPosition = {
1312
+ x,
1313
+ y
1314
+ };
1315
+ this.marker.style.left = `${x}px`;
1316
+ this.marker.style.top = `${y}px`;
1317
+ }
1318
+ /**
1319
+ * Sets the color at the given position.
1320
+ * @param x
1321
+ * @param y
1322
+ * @param alpha
1323
+ * @returns {*|tinycolor}
1324
+ */
1325
+ setColorAtPosition(x, y, alpha = 100) {
1326
+ const hsva = {
1327
+ h: this.hueSlider.value * 1,
1328
+ s: x / this.colorAreaDimension.width * 100,
1329
+ v: 100 - y / this.colorAreaDimension.height * 100,
1330
+ a: alpha / 100
1331
+ };
1332
+ return tinycolor(hsva);
1333
+ }
1334
+ }
1335
+ WJElement.define("wje-color-picker", ColorPicker);
1336
+ export {
1337
+ ColorPicker as default
1338
+ };
1339
+ //# sourceMappingURL=wje-color-picker.js.map