UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

177 lines (176 loc) 5.73 kB
import { defineComponent, ref, watch, onMounted, toRefs, nextTick, openBlock, createElementBlock, normalizeStyle, createElementVNode, normalizeClass, createCommentVNode, toDisplayString, pushScopeId, popScopeId } from "vue"; import _imports_0 from "./img/success.mjs"; import _imports_1 from "./img/info.mjs"; import _imports_2 from "./img/warning.mjs"; import _imports_3 from "./img/error.mjs"; import "./index.vue_vue_type_style_index_0_scoped_true_lang.mjs"; import _export_sfc from "../../_virtual/plugin-vue_export-helper.mjs"; const _sfc_main = defineComponent({ name: "CoPromptBoxStd", props: { width: { type: String }, height: { type: String }, text: { type: String }, textSize: { type: Number }, isIcon: { type: Boolean }, iconSrc: { type: String, default: "/data/images/compImages/success.png" }, iconWidth: { type: Number }, iconHeight: { type: Number }, align: { type: String, default: "flex-start" }, promptType: { type: String, default: "success" }, show: { type: Boolean } }, setup(props) { const promptDom = ref(); const promptParentDom = ref(); const promptTextDom = ref(); const promptTextHeight = ref(); const promptText = ref(props.text); const promptBoxType = ref(props.promptType); const isShow = ref(props.show); const closeFn = () => { isShow.value = false; }; const heightFn = () => { nextTick(() => { promptTextHeight.value = promptTextDom.value.offsetHeight; }); }; const getPromptType = ["success", "info", "warning", "error"]; const updataContent = (text, type) => { if (text) promptText.value = text; if (type) promptBoxType.value = type; heightFn(); }; watch( () => props.text, () => { promptText.value = props.text; heightFn(); } ); watch( () => props.textSize, () => { heightFn(); } ); watch( () => props.promptType, () => { promptBoxType.value = props.promptType; } ); watch( () => props.show, () => { isShow.value = props.show; } ); onMounted(() => { promptParentDom.value = promptDom.value.parentNode.parentNode.parentNode; }); return { promptDom, promptTextDom, isShow, promptText, promptBoxType, getPromptType, closeFn, updataContent, ...toRefs(props) }; } }); const _withScopeId = (n) => (pushScopeId("data-v-53b885cd"), n = n(), popScopeId(), n); const _hoisted_1 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("svg", { viewBox: "0 0 1024 1024" }, [ /* @__PURE__ */ createElementVNode("path", { d: "M550.848 502.496l308.64-308.896a31.968 31.968 0 1 0-45.248-45.248l-308.608 308.896-308.64-308.928a31.968 31.968 0 1 0-45.248 45.248l308.64 308.896-308.64 308.896a31.968 31.968 0 1 0 45.248 45.248l308.64-308.896 308.608 308.896a31.968 31.968 0 1 0 45.248-45.248l-308.64-308.864z", fill: "#8a8a8a" }) ], -1)); const _hoisted_2 = [ _hoisted_1 ]; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return _ctx.isShow ? (openBlock(), createElementBlock("div", { key: 0, class: "co-prompt-box-std", style: normalizeStyle({ width: _ctx.width || "100%", height: "100%" }), ref: "promptDom" }, [ createElementVNode("div", { class: normalizeClass(`prompt-box-std__box ${_ctx.promptBoxType}-color`), style: normalizeStyle({ borderRadius: "8px", justifyContent: "space-between" }) }, [ createElementVNode("p", { class: "prompt-box-std__text", style: normalizeStyle({ fontSize: `${_ctx.textSize}px`, justifyContent: _ctx.align }), ref: "promptTextDom" }, [ _ctx.promptBoxType === "success" && _ctx.isIcon ? (openBlock(), createElementBlock("img", { key: 0, src: _imports_0, style: normalizeStyle({ width: `${_ctx.iconWidth}px`, height: `${_ctx.iconHeight}px` }) }, null, 4)) : createCommentVNode("", true), _ctx.promptBoxType === "info" && _ctx.isIcon ? (openBlock(), createElementBlock("img", { key: 1, src: _imports_1, style: normalizeStyle({ width: `${_ctx.iconWidth}px`, height: `${_ctx.iconHeight}px` }) }, null, 4)) : createCommentVNode("", true), _ctx.promptBoxType === "warning" && _ctx.isIcon ? (openBlock(), createElementBlock("img", { key: 2, src: _imports_2, style: normalizeStyle({ width: `${_ctx.iconWidth}px`, height: `${_ctx.iconHeight}px` }) }, null, 4)) : createCommentVNode("", true), _ctx.promptBoxType === "error" && _ctx.isIcon ? (openBlock(), createElementBlock("img", { key: 3, src: _imports_3, style: normalizeStyle({ width: `${_ctx.iconWidth}px`, height: `${_ctx.iconHeight}px` }) }, null, 4)) : createCommentVNode("", true), createElementVNode("span", null, toDisplayString(_ctx.promptText), 1) ], 4), createElementVNode("span", { class: "prompt-box-std__icon", style: normalizeStyle({ color: "rgba(168, 171, 178,1)" }), onClick: _cache[0] || (_cache[0] = (...args) => _ctx.closeFn && _ctx.closeFn(...args)) }, _hoisted_2, 4) ], 6) ], 4)) : createCommentVNode("", true); } var CoPromptBoxStd = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-53b885cd"]]); export { CoPromptBoxStd as default };