@nebularstreams/libmui 2.0.12 → 2.0.14

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.
@@ -0,0 +1,1371 @@
1
+ /*! colorjoe - v4.1.1 - Juho Vepsalainen <bebraw@gmail.com> - MIT
2
+ https://bebraw.github.com/colorjoe - 2020-01-27 */
3
+ (function (global, factory) {
4
+ typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() :
5
+ typeof define === "function" && define.amd ? define(factory) :
6
+ (global.colorjoe = factory());
7
+ }(this, (function () {
8
+ "use strict";
9
+
10
+ var commonjsGlobal = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
11
+
12
+ function createCommonjsModule(fn, module) {
13
+ return module = {exports: {}}, fn(module, module.exports), module.exports;
14
+ }
15
+
16
+ var dragjs_umd = createCommonjsModule(function (module, exports) {
17
+ (function (root, factory) {
18
+
19
+ {
20
+ module.exports = factory();
21
+ }
22
+
23
+ }(commonjsGlobal, function () {
24
+
25
+ /*! dragjs - v0.8.0 - Juho Vepsalainen <bebraw@gmail.com> - MIT
26
+ https://bebraw.github.com/dragjs - 2018-07-03 */
27
+ var drag = (function () {
28
+ function drag(elem, cbs) {
29
+ if (!elem) {
30
+ console.warn("drag is missing elem!");
31
+ return;
32
+ }
33
+
34
+ dragTemplate(elem, cbs, "touchstart", "touchmove", "touchend");
35
+ dragTemplate(elem, cbs, "mousedown", "mousemove", "mouseup");
36
+ }
37
+
38
+ function xyslider(o) {
39
+ var twod = div(o["class"] || "", o.parent);
40
+ var pointer = div("pointer", twod);
41
+ div("shape shape1", pointer);
42
+ div("shape shape2", pointer);
43
+ div("bg bg1", twod);
44
+ div("bg bg2", twod);
45
+
46
+ drag(twod, attachPointer(o.cbs, pointer));
47
+
48
+ return {
49
+ background: twod,
50
+ pointer: pointer
51
+ };
52
+ }
53
+
54
+ function slider(o) {
55
+ var oned = div(o["class"], o.parent);
56
+ var pointer = div("pointer", oned);
57
+ div("shape", pointer);
58
+ div("bg", oned);
59
+
60
+ drag(oned, attachPointer(o.cbs, pointer));
61
+
62
+ return {
63
+ background: oned,
64
+ pointer: pointer
65
+ };
66
+ }
67
+
68
+ drag.xyslider = xyslider;
69
+ drag.slider = slider;
70
+
71
+ return drag;
72
+
73
+ function attachPointer(cbs, pointer) {
74
+ var ret = {};
75
+
76
+ for (var n in cbs) {
77
+ ret[n] = wrap(cbs[n]);
78
+ }
79
+
80
+ function wrap(fn) {
81
+ return function (p) {
82
+ p.pointer = pointer;
83
+ fn(p);
84
+ };
85
+ }
86
+
87
+ return ret;
88
+ }
89
+
90
+ // move to elemutils lib?
91
+ function div(klass, p) {
92
+ return e("div", klass, p);
93
+ }
94
+
95
+ function e(type, klass, p) {
96
+ var elem = document.createElement(type);
97
+ if (klass) {
98
+ elem.className = klass;
99
+ }
100
+ p.appendChild(elem);
101
+
102
+ return elem;
103
+ }
104
+
105
+ function dragTemplate(elem, cbs, down, move, up) {
106
+
107
+ cbs = getCbs(cbs);
108
+
109
+ var beginCb = cbs.begin;
110
+ var changeCb = cbs.change;
111
+ var endCb = cbs.end;
112
+
113
+ on(elem, down, function (e) {
114
+
115
+ var moveHandler = partial(callCb, changeCb, elem);
116
+
117
+ function upHandler() {
118
+
119
+ off(document, move, moveHandler);
120
+ off(document, up, upHandler);
121
+
122
+ callCb(endCb, elem, e);
123
+ }
124
+
125
+ on(document, move, moveHandler);
126
+ on(document, up, upHandler);
127
+
128
+ callCb(beginCb, elem, e);
129
+ });
130
+ }
131
+
132
+ // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection
133
+ function on(elem, evt, handler) {
134
+ // Test via a getter in the options object to see if the passive property is accessed
135
+ var supportsPassive = false;
136
+ try {
137
+ var opts = Object.defineProperty({}, "passive", {
138
+ get: function () {
139
+ supportsPassive = true;
140
+ }
141
+ });
142
+ window.addEventListener("testPassive", null, opts);
143
+ window.removeEventListener("testPassive", null, opts);
144
+ } catch (e) {
145
+ }
146
+
147
+ elem.addEventListener(evt, handler, supportsPassive ? {passive: false} : false);
148
+ }
149
+
150
+ function off(elem, evt, handler) {
151
+ elem.removeEventListener(evt, handler, false);
152
+ }
153
+
154
+ function getCbs(cbs) {
155
+ if (!cbs) {
156
+ var initialOffset;
157
+ var initialPos;
158
+
159
+ return {
160
+ begin: function (c) {
161
+ initialOffset = {x: c.elem.offsetLeft, y: c.elem.offsetTop};
162
+ initialPos = c.cursor;
163
+ },
164
+ change: function (c) {
165
+ style(c.elem, "left", (initialOffset.x + c.cursor.x - initialPos.x) + "px");
166
+ style(c.elem, "top", (initialOffset.y + c.cursor.y - initialPos.y) + "px");
167
+ },
168
+ end: empty
169
+ };
170
+ } else {
171
+ return {
172
+ begin: cbs.begin || empty,
173
+ change: cbs.change || empty,
174
+ end: cbs.end || empty
175
+ };
176
+ }
177
+ }
178
+
179
+ // TODO: set draggable class (handy for fx)
180
+ function style(e, prop, value) {
181
+ e.style[prop] = value;
182
+ }
183
+
184
+ function empty() {
185
+ }
186
+
187
+ function callCb(cb, elem, e) {
188
+ e.preventDefault();
189
+
190
+ var offset = findPos(elem);
191
+ var width = elem.clientWidth * (window.SCALE || 1);
192
+ var height = elem.clientHeight * (window.SCALE || 1);
193
+ var cursor = {
194
+ x: cursorX(elem, e),
195
+ y: cursorY(elem, e)
196
+ };
197
+ var x = (cursor.x - offset.x) / width;
198
+ var y = (cursor.y - offset.y) / height;
199
+
200
+ cb({
201
+ x: isNaN(x) ? 0 : x,
202
+ y: isNaN(y) ? 0 : y,
203
+ cursor: cursor,
204
+ elem: elem,
205
+ e: e
206
+ });
207
+ }
208
+
209
+ // http://stackoverflow.com/questions/4394747/javascript-curry-function
210
+ function partial(fn) {
211
+ var slice = Array.prototype.slice;
212
+ var args = slice.apply(arguments, [1]);
213
+
214
+ return function () {
215
+ return fn.apply(null, args.concat(slice.apply(arguments)));
216
+ };
217
+ }
218
+
219
+ // http://www.quirksmode.org/js/findpos.html
220
+ function findPos(e) {
221
+ var r = e.getBoundingClientRect();
222
+
223
+ return {
224
+ x: r.left,
225
+ y: r.top
226
+ };
227
+ }
228
+
229
+ // http://javascript.about.com/library/blmousepos.htm
230
+ function cursorX(elem, evt) {
231
+ var evtPos = evt.touches ? evt.touches[evt.touches.length - 1] : evt;
232
+ return Math.floor(evtPos.clientX);
233
+ }
234
+
235
+ function cursorY(elem, evt) {
236
+ var evtPos = evt.touches ? evt.touches[evt.touches.length - 1] : evt;
237
+ return Math.floor(evtPos.clientY);
238
+ }
239
+ })();
240
+ return drag;
241
+
242
+ }));
243
+ });
244
+
245
+ var oneColorAll = createCommonjsModule(function (module, exports) {
246
+ !function (e, a) {
247
+ module.exports = a();
248
+ }(commonjsGlobal,
249
+ function () {
250
+ function e(a) {
251
+ if (Array.isArray(a)) {
252
+ if ("string" == typeof a[0] && "function" == typeof e[a[0]]) return new e[a[0]](a.slice(1, a.length));
253
+ if (4 === a.length) return new e.RGB(a[0] / 255, a[1] / 255, a[2] / 255, a[3] / 255);
254
+ } else if ("string" == typeof a) {
255
+ var r = a.toLowerCase();
256
+ e.namedColors[r] && (a = "#" + e.namedColors[r]), "transparent" === r && (a = "rgba(0,0,0,0)");
257
+ var o = a.match(i);
258
+ if (o) {
259
+ var s = o[1].toUpperCase(),
260
+ f = t(o[8]) ? o[8] : parseFloat(o[8]),
261
+ u = "H" === s[0],
262
+ l = o[3] ? 100 : u ? 360 : 255,
263
+ h = o[5] || u ? 100 : 255,
264
+ c = o[7] || u ? 100 : 255;
265
+ if (t(e[s])) throw new Error("color." + s + " is not installed.");
266
+ return new e[s](parseFloat(o[2]) / l, parseFloat(o[4]) / h, parseFloat(o[6]) / c, f);
267
+ }
268
+ a.length < 6 && (a = a.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i, "$1$1$2$2$3$3"));
269
+ var d = a.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);
270
+ if (d) return new e.RGB(parseInt(d[1], 16) / 255, parseInt(d[2], 16) / 255, parseInt(d[3], 16) / 255);
271
+ if (e.CMYK) {
272
+ var b = a.match(new RegExp("^cmyk\\(" + n.source + "," + n.source + "," + n.source + "," + n.source + "\\)$", "i"));
273
+ if (b) return new e.CMYK(parseFloat(b[1]) / 100, parseFloat(b[2]) / 100, parseFloat(b[3]) / 100, parseFloat(b[4]) / 100);
274
+ }
275
+ } else if ("object" == typeof a && a.isColor) return a;
276
+ return !1;
277
+ }
278
+
279
+ var a = [],
280
+ t = function (e) {
281
+ return void 0 === e;
282
+ },
283
+ r = /\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,
284
+ n = /\s*(\.\d+|100|\d?\d(?:\.\d+)?)%\s*/,
285
+ i = new RegExp("^(rgb|hsl|hsv)a?\\(" + r.source + "," + r.source + "," + r.source + "(?:," + /\s*(\.\d+|\d+(?:\.\d+)?)\s*/.source + ")?\\)$", "i");
286
+ e.namedColors = {}, e.installColorSpace = function (r, n, i) {
287
+ function o(a, t) {
288
+ var r = {};
289
+ r[t.toLowerCase()] = function () {
290
+ return this.rgb()[t.toLowerCase()]();
291
+ }, e[t].propertyNames.forEach(function (e) {
292
+ var a = "black" === e ? "k" : e.charAt(0);
293
+ r[e] = r[a] = function (a, r) {
294
+ return this[t.toLowerCase()]()[e](a, r);
295
+ };
296
+ });
297
+ for (var n in r) r.hasOwnProperty(n) && void 0 === e[a].prototype[n] && (e[a].prototype[n] = r[n]);
298
+ }
299
+
300
+ e[r] = function (e) {
301
+ var a = Array.isArray(e) ? e : arguments;
302
+ n.forEach(function (e, t) {
303
+ var i = a[t];
304
+ if ("alpha" === e) {
305
+ this._alpha = isNaN(i) || i > 1 ? 1 : i < 0 ? 0 : i;
306
+ } else {
307
+ if (isNaN(i)) throw new Error("[" + r + "]: Invalid color: (" + n.join(",") + ")");
308
+ "hue" === e ? this._hue = i < 0 ? i - Math.floor(i) : i % 1 : this["_" + e] = i < 0 ? 0 : i > 1 ? 1 : i;
309
+ }
310
+ }, this);
311
+ }, e[r].propertyNames = n;
312
+ var s = e[r].prototype;
313
+ ["valueOf", "hex", "hexa", "css", "cssa"].forEach(function (e) {
314
+ s[e] = s[e] || ("RGB" === r ? s.hex : function () {
315
+ return this.rgb()[e]();
316
+ });
317
+ }), s.isColor = !0, s.equals = function (e, a) {
318
+ t(a) && (a = 1e-10), e = e[r.toLowerCase()]();
319
+ for (var i = 0; i < n.length; i += 1) if (Math.abs(this["_" + n[i]] - e["_" + n[i]]) > a) return !1;
320
+ return !0;
321
+ }, s.toJSON = function () {
322
+ return [r].concat(n.map(function (e) {
323
+ return this["_" + e];
324
+ }, this));
325
+ };
326
+ for (var f in i) {
327
+ if (i.hasOwnProperty(f)) {
328
+ var u = f.match(/^from(.*)$/);
329
+ u ? e[u[1].toUpperCase()].prototype[r.toLowerCase()] = i[f] : s[f] = i[f];
330
+ }
331
+ }
332
+ return s[r.toLowerCase()] = function () {
333
+ return this;
334
+ }, s.toString = function () {
335
+ return "[" + r + " " + n.map(function (e) {
336
+ return this["_" + e];
337
+ }, this)
338
+ .join(", ") + "]";
339
+ }, n.forEach(function (e) {
340
+ var a = "black" === e ? "k" : e.charAt(0);
341
+ s[e] = s[a] = function (a, t) {
342
+ return void 0 === a ? this["_" + e] : t ? new this.constructor(n.map(function (t) {
343
+ return this["_" + t] + (e === t ? a : 0);
344
+ }, this)) : new this.constructor(n.map(function (t) {
345
+ return e === t ? a : this["_" + t];
346
+ }, this));
347
+ };
348
+ }), a.forEach(function (e) {
349
+ o(r, e), o(e, r);
350
+ }), a.push(r), e;
351
+ }, e.pluginList = [], e.use = function (a) {
352
+ return -1 === e.pluginList.indexOf(a) && (this.pluginList.push(a), a(e)), e;
353
+ }, e.installMethod = function (t, r) {
354
+ return a.forEach(function (a) {
355
+ e[a].prototype[t] = r;
356
+ }), this;
357
+ }, e.installColorSpace("RGB", ["red", "green", "blue", "alpha"], {
358
+ hex: function () {
359
+ var e = (65536 * Math.round(255 * this._red) + 256 * Math.round(255 * this._green) + Math.round(255 * this._blue)).toString(16);
360
+ return "#" + "00000".substr(0, 6 - e.length) + e;
361
+ }, hexa: function () {
362
+ var e = Math.round(255 * this._alpha)
363
+ .toString(16);
364
+ return "#" + "00".substr(0, 2 - e.length) + e + this.hex()
365
+ .substr(1, 6);
366
+ }, css: function () {
367
+ return "rgb(" + Math.round(255 * this._red) + "," + Math.round(255 * this._green) + "," + Math.round(255 * this._blue) + ")";
368
+ }, cssa: function () {
369
+ return "rgba(" + Math.round(255 * this._red) + "," + Math.round(255 * this._green) + "," + Math.round(255 * this._blue) + "," + this._alpha + ")";
370
+ }
371
+ });
372
+ var o = e,
373
+ s = function (e) {
374
+ e.installColorSpace("XYZ", ["x", "y", "z", "alpha"], {
375
+ fromRgb: function () {
376
+ var a = function (e) {
377
+ return e > .04045 ? Math.pow((e + .055) / 1.055, 2.4) : e / 12.92;
378
+ },
379
+ t = a(this._red),
380
+ r = a(this._green),
381
+ n = a(this._blue);
382
+ return new e.XYZ(.4124564 * t + .3575761 * r + .1804375 * n, .2126729 * t + .7151522 * r + .072175 * n, .0193339 * t + .119192 * r + .9503041 * n,
383
+ this._alpha);
384
+ }, rgb: function () {
385
+ var a = this._x,
386
+ t = this._y,
387
+ r = this._z,
388
+ n = function (e) {
389
+ return e > .0031308 ? 1.055 * Math.pow(e, 1 / 2.4) - .055 : 12.92 * e;
390
+ };
391
+ return new e.RGB(n(3.2404542 * a + -1.5371385 * t + -.4985314 * r), n(-.969266 * a + 1.8760108 * t + .041556 * r),
392
+ n(.0556434 * a + -.2040259 * t + 1.0572252 * r), this._alpha);
393
+ }, lab: function () {
394
+ var a = function (e) {
395
+ return e > .008856 ? Math.pow(e, 1 / 3) : 7.787037 * e + 4 / 29;
396
+ },
397
+ t = a(this._x / 95.047),
398
+ r = a(this._y / 100),
399
+ n = a(this._z / 108.883);
400
+ return new e.LAB(116 * r - 16, 500 * (t - r), 200 * (r - n), this._alpha);
401
+ }
402
+ });
403
+ },
404
+ f = function (e) {
405
+ e.use(s), e.installColorSpace("LAB", ["l", "a", "b", "alpha"], {
406
+ fromRgb: function () {
407
+ return this.xyz()
408
+ .lab();
409
+ }, rgb: function () {
410
+ return this.xyz()
411
+ .rgb();
412
+ }, xyz: function () {
413
+ var a = function (e) {
414
+ var a = Math.pow(e, 3);
415
+ return a > .008856 ? a : (e - 16 / 116) / 7.87;
416
+ },
417
+ t = (this._l + 16) / 116,
418
+ r = this._a / 500 + t,
419
+ n = t - this._b / 200;
420
+ return new e.XYZ(95.047 * a(r), 100 * a(t), 108.883 * a(n), this._alpha);
421
+ }
422
+ });
423
+ },
424
+ u = function (e) {
425
+ e.installColorSpace("HSV", ["hue", "saturation", "value", "alpha"], {
426
+ rgb: function () {
427
+ var a,
428
+ t,
429
+ r,
430
+ n = this._hue,
431
+ i = this._saturation,
432
+ o = this._value,
433
+ s = Math.min(5, Math.floor(6 * n)),
434
+ f = 6 * n - s,
435
+ u = o * (1 - i),
436
+ l = o * (1 - f * i),
437
+ h = o * (1 - (1 - f) * i);
438
+ switch (s) {
439
+ case 0:
440
+ a = o, t = h, r = u;
441
+ break;
442
+ case 1:
443
+ a = l, t = o, r = u;
444
+ break;
445
+ case 2:
446
+ a = u, t = o, r = h;
447
+ break;
448
+ case 3:
449
+ a = u, t = l, r = o;
450
+ break;
451
+ case 4:
452
+ a = h, t = u, r = o;
453
+ break;
454
+ case 5:
455
+ a = o, t = u, r = l;
456
+ }
457
+ return new e.RGB(a, t, r, this._alpha);
458
+ }, hsl: function () {
459
+ var a,
460
+ t = (2 - this._saturation) * this._value,
461
+ r = this._saturation * this._value,
462
+ n = t <= 1 ? t : 2 - t;
463
+ return a = n < 1e-9 ? 0 : r / n, new e.HSL(this._hue, a, t / 2, this._alpha);
464
+ }, fromRgb: function () {
465
+ var a,
466
+ t = this._red,
467
+ r = this._green,
468
+ n = this._blue,
469
+ i = Math.max(t, r, n),
470
+ o = Math.min(t, r, n),
471
+ s = i - o,
472
+ f = 0 === i ? 0 : s / i,
473
+ u = i;
474
+ if (0 === s) {
475
+ a = 0;
476
+ } else {
477
+ switch (i) {
478
+ case t:
479
+ a = (r - n) / s / 6 + (r < n ? 1 : 0);
480
+ break;
481
+ case r:
482
+ a = (n - t) / s / 6 + 1 / 3;
483
+ break;
484
+ case n:
485
+ a = (t - r) / s / 6 + 2 / 3;
486
+ }
487
+ }
488
+ return new e.HSV(a, f, u, this._alpha);
489
+ }
490
+ });
491
+ },
492
+ l = function (e) {
493
+ e.use(u), e.installColorSpace("HSL", ["hue", "saturation", "lightness", "alpha"], {
494
+ hsv: function () {
495
+ var a,
496
+ t = 2 * this._lightness,
497
+ r = this._saturation * (t <= 1 ? t : 2 - t);
498
+ return a = t + r < 1e-9 ? 0 : 2 * r / (t + r), new e.HSV(this._hue, a, (t + r) / 2, this._alpha);
499
+ }, rgb: function () {
500
+ return this.hsv()
501
+ .rgb();
502
+ }, fromRgb: function () {
503
+ return this.hsv()
504
+ .hsl();
505
+ }
506
+ });
507
+ },
508
+ h = function (e) {
509
+ e.installColorSpace("CMYK", ["cyan", "magenta", "yellow", "black", "alpha"], {
510
+ rgb: function () {
511
+ return new e.RGB(1 - this._cyan * (1 - this._black) - this._black, 1 - this._magenta * (1 - this._black) - this._black,
512
+ 1 - this._yellow * (1 - this._black) - this._black, this._alpha);
513
+ }, fromRgb: function () {
514
+ var a = this._red,
515
+ t = this._green,
516
+ r = this._blue,
517
+ n = 1 - a,
518
+ i = 1 - t,
519
+ o = 1 - r,
520
+ s = 1;
521
+ return a || t || r ? (s = Math.min(n, Math.min(i, o)), n = (n - s) / (1 - s), i = (i - s) / (1 - s), o = (o - s) / (1 - s)) : s = 1, new e.CMYK(n, i, o,
522
+ s, this._alpha);
523
+ }
524
+ });
525
+ },
526
+ c = function (e) {
527
+ e.namedColors = {
528
+ aliceblue: "f0f8ff",
529
+ antiquewhite: "faebd7",
530
+ aqua: "0ff",
531
+ aquamarine: "7fffd4",
532
+ azure: "f0ffff",
533
+ beige: "f5f5dc",
534
+ bisque: "ffe4c4",
535
+ black: "000",
536
+ blanchedalmond: "ffebcd",
537
+ blue: "00f",
538
+ blueviolet: "8a2be2",
539
+ brown: "a52a2a",
540
+ burlywood: "deb887",
541
+ cadetblue: "5f9ea0",
542
+ chartreuse: "7fff00",
543
+ chocolate: "d2691e",
544
+ coral: "ff7f50",
545
+ cornflowerblue: "6495ed",
546
+ cornsilk: "fff8dc",
547
+ crimson: "dc143c",
548
+ cyan: "0ff",
549
+ darkblue: "00008b",
550
+ darkcyan: "008b8b",
551
+ darkgoldenrod: "b8860b",
552
+ darkgray: "a9a9a9",
553
+ darkgrey: "a9a9a9",
554
+ darkgreen: "006400",
555
+ darkkhaki: "bdb76b",
556
+ darkmagenta: "8b008b",
557
+ darkolivegreen: "556b2f",
558
+ darkorange: "ff8c00",
559
+ darkorchid: "9932cc",
560
+ darkred: "8b0000",
561
+ darksalmon: "e9967a",
562
+ darkseagreen: "8fbc8f",
563
+ darkslateblue: "483d8b",
564
+ darkslategray: "2f4f4f",
565
+ darkslategrey: "2f4f4f",
566
+ darkturquoise: "00ced1",
567
+ darkviolet: "9400d3",
568
+ deeppink: "ff1493",
569
+ deepskyblue: "00bfff",
570
+ dimgray: "696969",
571
+ dimgrey: "696969",
572
+ dodgerblue: "1e90ff",
573
+ firebrick: "b22222",
574
+ floralwhite: "fffaf0",
575
+ forestgreen: "228b22",
576
+ fuchsia: "f0f",
577
+ gainsboro: "dcdcdc",
578
+ ghostwhite: "f8f8ff",
579
+ gold: "ffd700",
580
+ goldenrod: "daa520",
581
+ gray: "808080",
582
+ grey: "808080",
583
+ green: "008000",
584
+ greenyellow: "adff2f",
585
+ honeydew: "f0fff0",
586
+ hotpink: "ff69b4",
587
+ indianred: "cd5c5c",
588
+ indigo: "4b0082",
589
+ ivory: "fffff0",
590
+ khaki: "f0e68c",
591
+ lavender: "e6e6fa",
592
+ lavenderblush: "fff0f5",
593
+ lawngreen: "7cfc00",
594
+ lemonchiffon: "fffacd",
595
+ lightblue: "add8e6",
596
+ lightcoral: "f08080",
597
+ lightcyan: "e0ffff",
598
+ lightgoldenrodyellow: "fafad2",
599
+ lightgray: "d3d3d3",
600
+ lightgrey: "d3d3d3",
601
+ lightgreen: "90ee90",
602
+ lightpink: "ffb6c1",
603
+ lightsalmon: "ffa07a",
604
+ lightseagreen: "20b2aa",
605
+ lightskyblue: "87cefa",
606
+ lightslategray: "789",
607
+ lightslategrey: "789",
608
+ lightsteelblue: "b0c4de",
609
+ lightyellow: "ffffe0",
610
+ lime: "0f0",
611
+ limegreen: "32cd32",
612
+ linen: "faf0e6",
613
+ magenta: "f0f",
614
+ maroon: "800000",
615
+ mediumaquamarine: "66cdaa",
616
+ mediumblue: "0000cd",
617
+ mediumorchid: "ba55d3",
618
+ mediumpurple: "9370d8",
619
+ mediumseagreen: "3cb371",
620
+ mediumslateblue: "7b68ee",
621
+ mediumspringgreen: "00fa9a",
622
+ mediumturquoise: "48d1cc",
623
+ mediumvioletred: "c71585",
624
+ midnightblue: "191970",
625
+ mintcream: "f5fffa",
626
+ mistyrose: "ffe4e1",
627
+ moccasin: "ffe4b5",
628
+ navajowhite: "ffdead",
629
+ navy: "000080",
630
+ oldlace: "fdf5e6",
631
+ olive: "808000",
632
+ olivedrab: "6b8e23",
633
+ orange: "ffa500",
634
+ orangered: "ff4500",
635
+ orchid: "da70d6",
636
+ palegoldenrod: "eee8aa",
637
+ palegreen: "98fb98",
638
+ paleturquoise: "afeeee",
639
+ palevioletred: "d87093",
640
+ papayawhip: "ffefd5",
641
+ peachpuff: "ffdab9",
642
+ peru: "cd853f",
643
+ pink: "ffc0cb",
644
+ plum: "dda0dd",
645
+ powderblue: "b0e0e6",
646
+ purple: "800080",
647
+ rebeccapurple: "639",
648
+ red: "f00",
649
+ rosybrown: "bc8f8f",
650
+ royalblue: "4169e1",
651
+ saddlebrown: "8b4513",
652
+ salmon: "fa8072",
653
+ sandybrown: "f4a460",
654
+ seagreen: "2e8b57",
655
+ seashell: "fff5ee",
656
+ sienna: "a0522d",
657
+ silver: "c0c0c0",
658
+ skyblue: "87ceeb",
659
+ slateblue: "6a5acd",
660
+ slategray: "708090",
661
+ slategrey: "708090",
662
+ snow: "fffafa",
663
+ springgreen: "00ff7f",
664
+ steelblue: "4682b4",
665
+ tan: "d2b48c",
666
+ teal: "008080",
667
+ thistle: "d8bfd8",
668
+ tomato: "ff6347",
669
+ turquoise: "40e0d0",
670
+ violet: "ee82ee",
671
+ wheat: "f5deb3",
672
+ white: "fff",
673
+ whitesmoke: "f5f5f5",
674
+ yellow: "ff0",
675
+ yellowgreen: "9acd32"
676
+ };
677
+ },
678
+ d = function (e) {
679
+ e.installMethod("clearer", function (e) {
680
+ return this.alpha(isNaN(e) ? -.1 : -e, !0);
681
+ });
682
+ },
683
+ b = function (e) {
684
+ e.use(l), e.installMethod("darken", function (e) {
685
+ return this.lightness(isNaN(e) ? -.1 : -e, !0);
686
+ });
687
+ },
688
+ p = function (e) {
689
+ e.use(l), e.installMethod("desaturate", function (e) {
690
+ return this.saturation(isNaN(e) ? -.1 : -e, !0);
691
+ });
692
+ },
693
+ g = function (e) {
694
+ function a() {
695
+ var a = this.rgb(),
696
+ t = .3 * a._red + .59 * a._green + .11 * a._blue;
697
+ return new e.RGB(t, t, t, a._alpha);
698
+ }
699
+
700
+ e.installMethod("greyscale", a)
701
+ .installMethod("grayscale", a);
702
+ },
703
+ _ = function (e) {
704
+ e.use(l), e.installMethod("lighten", function (e) {
705
+ return this.lightness(isNaN(e) ? .1 : e, !0);
706
+ });
707
+ },
708
+ m = function (e) {
709
+ e.installMethod("mix", function (a, t) {
710
+ a = e(a)
711
+ .rgb(), t = 1 - (isNaN(t) ? .5 : t);
712
+ var r = 2 * t - 1,
713
+ n = this._alpha - a._alpha,
714
+ i = ((r * n == -1 ? r : (r + n) / (1 + r * n)) + 1) / 2,
715
+ o = 1 - i,
716
+ s = this.rgb();
717
+ return new e.RGB(s._red * i + a._red * o, s._green * i + a._green * o, s._blue * i + a._blue * o, s._alpha * t + a._alpha * (1 - t));
718
+ });
719
+ },
720
+ w = function (e) {
721
+ e.installMethod("negate", function () {
722
+ var a = this.rgb();
723
+ return new e.RGB(1 - a._red, 1 - a._green, 1 - a._blue, this._alpha);
724
+ });
725
+ },
726
+ y = function (e) {
727
+ e.installMethod("opaquer", function (e) {
728
+ return this.alpha(isNaN(e) ? .1 : e, !0);
729
+ });
730
+ },
731
+ v = function (e) {
732
+ e.use(l), e.installMethod("rotate", function (e) {
733
+ return this.hue((e || 0) / 360, !0);
734
+ });
735
+ },
736
+ k = function (e) {
737
+ e.use(l), e.installMethod("saturate", function (e) {
738
+ return this.saturation(isNaN(e) ? .1 : e, !0);
739
+ });
740
+ },
741
+ M = function (e) {
742
+ e.installMethod("toAlpha", function (e) {
743
+ var a = this.rgb(),
744
+ t = e(e)
745
+ .rgb(),
746
+ r = new e.RGB(0, 0, 0, a._alpha),
747
+ n = ["_red", "_green", "_blue"];
748
+ return n.forEach(function (e) {
749
+ a[e] < 1e-10 ? r[e] = a[e] : a[e] > t[e] ? r[e] = (a[e] - t[e]) / (1 - t[e]) : a[e] > t[e] ? r[e] = (t[e] - a[e]) / t[e] : r[e] = 0;
750
+ }), r._red > r._green ? r._red > r._blue ? a._alpha = r._red : a._alpha = r._blue : r._green > r._blue ? a._alpha = r._green : a._alpha = r._blue, a._alpha < 1e-10 ? a : (n.forEach(
751
+ function (e) {
752
+ a[e] = (a[e] - t[e]) / a._alpha + t[e];
753
+ }), a._alpha *= r._alpha, a);
754
+ });
755
+ };
756
+ return o.use(s)
757
+ .use(f)
758
+ .use(u)
759
+ .use(l)
760
+ .use(h)
761
+ .use(c)
762
+ .use(d)
763
+ .use(b)
764
+ .use(p)
765
+ .use(g)
766
+ .use(_)
767
+ .use(m)
768
+ .use(w)
769
+ .use(y)
770
+ .use(v)
771
+ .use(k)
772
+ .use(M);
773
+ }
774
+ );
775
+
776
+ });
777
+
778
+ var div = partial(e, "div");
779
+
780
+ function e(type, klass, p) {
781
+ var elem = document.createElement(type);
782
+ elem.className = klass;
783
+ p.appendChild(elem);
784
+
785
+ return elem;
786
+ }
787
+
788
+ // http://stackoverflow.com/questions/4394747/javascript-curry-function
789
+ function partial(fn) {
790
+ var slice = Array.prototype.slice;
791
+ var args = slice.apply(arguments, [1]);
792
+
793
+ return function () {
794
+ return fn.apply(null, args.concat(slice.apply(arguments)));
795
+ };
796
+ }
797
+
798
+ function labelInput(klass, n, p, maxLen) {
799
+ var id = "colorPickerInput" + Math.floor(Math.random() * 1001);
800
+ var d = div(klass, p);
801
+ var l = label(n, d, id);
802
+ var i = input("text", d, maxLen, id);
803
+
804
+ return {
805
+ label: l,
806
+ input: i
807
+ };
808
+ }
809
+
810
+ function label(c, p, id) {
811
+ var elem = e("label", "", p);
812
+ elem.innerHTML = c;
813
+
814
+ if (id) {
815
+ elem.setAttribute("for", id);
816
+ }
817
+
818
+ return elem;
819
+ }
820
+
821
+ function input(t, p, maxLen, id) {
822
+ var elem = e("input", "", p);
823
+ elem.type = t;
824
+
825
+ if (maxLen) {
826
+ elem.maxLength = maxLen;
827
+ }
828
+
829
+ if (id) {
830
+ elem.setAttribute("id", id);
831
+ }
832
+
833
+ if (maxLen) {
834
+ elem.maxLength = maxLen;
835
+ }
836
+
837
+ return elem;
838
+ }
839
+
840
+ function X(p, a) {
841
+ p.style.left = clamp(a * 100, 0, 100) + "%";
842
+ }
843
+
844
+ function Y(p, a) {
845
+ p.style.top = clamp(a * 100, 0, 100) + "%";
846
+ }
847
+
848
+ function BG(e, c) {
849
+ e.style.background = c;
850
+ }
851
+
852
+ function clamp(a, minValue, maxValue) {
853
+ return Math.min(Math.max(a, minValue), maxValue);
854
+ }
855
+
856
+ var utils = {
857
+ clamp: clamp,
858
+ e: e,
859
+ div: div,
860
+ partial: partial,
861
+ labelInput: labelInput,
862
+ X: X,
863
+ Y: Y,
864
+ BG: BG
865
+ };
866
+
867
+ function currentColor(p) {
868
+ var e1 = utils.div("currentColorContainer", p);
869
+ var e = utils.div("currentColor", e1);
870
+
871
+ return {
872
+ change: function (col) {
873
+ utils.BG(e, col.cssa());
874
+ }
875
+ };
876
+ }
877
+
878
+ function fields(p, joe, o) {
879
+ var cs = o.space;
880
+ var fac = o.limit || 255;
881
+ var fix = o.fix >= 0 ? o.fix : 0;
882
+ var inputLen = ("" + fac).length + fix;
883
+ inputLen = fix ? inputLen + 1 : inputLen;
884
+
885
+ var initials = cs.split("");
886
+ var useAlpha = cs[cs.length - 1] == "A";
887
+ cs = useAlpha ? cs.slice(0, -1) : cs;
888
+
889
+ if (["RGB", "HSL", "HSV", "CMYK"].indexOf(cs) < 0) {
890
+ return console.warn("Invalid field names", cs);
891
+ }
892
+
893
+ var c = utils.div("colorFields", p);
894
+ var elems = initials.map(function (n) {
895
+ n = n.toLowerCase();
896
+
897
+ var e = utils.labelInput("color " + n, n, c, inputLen);
898
+ e.input.onblur = done;
899
+ e.input.onkeydown = validate;
900
+ e.input.onkeyup = update;
901
+
902
+ return {
903
+ name: n,
904
+ e: e
905
+ };
906
+ });
907
+
908
+ function done() {
909
+ joe.done();
910
+ }
911
+
912
+ function validate(e) {
913
+ if (!(e.ctrlKey || e.altKey) && /^[a-zA-Z]$/.test(e.key)) {
914
+ e.preventDefault();
915
+ }
916
+ }
917
+
918
+ function update() {
919
+ var col = [cs];
920
+
921
+ elems.forEach(function (o) {
922
+ col.push(o.e.input.value / fac);
923
+ });
924
+
925
+ if (!useAlpha) {
926
+ col.push(joe.getAlpha());
927
+ }
928
+
929
+ joe.set(col);
930
+ }
931
+
932
+ return {
933
+ change: function (col) {
934
+ elems.forEach(function (o) {
935
+ o.e.input.value = (col[o.name]() * fac).toFixed(fix);
936
+ });
937
+ }
938
+ };
939
+ }
940
+
941
+ function alpha(p, joe) {
942
+ var e = dragjs_umd.slider({
943
+ parent: p,
944
+ "class": "oned alpha chequered",
945
+ cbs: {
946
+ begin: change,
947
+ change: change,
948
+ end: done
949
+ }
950
+ });
951
+
952
+ function done() {
953
+ joe.done();
954
+ }
955
+
956
+ function change(p) {
957
+ var val = utils.clamp(p.y, 0, 1);
958
+
959
+ utils.Y(p.pointer, val);
960
+ joe.setAlpha(1 - val);
961
+ }
962
+
963
+ return {
964
+ change: function (col) {
965
+ utils.Y(e.pointer, 1 - col.alpha());
966
+ }
967
+ };
968
+ }
969
+
970
+ function hex(p, joe, o) {
971
+ var e = utils.labelInput("hex", o.label || "", p, 7);
972
+ e.input.value = "#";
973
+
974
+ e.input.onkeyup = function (elem) {
975
+ var key = elem.keyCode || elem.which;
976
+ var val = elem.target.value;
977
+ val = val[0] == "#" ? val : "#" + val;
978
+ val = pad(val, 7, "0");
979
+
980
+ if (key == 13) {
981
+ joe.set(val);
982
+ }
983
+ };
984
+
985
+ e.input.onblur = function (elem) {
986
+ joe.set(elem.target.value);
987
+ joe.done();
988
+ };
989
+
990
+ return {
991
+ change: function (col) {
992
+ e.input.value = e.input.value[0] == "#" ? "#" : "";
993
+ e.input.value += col.hex()
994
+ .slice(1);
995
+ }
996
+ };
997
+ }
998
+
999
+ function close(p, joe, o) {
1000
+ var elem = utils.e("a", o["class"] || "close", p);
1001
+ elem.href = "#";
1002
+ elem.innerHTML = o.label || "Close";
1003
+
1004
+ elem.onclick = function (e) {
1005
+ e.preventDefault();
1006
+
1007
+ joe.hide();
1008
+ };
1009
+ }
1010
+
1011
+ function pad(a, n, c) {
1012
+ var ret = a;
1013
+
1014
+ for (var i = a.length; i < n; i++) {
1015
+ ret += c;
1016
+ }
1017
+
1018
+ return ret;
1019
+ }
1020
+
1021
+ var extras = {
1022
+ currentColor: currentColor,
1023
+ fields: fields,
1024
+ hex: hex,
1025
+ alpha: alpha,
1026
+ close: close
1027
+ };
1028
+
1029
+ // Use the all build with cmyk and everything
1030
+
1031
+ var colorjoe = function (cbs) {
1032
+ if (!all(isFunction, [cbs.init, cbs.xy, cbs.z])) {
1033
+ return console.warn("colorjoe: missing cb");
1034
+ }
1035
+
1036
+ return function (element, initialColor, extras$$1) {
1037
+ return setup({
1038
+ e: element,
1039
+ color: initialColor,
1040
+ cbs: cbs,
1041
+ extras: extras$$1
1042
+ });
1043
+ };
1044
+ };
1045
+
1046
+ /* pickers */
1047
+ colorjoe.rgb = colorjoe({
1048
+ init: function (col, xy, z) {
1049
+ var ret = oneColorAll(col)
1050
+ .hsv();
1051
+
1052
+ this.xy(ret, {x: ret.saturation(), y: 1 - ret.value()}, xy, z);
1053
+ this.z(ret, ret.hue(), xy, z);
1054
+
1055
+ return ret;
1056
+ },
1057
+ xy: function (col, p, xy) {
1058
+ utils.X(xy.pointer, p.x);
1059
+ utils.Y(xy.pointer, p.y);
1060
+
1061
+ return col.saturation(p.x)
1062
+ .value(1 - p.y);
1063
+ },
1064
+ z: function (col, v, xy, z) {
1065
+ utils.Y(z.pointer, v);
1066
+ RGB_BG(xy.background, v);
1067
+
1068
+ return col.hue(v);
1069
+ }
1070
+ });
1071
+
1072
+ colorjoe.hsl = colorjoe({
1073
+ init: function (col, xy, z) {
1074
+ var ret = oneColorAll(col)
1075
+ .hsl();
1076
+
1077
+ this.xy(ret, {x: ret.hue(), y: 1 - ret.saturation()}, xy, z);
1078
+ this.z(ret, 1 - ret.lightness(), xy, z);
1079
+
1080
+ return ret;
1081
+ },
1082
+ xy: function (col, p, xy, z) {
1083
+ utils.X(xy.pointer, p.x);
1084
+ utils.Y(xy.pointer, p.y);
1085
+ RGB_BG(z.background, p.x);
1086
+
1087
+ return col.hue(p.x)
1088
+ .saturation(1 - p.y);
1089
+ },
1090
+ z: function (col, v, xy, z) {
1091
+ utils.Y(z.pointer, v);
1092
+
1093
+ return col.lightness(1 - v);
1094
+ }
1095
+ });
1096
+
1097
+ colorjoe.extras = {};
1098
+
1099
+ colorjoe.registerExtra = function (name, fn) {
1100
+ if (name in colorjoe.extras) {
1101
+ console.warn("Extra \"" + name + "\"has been registered already!");
1102
+ }
1103
+
1104
+ colorjoe.extras[name] = fn;
1105
+ };
1106
+
1107
+ for (var k in extras) {
1108
+ colorjoe.registerExtra(k, extras[k]);
1109
+ }
1110
+
1111
+ function RGB_BG(e, h) {
1112
+ utils.BG(e, new oneColorAll.HSV(h, 1, 1).cssa());
1113
+ }
1114
+
1115
+ function setup(o) {
1116
+ if (!o.e) {
1117
+ return console.warn("colorjoe: missing element");
1118
+ }
1119
+
1120
+ var e = isString(o.e) ? document.getElementById(o.e) : o.e;
1121
+ e.className = "colorPicker";
1122
+
1123
+ var cbs = o.cbs;
1124
+
1125
+ var xy = dragjs_umd.xyslider({
1126
+ parent: e,
1127
+ class: "twod",
1128
+ cbs: {
1129
+ begin: changeXY,
1130
+ change: changeXY,
1131
+ end: done
1132
+ }
1133
+ });
1134
+
1135
+ function changeXY(p) {
1136
+ col = cbs.xy(
1137
+ col,
1138
+ {
1139
+ x: utils.clamp(p.x, 0, 1),
1140
+ y: utils.clamp(p.y, 0, 1)
1141
+ },
1142
+ xy,
1143
+ z
1144
+ );
1145
+ changed();
1146
+ }
1147
+
1148
+ var z = dragjs_umd.slider({
1149
+ parent: e,
1150
+ class: "oned",
1151
+ cbs: {
1152
+ begin: changeZ,
1153
+ change: changeZ,
1154
+ end: done
1155
+ }
1156
+ });
1157
+
1158
+ function changeZ(p) {
1159
+ col = cbs.z(col, utils.clamp(p.y, 0, 1), xy, z);
1160
+ changed();
1161
+ }
1162
+
1163
+ // Initial color
1164
+ var previous = getColor(o.color);
1165
+ var col = cbs.init(previous, xy, z);
1166
+ var listeners = {change: [], done: []};
1167
+
1168
+ function changed(skip) {
1169
+ skip = isArray(skip) ? skip : [];
1170
+
1171
+ var li = listeners.change;
1172
+ var v;
1173
+
1174
+ for (var i = 0, len = li.length; i < len; i++) {
1175
+ v = li[i];
1176
+ if (skip.indexOf(v.name) == -1) {
1177
+ v.fn(col);
1178
+ }
1179
+ }
1180
+ }
1181
+
1182
+ function done() {
1183
+ // Do not call done callback if the color did not change
1184
+ if (previous.equals(col)) {
1185
+ return;
1186
+ }
1187
+
1188
+ for (var i = 0, len = listeners.done.length; i < len; i++) {
1189
+ listeners.done[i].fn(col);
1190
+ }
1191
+
1192
+ previous = col;
1193
+ }
1194
+
1195
+ var ob = {
1196
+ e: e,
1197
+ done: function () {
1198
+ done();
1199
+
1200
+ return this;
1201
+ },
1202
+ update: function (skip) {
1203
+ changed(skip);
1204
+
1205
+ return this;
1206
+ },
1207
+ hide: function () {
1208
+ e.style.display = "none";
1209
+
1210
+ return this;
1211
+ },
1212
+ show: function () {
1213
+ e.style.display = "";
1214
+
1215
+ return this;
1216
+ },
1217
+ get: function () {
1218
+ return col;
1219
+ },
1220
+ set: function (c) {
1221
+ var oldCol = this.get();
1222
+ col = cbs.init(getColor(c), xy, z);
1223
+
1224
+ if (!oldCol.equals(col)) {
1225
+ this.update();
1226
+ }
1227
+
1228
+ return this;
1229
+ },
1230
+ getAlpha: function () {
1231
+ return col.alpha();
1232
+ },
1233
+ setAlpha: function (v) {
1234
+ col = col.alpha(v);
1235
+
1236
+ this.update();
1237
+
1238
+ return this;
1239
+ },
1240
+ on: function (evt, cb, name) {
1241
+ if (evt == "change" || evt == "done") {
1242
+ listeners[evt].push({name: name, fn: cb});
1243
+ } else {
1244
+ console.warn(
1245
+ "Passed invalid evt name \"" + evt + "\" to colorjoe.on"
1246
+ );
1247
+ }
1248
+
1249
+ return this;
1250
+ },
1251
+ removeAllListeners: function (evt) {
1252
+ if (evt) {
1253
+ listeners[evt] = [];
1254
+ } else {
1255
+ for (var key in listeners) {
1256
+ listeners[key] = [];
1257
+ }
1258
+ }
1259
+
1260
+ return this;
1261
+ }
1262
+ };
1263
+
1264
+ setupExtras(e, ob, o.extras);
1265
+ changed();
1266
+
1267
+ return ob;
1268
+ }
1269
+
1270
+ function getColor(c) {
1271
+ if (!isDefined(c)) {
1272
+ return oneColorAll("#000");
1273
+ }
1274
+ if (c.isColor) {
1275
+ return c;
1276
+ }
1277
+
1278
+ var ret = oneColorAll(c);
1279
+
1280
+ if (ret) {
1281
+ return ret;
1282
+ }
1283
+
1284
+ if (isDefined(c)) {
1285
+ console.warn("Passed invalid color to colorjoe, using black instead");
1286
+ }
1287
+
1288
+ return oneColorAll("#000");
1289
+ }
1290
+
1291
+ function setupExtras(p, joe, extras$$1) {
1292
+ if (!extras$$1) {
1293
+ return;
1294
+ }
1295
+
1296
+ var c = utils.div("extras", p);
1297
+ var cbs;
1298
+ var name;
1299
+ var params;
1300
+
1301
+ extras$$1.forEach(function (e, i) {
1302
+ if (isArray(e)) {
1303
+ name = e[0];
1304
+ params = e.length > 1 ? e[1] : {};
1305
+ } else {
1306
+ name = e;
1307
+ params = {};
1308
+ }
1309
+ var extra = name in colorjoe.extras ? colorjoe.extras[name] : null;
1310
+
1311
+ if (extra) {
1312
+ cbs = extra(c, extraProxy(joe, name + i), params);
1313
+ for (var k in cbs) {
1314
+ joe.on(k, cbs[k], name);
1315
+ }
1316
+ }
1317
+ });
1318
+ }
1319
+
1320
+ function extraProxy(joe, name) {
1321
+ var ret = copy(joe);
1322
+
1323
+ ret.update = function () {
1324
+ joe.update([name]);
1325
+ };
1326
+
1327
+ return ret;
1328
+ }
1329
+
1330
+ function copy(o) {
1331
+ // returns a shallow copy
1332
+ var ret = {};
1333
+
1334
+ for (var k in o) {
1335
+ ret[k] = o[k];
1336
+ }
1337
+
1338
+ return ret;
1339
+ }
1340
+
1341
+ function all(cb, a) {
1342
+ return a.map(cb)
1343
+ .filter(id).length == a.length;
1344
+ }
1345
+
1346
+ function isArray(o) {
1347
+ return Object.prototype.toString.call(o) === "[object Array]";
1348
+ }
1349
+
1350
+ function isString(o) {
1351
+ return typeof o === "string";
1352
+ }
1353
+
1354
+ function isDefined(input) {
1355
+ return typeof input !== "undefined";
1356
+ }
1357
+
1358
+ function isFunction(input) {
1359
+ return typeof input === "function";
1360
+ }
1361
+
1362
+ function id(a) {
1363
+ return a;
1364
+ }
1365
+
1366
+ var colorjoe_1 = colorjoe;
1367
+
1368
+ return colorjoe_1;
1369
+
1370
+ })));
1371
+ //# sourceMappingURL=colorjoe.js.map