@opentiny/vue-renderless
Version:
An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.
41 lines (40 loc) • 1.08 kB
JavaScript
import {
__spreadProps,
__spreadValues
} from "../chunk-G2ADBYYC.js";
import { getIntegerAndDecimal, animateValue } from "./index";
const api = ["state", "getIntegerAndDecimal", "animateValue"];
const renderless = (props, hooks) => {
const { reactive, computed, watch } = hooks;
const state = reactive({
value: computed(() => api2.getIntegerAndDecimal(props)),
animatingValue: props.value,
displayValue: computed(() => {
if (props.useAnimation) {
const tempProps = __spreadProps(__spreadValues({}, props), { value: state.animatingValue });
return getIntegerAndDecimal({ props: tempProps })();
}
return state.value;
})
});
const api2 = {
state,
getIntegerAndDecimal: getIntegerAndDecimal({ props }),
animateValue: animateValue({ props, state })
};
watch(
() => props.value,
(newVal) => {
if (props.useAnimation) {
state.animatingValue = props.startValue;
api2.animateValue();
}
},
{ immediate: true }
);
return api2;
};
export {
api,
renderless
};