@salla.sa/twilight-components 2.14.345 → 2.14.348
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{filepond-B6UnxGJn.js → filepond-B_sfbQx7.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-BhapUCah.js → filepond-plugin-file-poster-CStjlaHV.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-kWSi8kox.js → filepond-plugin-file-validate-size-DrcM89vc.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-BQALkj0_.js → filepond-plugin-file-validate-type-DnIoL6mq.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-DARX63sP.js → filepond-plugin-image-edit-DLV0U0gb.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-Cv8PkAua.js → filepond-plugin-image-exif-orientation-tPl3p3z_.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-cPHzbxK5.js → filepond-plugin-image-preview-WTfIQM6C.js} +1 -1
- package/dist/cjs/{index-Dde27y5S.js → index-4jrFyN8u.js} +1 -1
- package/dist/cjs/{index-DdqKQOUt.js → index-CkpcUCU5.js} +9 -9
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion_62.cjs.entry.js +10368 -1323
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews-page.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/vanilla-picker-BBejdpPH.js +1045 -0
- package/dist/collection/components/salla-color-picker/salla-color-picker.js +67 -37
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-options-modal.js +4 -5
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.js +1 -1
- package/dist/collection/components/salla-products-slider/salla-products-slider.js +3 -0
- package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +68 -55
- package/dist/collection/components/salla-slider/salla-slider.css +687 -238
- package/dist/collection/components/salla-slider/salla-slider.js +76 -58
- package/dist/components/index.js +9 -9
- package/dist/components/salla-color-picker2.js +69 -1056
- package/dist/components/salla-multiple-bundle-product-options-modal2.js +4 -5
- package/dist/components/salla-multiple-bundle-product-slider2.js +1 -1
- package/dist/components/salla-products-slider2.js +3 -0
- package/dist/components/salla-quick-buy2.js +367 -139
- package/dist/components/salla-slider2.js +9861 -61
- package/dist/components/vanilla-picker.js +1043 -0
- package/dist/esm/{filepond-BJyHP15o.js → filepond-BBd4zIxi.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-cHeUHw0d.js → filepond-plugin-file-poster-Vvhvcuu3.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-BFMgCnGy.js → filepond-plugin-file-validate-size-NvdGUEr-.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-Byrty1k-.js → filepond-plugin-file-validate-type-BwVZhOLd.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-CIrkAkQv.js → filepond-plugin-image-edit-BOgZn2vW.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-DDOLykfz.js → filepond-plugin-image-exif-orientation-BmbDj4hl.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-B-39bdfF.js → filepond-plugin-image-preview-CDsLWAPe.js} +1 -1
- package/dist/esm/{index-CwcntRpx.js → index-BhHl4h44.js} +1 -1
- package/dist/esm/{index-fc9mQ2Cf.js → index-LmL2BolE.js} +9 -9
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion_62.entry.js +10368 -1323
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-review-card.entry.js +1 -1
- package/dist/esm/salla-reviews-page.entry.js +1 -1
- package/dist/esm/salla-reviews.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +1 -1
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/vanilla-picker-nCA1ATQw.js +1043 -0
- package/dist/twilight/{p-b22bf810.entry.js → p-03870195.entry.js} +1 -1
- package/dist/twilight/{p-88a33569.entry.js → p-06956c1d.entry.js} +1 -1
- package/dist/twilight/{p-528a454d.entry.js → p-07add349.entry.js} +1 -1
- package/dist/twilight/{p-b57fc27a.entry.js → p-09dceb55.entry.js} +1 -1
- package/dist/twilight/{p-aae932e3.entry.js → p-0aef5345.entry.js} +1 -1
- package/dist/twilight/{p-4cd1966a.entry.js → p-133f1a48.entry.js} +1 -1
- package/dist/twilight/{p-3215de15.entry.js → p-23ff2132.entry.js} +1 -1
- package/dist/twilight/{p-437ba197.entry.js → p-2c9d0518.entry.js} +1 -1
- package/dist/twilight/{p-8212fa71.entry.js → p-2ed7cfba.entry.js} +1 -1
- package/dist/twilight/p-2gPrnQD6.js +9 -0
- package/dist/twilight/{p-45d191a5.entry.js → p-312c1af1.entry.js} +1 -1
- package/dist/twilight/{p-ab4faa01.entry.js → p-388fb59e.entry.js} +1 -1
- package/dist/twilight/{p-5f6e3888.entry.js → p-3d69e45a.entry.js} +1 -1
- package/dist/twilight/{p-ee258c43.entry.js → p-45cd70b8.entry.js} +1 -1
- package/dist/twilight/{p-961c7884.entry.js → p-48b90fb3.entry.js} +1 -1
- package/dist/twilight/{p-26501701.entry.js → p-4cd30c07.entry.js} +1 -1
- package/dist/twilight/{p-6a0ce542.entry.js → p-4d47725f.entry.js} +1 -1
- package/dist/twilight/{p-8be23294.entry.js → p-549ff403.entry.js} +1 -1
- package/dist/twilight/{p-dbb2791e.entry.js → p-63e9750c.entry.js} +1 -1
- package/dist/twilight/{p-bcf625a5.entry.js → p-6c648552.entry.js} +1 -1
- package/dist/twilight/{p-b44b7927.entry.js → p-74aaf06c.entry.js} +1 -1
- package/dist/twilight/{p-0fe916a5.entry.js → p-7c85a102.entry.js} +1 -1
- package/dist/twilight/{p-caf27ebc.entry.js → p-8c111815.entry.js} +1 -1
- package/dist/twilight/{p-baa60190.entry.js → p-950f9a87.entry.js} +1 -1
- package/dist/twilight/{p-65fe63cd.entry.js → p-966ed241.entry.js} +1 -1
- package/dist/twilight/{p-d793b334.entry.js → p-9f39c553.entry.js} +1 -1
- package/dist/twilight/p-Bf4kQRcH.js +11 -0
- package/dist/twilight/{p-Ba24ST7F.js → p-CIEz2m31.js} +1 -1
- package/dist/twilight/{p-Cf1akxWz.js → p-D1_qMmD0.js} +1 -1
- package/dist/twilight/p-LmL2BolE.js +5 -0
- package/dist/twilight/{p-CLjQTDM8.js → p-TSs7NqKJ.js} +1 -1
- package/dist/twilight/{p-25d9f48a.entry.js → p-b30a12dc.entry.js} +1 -1
- package/dist/twilight/{p-f82c7ab2.entry.js → p-bcec0cf0.entry.js} +1 -1
- package/dist/twilight/{p-c5j6tKn6.js → p-c0pjDpvN.js} +1 -1
- package/dist/twilight/{p-64256ff5.entry.js → p-c302d3e3.entry.js} +1 -1
- package/dist/twilight/{p-2028ec4e.entry.js → p-c38c65f0.entry.js} +1 -1
- package/dist/twilight/{p-1b097db6.entry.js → p-cd2c9076.entry.js} +1 -1
- package/dist/twilight/{p-730571d5.entry.js → p-d2ed15e9.entry.js} +1 -1
- package/dist/twilight/{p-aa5df8f2.entry.js → p-f1f60ef7.entry.js} +1 -1
- package/dist/twilight/{p-3a6fb653.entry.js → p-f74f1591.entry.js} +1 -1
- package/dist/twilight/{p-bb03e091.entry.js → p-fbbd8d5d.entry.js} +1 -1
- package/dist/twilight/p-fff8923d.entry.js +4 -0
- package/dist/twilight/{p-OyH4M5A0.js → p-qNQwLhxq.js} +1 -1
- package/dist/twilight/{p-CpFtpQQs.js → p-v9xIxXO9.js} +1 -1
- package/dist/twilight/{p-BkGn8pcO.js → p-xUcnsSlW.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-color-picker/interfaces.d.ts +9 -0
- package/dist/types/components/salla-color-picker/salla-color-picker.d.ts +4 -1
- package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +1 -0
- package/dist/types/components/salla-quick-buy/salla-quick-buy.d.ts +2 -0
- package/dist/types/components/salla-slider/salla-slider.d.ts +9 -3
- package/package.json +6 -6
- package/dist/twilight/p-56f65b6c.entry.js +0 -11
- package/dist/twilight/p-DhH2aJLP.js +0 -9
- package/dist/twilight/p-fc9mQ2Cf.js +0 -5
|
@@ -0,0 +1,1045 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
var index = require('./index-CkpcUCU5.js');
|
|
7
|
+
|
|
8
|
+
function _mergeNamespaces(n, m) {
|
|
9
|
+
m.forEach(function (e) {
|
|
10
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default' && !(k in n)) {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var vanillaPicker$3 = {exports: {}};
|
|
24
|
+
|
|
25
|
+
/*!
|
|
26
|
+
* vanilla-picker v2.12.3
|
|
27
|
+
* https://vanilla-picker.js.org
|
|
28
|
+
*
|
|
29
|
+
* Copyright 2017-2024 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)
|
|
30
|
+
* Released under the ISC license.
|
|
31
|
+
*/
|
|
32
|
+
var vanillaPicker$2 = vanillaPicker$3.exports;
|
|
33
|
+
|
|
34
|
+
var hasRequiredVanillaPicker;
|
|
35
|
+
|
|
36
|
+
function requireVanillaPicker () {
|
|
37
|
+
if (hasRequiredVanillaPicker) return vanillaPicker$3.exports;
|
|
38
|
+
hasRequiredVanillaPicker = 1;
|
|
39
|
+
(function (module, exports) {
|
|
40
|
+
(function (global, factory) {
|
|
41
|
+
module.exports = factory() ;
|
|
42
|
+
})(vanillaPicker$2, (function () {
|
|
43
|
+
var classCallCheck = function (instance, Constructor) {
|
|
44
|
+
if (!(instance instanceof Constructor)) {
|
|
45
|
+
throw new TypeError("Cannot call a class as a function");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
var createClass = function () {
|
|
50
|
+
function defineProperties(target, props) {
|
|
51
|
+
for (var i = 0; i < props.length; i++) {
|
|
52
|
+
var descriptor = props[i];
|
|
53
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
54
|
+
descriptor.configurable = true;
|
|
55
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
56
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return function (Constructor, protoProps, staticProps) {
|
|
61
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
62
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
63
|
+
return Constructor;
|
|
64
|
+
};
|
|
65
|
+
}();
|
|
66
|
+
|
|
67
|
+
var slicedToArray = function () {
|
|
68
|
+
function sliceIterator(arr, i) {
|
|
69
|
+
var _arr = [];
|
|
70
|
+
var _n = true;
|
|
71
|
+
var _d = false;
|
|
72
|
+
var _e = undefined;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
76
|
+
_arr.push(_s.value);
|
|
77
|
+
|
|
78
|
+
if (i && _arr.length === i) break;
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
_d = true;
|
|
82
|
+
_e = err;
|
|
83
|
+
} finally {
|
|
84
|
+
try {
|
|
85
|
+
if (!_n && _i["return"]) _i["return"]();
|
|
86
|
+
} finally {
|
|
87
|
+
if (_d) throw _e;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return _arr;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return function (arr, i) {
|
|
95
|
+
if (Array.isArray(arr)) {
|
|
96
|
+
return arr;
|
|
97
|
+
} else if (Symbol.iterator in Object(arr)) {
|
|
98
|
+
return sliceIterator(arr, i);
|
|
99
|
+
} else {
|
|
100
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}();
|
|
104
|
+
|
|
105
|
+
String.prototype.startsWith = String.prototype.startsWith || function (needle) {
|
|
106
|
+
return this.indexOf(needle) === 0;
|
|
107
|
+
};
|
|
108
|
+
String.prototype.padStart = String.prototype.padStart || function (len, pad) {
|
|
109
|
+
var str = this;while (str.length < len) {
|
|
110
|
+
str = pad + str;
|
|
111
|
+
}return str;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
var colorNames = { cb: '0f8ff', tqw: 'aebd7', q: '-ffff', qmrn: '7fffd4', zr: '0ffff', bg: '5f5dc', bsq: 'e4c4', bck: '---', nch: 'ebcd', b: '--ff', bvt: '8a2be2', brwn: 'a52a2a', brw: 'deb887', ctb: '5f9ea0', hrt: '7fff-', chcT: 'd2691e', cr: '7f50', rnw: '6495ed', crns: '8dc', crms: 'dc143c', cn: '-ffff', Db: '--8b', Dcn: '-8b8b', Dgnr: 'b8860b', Dgr: 'a9a9a9', Dgrn: '-64-', Dkhk: 'bdb76b', Dmgn: '8b-8b', Dvgr: '556b2f', Drng: '8c-', Drch: '9932cc', Dr: '8b--', Dsmn: 'e9967a', Dsgr: '8fbc8f', DsTb: '483d8b', DsTg: '2f4f4f', Dtrq: '-ced1', Dvt: '94-d3', ppnk: '1493', pskb: '-bfff', mgr: '696969', grb: '1e90ff', rbrc: 'b22222', rwht: 'af0', stg: '228b22', chs: '-ff', gnsb: 'dcdcdc', st: '8f8ff', g: 'd7-', gnr: 'daa520', gr: '808080', grn: '-8-0', grnw: 'adff2f', hnw: '0fff0', htpn: '69b4', nnr: 'cd5c5c', ng: '4b-82', vr: '0', khk: '0e68c', vnr: 'e6e6fa', nrb: '0f5', wngr: '7cfc-', mnch: 'acd', Lb: 'add8e6', Lcr: '08080', Lcn: 'e0ffff', Lgnr: 'afad2', Lgr: 'd3d3d3', Lgrn: '90ee90', Lpnk: 'b6c1', Lsmn: 'a07a', Lsgr: '20b2aa', Lskb: '87cefa', LsTg: '778899', Lstb: 'b0c4de', Lw: 'e0', m: '-ff-', mgrn: '32cd32', nn: 'af0e6', mgnt: '-ff', mrn: '8--0', mqm: '66cdaa', mmb: '--cd', mmrc: 'ba55d3', mmpr: '9370db', msg: '3cb371', mmsT: '7b68ee', '': '-fa9a', mtr: '48d1cc', mmvt: 'c71585', mnLb: '191970', ntc: '5fffa', mstr: 'e4e1', mccs: 'e4b5', vjw: 'dead', nv: '--80', c: 'df5e6', v: '808-0', vrb: '6b8e23', rng: 'a5-', rngr: '45-', rch: 'da70d6', pgnr: 'eee8aa', pgrn: '98fb98', ptrq: 'afeeee', pvtr: 'db7093', ppwh: 'efd5', pchp: 'dab9', pr: 'cd853f', pnk: 'c0cb', pm: 'dda0dd', pwrb: 'b0e0e6', prp: '8-080', cc: '663399', r: '--', sbr: 'bc8f8f', rb: '4169e1', sbrw: '8b4513', smn: 'a8072', nbr: '4a460', sgrn: '2e8b57', ssh: '5ee', snn: 'a0522d', svr: 'c0c0c0', skb: '87ceeb', sTb: '6a5acd', sTgr: '708090', snw: 'afa', n: '-ff7f', stb: '4682b4', tn: 'd2b48c', t: '-8080', thst: 'd8bfd8', tmT: '6347', trqs: '40e0d0', vt: 'ee82ee', whT: '5deb3', wht: '', hts: '5f5f5', w: '-', wgrn: '9acd32' };
|
|
115
|
+
|
|
116
|
+
function printNum(num) {
|
|
117
|
+
var decs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
118
|
+
|
|
119
|
+
var str = decs > 0 ? num.toFixed(decs).replace(/0+$/, '').replace(/\.$/, '') : num.toString();
|
|
120
|
+
return str || '0';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var Color = function () {
|
|
124
|
+
function Color(r, g, b, a) {
|
|
125
|
+
classCallCheck(this, Color);
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
var that = this;
|
|
129
|
+
function parseString(input) {
|
|
130
|
+
|
|
131
|
+
if (input.startsWith('hsl')) {
|
|
132
|
+
var _input$match$map = input.match(/([\-\d\.e]+)/g).map(Number),
|
|
133
|
+
_input$match$map2 = slicedToArray(_input$match$map, 4),
|
|
134
|
+
h = _input$match$map2[0],
|
|
135
|
+
s = _input$match$map2[1],
|
|
136
|
+
l = _input$match$map2[2],
|
|
137
|
+
_a = _input$match$map2[3];
|
|
138
|
+
|
|
139
|
+
if (_a === undefined) {
|
|
140
|
+
_a = 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
h /= 360;
|
|
144
|
+
s /= 100;
|
|
145
|
+
l /= 100;
|
|
146
|
+
that.hsla = [h, s, l, _a];
|
|
147
|
+
} else if (input.startsWith('rgb')) {
|
|
148
|
+
var _input$match$map3 = input.match(/([\-\d\.e]+)/g).map(Number),
|
|
149
|
+
_input$match$map4 = slicedToArray(_input$match$map3, 4),
|
|
150
|
+
_r = _input$match$map4[0],
|
|
151
|
+
_g = _input$match$map4[1],
|
|
152
|
+
_b = _input$match$map4[2],
|
|
153
|
+
_a2 = _input$match$map4[3];
|
|
154
|
+
|
|
155
|
+
if (_a2 === undefined) {
|
|
156
|
+
_a2 = 1;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
that.rgba = [_r, _g, _b, _a2];
|
|
160
|
+
} else {
|
|
161
|
+
if (input.startsWith('#')) {
|
|
162
|
+
that.rgba = Color.hexToRgb(input);
|
|
163
|
+
} else {
|
|
164
|
+
that.rgba = Color.nameToRgb(input) || Color.hexToRgb(input);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (r === undefined) ; else if (Array.isArray(r)) {
|
|
170
|
+
this.rgba = r;
|
|
171
|
+
} else if (b === undefined) {
|
|
172
|
+
var color = r && '' + r;
|
|
173
|
+
if (color) {
|
|
174
|
+
parseString(color.toLowerCase());
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
this.rgba = [r, g, b, a === undefined ? 1 : a];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
createClass(Color, [{
|
|
182
|
+
key: 'printRGB',
|
|
183
|
+
value: function printRGB(alpha) {
|
|
184
|
+
var rgb = alpha ? this.rgba : this.rgba.slice(0, 3),
|
|
185
|
+
vals = rgb.map(function (x, i) {
|
|
186
|
+
return printNum(x, i === 3 ? 3 : 0);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
return alpha ? 'rgba(' + vals + ')' : 'rgb(' + vals + ')';
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
key: 'printHSL',
|
|
193
|
+
value: function printHSL(alpha) {
|
|
194
|
+
var mults = [360, 100, 100, 1],
|
|
195
|
+
suff = ['', '%', '%', ''];
|
|
196
|
+
|
|
197
|
+
var hsl = alpha ? this.hsla : this.hsla.slice(0, 3),
|
|
198
|
+
vals = hsl.map(function (x, i) {
|
|
199
|
+
return printNum(x * mults[i], i === 3 ? 3 : 1) + suff[i];
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
return alpha ? 'hsla(' + vals + ')' : 'hsl(' + vals + ')';
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
key: 'printHex',
|
|
206
|
+
value: function printHex(alpha) {
|
|
207
|
+
var hex = this.hex;
|
|
208
|
+
return alpha ? hex : hex.substring(0, 7);
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: 'rgba',
|
|
212
|
+
get: function get() {
|
|
213
|
+
if (this._rgba) {
|
|
214
|
+
return this._rgba;
|
|
215
|
+
}
|
|
216
|
+
if (!this._hsla) {
|
|
217
|
+
throw new Error('No color is set');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return this._rgba = Color.hslToRgb(this._hsla);
|
|
221
|
+
},
|
|
222
|
+
set: function set(rgb) {
|
|
223
|
+
if (rgb.length === 3) {
|
|
224
|
+
rgb[3] = 1;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
this._rgba = rgb;
|
|
228
|
+
this._hsla = null;
|
|
229
|
+
}
|
|
230
|
+
}, {
|
|
231
|
+
key: 'rgbString',
|
|
232
|
+
get: function get() {
|
|
233
|
+
return this.printRGB();
|
|
234
|
+
}
|
|
235
|
+
}, {
|
|
236
|
+
key: 'rgbaString',
|
|
237
|
+
get: function get() {
|
|
238
|
+
return this.printRGB(true);
|
|
239
|
+
}
|
|
240
|
+
}, {
|
|
241
|
+
key: 'hsla',
|
|
242
|
+
get: function get() {
|
|
243
|
+
if (this._hsla) {
|
|
244
|
+
return this._hsla;
|
|
245
|
+
}
|
|
246
|
+
if (!this._rgba) {
|
|
247
|
+
throw new Error('No color is set');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return this._hsla = Color.rgbToHsl(this._rgba);
|
|
251
|
+
},
|
|
252
|
+
set: function set(hsl) {
|
|
253
|
+
if (hsl.length === 3) {
|
|
254
|
+
hsl[3] = 1;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
this._hsla = hsl;
|
|
258
|
+
this._rgba = null;
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
key: 'hslString',
|
|
262
|
+
get: function get() {
|
|
263
|
+
return this.printHSL();
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
key: 'hslaString',
|
|
267
|
+
get: function get() {
|
|
268
|
+
return this.printHSL(true);
|
|
269
|
+
}
|
|
270
|
+
}, {
|
|
271
|
+
key: 'hex',
|
|
272
|
+
get: function get() {
|
|
273
|
+
var rgb = this.rgba,
|
|
274
|
+
hex = rgb.map(function (x, i) {
|
|
275
|
+
return i < 3 ? x.toString(16) : Math.round(x * 255).toString(16);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
return '#' + hex.map(function (x) {
|
|
279
|
+
return x.padStart(2, '0');
|
|
280
|
+
}).join('');
|
|
281
|
+
},
|
|
282
|
+
set: function set(hex) {
|
|
283
|
+
this.rgba = Color.hexToRgb(hex);
|
|
284
|
+
}
|
|
285
|
+
}], [{
|
|
286
|
+
key: 'hexToRgb',
|
|
287
|
+
value: function hexToRgb(input) {
|
|
288
|
+
|
|
289
|
+
var hex = (input.startsWith('#') ? input.slice(1) : input).replace(/^(\w{3})$/, '$1F').replace(/^(\w)(\w)(\w)(\w)$/, '$1$1$2$2$3$3$4$4').replace(/^(\w{6})$/, '$1FF');
|
|
290
|
+
|
|
291
|
+
if (!hex.match(/^([0-9a-fA-F]{8})$/)) {
|
|
292
|
+
throw new Error('Unknown hex color; ' + input);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
var rgba = hex.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map(function (x) {
|
|
296
|
+
return parseInt(x, 16);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
rgba[3] = rgba[3] / 255;
|
|
300
|
+
return rgba;
|
|
301
|
+
}
|
|
302
|
+
}, {
|
|
303
|
+
key: 'nameToRgb',
|
|
304
|
+
value: function nameToRgb(input) {
|
|
305
|
+
|
|
306
|
+
var hash = input.toLowerCase().replace('at', 'T').replace(/[aeiouyldf]/g, '').replace('ght', 'L').replace('rk', 'D').slice(-5, 4),
|
|
307
|
+
hex = colorNames[hash];
|
|
308
|
+
return hex === undefined ? hex : Color.hexToRgb(hex.replace(/\-/g, '00').padStart(6, 'f'));
|
|
309
|
+
}
|
|
310
|
+
}, {
|
|
311
|
+
key: 'rgbToHsl',
|
|
312
|
+
value: function rgbToHsl(_ref) {
|
|
313
|
+
var _ref2 = slicedToArray(_ref, 4),
|
|
314
|
+
r = _ref2[0],
|
|
315
|
+
g = _ref2[1],
|
|
316
|
+
b = _ref2[2],
|
|
317
|
+
a = _ref2[3];
|
|
318
|
+
|
|
319
|
+
r /= 255;
|
|
320
|
+
g /= 255;
|
|
321
|
+
b /= 255;
|
|
322
|
+
|
|
323
|
+
var max = Math.max(r, g, b),
|
|
324
|
+
min = Math.min(r, g, b);
|
|
325
|
+
var h = void 0,
|
|
326
|
+
s = void 0,
|
|
327
|
+
l = (max + min) / 2;
|
|
328
|
+
|
|
329
|
+
if (max === min) {
|
|
330
|
+
h = s = 0;
|
|
331
|
+
} else {
|
|
332
|
+
var d = max - min;
|
|
333
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
334
|
+
switch (max) {
|
|
335
|
+
case r:
|
|
336
|
+
h = (g - b) / d + (g < b ? 6 : 0);break;
|
|
337
|
+
case g:
|
|
338
|
+
h = (b - r) / d + 2;break;
|
|
339
|
+
case b:
|
|
340
|
+
h = (r - g) / d + 4;break;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
h /= 6;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return [h, s, l, a];
|
|
347
|
+
}
|
|
348
|
+
}, {
|
|
349
|
+
key: 'hslToRgb',
|
|
350
|
+
value: function hslToRgb(_ref3) {
|
|
351
|
+
var _ref4 = slicedToArray(_ref3, 4),
|
|
352
|
+
h = _ref4[0],
|
|
353
|
+
s = _ref4[1],
|
|
354
|
+
l = _ref4[2],
|
|
355
|
+
a = _ref4[3];
|
|
356
|
+
|
|
357
|
+
var r = void 0,
|
|
358
|
+
g = void 0,
|
|
359
|
+
b = void 0;
|
|
360
|
+
|
|
361
|
+
if (s === 0) {
|
|
362
|
+
r = g = b = l;
|
|
363
|
+
} else {
|
|
364
|
+
var hue2rgb = function hue2rgb(p, q, t) {
|
|
365
|
+
if (t < 0) t += 1;
|
|
366
|
+
if (t > 1) t -= 1;
|
|
367
|
+
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
368
|
+
if (t < 1 / 2) return q;
|
|
369
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
370
|
+
return p;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s,
|
|
374
|
+
p = 2 * l - q;
|
|
375
|
+
|
|
376
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
377
|
+
g = hue2rgb(p, q, h);
|
|
378
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
var rgba = [r * 255, g * 255, b * 255].map(Math.round);
|
|
382
|
+
rgba[3] = a;
|
|
383
|
+
|
|
384
|
+
return rgba;
|
|
385
|
+
}
|
|
386
|
+
}]);
|
|
387
|
+
return Color;
|
|
388
|
+
}();
|
|
389
|
+
|
|
390
|
+
var EventBucket = function () {
|
|
391
|
+
function EventBucket() {
|
|
392
|
+
classCallCheck(this, EventBucket);
|
|
393
|
+
|
|
394
|
+
this._events = [];
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
createClass(EventBucket, [{
|
|
398
|
+
key: 'add',
|
|
399
|
+
value: function add(target, type, handler) {
|
|
400
|
+
target.addEventListener(type, handler, false);
|
|
401
|
+
this._events.push({
|
|
402
|
+
target: target,
|
|
403
|
+
type: type,
|
|
404
|
+
handler: handler
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}, {
|
|
408
|
+
key: 'remove',
|
|
409
|
+
value: function remove(target, type, handler) {
|
|
410
|
+
this._events = this._events.filter(function (e) {
|
|
411
|
+
var isMatch = true;
|
|
412
|
+
if (target && target !== e.target) {
|
|
413
|
+
isMatch = false;
|
|
414
|
+
}
|
|
415
|
+
if (type && type !== e.type) {
|
|
416
|
+
isMatch = false;
|
|
417
|
+
}
|
|
418
|
+
if (handler && handler !== e.handler) {
|
|
419
|
+
isMatch = false;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (isMatch) {
|
|
423
|
+
EventBucket._doRemove(e.target, e.type, e.handler);
|
|
424
|
+
}
|
|
425
|
+
return !isMatch;
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}, {
|
|
429
|
+
key: 'destroy',
|
|
430
|
+
value: function destroy() {
|
|
431
|
+
this._events.forEach(function (e) {
|
|
432
|
+
return EventBucket._doRemove(e.target, e.type, e.handler);
|
|
433
|
+
});
|
|
434
|
+
this._events = [];
|
|
435
|
+
}
|
|
436
|
+
}], [{
|
|
437
|
+
key: '_doRemove',
|
|
438
|
+
value: function _doRemove(target, type, handler) {
|
|
439
|
+
target.removeEventListener(type, handler, false);
|
|
440
|
+
}
|
|
441
|
+
}]);
|
|
442
|
+
return EventBucket;
|
|
443
|
+
}();
|
|
444
|
+
|
|
445
|
+
function parseHTML(htmlString) {
|
|
446
|
+
|
|
447
|
+
var div = document.createElement('div');
|
|
448
|
+
div.innerHTML = htmlString;
|
|
449
|
+
return div.firstElementChild;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function dragTrack(eventBucket, area, callback) {
|
|
453
|
+
var dragging = false;
|
|
454
|
+
|
|
455
|
+
function clamp(val, min, max) {
|
|
456
|
+
return Math.max(min, Math.min(val, max));
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function onMove(e, info, starting) {
|
|
460
|
+
if (starting) {
|
|
461
|
+
dragging = true;
|
|
462
|
+
}
|
|
463
|
+
if (!dragging) {
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
e.preventDefault();
|
|
468
|
+
|
|
469
|
+
var bounds = area.getBoundingClientRect(),
|
|
470
|
+
w = bounds.width,
|
|
471
|
+
h = bounds.height,
|
|
472
|
+
x = info.clientX,
|
|
473
|
+
y = info.clientY;
|
|
474
|
+
|
|
475
|
+
var relX = clamp(x - bounds.left, 0, w),
|
|
476
|
+
relY = clamp(y - bounds.top, 0, h);
|
|
477
|
+
|
|
478
|
+
callback(relX / w, relY / h);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function onMouse(e, starting) {
|
|
482
|
+
var button = e.buttons === undefined ? e.which : e.buttons;
|
|
483
|
+
if (button === 1) {
|
|
484
|
+
onMove(e, e, starting);
|
|
485
|
+
} else {
|
|
486
|
+
dragging = false;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function onTouch(e, starting) {
|
|
491
|
+
if (e.touches.length === 1) {
|
|
492
|
+
onMove(e, e.touches[0], starting);
|
|
493
|
+
} else {
|
|
494
|
+
dragging = false;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
eventBucket.add(area, 'mousedown', function (e) {
|
|
499
|
+
onMouse(e, true);
|
|
500
|
+
});
|
|
501
|
+
eventBucket.add(area, 'touchstart', function (e) {
|
|
502
|
+
onTouch(e, true);
|
|
503
|
+
});
|
|
504
|
+
eventBucket.add(window, 'mousemove', onMouse);
|
|
505
|
+
eventBucket.add(area, 'touchmove', onTouch);
|
|
506
|
+
eventBucket.add(window, 'mouseup', function (e) {
|
|
507
|
+
dragging = false;
|
|
508
|
+
});
|
|
509
|
+
eventBucket.add(area, 'touchend', function (e) {
|
|
510
|
+
dragging = false;
|
|
511
|
+
});
|
|
512
|
+
eventBucket.add(area, 'touchcancel', function (e) {
|
|
513
|
+
dragging = false;
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
var BG_TRANSP = 'linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em';
|
|
518
|
+
var HUES = 360;
|
|
519
|
+
|
|
520
|
+
var EVENT_KEY = 'keydown',
|
|
521
|
+
EVENT_CLICK_OUTSIDE = 'mousedown',
|
|
522
|
+
EVENT_TAB_MOVE = 'focusin';
|
|
523
|
+
|
|
524
|
+
function $(selector, context) {
|
|
525
|
+
return (context || document).querySelector(selector);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function stopEvent(e) {
|
|
529
|
+
|
|
530
|
+
e.preventDefault();
|
|
531
|
+
e.stopPropagation();
|
|
532
|
+
}
|
|
533
|
+
function onKey(bucket, target, keys, handler, stop) {
|
|
534
|
+
bucket.add(target, EVENT_KEY, function (e) {
|
|
535
|
+
if (keys.indexOf(e.key) >= 0) {
|
|
536
|
+
handler(e);
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
var Picker = function () {
|
|
542
|
+
function Picker(options) {
|
|
543
|
+
classCallCheck(this, Picker);
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
this.settings = {
|
|
547
|
+
|
|
548
|
+
popup: 'right',
|
|
549
|
+
layout: 'default',
|
|
550
|
+
alpha: true,
|
|
551
|
+
editor: true,
|
|
552
|
+
editorFormat: 'hex',
|
|
553
|
+
cancelButton: false,
|
|
554
|
+
defaultColor: '#0cf'
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
this._events = new EventBucket();
|
|
558
|
+
|
|
559
|
+
this.onChange = null;
|
|
560
|
+
|
|
561
|
+
this.onDone = null;
|
|
562
|
+
|
|
563
|
+
this.onOpen = null;
|
|
564
|
+
|
|
565
|
+
this.onClose = null;
|
|
566
|
+
|
|
567
|
+
this.setOptions(options);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
createClass(Picker, [{
|
|
571
|
+
key: 'setOptions',
|
|
572
|
+
value: function setOptions(options) {
|
|
573
|
+
var _this = this;
|
|
574
|
+
|
|
575
|
+
if (!options) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
var settings = this.settings;
|
|
579
|
+
|
|
580
|
+
function transfer(source, target, skipKeys) {
|
|
581
|
+
for (var key in source) {
|
|
582
|
+
|
|
583
|
+
target[key] = source[key];
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (options instanceof HTMLElement) {
|
|
588
|
+
settings.parent = options;
|
|
589
|
+
} else {
|
|
590
|
+
|
|
591
|
+
if (settings.parent && options.parent && settings.parent !== options.parent) {
|
|
592
|
+
this._events.remove(settings.parent);
|
|
593
|
+
this._popupInited = false;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
transfer(options, settings);
|
|
597
|
+
|
|
598
|
+
if (options.onChange) {
|
|
599
|
+
this.onChange = options.onChange;
|
|
600
|
+
}
|
|
601
|
+
if (options.onDone) {
|
|
602
|
+
this.onDone = options.onDone;
|
|
603
|
+
}
|
|
604
|
+
if (options.onOpen) {
|
|
605
|
+
this.onOpen = options.onOpen;
|
|
606
|
+
}
|
|
607
|
+
if (options.onClose) {
|
|
608
|
+
this.onClose = options.onClose;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
var col = options.color || options.colour;
|
|
612
|
+
if (col) {
|
|
613
|
+
this._setColor(col);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
var parent = settings.parent;
|
|
618
|
+
if (parent && settings.popup && !this._popupInited) {
|
|
619
|
+
|
|
620
|
+
var openProxy = function openProxy(e) {
|
|
621
|
+
return _this.openHandler(e);
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
this._events.add(parent, 'click', openProxy);
|
|
625
|
+
|
|
626
|
+
onKey(this._events, parent, [' ', 'Spacebar', 'Enter'], openProxy);
|
|
627
|
+
|
|
628
|
+
this._popupInited = true;
|
|
629
|
+
} else if (options.parent && !settings.popup) {
|
|
630
|
+
this.show();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}, {
|
|
634
|
+
key: 'openHandler',
|
|
635
|
+
value: function openHandler(e) {
|
|
636
|
+
if (this.show()) {
|
|
637
|
+
|
|
638
|
+
e && e.preventDefault();
|
|
639
|
+
|
|
640
|
+
this.settings.parent.style.pointerEvents = 'none';
|
|
641
|
+
|
|
642
|
+
var toFocus = e && e.type === EVENT_KEY ? this._domEdit : this.domElement;
|
|
643
|
+
setTimeout(function () {
|
|
644
|
+
return toFocus.focus();
|
|
645
|
+
}, 100);
|
|
646
|
+
|
|
647
|
+
if (this.onOpen) {
|
|
648
|
+
this.onOpen(this.colour);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}, {
|
|
653
|
+
key: 'closeHandler',
|
|
654
|
+
value: function closeHandler(e) {
|
|
655
|
+
var event = e && e.type;
|
|
656
|
+
var doHide = false;
|
|
657
|
+
|
|
658
|
+
if (!e) {
|
|
659
|
+
doHide = true;
|
|
660
|
+
} else if (event === EVENT_CLICK_OUTSIDE || event === EVENT_TAB_MOVE) {
|
|
661
|
+
|
|
662
|
+
var knownTime = (this.__containedEvent || 0) + 100;
|
|
663
|
+
if (e.timeStamp > knownTime) {
|
|
664
|
+
doHide = true;
|
|
665
|
+
}
|
|
666
|
+
} else {
|
|
667
|
+
|
|
668
|
+
stopEvent(e);
|
|
669
|
+
|
|
670
|
+
doHide = true;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
if (doHide && this.hide()) {
|
|
674
|
+
this.settings.parent.style.pointerEvents = '';
|
|
675
|
+
|
|
676
|
+
if (event !== EVENT_CLICK_OUTSIDE) {
|
|
677
|
+
this.settings.parent.focus();
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
if (this.onClose) {
|
|
681
|
+
this.onClose(this.colour);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}, {
|
|
686
|
+
key: 'movePopup',
|
|
687
|
+
value: function movePopup(options, open) {
|
|
688
|
+
|
|
689
|
+
this.closeHandler();
|
|
690
|
+
|
|
691
|
+
this.setOptions(options);
|
|
692
|
+
if (open) {
|
|
693
|
+
this.openHandler();
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}, {
|
|
697
|
+
key: 'setColor',
|
|
698
|
+
value: function setColor(color, silent) {
|
|
699
|
+
this._setColor(color, { silent: silent });
|
|
700
|
+
}
|
|
701
|
+
}, {
|
|
702
|
+
key: '_setColor',
|
|
703
|
+
value: function _setColor(color, flags) {
|
|
704
|
+
if (typeof color === 'string') {
|
|
705
|
+
color = color.trim();
|
|
706
|
+
}
|
|
707
|
+
if (!color) {
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
flags = flags || {};
|
|
712
|
+
var c = void 0;
|
|
713
|
+
try {
|
|
714
|
+
|
|
715
|
+
c = new Color(color);
|
|
716
|
+
} catch (ex) {
|
|
717
|
+
if (flags.failSilently) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
throw ex;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (!this.settings.alpha) {
|
|
724
|
+
var hsla = c.hsla;
|
|
725
|
+
hsla[3] = 1;
|
|
726
|
+
c.hsla = hsla;
|
|
727
|
+
}
|
|
728
|
+
this.colour = this.color = c;
|
|
729
|
+
this._setHSLA(null, null, null, null, flags);
|
|
730
|
+
}
|
|
731
|
+
}, {
|
|
732
|
+
key: 'setColour',
|
|
733
|
+
value: function setColour(colour, silent) {
|
|
734
|
+
this.setColor(colour, silent);
|
|
735
|
+
}
|
|
736
|
+
}, {
|
|
737
|
+
key: 'show',
|
|
738
|
+
value: function show() {
|
|
739
|
+
var parent = this.settings.parent;
|
|
740
|
+
if (!parent) {
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if (this.domElement) {
|
|
745
|
+
var toggled = this._toggleDOM(true);
|
|
746
|
+
|
|
747
|
+
this._setPosition();
|
|
748
|
+
|
|
749
|
+
return toggled;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
var html = this.settings.template || '<div class="picker_wrapper" tabindex="-1"><div class="picker_arrow"></div><div class="picker_hue picker_slider"><div class="picker_selector"></div></div><div class="picker_sl"><div class="picker_selector"></div></div><div class="picker_alpha picker_slider"><div class="picker_selector"></div></div><div class="picker_editor"><input aria-label="Type a color name or hex value"/></div><div class="picker_sample"></div><div class="picker_done"><button>Ok</button></div><div class="picker_cancel"><button>Cancel</button></div></div>';
|
|
753
|
+
var wrapper = parseHTML(html);
|
|
754
|
+
|
|
755
|
+
this.domElement = wrapper;
|
|
756
|
+
this._domH = $('.picker_hue', wrapper);
|
|
757
|
+
this._domSL = $('.picker_sl', wrapper);
|
|
758
|
+
this._domA = $('.picker_alpha', wrapper);
|
|
759
|
+
this._domEdit = $('.picker_editor input', wrapper);
|
|
760
|
+
this._domSample = $('.picker_sample', wrapper);
|
|
761
|
+
this._domOkay = $('.picker_done button', wrapper);
|
|
762
|
+
this._domCancel = $('.picker_cancel button', wrapper);
|
|
763
|
+
|
|
764
|
+
wrapper.classList.add('layout_' + this.settings.layout);
|
|
765
|
+
if (!this.settings.alpha) {
|
|
766
|
+
wrapper.classList.add('no_alpha');
|
|
767
|
+
}
|
|
768
|
+
if (!this.settings.editor) {
|
|
769
|
+
wrapper.classList.add('no_editor');
|
|
770
|
+
}
|
|
771
|
+
if (!this.settings.cancelButton) {
|
|
772
|
+
wrapper.classList.add('no_cancel');
|
|
773
|
+
}
|
|
774
|
+
this._ifPopup(function () {
|
|
775
|
+
return wrapper.classList.add('popup');
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
this._setPosition();
|
|
779
|
+
|
|
780
|
+
if (this.colour) {
|
|
781
|
+
this._updateUI();
|
|
782
|
+
} else {
|
|
783
|
+
this._setColor(this.settings.defaultColor);
|
|
784
|
+
}
|
|
785
|
+
this._bindEvents();
|
|
786
|
+
|
|
787
|
+
return true;
|
|
788
|
+
}
|
|
789
|
+
}, {
|
|
790
|
+
key: 'hide',
|
|
791
|
+
value: function hide() {
|
|
792
|
+
return this._toggleDOM(false);
|
|
793
|
+
}
|
|
794
|
+
}, {
|
|
795
|
+
key: 'destroy',
|
|
796
|
+
value: function destroy() {
|
|
797
|
+
this._events.destroy();
|
|
798
|
+
if (this.domElement) {
|
|
799
|
+
this.settings.parent.removeChild(this.domElement);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}, {
|
|
803
|
+
key: '_bindEvents',
|
|
804
|
+
value: function _bindEvents() {
|
|
805
|
+
var _this2 = this;
|
|
806
|
+
|
|
807
|
+
var that = this,
|
|
808
|
+
dom = this.domElement,
|
|
809
|
+
events = this._events;
|
|
810
|
+
|
|
811
|
+
function addEvent(target, type, handler) {
|
|
812
|
+
events.add(target, type, handler);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
addEvent(dom, 'click', function (e) {
|
|
816
|
+
return e.preventDefault();
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
dragTrack(events, this._domH, function (x, y) {
|
|
820
|
+
return that._setHSLA(x);
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
dragTrack(events, this._domSL, function (x, y) {
|
|
824
|
+
return that._setHSLA(null, x, 1 - y);
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
if (this.settings.alpha) {
|
|
828
|
+
dragTrack(events, this._domA, function (x, y) {
|
|
829
|
+
return that._setHSLA(null, null, null, 1 - y);
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
var editInput = this._domEdit;
|
|
834
|
+
{
|
|
835
|
+
addEvent(editInput, 'input', function (e) {
|
|
836
|
+
that._setColor(this.value, { fromEditor: true, failSilently: true });
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
addEvent(editInput, 'focus', function (e) {
|
|
840
|
+
var input = this;
|
|
841
|
+
|
|
842
|
+
if (input.selectionStart === input.selectionEnd) {
|
|
843
|
+
input.select();
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
this._ifPopup(function () {
|
|
849
|
+
|
|
850
|
+
var popupCloseProxy = function popupCloseProxy(e) {
|
|
851
|
+
return _this2.closeHandler(e);
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
addEvent(window, EVENT_CLICK_OUTSIDE, popupCloseProxy);
|
|
855
|
+
addEvent(window, EVENT_TAB_MOVE, popupCloseProxy);
|
|
856
|
+
onKey(events, dom, ['Esc', 'Escape'], popupCloseProxy);
|
|
857
|
+
|
|
858
|
+
var timeKeeper = function timeKeeper(e) {
|
|
859
|
+
_this2.__containedEvent = e.timeStamp;
|
|
860
|
+
};
|
|
861
|
+
addEvent(dom, EVENT_CLICK_OUTSIDE, timeKeeper);
|
|
862
|
+
|
|
863
|
+
addEvent(dom, EVENT_TAB_MOVE, timeKeeper);
|
|
864
|
+
|
|
865
|
+
addEvent(_this2._domCancel, 'click', popupCloseProxy);
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
var onDoneProxy = function onDoneProxy(e) {
|
|
869
|
+
_this2._ifPopup(function () {
|
|
870
|
+
return _this2.closeHandler(e);
|
|
871
|
+
});
|
|
872
|
+
if (_this2.onDone) {
|
|
873
|
+
_this2.onDone(_this2.colour);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
addEvent(this._domOkay, 'click', onDoneProxy);
|
|
877
|
+
onKey(events, dom, ['Enter'], onDoneProxy);
|
|
878
|
+
}
|
|
879
|
+
}, {
|
|
880
|
+
key: '_setPosition',
|
|
881
|
+
value: function _setPosition() {
|
|
882
|
+
var parent = this.settings.parent,
|
|
883
|
+
elm = this.domElement;
|
|
884
|
+
|
|
885
|
+
if (parent !== elm.parentNode) {
|
|
886
|
+
parent.appendChild(elm);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
this._ifPopup(function (popup) {
|
|
890
|
+
|
|
891
|
+
if (getComputedStyle(parent).position === 'static') {
|
|
892
|
+
parent.style.position = 'relative';
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
var cssClass = popup === true ? 'popup_right' : 'popup_' + popup;
|
|
896
|
+
|
|
897
|
+
['popup_top', 'popup_bottom', 'popup_left', 'popup_right'].forEach(function (c) {
|
|
898
|
+
|
|
899
|
+
if (c === cssClass) {
|
|
900
|
+
elm.classList.add(c);
|
|
901
|
+
} else {
|
|
902
|
+
elm.classList.remove(c);
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
elm.classList.add(cssClass);
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
}, {
|
|
910
|
+
key: '_setHSLA',
|
|
911
|
+
value: function _setHSLA(h, s, l, a, flags) {
|
|
912
|
+
flags = flags || {};
|
|
913
|
+
|
|
914
|
+
var col = this.colour,
|
|
915
|
+
hsla = col.hsla;
|
|
916
|
+
|
|
917
|
+
[h, s, l, a].forEach(function (x, i) {
|
|
918
|
+
if (x || x === 0) {
|
|
919
|
+
hsla[i] = x;
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
col.hsla = hsla;
|
|
923
|
+
|
|
924
|
+
this._updateUI(flags);
|
|
925
|
+
|
|
926
|
+
if (this.onChange && !flags.silent) {
|
|
927
|
+
this.onChange(col);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}, {
|
|
931
|
+
key: '_updateUI',
|
|
932
|
+
value: function _updateUI(flags) {
|
|
933
|
+
if (!this.domElement) {
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
flags = flags || {};
|
|
937
|
+
|
|
938
|
+
var col = this.colour,
|
|
939
|
+
hsl = col.hsla,
|
|
940
|
+
cssHue = 'hsl(' + hsl[0] * HUES + ', 100%, 50%)',
|
|
941
|
+
cssHSL = col.hslString,
|
|
942
|
+
cssHSLA = col.hslaString;
|
|
943
|
+
|
|
944
|
+
var uiH = this._domH,
|
|
945
|
+
uiSL = this._domSL,
|
|
946
|
+
uiA = this._domA,
|
|
947
|
+
thumbH = $('.picker_selector', uiH),
|
|
948
|
+
thumbSL = $('.picker_selector', uiSL),
|
|
949
|
+
thumbA = $('.picker_selector', uiA);
|
|
950
|
+
|
|
951
|
+
function posX(parent, child, relX) {
|
|
952
|
+
child.style.left = relX * 100 + '%';
|
|
953
|
+
}
|
|
954
|
+
function posY(parent, child, relY) {
|
|
955
|
+
child.style.top = relY * 100 + '%';
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
posX(uiH, thumbH, hsl[0]);
|
|
959
|
+
|
|
960
|
+
this._domSL.style.backgroundColor = this._domH.style.color = cssHue;
|
|
961
|
+
|
|
962
|
+
posX(uiSL, thumbSL, hsl[1]);
|
|
963
|
+
posY(uiSL, thumbSL, 1 - hsl[2]);
|
|
964
|
+
|
|
965
|
+
uiSL.style.color = cssHSL;
|
|
966
|
+
|
|
967
|
+
posY(uiA, thumbA, 1 - hsl[3]);
|
|
968
|
+
|
|
969
|
+
var opaque = cssHSL,
|
|
970
|
+
transp = opaque.replace('hsl', 'hsla').replace(')', ', 0)'),
|
|
971
|
+
bg = 'linear-gradient(' + [opaque, transp] + ')';
|
|
972
|
+
|
|
973
|
+
this._domA.style.background = bg + ', ' + BG_TRANSP;
|
|
974
|
+
|
|
975
|
+
if (!flags.fromEditor) {
|
|
976
|
+
var format = this.settings.editorFormat,
|
|
977
|
+
alpha = this.settings.alpha;
|
|
978
|
+
|
|
979
|
+
var value = void 0;
|
|
980
|
+
switch (format) {
|
|
981
|
+
case 'rgb':
|
|
982
|
+
value = col.printRGB(alpha);break;
|
|
983
|
+
case 'hsl':
|
|
984
|
+
value = col.printHSL(alpha);break;
|
|
985
|
+
default:
|
|
986
|
+
value = col.printHex(alpha);
|
|
987
|
+
}
|
|
988
|
+
this._domEdit.value = value;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
this._domSample.style.color = cssHSLA;
|
|
992
|
+
}
|
|
993
|
+
}, {
|
|
994
|
+
key: '_ifPopup',
|
|
995
|
+
value: function _ifPopup(actionIf, actionElse) {
|
|
996
|
+
if (this.settings.parent && this.settings.popup) {
|
|
997
|
+
actionIf && actionIf(this.settings.popup);
|
|
998
|
+
} else {
|
|
999
|
+
actionElse && actionElse();
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}, {
|
|
1003
|
+
key: '_toggleDOM',
|
|
1004
|
+
value: function _toggleDOM(toVisible) {
|
|
1005
|
+
var dom = this.domElement;
|
|
1006
|
+
if (!dom) {
|
|
1007
|
+
return false;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
var displayStyle = toVisible ? '' : 'none',
|
|
1011
|
+
toggle = dom.style.display !== displayStyle;
|
|
1012
|
+
|
|
1013
|
+
if (toggle) {
|
|
1014
|
+
dom.style.display = displayStyle;
|
|
1015
|
+
}
|
|
1016
|
+
return toggle;
|
|
1017
|
+
}
|
|
1018
|
+
}]);
|
|
1019
|
+
return Picker;
|
|
1020
|
+
}();
|
|
1021
|
+
|
|
1022
|
+
{
|
|
1023
|
+
var style = document.createElement('style');
|
|
1024
|
+
style.textContent = '.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:"";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:"";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:"";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:"";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}';
|
|
1025
|
+
document.documentElement.firstElementChild.appendChild(style);
|
|
1026
|
+
|
|
1027
|
+
Picker.StyleElement = style;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
return Picker;
|
|
1031
|
+
|
|
1032
|
+
}));
|
|
1033
|
+
} (vanillaPicker$3));
|
|
1034
|
+
return vanillaPicker$3.exports;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
var vanillaPickerExports = requireVanillaPicker();
|
|
1038
|
+
var vanillaPicker = /*@__PURE__*/index.getDefaultExportFromCjs(vanillaPickerExports);
|
|
1039
|
+
|
|
1040
|
+
var vanillaPicker$1 = /*#__PURE__*/_mergeNamespaces({
|
|
1041
|
+
__proto__: null,
|
|
1042
|
+
default: vanillaPicker
|
|
1043
|
+
}, [vanillaPickerExports]);
|
|
1044
|
+
|
|
1045
|
+
exports.vanillaPicker = vanillaPicker$1;
|