UNPKG

@ykcl/smart-ui-oversea

Version:

A Component Library for Vue.js.

1,698 lines (1,477 loc) 188 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/dist/"; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 107); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, exports) { module.exports = require("vue"); /***/ }), /***/ 1: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return on; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return off; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return once; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return hasClass; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return addClass; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return removeClass; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getStyle; }); /* unused harmony export setStyle */ /* unused harmony export isScroll */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getScrollContainer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return isInContainer; }); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* istanbul ignore next */ var isServer = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer; var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; var MOZ_HACK_REGEXP = /^moz([A-Z])/; var ieVersion = isServer ? 0 : Number(document.documentMode); /* istanbul ignore next */ var trim = function trim(string) { return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, ''); }; /* istanbul ignore next */ var camelCase = function camelCase(name) { return name.replace(SPECIAL_CHARS_REGEXP, function (_, separator, letter, offset) { return offset ? letter.toUpperCase() : letter; }).replace(MOZ_HACK_REGEXP, 'Moz$1'); }; /* istanbul ignore next */ var on = function () { if (!isServer && document.addEventListener) { return function (element, event, handler) { if (element && event && handler) { element.addEventListener(event, handler, false); } }; } else { return function (element, event, handler) { if (element && event && handler) { element.attachEvent('on' + event, handler); } }; } }(); /* istanbul ignore next */ var off = function () { if (!isServer && document.removeEventListener) { return function (element, event, handler) { if (element && event) { element.removeEventListener(event, handler, false); } }; } else { return function (element, event, handler) { if (element && event) { element.detachEvent('on' + event, handler); } }; } }(); /* istanbul ignore next */ var once = function once(el, event, fn) { var listener = function listener() { if (fn) { fn.apply(this, arguments); } off(el, event, listener); }; on(el, event, listener); }; /* istanbul ignore next */ function hasClass(el, cls) { if (!el || !cls) return false; if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.'); if (el.classList) { return el.classList.contains(cls); } else { return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1; } }; /* istanbul ignore next */ function addClass(el, cls) { if (!el) return; var curClass = el.className; var classes = (cls || '').split(' '); for (var i = 0, j = classes.length; i < j; i++) { var clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.add(clsName); } else if (!hasClass(el, clsName)) { curClass += ' ' + clsName; } } if (!el.classList) { el.setAttribute('class', curClass); } }; /* istanbul ignore next */ function removeClass(el, cls) { if (!el || !cls) return; var classes = cls.split(' '); var curClass = ' ' + el.className + ' '; for (var i = 0, j = classes.length; i < j; i++) { var clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.remove(clsName); } else if (hasClass(el, clsName)) { curClass = curClass.replace(' ' + clsName + ' ', ' '); } } if (!el.classList) { el.setAttribute('class', trim(curClass)); } }; /* istanbul ignore next */ var getStyle = ieVersion < 9 ? function (element, styleName) { if (isServer) return; if (!element || !styleName) return null; styleName = camelCase(styleName); if (styleName === 'float') { styleName = 'styleFloat'; } try { switch (styleName) { case 'opacity': try { return element.filters.item('alpha').opacity / 100; } catch (e) { return 1.0; } default: return element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null; } } catch (e) { return element.style[styleName]; } } : function (element, styleName) { if (isServer) return; if (!element || !styleName) return null; styleName = camelCase(styleName); if (styleName === 'float') { styleName = 'cssFloat'; } try { var computed = document.defaultView.getComputedStyle(element, ''); return element.style[styleName] || computed ? computed[styleName] : null; } catch (e) { return element.style[styleName]; } }; /* istanbul ignore next */ function setStyle(element, styleName, value) { if (!element || !styleName) return; if ((typeof styleName === 'undefined' ? 'undefined' : _typeof(styleName)) === 'object') { for (var prop in styleName) { if (styleName.hasOwnProperty(prop)) { setStyle(element, prop, styleName[prop]); } } } else { styleName = camelCase(styleName); if (styleName === 'opacity' && ieVersion < 9) { element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')'; } else { element.style[styleName] = value; } } }; var isScroll = function isScroll(el, vertical) { if (isServer) return; var determinedDirection = vertical !== null && vertical !== undefined; var overflow = determinedDirection ? vertical ? getStyle(el, 'overflow-y') : getStyle(el, 'overflow-x') : getStyle(el, 'overflow'); return overflow.match(/(scroll|auto|overlay)/); }; var getScrollContainer = function getScrollContainer(el, vertical) { if (isServer) return; var parent = el; while (parent) { if ([window, document, document.documentElement].includes(parent)) { return window; } if (isScroll(parent, vertical)) { return parent; } parent = parent.parentNode; } return parent; }; var isInContainer = function isInContainer(el, container) { if (isServer || !el || !container) return false; var elRect = el.getBoundingClientRect(); var containerRect = void 0; if ([window, document, document.documentElement, null, undefined].includes(container)) { containerRect = { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0 }; } else { containerRect = container.getBoundingClientRect(); } return elRect.top < containerRect.bottom && elRect.bottom > containerRect.top && elRect.right > containerRect.left && elRect.left < containerRect.right; }; /***/ }), /***/ 10: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var element_ui_src_utils_popup__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9); var PopperJS = vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer ? function () {} : __webpack_require__(24); var stop = function stop(e) { return e.stopPropagation(); }; /** * @param {HTMLElement} [reference=$refs.reference] - The reference element used to position the popper. * @param {HTMLElement} [popper=$refs.popper] - The HTML element used as popper, or a configuration used to generate the popper. * @param {String} [placement=button] - Placement of the popper accepted values: top(-start, -end), right(-start, -end), bottom(-start, -end), left(-start, -end) * @param {Number} [offset=0] - Amount of pixels the popper will be shifted (can be negative). * @param {Boolean} [visible=false] Visibility of the popup element. * @param {Boolean} [visible-arrow=false] Visibility of the arrow, no style. */ /* harmony default export */ __webpack_exports__["a"] = ({ props: { transformOrigin: { type: [Boolean, String], default: true }, placement: { type: String, default: 'bottom' }, boundariesPadding: { type: Number, default: 10 }, reference: {}, popper: {}, offset: { default: 0 }, value: Boolean, visibleArrow: Boolean, arrowOffset: { type: Number, default: 35 }, appendToBody: { type: Boolean, default: true }, popperOptions: { type: Object, default: function _default() { return { gpuAcceleration: false }; } } }, data: function data() { return { showPopper: false, currentPlacement: '' }; }, watch: { value: { immediate: true, handler: function handler(val) { this.showPopper = val; this.$emit('input', val); } }, showPopper: function showPopper(val) { if (this.disabled) return; val ? this.updatePopper() : this.destroyPopper(); this.$emit('input', val); } }, methods: { createPopper: function createPopper() { var _this = this; if (this.$isServer) return; this.currentPlacement = this.currentPlacement || this.placement; if (!/^(top|bottom|left|right)(-start|-end)?$/g.test(this.currentPlacement)) { return; } var options = this.popperOptions; var popper = this.popperElm = this.popperElm || this.popper || this.$refs.popper; var reference = this.referenceElm = this.referenceElm || this.reference || this.$refs.reference; if (!reference && this.$slots.reference && this.$slots.reference[0]) { reference = this.referenceElm = this.$slots.reference[0].elm; } if (!popper || !reference) return; if (this.visibleArrow) this.appendArrow(popper); if (this.appendToBody) document.body.appendChild(this.popperElm); if (this.popperJS && this.popperJS.destroy) { this.popperJS.destroy(); } options.placement = this.currentPlacement; options.offset = this.offset; options.arrowOffset = this.arrowOffset; options.boundariesPadding = this.boundariesPadding; this.popperJS = new PopperJS(reference, popper, options); this.popperJS.onCreate(function (_) { _this.$emit('created', _this); _this.resetTransformOrigin(); _this.$nextTick(_this.updatePopper); }); if (typeof options.onUpdate === 'function') { this.popperJS.onUpdate(options.onUpdate); } this.popperJS._popper.style.zIndex = element_ui_src_utils_popup__WEBPACK_IMPORTED_MODULE_1__[/* PopupManager */ "a"].nextZIndex(); this.popperElm.addEventListener('click', stop); }, updatePopper: function updatePopper() { var popperJS = this.popperJS; if (popperJS) { popperJS.update(); if (popperJS._popper) { popperJS._popper.style.zIndex = element_ui_src_utils_popup__WEBPACK_IMPORTED_MODULE_1__[/* PopupManager */ "a"].nextZIndex(); } } else { this.createPopper(); } }, doDestroy: function doDestroy(forceDestroy) { /* istanbul ignore if */ if (!this.popperJS || this.showPopper && !forceDestroy) return; this.popperJS.destroy(); this.popperJS = null; }, destroyPopper: function destroyPopper() { if (this.popperJS) { this.resetTransformOrigin(); } }, resetTransformOrigin: function resetTransformOrigin() { if (!this.transformOrigin) return; var placementMap = { top: 'bottom', bottom: 'top', left: 'right', right: 'left' }; var placement = this.popperJS._popper.getAttribute('x-placement').split('-')[0]; var origin = placementMap[placement]; this.popperJS._popper.style.transformOrigin = typeof this.transformOrigin === 'string' ? this.transformOrigin : ['top', 'bottom'].indexOf(placement) > -1 ? 'center ' + origin : origin + ' center'; }, appendArrow: function appendArrow(element) { var hash = void 0; if (this.appended) { return; } this.appended = true; for (var item in element.attributes) { if (/^_v-/.test(element.attributes[item].name)) { hash = element.attributes[item].name; break; } } var arrow = document.createElement('div'); if (hash) { arrow.setAttribute(hash, ''); } arrow.setAttribute('x-arrow', ''); arrow.className = 'popper__arrow'; element.appendChild(arrow); } }, beforeDestroy: function beforeDestroy() { this.doDestroy(true); if (this.popperElm && this.popperElm.parentNode === document.body) { this.popperElm.removeEventListener('click', stop); document.body.removeChild(this.popperElm); } }, // call destroy in keep-alive mode deactivated: function deactivated() { this.$options.beforeDestroy[0].call(this); } }); /***/ }), /***/ 107: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/_vue-loader@15.11.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/color-picker/src/main.vue?vue&type=template&id=18f7a9f0 var render = function () { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "div", { directives: [ { name: "clickoutside", rawName: "v-clickoutside", value: _vm.hide, expression: "hide", }, ], class: [ "yk-color-picker", _vm.colorDisabled ? "is-disabled" : "", _vm.colorSize ? "yk-color-picker--" + _vm.colorSize : "", ], }, [ _vm.colorDisabled ? _c("div", { staticClass: "yk-color-picker__mask" }) : _vm._e(), _c( "div", { staticClass: "yk-color-picker__trigger", on: { click: _vm.handleTrigger }, }, [ _c( "span", { staticClass: "yk-color-picker__color", class: { "is-alpha": _vm.showAlpha }, }, [ _c("span", { staticClass: "yk-color-picker__color-inner", style: { backgroundColor: _vm.displayedColor, }, }), !_vm.value && !_vm.showPanelColor ? _c("span", { staticClass: "yk-color-picker__empty el-icon-close", }) : _vm._e(), ] ), _c("span", { directives: [ { name: "show", rawName: "v-show", value: _vm.value || _vm.showPanelColor, expression: "value || showPanelColor", }, ], staticClass: "yk-color-picker__icon el-icon-arrow-down", }), ] ), _c("picker-dropdown", { ref: "dropdown", class: ["yk-color-picker__panel", _vm.popperClass || ""], attrs: { color: _vm.color, "show-alpha": _vm.showAlpha, predefine: _vm.predefine, }, on: { pick: _vm.confirmValue, clear: _vm.clearValue }, model: { value: _vm.showPicker, callback: function ($$v) { _vm.showPicker = $$v }, expression: "showPicker", }, }), ], 1 ) } var staticRenderFns = [] render._withStripped = true // CONCATENATED MODULE: ./packages/color-picker/src/main.vue?vue&type=template&id=18f7a9f0 // CONCATENATED MODULE: ./packages/color-picker/src/color.js var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var hsv2hsl = function hsv2hsl(hue, sat, val) { return [hue, sat * val / ((hue = (2 - sat) * val) < 1 ? hue : 2 - hue) || 0, hue / 2]; }; // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0> var isOnePointZero = function isOnePointZero(n) { return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1; }; var isPercentage = function isPercentage(n) { return typeof n === 'string' && n.indexOf('%') !== -1; }; // Take input from [0, n] and return it as [0, 1] var bound01 = function bound01(value, max) { if (isOnePointZero(value)) value = '100%'; var processPercent = isPercentage(value); value = Math.min(max, Math.max(0, parseFloat(value))); // Automatically convert percentage into number if (processPercent) { value = parseInt(value * max, 10) / 100; } // Handle floating point rounding errors if (Math.abs(value - max) < 0.000001) { return 1; } // Convert into [0, 1] range if it isn't already return value % max / parseFloat(max); }; var INT_HEX_MAP = { 10: 'A', 11: 'B', 12: 'C', 13: 'D', 14: 'E', 15: 'F' }; var toHex = function toHex(_ref) { var r = _ref.r, g = _ref.g, b = _ref.b; var hexOne = function hexOne(value) { value = Math.min(Math.round(value), 255); var high = Math.floor(value / 16); var low = value % 16; return '' + (INT_HEX_MAP[high] || high) + (INT_HEX_MAP[low] || low); }; if (isNaN(r) || isNaN(g) || isNaN(b)) return ''; return '#' + hexOne(r) + hexOne(g) + hexOne(b); }; var HEX_INT_MAP = { A: 10, B: 11, C: 12, D: 13, E: 14, F: 15 }; var parseHexChannel = function parseHexChannel(hex) { if (hex.length === 2) { return (HEX_INT_MAP[hex[0].toUpperCase()] || +hex[0]) * 16 + (HEX_INT_MAP[hex[1].toUpperCase()] || +hex[1]); } return HEX_INT_MAP[hex[1].toUpperCase()] || +hex[1]; }; var hsl2hsv = function hsl2hsv(hue, sat, light) { sat = sat / 100; light = light / 100; var smin = sat; var lmin = Math.max(light, 0.01); var sv = void 0; var v = void 0; light *= 2; sat *= light <= 1 ? light : 2 - light; smin *= lmin <= 1 ? lmin : 2 - lmin; v = (light + sat) / 2; sv = light === 0 ? 2 * smin / (lmin + smin) : 2 * sat / (light + sat); return { h: hue, s: sv * 100, v: v * 100 }; }; // `rgbToHsv` // Converts an RGB color value to HSV // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] // *Returns:* { h, s, v } in [0,1] var rgb2hsv = function rgb2hsv(r, g, b) { r = bound01(r, 255); g = bound01(g, 255); b = bound01(b, 255); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var h = void 0, s = void 0; var v = max; var d = max - min; s = max === 0 ? 0 : d / max; if (max === min) { h = 0; // achromatic } else { switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } return { h: h * 360, s: s * 100, v: v * 100 }; }; // `hsvToRgb` // Converts an HSV color value to RGB. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] // *Returns:* { r, g, b } in the set [0, 255] var hsv2rgb = function hsv2rgb(h, s, v) { h = bound01(h, 360) * 6; s = bound01(s, 100); v = bound01(v, 100); var i = Math.floor(h); var f = h - i; var p = v * (1 - s); var q = v * (1 - f * s); var t = v * (1 - (1 - f) * s); var mod = i % 6; var r = [v, q, p, p, t, v][mod]; var g = [t, v, v, q, p, p][mod]; var b = [p, p, t, v, v, q][mod]; return { r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255) }; }; var Color = function () { function Color(options) { _classCallCheck(this, Color); this._hue = 0; this._saturation = 100; this._value = 100; this._alpha = 100; this.enableAlpha = false; this.format = 'hex'; this.value = ''; options = options || {}; for (var option in options) { if (options.hasOwnProperty(option)) { this[option] = options[option]; } } this.doOnChange(); } Color.prototype.set = function set(prop, value) { if (arguments.length === 1 && (typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object') { for (var p in prop) { if (prop.hasOwnProperty(p)) { this.set(p, prop[p]); } } return; } this['_' + prop] = value; this.doOnChange(); }; Color.prototype.get = function get(prop) { return this['_' + prop]; }; Color.prototype.toRgb = function toRgb() { return hsv2rgb(this._hue, this._saturation, this._value); }; Color.prototype.fromString = function fromString(value) { var _this = this; if (!value) { this._hue = 0; this._saturation = 100; this._value = 100; this.doOnChange(); return; } var fromHSV = function fromHSV(h, s, v) { _this._hue = Math.max(0, Math.min(360, h)); _this._saturation = Math.max(0, Math.min(100, s)); _this._value = Math.max(0, Math.min(100, v)); _this.doOnChange(); }; if (value.indexOf('hsl') !== -1) { var parts = value.replace(/hsla|hsl|\(|\)/gm, '').split(/\s|,/g).filter(function (val) { return val !== ''; }).map(function (val, index) { return index > 2 ? parseFloat(val) : parseInt(val, 10); }); if (parts.length === 4) { this._alpha = Math.floor(parseFloat(parts[3]) * 100); } else if (parts.length === 3) { this._alpha = 100; } if (parts.length >= 3) { var _hsl2hsv = hsl2hsv(parts[0], parts[1], parts[2]), h = _hsl2hsv.h, s = _hsl2hsv.s, v = _hsl2hsv.v; fromHSV(h, s, v); } } else if (value.indexOf('hsv') !== -1) { var _parts = value.replace(/hsva|hsv|\(|\)/gm, '').split(/\s|,/g).filter(function (val) { return val !== ''; }).map(function (val, index) { return index > 2 ? parseFloat(val) : parseInt(val, 10); }); if (_parts.length === 4) { this._alpha = Math.floor(parseFloat(_parts[3]) * 100); } else if (_parts.length === 3) { this._alpha = 100; } if (_parts.length >= 3) { fromHSV(_parts[0], _parts[1], _parts[2]); } } else if (value.indexOf('rgb') !== -1) { var _parts2 = value.replace(/rgba|rgb|\(|\)/gm, '').split(/\s|,/g).filter(function (val) { return val !== ''; }).map(function (val, index) { return index > 2 ? parseFloat(val) : parseInt(val, 10); }); if (_parts2.length === 4) { this._alpha = Math.floor(parseFloat(_parts2[3]) * 100); } else if (_parts2.length === 3) { this._alpha = 100; } if (_parts2.length >= 3) { var _rgb2hsv = rgb2hsv(_parts2[0], _parts2[1], _parts2[2]), _h = _rgb2hsv.h, _s = _rgb2hsv.s, _v = _rgb2hsv.v; fromHSV(_h, _s, _v); } } else if (value.indexOf('#') !== -1) { var hex = value.replace('#', '').trim(); if (!/^(?:[0-9a-fA-F]{3}){1,2}|[0-9a-fA-F]{8}$/.test(hex)) return; var r = void 0, g = void 0, b = void 0; if (hex.length === 3) { r = parseHexChannel(hex[0] + hex[0]); g = parseHexChannel(hex[1] + hex[1]); b = parseHexChannel(hex[2] + hex[2]); } else if (hex.length === 6 || hex.length === 8) { r = parseHexChannel(hex.substring(0, 2)); g = parseHexChannel(hex.substring(2, 4)); b = parseHexChannel(hex.substring(4, 6)); } if (hex.length === 8) { this._alpha = Math.floor(parseHexChannel(hex.substring(6)) / 255 * 100); } else if (hex.length === 3 || hex.length === 6) { this._alpha = 100; } var _rgb2hsv2 = rgb2hsv(r, g, b), _h2 = _rgb2hsv2.h, _s2 = _rgb2hsv2.s, _v2 = _rgb2hsv2.v; fromHSV(_h2, _s2, _v2); } }; Color.prototype.compare = function compare(color) { return Math.abs(color._hue - this._hue) < 2 && Math.abs(color._saturation - this._saturation) < 1 && Math.abs(color._value - this._value) < 1 && Math.abs(color._alpha - this._alpha) < 1; }; Color.prototype.doOnChange = function doOnChange() { var _hue = this._hue, _saturation = this._saturation, _value = this._value, _alpha = this._alpha, format = this.format; if (this.enableAlpha) { switch (format) { case 'hsl': var hsl = hsv2hsl(_hue, _saturation / 100, _value / 100); this.value = 'hsla(' + _hue + ', ' + Math.round(hsl[1] * 100) + '%, ' + Math.round(hsl[2] * 100) + '%, ' + _alpha / 100 + ')'; break; case 'hsv': this.value = 'hsva(' + _hue + ', ' + Math.round(_saturation) + '%, ' + Math.round(_value) + '%, ' + _alpha / 100 + ')'; break; default: var _hsv2rgb = hsv2rgb(_hue, _saturation, _value), r = _hsv2rgb.r, g = _hsv2rgb.g, b = _hsv2rgb.b; this.value = 'rgba(' + r + ', ' + g + ', ' + b + ', ' + _alpha / 100 + ')'; } } else { switch (format) { case 'hsl': var _hsl = hsv2hsl(_hue, _saturation / 100, _value / 100); this.value = 'hsl(' + _hue + ', ' + Math.round(_hsl[1] * 100) + '%, ' + Math.round(_hsl[2] * 100) + '%)'; break; case 'hsv': this.value = 'hsv(' + _hue + ', ' + Math.round(_saturation) + '%, ' + Math.round(_value) + '%)'; break; case 'rgb': var _hsv2rgb2 = hsv2rgb(_hue, _saturation, _value), _r = _hsv2rgb2.r, _g = _hsv2rgb2.g, _b = _hsv2rgb2.b; this.value = 'rgb(' + _r + ', ' + _g + ', ' + _b + ')'; break; default: this.value = toHex(hsv2rgb(_hue, _saturation, _value)); } } }; return Color; }(); /* harmony default export */ var src_color = (Color); ; // CONCATENATED MODULE: ./node_modules/_vue-loader@15.11.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/color-picker/src/components/picker-dropdown.vue?vue&type=template&id=0793d88a var picker_dropdownvue_type_template_id_0793d88a_render = function () { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "transition", { attrs: { name: "el-zoom-in-top" }, on: { "after-leave": _vm.doDestroy } }, [ _c( "div", { directives: [ { name: "show", rawName: "v-show", value: _vm.showPopper, expression: "showPopper", }, ], staticClass: "yk-color-dropdown", }, [ _c( "div", { staticClass: "yk-color-dropdown__main-wrapper" }, [ _c("hue-slider", { ref: "hue", staticStyle: { float: "right" }, attrs: { color: _vm.color, vertical: "" }, }), _c("sv-panel", { ref: "sl", attrs: { color: _vm.color } }), ], 1 ), _vm.showAlpha ? _c("alpha-slider", { ref: "alpha", attrs: { color: _vm.color } }) : _vm._e(), _vm.predefine ? _c("predefine", { attrs: { color: _vm.color, colors: _vm.predefine }, }) : _vm._e(), _c( "div", { staticClass: "yk-color-dropdown__btns" }, [ _c( "span", { staticClass: "yk-color-dropdown__value" }, [ _c("yk-input", { attrs: { "validate-event": false, size: "mini" }, on: { blur: _vm.handleConfirm }, nativeOn: { keyup: function ($event) { if ( !("button" in $event) && _vm._k( $event.keyCode, "enter", 13, $event.key, "Enter" ) ) { return null } return _vm.handleConfirm($event) }, }, model: { value: _vm.customInput, callback: function ($$v) { _vm.customInput = $$v }, expression: "customInput", }, }), ], 1 ), _c( "yk-button", { staticClass: "yk-color-dropdown__link-btn", attrs: { size: "mini", type: "text" }, on: { click: function ($event) { _vm.$emit("clear") }, }, }, [ _vm._v( "\n " + _vm._s(_vm.t("el.colorpicker.clear")) + "\n " ), ] ), _c( "yk-button", { staticClass: "yk-color-dropdown__btn", attrs: { plain: "", size: "mini" }, on: { click: _vm.confirmValue }, }, [ _vm._v( "\n " + _vm._s(_vm.t("el.colorpicker.confirm")) + "\n " ), ] ), ], 1 ), ], 1 ), ] ) } var picker_dropdownvue_type_template_id_0793d88a_staticRenderFns = [] picker_dropdownvue_type_template_id_0793d88a_render._withStripped = true // CONCATENATED MODULE: ./packages/color-picker/src/components/picker-dropdown.vue?vue&type=template&id=0793d88a // CONCATENATED MODULE: ./node_modules/_vue-loader@15.11.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/color-picker/src/components/sv-panel.vue?vue&type=template&id=3722f170 var sv_panelvue_type_template_id_3722f170_render = function () { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "div", { staticClass: "yk-color-svpanel", style: { backgroundColor: _vm.background, }, }, [ _c("div", { staticClass: "yk-color-svpanel__white" }), _c("div", { staticClass: "yk-color-svpanel__black" }), _c( "div", { staticClass: "yk-color-svpanel__cursor", style: { top: _vm.cursorTop + "px", left: _vm.cursorLeft + "px", }, }, [_c("div")] ), ] ) } var sv_panelvue_type_template_id_3722f170_staticRenderFns = [] sv_panelvue_type_template_id_3722f170_render._withStripped = true // CONCATENATED MODULE: ./packages/color-picker/src/components/sv-panel.vue?vue&type=template&id=3722f170 // EXTERNAL MODULE: external "vue" var external_vue_ = __webpack_require__(0); var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_); // CONCATENATED MODULE: ./packages/color-picker/src/draggable.js var isDragging = false; /* harmony default export */ var draggable = (function (element, options) { if (external_vue_default.a.prototype.$isServer) return; var moveFn = function moveFn(event) { if (options.drag) { options.drag(event); } }; var upFn = function upFn(event) { document.removeEventListener('mousemove', moveFn); document.removeEventListener('mouseup', upFn); document.onselectstart = null; document.ondragstart = null; isDragging = false; if (options.end) { options.end(event); } }; element.addEventListener('mousedown', function (event) { if (isDragging) return; document.onselectstart = function () { return false; }; document.ondragstart = function () { return false; }; document.addEventListener('mousemove', moveFn); document.addEventListener('mouseup', upFn); isDragging = true; if (options.start) { options.start(event); } }); }); // CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/color-picker/src/components/sv-panel.vue?vue&type=script&lang=js // // // // // // // // // // // // // // // // // /* harmony default export */ var sv_panelvue_type_script_lang_js = ({ name: 'el-sl-panel', props: { color: { required: true } }, computed: { colorValue: function colorValue() { var hue = this.color.get('hue'); var value = this.color.get('value'); return { hue: hue, value: value }; } }, watch: { colorValue: function colorValue() { this.update(); } }, methods: { update: function update() { var saturation = this.color.get('saturation'); var value = this.color.get('value'); var el = this.$el; var width = el.clientWidth, height = el.clientHeight; this.cursorLeft = saturation * width / 100; this.cursorTop = (100 - value) * height / 100; this.background = 'hsl(' + this.color.get('hue') + ', 100%, 50%)'; }, handleDrag: function handleDrag(event) { var el = this.$el; var rect = el.getBoundingClientRect(); var left = event.clientX - rect.left; var top = event.clientY - rect.top; left = Math.max(0, left); left = Math.min(left, rect.width); top = Math.max(0, top); top = Math.min(top, rect.height); this.cursorLeft = left; this.cursorTop = top; this.color.set({ saturation: left / rect.width * 100, value: 100 - top / rect.height * 100 }); } }, mounted: function mounted() { var _this = this; draggable(this.$el, { drag: function drag(event) { _this.handleDrag(event); }, end: function end(event) { _this.handleDrag(event); } }); this.update(); }, data: function data() { return { cursorTop: 0, cursorLeft: 0, background: 'hsl(0, 100%, 50%)' }; } }); // CONCATENATED MODULE: ./packages/color-picker/src/components/sv-panel.vue?vue&type=script&lang=js /* harmony default export */ var components_sv_panelvue_type_script_lang_js = (sv_panelvue_type_script_lang_js); // EXTERNAL MODULE: ./node_modules/_vue-loader@15.11.1@vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(2); // CONCATENATED MODULE: ./packages/color-picker/src/components/sv-panel.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( components_sv_panelvue_type_script_lang_js, sv_panelvue_type_template_id_3722f170_render, sv_panelvue_type_template_id_3722f170_staticRenderFns, false, null, null, null ) /* harmony default export */ var sv_panel = (component.exports); // CONCATENATED MODULE: ./node_modules/_vue-loader@15.11.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/color-picker/src/components/hue-slider.vue?vue&type=template&id=4847eb7c var hue_slidervue_type_template_id_4847eb7c_render = function () { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "div", { staticClass: "yk-color-hue-slider", class: { "is-vertical": _vm.vertical }, }, [ _c("div", { ref: "bar", staticClass: "yk-color-hue-slider__bar", on: { click: _vm.handleClick }, }), _c("div", { ref: "thumb", staticClass: "yk-color-hue-slider__thumb", style: { left: _vm.thumbLeft + "px", top: _vm.thumbTop + "px", }, }), ] ) } var hue_slidervue_type_template_id_4847eb7c_staticRenderFns = [] hue_slidervue_type_template_id_4847eb7c_render._withStripped = true // CONCATENATED MODULE: ./packages/color-picker/src/components/hue-slider.vue?vue&type=template&id=4847eb7c // CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/color-picker/src/components/hue-slider.vue?vue&type=script&lang=js // // // // // // // // // // // // // /* harmony default export */ var hue_slidervue_type_script_lang_js = ({ name: 'yk-color-hue-slider', props: { color: { required: true }, vertical: Boolean }, data: function data() { return { thumbLeft: 0, thumbTop: 0 }; }, computed: { hueValue: function hueValue() { var hue = this.color.get('hue'); return hue; } }, watch: { hueValue: function hueValue() { this.update(); } }, methods: { handleClick: function handleClick(event) { var thumb = this.$refs.thumb; var target = event.target; if (target !== thumb) { this.handleDrag(event); } }, handleDrag: function handleDrag(event) { var rect = this.$el.getBoundingClientRect(); var thumb = this.$refs.thumb; var hue = void 0; if (!this.vertical) { var left = event.clientX - rect.left; left = Math.min(left, rect.width - thumb.offsetWidth / 2); left = Math.max(thumb.offsetWidth / 2, left); hue = Math.round((left - thumb.offsetWidth / 2) / (rect.width - thumb.offsetWidth) * 360); } else { var top = event.clientY - rect.top; top = Math.min(top, rect.height - thumb.offsetHeight / 2); top = Math.max(thumb.offsetHeight / 2, top); hue = Math.round((top - thumb.offsetHeight / 2) / (rect.height - thumb.offsetHeight) * 360); } this.color.set('hue', hue); }, getThumbLeft: function getThumbLeft() { if (this.vertical) return 0; var el = this.$el; var hue = this.color.get('hue'); if (!el) return 0; var thumb = this.$refs.thumb; return Math.round(hue * (el.offsetWidth - thumb.offsetWidth / 2) / 360); }, getThumbTop: function getThumbTop() { if (!this.vertical) return 0; var el = this.$el; var hue = this.color.get('hue'); if (!el) return 0; var thumb = this.$refs.thumb; return Math.round(hue * (el.offsetHeight - thumb.offsetHeight / 2) / 360); }, update: function update() { this.thumbLeft = this.getThumbLeft(); this.thumbTop = this.getThumbTop(); } }, mounted: function mounted() { var _this = this; var _$refs = this.$refs, bar = _$refs.bar, thumb = _$refs.thumb; var dragConfig = { drag: function drag(event) { _this.handleDrag(event); }, end: function end(event) { _this.handleDrag(event); } }; draggable(bar, dragConfig); draggable(thumb, dragConfig); this.update(); } }); // CONCATENATED MODULE: ./packages/color-picker/src/components/hue-slider.vue?vue&type=script&lang=js /* harmony default export */ var components_hue_slidervue_type_script_lang_js = (hue_slidervue_type_script_lang_js); // CONCATENATED MODULE: ./packages/color-picker/src/components/hue-slider.vue /* normalize component */ var hue_slider_component = Object(componentNormalizer["a" /* default */])( components_hue_slidervue_type_script_lang_js, hue_slidervue_type_template_id_4847eb7c_render, hue_slidervue_type_template_id_4847eb7c_staticRenderFns, false, null, null, null ) /* harmony default export */ var hue_slider = (hue_slider_component.exports); // CONCATENATED MODULE: ./node_modules/_vue-loader@15.11.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/color-picker/src/components/alpha-slider.vue?vue&type=template&id=0f111fc4 var alpha_slidervue_type_template_id_0f111fc4_render = function () { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "div", { staticClass: "yk-color-alpha-slider", class: { "is-vertical": _vm.vertical }, }, [ _c("div", { ref: "bar", staticClass: "yk-color-alpha-slider__bar", style: { background: _vm.background, }, on: { click: _vm.handleClick }, }), _c("div", { ref: "thumb", staticClass: "yk-color-alpha-slider__thumb", style: { left: _vm.thumbLeft + "px", top: _vm.thumbTop + "px", }, }), ] ) } var alpha_slidervue_type_template_id_0f111fc4_staticRenderFns = [] alpha_slidervue_type_template_id_0f111fc4_render._withStripped = true // CONCATENATED MODULE: ./packages/color-picker/src/components/alpha-slider.vue?vue&type=template&id=0f111fc4 // CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/color-picker/src/components/alpha-slider.vue?vue&type=script&lang=js // // // // // // // // // // // // // // // // // // // /* harmony default export */ var alpha_slidervue_type_script_lang_js = ({ name: 'yk-color-alpha-slider', props: { color: { required: true }, vertical: Boolean }, watch: { 'color._alpha': function color_alpha() { this.update(); }, 'color.value': function colorValue() { this.update(); } }, methods: { handleClick: function handleClick(event) { var thumb = this.$refs.thumb; var target = event.target; if (target !== thumb) { this.handleDrag(event); } }, handleDrag: function handleDrag(event) { var rect = this.$el.getBoundingClientRect(); var thumb = this.$refs.thumb; if (!this.vertical) { var left = event.clientX - rect.left; left = Math.max(thumb.offsetWidth / 2, left); left = Math.min(left, rect.width - thumb.offsetWidth / 2); this.color.set('alpha', Math.round((left - thumb.offsetWidth / 2) / (rect.width - thumb.offsetWidth) * 100)); } else { var top = event.clientY - rect.top; top = Math.max(thumb.offsetHeight / 2, top); top = Math.min(top, rect.height - thumb.offsetHeight / 2); this.color.set('alpha', Math.round((top - thumb.offsetHeight / 2) / (rect.height - thumb.offsetHeight) * 100)); } }, getThumbLeft: function getThumbLeft() { if (this.vertical) return 0; var el = this.$el; var alpha = this.color._alpha; if (!el) return 0; var thumb = this.$refs.thumb; return Math.round(alpha * (el.offsetWidth - thumb.offsetWidth / 2) / 100); }, getThumbTop: function getThumbTop() { if (!this.vertical) return 0; var el = this.$el; var alpha = this.color._alpha; if (!el) return 0; var thumb = this.$refs.thumb; return Math.round(alpha * (el.offsetHeight - thumb.offsetHeight / 2) / 100); }, getBackground: function getBackground() { if (this.color && this.color.value) { var _color$toRgb = this.color.toRgb(), r = _color$toRgb.r, g = _color$toRgb.g, b = _color$toRgb.b; return 'linear-gradient(to right, rgba(' + r + ', ' + g + ', ' + b + ', 0) 0%, rgba(' + r + ', ' + g + ', ' + b + ', 1) 100%)'; } return null; }, update: function update() { this.thumbLeft = this.getThumbLeft(); this.thumbTop = this.getThumbTop(); this.background = this.getBackground(); } }, data: function data() { return { thumbLeft: 0, thumbTop: 0, background: null }; }, mounted: function mounted() { var _this = this; var _$refs = this.$refs, bar = _$refs.bar, thumb = _$refs.thumb; var dragConfig = { drag: function drag(event) { _this.handleDrag(event); }, end: function end(event) { _this.handleDrag(event); } }; draggable(bar, dragConfig); draggable(thumb