@salla.sa/twilight-components 2.14.346 → 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-D3JT19b9.js → filepond-B_sfbQx7.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-vIqpi5Jb.js → filepond-plugin-file-poster-CStjlaHV.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-CGka-OOR.js → filepond-plugin-file-validate-size-DrcM89vc.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-D5Xexu4N.js → filepond-plugin-file-validate-type-DnIoL6mq.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-CIxcoEFX.js → filepond-plugin-image-edit-DLV0U0gb.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-yRezDeUb.js → filepond-plugin-image-exif-orientation-tPl3p3z_.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-CPE8T2_S.js → filepond-plugin-image-preview-WTfIQM6C.js} +1 -1
- package/dist/cjs/{index-B_jylE1-.js → index-4jrFyN8u.js} +1 -1
- package/dist/cjs/{index-CBbHmJY_.js → index-CkpcUCU5.js} +2 -2
- 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 +2 -2
- 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-ESI025KA.js → filepond-BBd4zIxi.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-CWHjkl55.js → filepond-plugin-file-poster-Vvhvcuu3.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-B7W5i7Mk.js → filepond-plugin-file-validate-size-NvdGUEr-.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-B1Ny76Ep.js → filepond-plugin-file-validate-type-BwVZhOLd.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-DfqS6NSZ.js → filepond-plugin-image-edit-BOgZn2vW.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-3kpdQNdB.js → filepond-plugin-image-exif-orientation-BmbDj4hl.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-Ck91BQiY.js → filepond-plugin-image-preview-CDsLWAPe.js} +1 -1
- package/dist/esm/{index-5xSCOnsp.js → index-BhHl4h44.js} +1 -1
- package/dist/esm/{index-gdKTeC4S.js → index-LmL2BolE.js} +2 -2
- 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-158398ff.entry.js → p-03870195.entry.js} +1 -1
- package/dist/twilight/{p-db68f32e.entry.js → p-06956c1d.entry.js} +1 -1
- package/dist/twilight/{p-4e98e961.entry.js → p-07add349.entry.js} +1 -1
- package/dist/twilight/{p-343c8271.entry.js → p-09dceb55.entry.js} +1 -1
- package/dist/twilight/{p-f64cd638.entry.js → p-0aef5345.entry.js} +1 -1
- package/dist/twilight/{p-eab13555.entry.js → p-133f1a48.entry.js} +1 -1
- package/dist/twilight/{p-936a76d1.entry.js → p-23ff2132.entry.js} +1 -1
- package/dist/twilight/{p-1445c077.entry.js → p-2c9d0518.entry.js} +1 -1
- package/dist/twilight/{p-6bd166a7.entry.js → p-2ed7cfba.entry.js} +1 -1
- package/dist/twilight/p-2gPrnQD6.js +9 -0
- package/dist/twilight/{p-369ada5a.entry.js → p-312c1af1.entry.js} +1 -1
- package/dist/twilight/{p-b8f7b4eb.entry.js → p-388fb59e.entry.js} +1 -1
- package/dist/twilight/{p-a7a488d5.entry.js → p-3d69e45a.entry.js} +1 -1
- package/dist/twilight/{p-ad2b2919.entry.js → p-45cd70b8.entry.js} +1 -1
- package/dist/twilight/{p-0a4b04a4.entry.js → p-48b90fb3.entry.js} +1 -1
- package/dist/twilight/{p-ebd8dbf8.entry.js → p-4cd30c07.entry.js} +1 -1
- package/dist/twilight/{p-ef0fa205.entry.js → p-4d47725f.entry.js} +1 -1
- package/dist/twilight/{p-8a1aa61c.entry.js → p-549ff403.entry.js} +1 -1
- package/dist/twilight/{p-46b242d9.entry.js → p-63e9750c.entry.js} +1 -1
- package/dist/twilight/{p-b0e7c134.entry.js → p-6c648552.entry.js} +1 -1
- package/dist/twilight/{p-5099bc51.entry.js → p-74aaf06c.entry.js} +1 -1
- package/dist/twilight/{p-003a77fe.entry.js → p-7c85a102.entry.js} +1 -1
- package/dist/twilight/{p-49638a91.entry.js → p-8c111815.entry.js} +1 -1
- package/dist/twilight/{p-e465a952.entry.js → p-950f9a87.entry.js} +1 -1
- package/dist/twilight/{p-8563e747.entry.js → p-966ed241.entry.js} +1 -1
- package/dist/twilight/{p-aefe5639.entry.js → p-9f39c553.entry.js} +1 -1
- package/dist/twilight/p-Bf4kQRcH.js +11 -0
- package/dist/twilight/{p-D3JRC8L6.js → p-CIEz2m31.js} +1 -1
- package/dist/twilight/{p-DH5ljldi.js → p-D1_qMmD0.js} +1 -1
- package/dist/twilight/{p-gdKTeC4S.js → p-LmL2BolE.js} +1 -1
- package/dist/twilight/{p-DpJnHcvE.js → p-TSs7NqKJ.js} +1 -1
- package/dist/twilight/{p-1037bca4.entry.js → p-b30a12dc.entry.js} +1 -1
- package/dist/twilight/{p-8100a941.entry.js → p-bcec0cf0.entry.js} +1 -1
- package/dist/twilight/{p-CUtvZOiz.js → p-c0pjDpvN.js} +1 -1
- package/dist/twilight/{p-3e410acd.entry.js → p-c302d3e3.entry.js} +1 -1
- package/dist/twilight/{p-5570cae4.entry.js → p-c38c65f0.entry.js} +1 -1
- package/dist/twilight/{p-7b5906b8.entry.js → p-cd2c9076.entry.js} +1 -1
- package/dist/twilight/{p-36a95a0f.entry.js → p-d2ed15e9.entry.js} +1 -1
- package/dist/twilight/{p-8418b725.entry.js → p-f1f60ef7.entry.js} +1 -1
- package/dist/twilight/{p-360a28b9.entry.js → p-f74f1591.entry.js} +1 -1
- package/dist/twilight/{p-d5da6f45.entry.js → p-fbbd8d5d.entry.js} +1 -1
- package/dist/twilight/p-fff8923d.entry.js +4 -0
- package/dist/twilight/{p-DId3Z42j.js → p-qNQwLhxq.js} +1 -1
- package/dist/twilight/{p-rYLDeLaL.js → p-v9xIxXO9.js} +1 -1
- package/dist/twilight/{p-CMYBgZIX.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-04e81b46.entry.js +0 -11
- package/dist/twilight/p-EnsROQgl.js +0 -9
|
@@ -1,1030 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import { proxyCustomElement, HTMLElement
|
|
5
|
-
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.js';
|
|
4
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
6
5
|
import { A as ArrowDown } from './keyboard_arrow_down.js';
|
|
7
6
|
|
|
8
|
-
var vanillaPicker$1 = {exports: {}};
|
|
9
|
-
|
|
10
|
-
/*!
|
|
11
|
-
* vanilla-picker v2.12.3
|
|
12
|
-
* https://vanilla-picker.js.org
|
|
13
|
-
*
|
|
14
|
-
* Copyright 2017-2024 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)
|
|
15
|
-
* Released under the ISC license.
|
|
16
|
-
*/
|
|
17
|
-
var vanillaPicker = vanillaPicker$1.exports;
|
|
18
|
-
|
|
19
|
-
var hasRequiredVanillaPicker;
|
|
20
|
-
|
|
21
|
-
function requireVanillaPicker () {
|
|
22
|
-
if (hasRequiredVanillaPicker) return vanillaPicker$1.exports;
|
|
23
|
-
hasRequiredVanillaPicker = 1;
|
|
24
|
-
(function (module, exports) {
|
|
25
|
-
(function (global, factory) {
|
|
26
|
-
module.exports = factory() ;
|
|
27
|
-
})(vanillaPicker, (function () {
|
|
28
|
-
var classCallCheck = function (instance, Constructor) {
|
|
29
|
-
if (!(instance instanceof Constructor)) {
|
|
30
|
-
throw new TypeError("Cannot call a class as a function");
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
var createClass = function () {
|
|
35
|
-
function defineProperties(target, props) {
|
|
36
|
-
for (var i = 0; i < props.length; i++) {
|
|
37
|
-
var descriptor = props[i];
|
|
38
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
39
|
-
descriptor.configurable = true;
|
|
40
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
41
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return function (Constructor, protoProps, staticProps) {
|
|
46
|
-
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
47
|
-
if (staticProps) defineProperties(Constructor, staticProps);
|
|
48
|
-
return Constructor;
|
|
49
|
-
};
|
|
50
|
-
}();
|
|
51
|
-
|
|
52
|
-
var slicedToArray = function () {
|
|
53
|
-
function sliceIterator(arr, i) {
|
|
54
|
-
var _arr = [];
|
|
55
|
-
var _n = true;
|
|
56
|
-
var _d = false;
|
|
57
|
-
var _e = undefined;
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
61
|
-
_arr.push(_s.value);
|
|
62
|
-
|
|
63
|
-
if (i && _arr.length === i) break;
|
|
64
|
-
}
|
|
65
|
-
} catch (err) {
|
|
66
|
-
_d = true;
|
|
67
|
-
_e = err;
|
|
68
|
-
} finally {
|
|
69
|
-
try {
|
|
70
|
-
if (!_n && _i["return"]) _i["return"]();
|
|
71
|
-
} finally {
|
|
72
|
-
if (_d) throw _e;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return _arr;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return function (arr, i) {
|
|
80
|
-
if (Array.isArray(arr)) {
|
|
81
|
-
return arr;
|
|
82
|
-
} else if (Symbol.iterator in Object(arr)) {
|
|
83
|
-
return sliceIterator(arr, i);
|
|
84
|
-
} else {
|
|
85
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}();
|
|
89
|
-
|
|
90
|
-
String.prototype.startsWith = String.prototype.startsWith || function (needle) {
|
|
91
|
-
return this.indexOf(needle) === 0;
|
|
92
|
-
};
|
|
93
|
-
String.prototype.padStart = String.prototype.padStart || function (len, pad) {
|
|
94
|
-
var str = this;while (str.length < len) {
|
|
95
|
-
str = pad + str;
|
|
96
|
-
}return str;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
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' };
|
|
100
|
-
|
|
101
|
-
function printNum(num) {
|
|
102
|
-
var decs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
103
|
-
|
|
104
|
-
var str = decs > 0 ? num.toFixed(decs).replace(/0+$/, '').replace(/\.$/, '') : num.toString();
|
|
105
|
-
return str || '0';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var Color = function () {
|
|
109
|
-
function Color(r, g, b, a) {
|
|
110
|
-
classCallCheck(this, Color);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var that = this;
|
|
114
|
-
function parseString(input) {
|
|
115
|
-
|
|
116
|
-
if (input.startsWith('hsl')) {
|
|
117
|
-
var _input$match$map = input.match(/([\-\d\.e]+)/g).map(Number),
|
|
118
|
-
_input$match$map2 = slicedToArray(_input$match$map, 4),
|
|
119
|
-
h = _input$match$map2[0],
|
|
120
|
-
s = _input$match$map2[1],
|
|
121
|
-
l = _input$match$map2[2],
|
|
122
|
-
_a = _input$match$map2[3];
|
|
123
|
-
|
|
124
|
-
if (_a === undefined) {
|
|
125
|
-
_a = 1;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
h /= 360;
|
|
129
|
-
s /= 100;
|
|
130
|
-
l /= 100;
|
|
131
|
-
that.hsla = [h, s, l, _a];
|
|
132
|
-
} else if (input.startsWith('rgb')) {
|
|
133
|
-
var _input$match$map3 = input.match(/([\-\d\.e]+)/g).map(Number),
|
|
134
|
-
_input$match$map4 = slicedToArray(_input$match$map3, 4),
|
|
135
|
-
_r = _input$match$map4[0],
|
|
136
|
-
_g = _input$match$map4[1],
|
|
137
|
-
_b = _input$match$map4[2],
|
|
138
|
-
_a2 = _input$match$map4[3];
|
|
139
|
-
|
|
140
|
-
if (_a2 === undefined) {
|
|
141
|
-
_a2 = 1;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
that.rgba = [_r, _g, _b, _a2];
|
|
145
|
-
} else {
|
|
146
|
-
if (input.startsWith('#')) {
|
|
147
|
-
that.rgba = Color.hexToRgb(input);
|
|
148
|
-
} else {
|
|
149
|
-
that.rgba = Color.nameToRgb(input) || Color.hexToRgb(input);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (r === undefined) ; else if (Array.isArray(r)) {
|
|
155
|
-
this.rgba = r;
|
|
156
|
-
} else if (b === undefined) {
|
|
157
|
-
var color = r && '' + r;
|
|
158
|
-
if (color) {
|
|
159
|
-
parseString(color.toLowerCase());
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
this.rgba = [r, g, b, a === undefined ? 1 : a];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
createClass(Color, [{
|
|
167
|
-
key: 'printRGB',
|
|
168
|
-
value: function printRGB(alpha) {
|
|
169
|
-
var rgb = alpha ? this.rgba : this.rgba.slice(0, 3),
|
|
170
|
-
vals = rgb.map(function (x, i) {
|
|
171
|
-
return printNum(x, i === 3 ? 3 : 0);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
return alpha ? 'rgba(' + vals + ')' : 'rgb(' + vals + ')';
|
|
175
|
-
}
|
|
176
|
-
}, {
|
|
177
|
-
key: 'printHSL',
|
|
178
|
-
value: function printHSL(alpha) {
|
|
179
|
-
var mults = [360, 100, 100, 1],
|
|
180
|
-
suff = ['', '%', '%', ''];
|
|
181
|
-
|
|
182
|
-
var hsl = alpha ? this.hsla : this.hsla.slice(0, 3),
|
|
183
|
-
vals = hsl.map(function (x, i) {
|
|
184
|
-
return printNum(x * mults[i], i === 3 ? 3 : 1) + suff[i];
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
return alpha ? 'hsla(' + vals + ')' : 'hsl(' + vals + ')';
|
|
188
|
-
}
|
|
189
|
-
}, {
|
|
190
|
-
key: 'printHex',
|
|
191
|
-
value: function printHex(alpha) {
|
|
192
|
-
var hex = this.hex;
|
|
193
|
-
return alpha ? hex : hex.substring(0, 7);
|
|
194
|
-
}
|
|
195
|
-
}, {
|
|
196
|
-
key: 'rgba',
|
|
197
|
-
get: function get() {
|
|
198
|
-
if (this._rgba) {
|
|
199
|
-
return this._rgba;
|
|
200
|
-
}
|
|
201
|
-
if (!this._hsla) {
|
|
202
|
-
throw new Error('No color is set');
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return this._rgba = Color.hslToRgb(this._hsla);
|
|
206
|
-
},
|
|
207
|
-
set: function set(rgb) {
|
|
208
|
-
if (rgb.length === 3) {
|
|
209
|
-
rgb[3] = 1;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
this._rgba = rgb;
|
|
213
|
-
this._hsla = null;
|
|
214
|
-
}
|
|
215
|
-
}, {
|
|
216
|
-
key: 'rgbString',
|
|
217
|
-
get: function get() {
|
|
218
|
-
return this.printRGB();
|
|
219
|
-
}
|
|
220
|
-
}, {
|
|
221
|
-
key: 'rgbaString',
|
|
222
|
-
get: function get() {
|
|
223
|
-
return this.printRGB(true);
|
|
224
|
-
}
|
|
225
|
-
}, {
|
|
226
|
-
key: 'hsla',
|
|
227
|
-
get: function get() {
|
|
228
|
-
if (this._hsla) {
|
|
229
|
-
return this._hsla;
|
|
230
|
-
}
|
|
231
|
-
if (!this._rgba) {
|
|
232
|
-
throw new Error('No color is set');
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return this._hsla = Color.rgbToHsl(this._rgba);
|
|
236
|
-
},
|
|
237
|
-
set: function set(hsl) {
|
|
238
|
-
if (hsl.length === 3) {
|
|
239
|
-
hsl[3] = 1;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
this._hsla = hsl;
|
|
243
|
-
this._rgba = null;
|
|
244
|
-
}
|
|
245
|
-
}, {
|
|
246
|
-
key: 'hslString',
|
|
247
|
-
get: function get() {
|
|
248
|
-
return this.printHSL();
|
|
249
|
-
}
|
|
250
|
-
}, {
|
|
251
|
-
key: 'hslaString',
|
|
252
|
-
get: function get() {
|
|
253
|
-
return this.printHSL(true);
|
|
254
|
-
}
|
|
255
|
-
}, {
|
|
256
|
-
key: 'hex',
|
|
257
|
-
get: function get() {
|
|
258
|
-
var rgb = this.rgba,
|
|
259
|
-
hex = rgb.map(function (x, i) {
|
|
260
|
-
return i < 3 ? x.toString(16) : Math.round(x * 255).toString(16);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
return '#' + hex.map(function (x) {
|
|
264
|
-
return x.padStart(2, '0');
|
|
265
|
-
}).join('');
|
|
266
|
-
},
|
|
267
|
-
set: function set(hex) {
|
|
268
|
-
this.rgba = Color.hexToRgb(hex);
|
|
269
|
-
}
|
|
270
|
-
}], [{
|
|
271
|
-
key: 'hexToRgb',
|
|
272
|
-
value: function hexToRgb(input) {
|
|
273
|
-
|
|
274
|
-
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');
|
|
275
|
-
|
|
276
|
-
if (!hex.match(/^([0-9a-fA-F]{8})$/)) {
|
|
277
|
-
throw new Error('Unknown hex color; ' + input);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
var rgba = hex.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map(function (x) {
|
|
281
|
-
return parseInt(x, 16);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
rgba[3] = rgba[3] / 255;
|
|
285
|
-
return rgba;
|
|
286
|
-
}
|
|
287
|
-
}, {
|
|
288
|
-
key: 'nameToRgb',
|
|
289
|
-
value: function nameToRgb(input) {
|
|
290
|
-
|
|
291
|
-
var hash = input.toLowerCase().replace('at', 'T').replace(/[aeiouyldf]/g, '').replace('ght', 'L').replace('rk', 'D').slice(-5, 4),
|
|
292
|
-
hex = colorNames[hash];
|
|
293
|
-
return hex === undefined ? hex : Color.hexToRgb(hex.replace(/\-/g, '00').padStart(6, 'f'));
|
|
294
|
-
}
|
|
295
|
-
}, {
|
|
296
|
-
key: 'rgbToHsl',
|
|
297
|
-
value: function rgbToHsl(_ref) {
|
|
298
|
-
var _ref2 = slicedToArray(_ref, 4),
|
|
299
|
-
r = _ref2[0],
|
|
300
|
-
g = _ref2[1],
|
|
301
|
-
b = _ref2[2],
|
|
302
|
-
a = _ref2[3];
|
|
303
|
-
|
|
304
|
-
r /= 255;
|
|
305
|
-
g /= 255;
|
|
306
|
-
b /= 255;
|
|
307
|
-
|
|
308
|
-
var max = Math.max(r, g, b),
|
|
309
|
-
min = Math.min(r, g, b);
|
|
310
|
-
var h = void 0,
|
|
311
|
-
s = void 0,
|
|
312
|
-
l = (max + min) / 2;
|
|
313
|
-
|
|
314
|
-
if (max === min) {
|
|
315
|
-
h = s = 0;
|
|
316
|
-
} else {
|
|
317
|
-
var d = max - min;
|
|
318
|
-
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
319
|
-
switch (max) {
|
|
320
|
-
case r:
|
|
321
|
-
h = (g - b) / d + (g < b ? 6 : 0);break;
|
|
322
|
-
case g:
|
|
323
|
-
h = (b - r) / d + 2;break;
|
|
324
|
-
case b:
|
|
325
|
-
h = (r - g) / d + 4;break;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
h /= 6;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return [h, s, l, a];
|
|
332
|
-
}
|
|
333
|
-
}, {
|
|
334
|
-
key: 'hslToRgb',
|
|
335
|
-
value: function hslToRgb(_ref3) {
|
|
336
|
-
var _ref4 = slicedToArray(_ref3, 4),
|
|
337
|
-
h = _ref4[0],
|
|
338
|
-
s = _ref4[1],
|
|
339
|
-
l = _ref4[2],
|
|
340
|
-
a = _ref4[3];
|
|
341
|
-
|
|
342
|
-
var r = void 0,
|
|
343
|
-
g = void 0,
|
|
344
|
-
b = void 0;
|
|
345
|
-
|
|
346
|
-
if (s === 0) {
|
|
347
|
-
r = g = b = l;
|
|
348
|
-
} else {
|
|
349
|
-
var hue2rgb = function hue2rgb(p, q, t) {
|
|
350
|
-
if (t < 0) t += 1;
|
|
351
|
-
if (t > 1) t -= 1;
|
|
352
|
-
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
353
|
-
if (t < 1 / 2) return q;
|
|
354
|
-
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
355
|
-
return p;
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
var q = l < 0.5 ? l * (1 + s) : l + s - l * s,
|
|
359
|
-
p = 2 * l - q;
|
|
360
|
-
|
|
361
|
-
r = hue2rgb(p, q, h + 1 / 3);
|
|
362
|
-
g = hue2rgb(p, q, h);
|
|
363
|
-
b = hue2rgb(p, q, h - 1 / 3);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
var rgba = [r * 255, g * 255, b * 255].map(Math.round);
|
|
367
|
-
rgba[3] = a;
|
|
368
|
-
|
|
369
|
-
return rgba;
|
|
370
|
-
}
|
|
371
|
-
}]);
|
|
372
|
-
return Color;
|
|
373
|
-
}();
|
|
374
|
-
|
|
375
|
-
var EventBucket = function () {
|
|
376
|
-
function EventBucket() {
|
|
377
|
-
classCallCheck(this, EventBucket);
|
|
378
|
-
|
|
379
|
-
this._events = [];
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
createClass(EventBucket, [{
|
|
383
|
-
key: 'add',
|
|
384
|
-
value: function add(target, type, handler) {
|
|
385
|
-
target.addEventListener(type, handler, false);
|
|
386
|
-
this._events.push({
|
|
387
|
-
target: target,
|
|
388
|
-
type: type,
|
|
389
|
-
handler: handler
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
}, {
|
|
393
|
-
key: 'remove',
|
|
394
|
-
value: function remove(target, type, handler) {
|
|
395
|
-
this._events = this._events.filter(function (e) {
|
|
396
|
-
var isMatch = true;
|
|
397
|
-
if (target && target !== e.target) {
|
|
398
|
-
isMatch = false;
|
|
399
|
-
}
|
|
400
|
-
if (type && type !== e.type) {
|
|
401
|
-
isMatch = false;
|
|
402
|
-
}
|
|
403
|
-
if (handler && handler !== e.handler) {
|
|
404
|
-
isMatch = false;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (isMatch) {
|
|
408
|
-
EventBucket._doRemove(e.target, e.type, e.handler);
|
|
409
|
-
}
|
|
410
|
-
return !isMatch;
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
}, {
|
|
414
|
-
key: 'destroy',
|
|
415
|
-
value: function destroy() {
|
|
416
|
-
this._events.forEach(function (e) {
|
|
417
|
-
return EventBucket._doRemove(e.target, e.type, e.handler);
|
|
418
|
-
});
|
|
419
|
-
this._events = [];
|
|
420
|
-
}
|
|
421
|
-
}], [{
|
|
422
|
-
key: '_doRemove',
|
|
423
|
-
value: function _doRemove(target, type, handler) {
|
|
424
|
-
target.removeEventListener(type, handler, false);
|
|
425
|
-
}
|
|
426
|
-
}]);
|
|
427
|
-
return EventBucket;
|
|
428
|
-
}();
|
|
429
|
-
|
|
430
|
-
function parseHTML(htmlString) {
|
|
431
|
-
|
|
432
|
-
var div = document.createElement('div');
|
|
433
|
-
div.innerHTML = htmlString;
|
|
434
|
-
return div.firstElementChild;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
function dragTrack(eventBucket, area, callback) {
|
|
438
|
-
var dragging = false;
|
|
439
|
-
|
|
440
|
-
function clamp(val, min, max) {
|
|
441
|
-
return Math.max(min, Math.min(val, max));
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
function onMove(e, info, starting) {
|
|
445
|
-
if (starting) {
|
|
446
|
-
dragging = true;
|
|
447
|
-
}
|
|
448
|
-
if (!dragging) {
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
e.preventDefault();
|
|
453
|
-
|
|
454
|
-
var bounds = area.getBoundingClientRect(),
|
|
455
|
-
w = bounds.width,
|
|
456
|
-
h = bounds.height,
|
|
457
|
-
x = info.clientX,
|
|
458
|
-
y = info.clientY;
|
|
459
|
-
|
|
460
|
-
var relX = clamp(x - bounds.left, 0, w),
|
|
461
|
-
relY = clamp(y - bounds.top, 0, h);
|
|
462
|
-
|
|
463
|
-
callback(relX / w, relY / h);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
function onMouse(e, starting) {
|
|
467
|
-
var button = e.buttons === undefined ? e.which : e.buttons;
|
|
468
|
-
if (button === 1) {
|
|
469
|
-
onMove(e, e, starting);
|
|
470
|
-
} else {
|
|
471
|
-
dragging = false;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
function onTouch(e, starting) {
|
|
476
|
-
if (e.touches.length === 1) {
|
|
477
|
-
onMove(e, e.touches[0], starting);
|
|
478
|
-
} else {
|
|
479
|
-
dragging = false;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
eventBucket.add(area, 'mousedown', function (e) {
|
|
484
|
-
onMouse(e, true);
|
|
485
|
-
});
|
|
486
|
-
eventBucket.add(area, 'touchstart', function (e) {
|
|
487
|
-
onTouch(e, true);
|
|
488
|
-
});
|
|
489
|
-
eventBucket.add(window, 'mousemove', onMouse);
|
|
490
|
-
eventBucket.add(area, 'touchmove', onTouch);
|
|
491
|
-
eventBucket.add(window, 'mouseup', function (e) {
|
|
492
|
-
dragging = false;
|
|
493
|
-
});
|
|
494
|
-
eventBucket.add(area, 'touchend', function (e) {
|
|
495
|
-
dragging = false;
|
|
496
|
-
});
|
|
497
|
-
eventBucket.add(area, 'touchcancel', function (e) {
|
|
498
|
-
dragging = false;
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
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';
|
|
503
|
-
var HUES = 360;
|
|
504
|
-
|
|
505
|
-
var EVENT_KEY = 'keydown',
|
|
506
|
-
EVENT_CLICK_OUTSIDE = 'mousedown',
|
|
507
|
-
EVENT_TAB_MOVE = 'focusin';
|
|
508
|
-
|
|
509
|
-
function $(selector, context) {
|
|
510
|
-
return (context || document).querySelector(selector);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
function stopEvent(e) {
|
|
514
|
-
|
|
515
|
-
e.preventDefault();
|
|
516
|
-
e.stopPropagation();
|
|
517
|
-
}
|
|
518
|
-
function onKey(bucket, target, keys, handler, stop) {
|
|
519
|
-
bucket.add(target, EVENT_KEY, function (e) {
|
|
520
|
-
if (keys.indexOf(e.key) >= 0) {
|
|
521
|
-
handler(e);
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
var Picker = function () {
|
|
527
|
-
function Picker(options) {
|
|
528
|
-
classCallCheck(this, Picker);
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
this.settings = {
|
|
532
|
-
|
|
533
|
-
popup: 'right',
|
|
534
|
-
layout: 'default',
|
|
535
|
-
alpha: true,
|
|
536
|
-
editor: true,
|
|
537
|
-
editorFormat: 'hex',
|
|
538
|
-
cancelButton: false,
|
|
539
|
-
defaultColor: '#0cf'
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
this._events = new EventBucket();
|
|
543
|
-
|
|
544
|
-
this.onChange = null;
|
|
545
|
-
|
|
546
|
-
this.onDone = null;
|
|
547
|
-
|
|
548
|
-
this.onOpen = null;
|
|
549
|
-
|
|
550
|
-
this.onClose = null;
|
|
551
|
-
|
|
552
|
-
this.setOptions(options);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
createClass(Picker, [{
|
|
556
|
-
key: 'setOptions',
|
|
557
|
-
value: function setOptions(options) {
|
|
558
|
-
var _this = this;
|
|
559
|
-
|
|
560
|
-
if (!options) {
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
var settings = this.settings;
|
|
564
|
-
|
|
565
|
-
function transfer(source, target, skipKeys) {
|
|
566
|
-
for (var key in source) {
|
|
567
|
-
|
|
568
|
-
target[key] = source[key];
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
if (options instanceof HTMLElement) {
|
|
573
|
-
settings.parent = options;
|
|
574
|
-
} else {
|
|
575
|
-
|
|
576
|
-
if (settings.parent && options.parent && settings.parent !== options.parent) {
|
|
577
|
-
this._events.remove(settings.parent);
|
|
578
|
-
this._popupInited = false;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
transfer(options, settings);
|
|
582
|
-
|
|
583
|
-
if (options.onChange) {
|
|
584
|
-
this.onChange = options.onChange;
|
|
585
|
-
}
|
|
586
|
-
if (options.onDone) {
|
|
587
|
-
this.onDone = options.onDone;
|
|
588
|
-
}
|
|
589
|
-
if (options.onOpen) {
|
|
590
|
-
this.onOpen = options.onOpen;
|
|
591
|
-
}
|
|
592
|
-
if (options.onClose) {
|
|
593
|
-
this.onClose = options.onClose;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
var col = options.color || options.colour;
|
|
597
|
-
if (col) {
|
|
598
|
-
this._setColor(col);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
var parent = settings.parent;
|
|
603
|
-
if (parent && settings.popup && !this._popupInited) {
|
|
604
|
-
|
|
605
|
-
var openProxy = function openProxy(e) {
|
|
606
|
-
return _this.openHandler(e);
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
this._events.add(parent, 'click', openProxy);
|
|
610
|
-
|
|
611
|
-
onKey(this._events, parent, [' ', 'Spacebar', 'Enter'], openProxy);
|
|
612
|
-
|
|
613
|
-
this._popupInited = true;
|
|
614
|
-
} else if (options.parent && !settings.popup) {
|
|
615
|
-
this.show();
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
}, {
|
|
619
|
-
key: 'openHandler',
|
|
620
|
-
value: function openHandler(e) {
|
|
621
|
-
if (this.show()) {
|
|
622
|
-
|
|
623
|
-
e && e.preventDefault();
|
|
624
|
-
|
|
625
|
-
this.settings.parent.style.pointerEvents = 'none';
|
|
626
|
-
|
|
627
|
-
var toFocus = e && e.type === EVENT_KEY ? this._domEdit : this.domElement;
|
|
628
|
-
setTimeout(function () {
|
|
629
|
-
return toFocus.focus();
|
|
630
|
-
}, 100);
|
|
631
|
-
|
|
632
|
-
if (this.onOpen) {
|
|
633
|
-
this.onOpen(this.colour);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}, {
|
|
638
|
-
key: 'closeHandler',
|
|
639
|
-
value: function closeHandler(e) {
|
|
640
|
-
var event = e && e.type;
|
|
641
|
-
var doHide = false;
|
|
642
|
-
|
|
643
|
-
if (!e) {
|
|
644
|
-
doHide = true;
|
|
645
|
-
} else if (event === EVENT_CLICK_OUTSIDE || event === EVENT_TAB_MOVE) {
|
|
646
|
-
|
|
647
|
-
var knownTime = (this.__containedEvent || 0) + 100;
|
|
648
|
-
if (e.timeStamp > knownTime) {
|
|
649
|
-
doHide = true;
|
|
650
|
-
}
|
|
651
|
-
} else {
|
|
652
|
-
|
|
653
|
-
stopEvent(e);
|
|
654
|
-
|
|
655
|
-
doHide = true;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
if (doHide && this.hide()) {
|
|
659
|
-
this.settings.parent.style.pointerEvents = '';
|
|
660
|
-
|
|
661
|
-
if (event !== EVENT_CLICK_OUTSIDE) {
|
|
662
|
-
this.settings.parent.focus();
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
if (this.onClose) {
|
|
666
|
-
this.onClose(this.colour);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
}, {
|
|
671
|
-
key: 'movePopup',
|
|
672
|
-
value: function movePopup(options, open) {
|
|
673
|
-
|
|
674
|
-
this.closeHandler();
|
|
675
|
-
|
|
676
|
-
this.setOptions(options);
|
|
677
|
-
if (open) {
|
|
678
|
-
this.openHandler();
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
}, {
|
|
682
|
-
key: 'setColor',
|
|
683
|
-
value: function setColor(color, silent) {
|
|
684
|
-
this._setColor(color, { silent: silent });
|
|
685
|
-
}
|
|
686
|
-
}, {
|
|
687
|
-
key: '_setColor',
|
|
688
|
-
value: function _setColor(color, flags) {
|
|
689
|
-
if (typeof color === 'string') {
|
|
690
|
-
color = color.trim();
|
|
691
|
-
}
|
|
692
|
-
if (!color) {
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
flags = flags || {};
|
|
697
|
-
var c = void 0;
|
|
698
|
-
try {
|
|
699
|
-
|
|
700
|
-
c = new Color(color);
|
|
701
|
-
} catch (ex) {
|
|
702
|
-
if (flags.failSilently) {
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
throw ex;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
if (!this.settings.alpha) {
|
|
709
|
-
var hsla = c.hsla;
|
|
710
|
-
hsla[3] = 1;
|
|
711
|
-
c.hsla = hsla;
|
|
712
|
-
}
|
|
713
|
-
this.colour = this.color = c;
|
|
714
|
-
this._setHSLA(null, null, null, null, flags);
|
|
715
|
-
}
|
|
716
|
-
}, {
|
|
717
|
-
key: 'setColour',
|
|
718
|
-
value: function setColour(colour, silent) {
|
|
719
|
-
this.setColor(colour, silent);
|
|
720
|
-
}
|
|
721
|
-
}, {
|
|
722
|
-
key: 'show',
|
|
723
|
-
value: function show() {
|
|
724
|
-
var parent = this.settings.parent;
|
|
725
|
-
if (!parent) {
|
|
726
|
-
return false;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
if (this.domElement) {
|
|
730
|
-
var toggled = this._toggleDOM(true);
|
|
731
|
-
|
|
732
|
-
this._setPosition();
|
|
733
|
-
|
|
734
|
-
return toggled;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
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>';
|
|
738
|
-
var wrapper = parseHTML(html);
|
|
739
|
-
|
|
740
|
-
this.domElement = wrapper;
|
|
741
|
-
this._domH = $('.picker_hue', wrapper);
|
|
742
|
-
this._domSL = $('.picker_sl', wrapper);
|
|
743
|
-
this._domA = $('.picker_alpha', wrapper);
|
|
744
|
-
this._domEdit = $('.picker_editor input', wrapper);
|
|
745
|
-
this._domSample = $('.picker_sample', wrapper);
|
|
746
|
-
this._domOkay = $('.picker_done button', wrapper);
|
|
747
|
-
this._domCancel = $('.picker_cancel button', wrapper);
|
|
748
|
-
|
|
749
|
-
wrapper.classList.add('layout_' + this.settings.layout);
|
|
750
|
-
if (!this.settings.alpha) {
|
|
751
|
-
wrapper.classList.add('no_alpha');
|
|
752
|
-
}
|
|
753
|
-
if (!this.settings.editor) {
|
|
754
|
-
wrapper.classList.add('no_editor');
|
|
755
|
-
}
|
|
756
|
-
if (!this.settings.cancelButton) {
|
|
757
|
-
wrapper.classList.add('no_cancel');
|
|
758
|
-
}
|
|
759
|
-
this._ifPopup(function () {
|
|
760
|
-
return wrapper.classList.add('popup');
|
|
761
|
-
});
|
|
762
|
-
|
|
763
|
-
this._setPosition();
|
|
764
|
-
|
|
765
|
-
if (this.colour) {
|
|
766
|
-
this._updateUI();
|
|
767
|
-
} else {
|
|
768
|
-
this._setColor(this.settings.defaultColor);
|
|
769
|
-
}
|
|
770
|
-
this._bindEvents();
|
|
771
|
-
|
|
772
|
-
return true;
|
|
773
|
-
}
|
|
774
|
-
}, {
|
|
775
|
-
key: 'hide',
|
|
776
|
-
value: function hide() {
|
|
777
|
-
return this._toggleDOM(false);
|
|
778
|
-
}
|
|
779
|
-
}, {
|
|
780
|
-
key: 'destroy',
|
|
781
|
-
value: function destroy() {
|
|
782
|
-
this._events.destroy();
|
|
783
|
-
if (this.domElement) {
|
|
784
|
-
this.settings.parent.removeChild(this.domElement);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
}, {
|
|
788
|
-
key: '_bindEvents',
|
|
789
|
-
value: function _bindEvents() {
|
|
790
|
-
var _this2 = this;
|
|
791
|
-
|
|
792
|
-
var that = this,
|
|
793
|
-
dom = this.domElement,
|
|
794
|
-
events = this._events;
|
|
795
|
-
|
|
796
|
-
function addEvent(target, type, handler) {
|
|
797
|
-
events.add(target, type, handler);
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
addEvent(dom, 'click', function (e) {
|
|
801
|
-
return e.preventDefault();
|
|
802
|
-
});
|
|
803
|
-
|
|
804
|
-
dragTrack(events, this._domH, function (x, y) {
|
|
805
|
-
return that._setHSLA(x);
|
|
806
|
-
});
|
|
807
|
-
|
|
808
|
-
dragTrack(events, this._domSL, function (x, y) {
|
|
809
|
-
return that._setHSLA(null, x, 1 - y);
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
if (this.settings.alpha) {
|
|
813
|
-
dragTrack(events, this._domA, function (x, y) {
|
|
814
|
-
return that._setHSLA(null, null, null, 1 - y);
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
var editInput = this._domEdit;
|
|
819
|
-
{
|
|
820
|
-
addEvent(editInput, 'input', function (e) {
|
|
821
|
-
that._setColor(this.value, { fromEditor: true, failSilently: true });
|
|
822
|
-
});
|
|
823
|
-
|
|
824
|
-
addEvent(editInput, 'focus', function (e) {
|
|
825
|
-
var input = this;
|
|
826
|
-
|
|
827
|
-
if (input.selectionStart === input.selectionEnd) {
|
|
828
|
-
input.select();
|
|
829
|
-
}
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
this._ifPopup(function () {
|
|
834
|
-
|
|
835
|
-
var popupCloseProxy = function popupCloseProxy(e) {
|
|
836
|
-
return _this2.closeHandler(e);
|
|
837
|
-
};
|
|
838
|
-
|
|
839
|
-
addEvent(window, EVENT_CLICK_OUTSIDE, popupCloseProxy);
|
|
840
|
-
addEvent(window, EVENT_TAB_MOVE, popupCloseProxy);
|
|
841
|
-
onKey(events, dom, ['Esc', 'Escape'], popupCloseProxy);
|
|
842
|
-
|
|
843
|
-
var timeKeeper = function timeKeeper(e) {
|
|
844
|
-
_this2.__containedEvent = e.timeStamp;
|
|
845
|
-
};
|
|
846
|
-
addEvent(dom, EVENT_CLICK_OUTSIDE, timeKeeper);
|
|
847
|
-
|
|
848
|
-
addEvent(dom, EVENT_TAB_MOVE, timeKeeper);
|
|
849
|
-
|
|
850
|
-
addEvent(_this2._domCancel, 'click', popupCloseProxy);
|
|
851
|
-
});
|
|
852
|
-
|
|
853
|
-
var onDoneProxy = function onDoneProxy(e) {
|
|
854
|
-
_this2._ifPopup(function () {
|
|
855
|
-
return _this2.closeHandler(e);
|
|
856
|
-
});
|
|
857
|
-
if (_this2.onDone) {
|
|
858
|
-
_this2.onDone(_this2.colour);
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
addEvent(this._domOkay, 'click', onDoneProxy);
|
|
862
|
-
onKey(events, dom, ['Enter'], onDoneProxy);
|
|
863
|
-
}
|
|
864
|
-
}, {
|
|
865
|
-
key: '_setPosition',
|
|
866
|
-
value: function _setPosition() {
|
|
867
|
-
var parent = this.settings.parent,
|
|
868
|
-
elm = this.domElement;
|
|
869
|
-
|
|
870
|
-
if (parent !== elm.parentNode) {
|
|
871
|
-
parent.appendChild(elm);
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
this._ifPopup(function (popup) {
|
|
875
|
-
|
|
876
|
-
if (getComputedStyle(parent).position === 'static') {
|
|
877
|
-
parent.style.position = 'relative';
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
var cssClass = popup === true ? 'popup_right' : 'popup_' + popup;
|
|
881
|
-
|
|
882
|
-
['popup_top', 'popup_bottom', 'popup_left', 'popup_right'].forEach(function (c) {
|
|
883
|
-
|
|
884
|
-
if (c === cssClass) {
|
|
885
|
-
elm.classList.add(c);
|
|
886
|
-
} else {
|
|
887
|
-
elm.classList.remove(c);
|
|
888
|
-
}
|
|
889
|
-
});
|
|
890
|
-
|
|
891
|
-
elm.classList.add(cssClass);
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
}, {
|
|
895
|
-
key: '_setHSLA',
|
|
896
|
-
value: function _setHSLA(h, s, l, a, flags) {
|
|
897
|
-
flags = flags || {};
|
|
898
|
-
|
|
899
|
-
var col = this.colour,
|
|
900
|
-
hsla = col.hsla;
|
|
901
|
-
|
|
902
|
-
[h, s, l, a].forEach(function (x, i) {
|
|
903
|
-
if (x || x === 0) {
|
|
904
|
-
hsla[i] = x;
|
|
905
|
-
}
|
|
906
|
-
});
|
|
907
|
-
col.hsla = hsla;
|
|
908
|
-
|
|
909
|
-
this._updateUI(flags);
|
|
910
|
-
|
|
911
|
-
if (this.onChange && !flags.silent) {
|
|
912
|
-
this.onChange(col);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}, {
|
|
916
|
-
key: '_updateUI',
|
|
917
|
-
value: function _updateUI(flags) {
|
|
918
|
-
if (!this.domElement) {
|
|
919
|
-
return;
|
|
920
|
-
}
|
|
921
|
-
flags = flags || {};
|
|
922
|
-
|
|
923
|
-
var col = this.colour,
|
|
924
|
-
hsl = col.hsla,
|
|
925
|
-
cssHue = 'hsl(' + hsl[0] * HUES + ', 100%, 50%)',
|
|
926
|
-
cssHSL = col.hslString,
|
|
927
|
-
cssHSLA = col.hslaString;
|
|
928
|
-
|
|
929
|
-
var uiH = this._domH,
|
|
930
|
-
uiSL = this._domSL,
|
|
931
|
-
uiA = this._domA,
|
|
932
|
-
thumbH = $('.picker_selector', uiH),
|
|
933
|
-
thumbSL = $('.picker_selector', uiSL),
|
|
934
|
-
thumbA = $('.picker_selector', uiA);
|
|
935
|
-
|
|
936
|
-
function posX(parent, child, relX) {
|
|
937
|
-
child.style.left = relX * 100 + '%';
|
|
938
|
-
}
|
|
939
|
-
function posY(parent, child, relY) {
|
|
940
|
-
child.style.top = relY * 100 + '%';
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
posX(uiH, thumbH, hsl[0]);
|
|
944
|
-
|
|
945
|
-
this._domSL.style.backgroundColor = this._domH.style.color = cssHue;
|
|
946
|
-
|
|
947
|
-
posX(uiSL, thumbSL, hsl[1]);
|
|
948
|
-
posY(uiSL, thumbSL, 1 - hsl[2]);
|
|
949
|
-
|
|
950
|
-
uiSL.style.color = cssHSL;
|
|
951
|
-
|
|
952
|
-
posY(uiA, thumbA, 1 - hsl[3]);
|
|
953
|
-
|
|
954
|
-
var opaque = cssHSL,
|
|
955
|
-
transp = opaque.replace('hsl', 'hsla').replace(')', ', 0)'),
|
|
956
|
-
bg = 'linear-gradient(' + [opaque, transp] + ')';
|
|
957
|
-
|
|
958
|
-
this._domA.style.background = bg + ', ' + BG_TRANSP;
|
|
959
|
-
|
|
960
|
-
if (!flags.fromEditor) {
|
|
961
|
-
var format = this.settings.editorFormat,
|
|
962
|
-
alpha = this.settings.alpha;
|
|
963
|
-
|
|
964
|
-
var value = void 0;
|
|
965
|
-
switch (format) {
|
|
966
|
-
case 'rgb':
|
|
967
|
-
value = col.printRGB(alpha);break;
|
|
968
|
-
case 'hsl':
|
|
969
|
-
value = col.printHSL(alpha);break;
|
|
970
|
-
default:
|
|
971
|
-
value = col.printHex(alpha);
|
|
972
|
-
}
|
|
973
|
-
this._domEdit.value = value;
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
this._domSample.style.color = cssHSLA;
|
|
977
|
-
}
|
|
978
|
-
}, {
|
|
979
|
-
key: '_ifPopup',
|
|
980
|
-
value: function _ifPopup(actionIf, actionElse) {
|
|
981
|
-
if (this.settings.parent && this.settings.popup) {
|
|
982
|
-
actionIf && actionIf(this.settings.popup);
|
|
983
|
-
} else {
|
|
984
|
-
actionElse && actionElse();
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
}, {
|
|
988
|
-
key: '_toggleDOM',
|
|
989
|
-
value: function _toggleDOM(toVisible) {
|
|
990
|
-
var dom = this.domElement;
|
|
991
|
-
if (!dom) {
|
|
992
|
-
return false;
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
var displayStyle = toVisible ? '' : 'none',
|
|
996
|
-
toggle = dom.style.display !== displayStyle;
|
|
997
|
-
|
|
998
|
-
if (toggle) {
|
|
999
|
-
dom.style.display = displayStyle;
|
|
1000
|
-
}
|
|
1001
|
-
return toggle;
|
|
1002
|
-
}
|
|
1003
|
-
}]);
|
|
1004
|
-
return Picker;
|
|
1005
|
-
}();
|
|
1006
|
-
|
|
1007
|
-
{
|
|
1008
|
-
var style = document.createElement('style');
|
|
1009
|
-
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}';
|
|
1010
|
-
document.documentElement.firstElementChild.appendChild(style);
|
|
1011
|
-
|
|
1012
|
-
Picker.StyleElement = style;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
return Picker;
|
|
1016
|
-
|
|
1017
|
-
}));
|
|
1018
|
-
} (vanillaPicker$1));
|
|
1019
|
-
return vanillaPicker$1.exports;
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
var vanillaPickerExports = requireVanillaPicker();
|
|
1023
|
-
var Picker = /*@__PURE__*/getDefaultExportFromCjs(vanillaPickerExports);
|
|
1024
|
-
|
|
1025
7
|
const sallaColorPickerCss = "";
|
|
1026
8
|
|
|
1027
|
-
const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker extends HTMLElement
|
|
9
|
+
const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker extends HTMLElement {
|
|
1028
10
|
constructor() {
|
|
1029
11
|
super();
|
|
1030
12
|
this.__registerHost();
|
|
@@ -1033,6 +15,9 @@ const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker
|
|
|
1033
15
|
this.submitted = createEvent(this, "submitted", 7);
|
|
1034
16
|
this.popupOpened = createEvent(this, "popupOpened", 7);
|
|
1035
17
|
this.popupClosed = createEvent(this, "popupClosed", 7);
|
|
18
|
+
/** Lazy-loaded to avoid bundling vanilla-picker (Babel polyfills) into main/hydrate bundle. */
|
|
19
|
+
this.picker = null;
|
|
20
|
+
this.pickerReady = null;
|
|
1036
21
|
/**
|
|
1037
22
|
* File input name for the native formData
|
|
1038
23
|
*/
|
|
@@ -1060,14 +45,18 @@ const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker
|
|
|
1060
45
|
this.enableAlpha = false;
|
|
1061
46
|
}
|
|
1062
47
|
colorChangeHandler(color) {
|
|
1063
|
-
this.colorInput
|
|
48
|
+
if (this.colorInput)
|
|
49
|
+
this.colorInput.value = color.hex;
|
|
1064
50
|
this.colorChanged.emit(color);
|
|
1065
51
|
}
|
|
1066
|
-
submittedHandler(color) {
|
|
1067
|
-
this.setColorValue(color.rgbaString, true);
|
|
1068
|
-
this.canvas
|
|
1069
|
-
|
|
1070
|
-
this.colorInput
|
|
52
|
+
async submittedHandler(color) {
|
|
53
|
+
await this.setColorValue(color.rgbaString, true);
|
|
54
|
+
if (this.canvas)
|
|
55
|
+
this.canvas.style.backgroundColor = color.rgbString;
|
|
56
|
+
if (this.colorInput) {
|
|
57
|
+
this.colorInput.value = color.hex;
|
|
58
|
+
this.colorInput.dispatchEvent(new window.Event('change', { bubbles: true }));
|
|
59
|
+
}
|
|
1071
60
|
this.submitted.emit(color);
|
|
1072
61
|
}
|
|
1073
62
|
popupOpenedHandler(color) {
|
|
@@ -1078,6 +67,13 @@ const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker
|
|
|
1078
67
|
this.popupClosed.emit(color);
|
|
1079
68
|
}
|
|
1080
69
|
/** Methods */
|
|
70
|
+
async ensurePicker() {
|
|
71
|
+
if (this.picker)
|
|
72
|
+
return this.picker;
|
|
73
|
+
if (this.pickerReady)
|
|
74
|
+
return await this.pickerReady;
|
|
75
|
+
throw new Error('Color picker not initialized');
|
|
76
|
+
}
|
|
1081
77
|
/**
|
|
1082
78
|
* Set the picker options.
|
|
1083
79
|
*
|
|
@@ -1085,7 +81,8 @@ const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker
|
|
|
1085
81
|
* @param {Object} options
|
|
1086
82
|
*/
|
|
1087
83
|
async setPickerOption(options) {
|
|
1088
|
-
this.
|
|
84
|
+
const picker = await this.ensurePicker();
|
|
85
|
+
picker.setOptions(options);
|
|
1089
86
|
}
|
|
1090
87
|
/**
|
|
1091
88
|
* Move the popup to a different parent, optionally opening it at the same time.
|
|
@@ -1097,7 +94,8 @@ const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker
|
|
|
1097
94
|
* @param {boolean} openImmediately
|
|
1098
95
|
*/
|
|
1099
96
|
async movePopUp(options, openImmediately) {
|
|
1100
|
-
this.
|
|
97
|
+
const picker = await this.ensurePicker();
|
|
98
|
+
picker.movePopup(options, openImmediately);
|
|
1101
99
|
}
|
|
1102
100
|
/**
|
|
1103
101
|
* Set/initialize the picker's color.
|
|
@@ -1109,25 +107,31 @@ const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker
|
|
|
1109
107
|
* @param {boolean} triggerEvent
|
|
1110
108
|
*/
|
|
1111
109
|
async setColorValue(color, triggerEvent) {
|
|
1112
|
-
this.
|
|
110
|
+
const picker = await this.ensurePicker();
|
|
111
|
+
picker.setColor(color, triggerEvent);
|
|
1113
112
|
}
|
|
1114
113
|
/**
|
|
1115
114
|
* Show/open the picker.
|
|
1116
115
|
*/
|
|
1117
116
|
async openPicker() {
|
|
1118
|
-
this.
|
|
117
|
+
const picker = await this.ensurePicker();
|
|
118
|
+
picker.show();
|
|
1119
119
|
}
|
|
1120
120
|
/**
|
|
1121
121
|
* Close/Hide the picker.
|
|
1122
122
|
*/
|
|
1123
123
|
async closePicker() {
|
|
1124
|
-
this.
|
|
124
|
+
const picker = await this.ensurePicker();
|
|
125
|
+
picker.hide();
|
|
1125
126
|
}
|
|
1126
127
|
/**
|
|
1127
128
|
* Release all resources used by this picker instance.
|
|
1128
129
|
*/
|
|
1129
130
|
async destroyPicker() {
|
|
1130
|
-
this.
|
|
131
|
+
const picker = await this.ensurePicker();
|
|
132
|
+
picker.destroy();
|
|
133
|
+
this.picker = null;
|
|
134
|
+
this.pickerReady = null;
|
|
1131
135
|
}
|
|
1132
136
|
componentWillLoad() {
|
|
1133
137
|
salla.onReady(() => {
|
|
@@ -1136,7 +140,10 @@ const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker
|
|
|
1136
140
|
}
|
|
1137
141
|
setPopInPosition() {
|
|
1138
142
|
const popup = this.host.querySelector('.picker_wrapper');
|
|
1139
|
-
const
|
|
143
|
+
const widgetEl = this.host.querySelector('.s-color-picker-widget');
|
|
144
|
+
if (!popup || !widgetEl)
|
|
145
|
+
return;
|
|
146
|
+
const widgetPosition = widgetEl.getBoundingClientRect();
|
|
1140
147
|
const widgetToWindowEq = window.innerWidth / 2 - widgetPosition.width / 2;
|
|
1141
148
|
const widgetInLeft = widgetToWindowEq > widgetPosition.x;
|
|
1142
149
|
const widgetInRight = widgetToWindowEq < widgetPosition.x;
|
|
@@ -1153,35 +160,41 @@ const SallaColorPicker = /*@__PURE__*/ proxyCustomElement(class SallaColorPicker
|
|
|
1153
160
|
}
|
|
1154
161
|
}
|
|
1155
162
|
initColorPicker() {
|
|
1156
|
-
this.
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
163
|
+
this.pickerReady = import('./vanilla-picker.js').then(function (n) { return n.v; }).then((mod) => {
|
|
164
|
+
const Picker = mod.default;
|
|
165
|
+
const picker = new Picker({
|
|
166
|
+
parent: this.host,
|
|
167
|
+
color: this.color,
|
|
168
|
+
popup: 'bottom',
|
|
169
|
+
alpha: this.enableAlpha,
|
|
170
|
+
editor: this.showTextField,
|
|
171
|
+
editorFormat: this.format,
|
|
172
|
+
cancelButton: this.showCancelButton,
|
|
173
|
+
onChange: (color) => this.colorChangeHandler(color),
|
|
174
|
+
onDone: (color) => this.submittedHandler(color),
|
|
175
|
+
onOpen: (color) => this.popupOpenedHandler(color),
|
|
176
|
+
onClose: (color) => this.popupClosedHandler(color),
|
|
177
|
+
});
|
|
178
|
+
this.picker = picker;
|
|
179
|
+
return this.picker;
|
|
1170
180
|
});
|
|
1171
181
|
}
|
|
1172
182
|
render() {
|
|
1173
|
-
return (h(Host, { key: '
|
|
183
|
+
return (h(Host, { key: 'f6a001611bf20e8264346028c848490cf94c686a', class: "s-color-picker-main" }, h("slot", { key: '79648d165d81f200e064c8ef56a138f6b66757ed', name: "widget" }, h("div", { key: '95e7a8b7a92f5bb8f6f05b8cd39e6c91710e52a2', class: "s-color-picker-widget" }, h("div", { key: '24813d1de9a5834cfd37edf7affd4be94608f96c', class: "s-color-picker-widget-canvas", ref: dv => this.canvas = dv }), h("span", { key: '5f29f537140bc4b74431fc33229563cb1b7ce231', innerHTML: ArrowDown }))), h("input", { key: '188a9d7233388fca9a25cd5d319c0973448b07bc', class: "s-hidden", name: this.name, required: this.required, value: this.color, ref: color => this.colorInput = color })));
|
|
1174
184
|
}
|
|
1175
185
|
componentDidLoad() {
|
|
1176
|
-
this.canvas
|
|
186
|
+
if (this.canvas)
|
|
187
|
+
this.canvas.style.backgroundColor = this.color;
|
|
1177
188
|
this.initColorPicker();
|
|
1178
|
-
this.colorInput
|
|
1179
|
-
this.
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
this.colorInput.
|
|
1183
|
-
|
|
1184
|
-
|
|
189
|
+
if (this.colorInput) {
|
|
190
|
+
this.colorInput.addEventListener('invalid', (e) => {
|
|
191
|
+
this.invalidInput.emit(e);
|
|
192
|
+
});
|
|
193
|
+
this.colorInput.addEventListener('input', () => {
|
|
194
|
+
this.colorInput.setCustomValidity('');
|
|
195
|
+
this.colorInput.reportValidity();
|
|
196
|
+
});
|
|
197
|
+
}
|
|
1185
198
|
}
|
|
1186
199
|
get host() { return this; }
|
|
1187
200
|
static get style() { return sallaColorPickerCss; }
|