@ly-js/ui
Version:
`@ly-js/ui` 是基于`vue3`常用库,会在`@ly-js/element`、`@ly-js/vant`中引入
71 lines (66 loc) • 1.76 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var utils = require('@ly-js/utils');
var base = require('./base.js');
const SpinIcon = Array(12).fill(null).map((_, index) => vue.createVNode("i", {
"class": base.bem("line", String(index + 1))
}, null, 2));
const CircularIcon = vue.createVNode("svg", {
"class": base.bem("circular"),
"viewBox": "25 25 50 50"
}, [vue.createVNode("circle", {
"cx": "50",
"cy": "50",
"r": "20",
"fill": "none"
}, null)], 2);
var _Loading = vue.defineComponent({
name: base.name,
props: base.loadingProps,
setup(props, {
slots
}) {
const spinnerStyle = vue.computed(() => ({
color: props.color,
size: props.size,
width: props.size,
height: props.size
}));
const renderText = () => {
var _a;
if (slots.default) {
return vue.createVNode("span", {
"class": base.bem("text"),
"style": {
fontSize: utils.addUnit(props.textSize),
color: (_a = props.textColor) != null ? _a : props.color
}
}, [slots.default()], 6);
}
};
const renderLoadingAnimation = () => {
const {
type
} = props;
if (!props.onlyText) {
return vue.createVNode("span", {
"class": base.bem("spinner", type),
"style": spinnerStyle.value
}, [type === "spinner" ? SpinIcon : CircularIcon], 6);
}
};
return () => {
const {
type,
vertical
} = props;
return vue.createVNode("div", {
"class": base.bem([type, {
vertical
}])
}, [renderLoadingAnimation(), renderText()], 2);
};
}
});
exports["default"] = _Loading;