vuux
Version:
Vue3 Nuxt3 Nuxt4 组件库
30 lines (29 loc) • 812 B
JavaScript
import { computed as i } from "vue";
const f = (t) => {
const s = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], a = (e) => e === "." || e === ",", u = (e) => {
const [n, r] = e.toString().split(".");
return n.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (r ? `.${r}` : "");
}, c = i(() => typeof t.value != "number" ? [] : (t.sep ? u(t.value) : String(t.value)).split("")), l = i(() => ({
height: `${t.size}px`
})), o = i(() => ({
fontSize: `${t.size}px`,
lineHeight: `${t.size}px`,
height: `${t.size}px`
}));
return {
digits: s,
valueArr: c,
styles: l,
numStyle: o,
isSeparator: a,
getItemStyle: (e) => {
const n = parseInt(e);
return isNaN(n) ? {} : {
transform: `translateY(-${t.size * n}px)`
};
}
};
};
export {
f as useMagicNumber
};