Files
zhibo/node_modules/ele-admin/es/ele-icon-picker/index.js
T
xiaoyu 5488f5f0a2 init
2023-05-22 14:07:59 +08:00

180 lines
6.6 KiB
JavaScript

import Locale from "element-ui/lib/mixins/locale";
import { LicenseMixin } from "../utils/license-util";
import props from "./props";
function normalizeComponent(scriptExports, render2, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
if (render2) {
options.render = render2;
options.staticRenderFns = staticRenderFns;
options._compiled = true;
}
if (functionalTemplate) {
options.functional = true;
}
if (scopeId) {
options._scopeId = "data-v-" + scopeId;
}
var hook;
if (moduleIdentifier) {
hook = function(context) {
context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
context = __VUE_SSR_CONTEXT__;
}
if (injectStyles) {
injectStyles.call(this, context);
}
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier);
}
};
options._ssrRegister = hook;
} else if (injectStyles) {
hook = shadowMode ? function() {
injectStyles.call(
this,
(options.functional ? this.parent : this).$root.$options.shadowRoot
);
} : injectStyles;
}
if (hook) {
if (options.functional) {
options._injectStyles = hook;
var originalRender = options.render;
options.render = function renderWithStyleInjection(h, context) {
hook.call(context);
return originalRender(h, context);
};
} else {
var existing = options.beforeCreate;
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
}
}
return {
exports: scriptExports,
options
};
}
const _sfc_main = {
name: "EleIconPicker",
mixins: [Locale, LicenseMixin],
props,
data() {
return {
show: false,
keywords: "",
listShow: false,
timer: null
};
},
computed: {
isDisabled() {
return !this.authenticated || this.disabled;
},
pickerClass() {
return [
"ele-icon-picker",
{ "ele-icon-picker-open": this.show },
{ "ele-icon-picker-style2": this.theme === "style2" },
{ "ele-icon-picker-style3": this.theme === "style3" }
];
},
result() {
if (!this.keywords) {
return this.data;
}
let result = [];
this.data.forEach((item) => {
result.push({
title: item.title,
icons: item.icons.filter((d) => d.indexOf(this.keywords) !== -1)
});
});
return result;
},
active: {
get() {
if (!this.result || this.result.length === 0) {
return null;
}
for (let i = 0; i < this.result.length; i++)
if (this.result[i].icons.length !== 0) {
return this.result[i].title;
}
return null;
},
set() {
}
}
},
methods: {
choose(value) {
this.show = false;
this.$emit("input", value);
this.$emit("change", value);
},
clear() {
this.$emit("input", "");
this.$emit("change", "");
},
setReadonly(e) {
if (this.readonly) {
e.target.readOnly = true;
}
},
afterEnter() {
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
this.listShow = true;
}, 50);
},
afterLeave() {
if (this.timer) {
clearTimeout(this.timer);
}
this.listShow = false;
}
}
};
var _sfc_render = function render() {
var _vm = this, _c = _vm._self._c;
return _c("el-popover", { attrs: { "width": _vm.width, "popper-class": "ele-icon-picker-popper", "placement": "bottom-start", "transition": "el-zoom-in-top", "disabled": _vm.isDisabled }, on: { "show": _vm.afterEnter, "hide": _vm.afterLeave }, scopedSlots: _vm._u([{ key: "reference", fn: function() {
return [_c("div", { class: _vm.pickerClass }, [_vm._t("default", function() {
return [_vm.theme === "style2" ? _c("el-input", { attrs: { "value": _vm.value, "placeholder": _vm.placeholder, "clearable": _vm.clearable, "disabled": _vm.isDisabled, "size": _vm.size }, on: { "focus": _vm.setReadonly, "clear": _vm.clear }, scopedSlots: _vm._u([{ key: "append", fn: function() {
return [_c("i", { class: _vm.value })];
}, proxy: true }], null, false, 4065409850) }) : _vm.theme === "style3" ? _c("el-input", { attrs: { "prefix-icon": _vm.value, "disabled": _vm.isDisabled, "size": _vm.size, "readonly": "readonly" }, scopedSlots: _vm._u([{ key: "append", fn: function() {
return [_c("i", { staticClass: "el-icon-arrow-down" })];
}, proxy: true }]) }) : _c("el-input", { attrs: { "value": _vm.value, "prefix-icon": _vm.value, "placeholder": _vm.placeholder, "clearable": _vm.clearable, "disabled": _vm.isDisabled, "size": _vm.size, "suffix-icon": "el-icon-arrow-down" }, on: { "focus": _vm.setReadonly, "clear": _vm.clear } })];
}, { "show": _vm.show, "value": _vm.value })], 2)];
}, proxy: true }], null, true), model: { value: _vm.show, callback: function($$v) {
_vm.show = $$v;
}, expression: "show" } }, [_c("el-tabs", { model: { value: _vm.active, callback: function($$v) {
_vm.active = $$v;
}, expression: "active" } }, _vm._l(_vm.result, function(item, index2) {
return _c("el-tab-pane", { key: index2, attrs: { "label": item.title, "name": item.title } }, [_vm.listShow ? _c("el-scrollbar", { staticStyle: { "height": "225px" } }, [_c("el-row", _vm._l(item.icons, function(d, i) {
return _c("el-col", { key: i, attrs: { "span": 4 } }, [_c("el-card", { staticClass: "ele-card-border", attrs: { "shadow": "hover", "title": d } }, [_c("div", { staticClass: "ele-icon-picker-item", on: { "click": function($event) {
return _vm.choose(d);
} } }, [_c("i", { class: d })])])], 1);
}), 1)], 1) : _c("div", { staticStyle: { "height": "225px", "line-height": "225px", "text-align": "center" } }, [_vm._v(" " + _vm._s(_vm.t("el.select.loading")) + ".. ")])], 1);
}), 1), _vm.search ? _c("el-input", { staticClass: "ele-icon-picker-search", attrs: { "placeholder": _vm.searchPlaceholder, "size": "mini", "suffix-icon": "el-icon-search" }, model: { value: _vm.keywords, callback: function($$v) {
_vm.keywords = $$v;
}, expression: "keywords" } }) : _vm._e()], 1);
};
var _sfc_staticRenderFns = [];
var __component__ = /* @__PURE__ */ normalizeComponent(
_sfc_main,
_sfc_render,
_sfc_staticRenderFns,
false,
null,
null,
null,
null
);
const index = __component__.exports;
export {
index as default
};