UNPKG

@opensig/opendesign

Version:

81 lines (80 loc) 3.05 kB
import { defineComponent, ref, createBlock, openBlock, unref, normalizeClass, withCtx, renderSlot, createElementVNode, createElementBlock, createCommentVNode, resolveDynamicComponent, createTextVNode, toDisplayString } from "vue"; import { IconLoading } from "../_utils/icons.mjs"; import { OLayer } from "../layer/index.mjs"; import { loadingProps } from "./types.mjs"; import { mergeClass } from "../_utils/vue-utils.mjs"; const _hoisted_1 = { class: "o-loading-icon" }; const _hoisted_2 = { key: 0, class: "o-loading-label" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "OLoading", props: loadingProps, emits: ["change", "update:visible"], setup(__props, { expose: __expose, emit: __emit }) { const props = __props; const emits = __emit; const layerRef = ref(null); __expose({ /** * @zh-CN 切换加载状态显示 * @en-US Toggle loading visibility */ toggle(show) { var _a; (_a = layerRef.value) == null ? void 0 : _a.toggle(show); } }); return (_ctx, _cache) => { return openBlock(), createBlock(unref(OLayer), { ref_key: "layerRef", ref: layerRef, class: normalizeClass(["o-loading", [ `o-loading-${props.size}` ]]), visible: props.visible, wrapper: props.wrapper, "unmount-on-hide": props.unmountOnHide, "main-class": unref(mergeClass)("o-loading-main", props.mainClass), "main-transition": props.mainTransition, "mask-transition": props.maskTransition, "transition-orign": "css", mask: props.mask, "mask-close": false, onChange: _cache[0] || (_cache[0] = (v) => emits("change", v)), "onUpdate:visible": _cache[1] || (_cache[1] = (v, e) => emits("update:visible", v, e)) }, { default: withCtx(() => [ renderSlot(_ctx.$slots, "default", {}, () => [ createElementVNode("div", _hoisted_1, [ renderSlot(_ctx.$slots, "icon", {}, () => [ props.icon ? (openBlock(), createBlock(resolveDynamicComponent(props.icon), { key: 0, class: normalizeClass({ "o-rotating": props.iconRotating }) }, null, 8, ["class"])) : (openBlock(), createBlock(unref(IconLoading), { key: 1, class: "o-rotating" })) ]) ]), _ctx.$slots.label || props.label ? (openBlock(), createElementBlock("div", _hoisted_2, [ renderSlot(_ctx.$slots, "label", {}, () => [ createTextVNode( toDisplayString(props.label), 1 /* TEXT */ ) ]) ])) : createCommentVNode("v-if", true) ]) ]), _: 3 /* FORWARDED */ }, 8, ["class", "visible", "wrapper", "unmount-on-hide", "main-class", "main-transition", "mask-transition", "mask"]); }; } }); export { _sfc_main as default };