@varlet/ui
Version:
A Vue3 component library based on Material Design 2 and 3, supporting mobile and desktop.
90 lines (89 loc) • 2.99 kB
JavaScript
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
import { defineComponent, nextTick, ref, watch } from "vue";
import { isURL, toNumber } from "@varlet/shared";
import { createNamespace } from "../utils/components.mjs";
import { toSizeUnit } from "../utils/elements.mjs";
import { props } from "./props.mjs";
const { name, n, classes } = createNamespace("icon");
import { resolveDynamicComponent as _resolveDynamicComponent, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createBlock as _createBlock } from "vue";
function __render__(_ctx, _cache) {
return _openBlock(), _createBlock(_resolveDynamicComponent(_ctx.isURL(_ctx.name) ? "img" : "i"), {
class: _normalizeClass(
_ctx.classes(
_ctx.n(),
[_ctx.namespace !== _ctx.n(), _ctx.namespace],
`${_ctx.namespace}--set`,
[_ctx.isURL(_ctx.name), _ctx.n("image"), `${_ctx.namespace}-${_ctx.nextName}`],
[_ctx.animateInProgress, _ctx.animationClass == null ? _ctx.n("--shrinking") : _ctx.animationClass]
)
),
style: _normalizeStyle({
color: _ctx.color,
"transition-duration": `${_ctx.toNumber(_ctx.transition)}ms`,
width: _ctx.isURL(_ctx.name) ? _ctx.toSizeUnit(_ctx.size) : null,
height: _ctx.isURL(_ctx.name) ? _ctx.toSizeUnit(_ctx.size) : null,
fontSize: _ctx.toSizeUnit(_ctx.size)
}),
src: _ctx.isURL(_ctx.name) ? _ctx.nextName : null,
onClick: _ctx.onClick
}, null, 8, ["class", "style", "src", "onClick"]);
}
const __sfc__ = defineComponent({
name,
props,
setup(props2) {
const nextName = ref("");
const animateInProgress = ref(false);
watch(() => props2.name, handleNameChange, { immediate: true });
function handleNameChange(newName, oldName) {
return __async(this, null, function* () {
const { transition } = props2;
if (oldName == null || toNumber(transition) === 0) {
nextName.value = newName;
return;
}
animateInProgress.value = true;
yield nextTick();
setTimeout(() => {
if (oldName != null) {
nextName.value = newName;
}
animateInProgress.value = false;
}, toNumber(transition));
});
}
return {
nextName,
animateInProgress,
n,
classes,
isURL,
toNumber,
toSizeUnit
};
}
});
__sfc__.render = __render__;
var stdin_default = __sfc__;
export {
stdin_default as default
};