UNPKG

vuux

Version:

Vue3 Nuxt3 Nuxt4 组件库

38 lines (37 loc) 999 B
import k from "../day/index.mjs"; import { ref as u, computed as p, nextTick as Y } from "vue"; import { Utils as d } from "@vuux/utils"; const D = (l, v, a, i) => { const s = u(!1), t = u(null), f = () => { l.disabled || l.readonly || (s.value = !0, t.value && t.value.init(a.value)); }, c = () => { s.value = !1; }, n = (e) => { i("change", e), c(); }, h = async (e) => { a.value = k(e.value).format("YYYY-MM-DD"), t.value && t.value.init(e.value), await d.wait(100), Y(() => { n(a.value); }); }, y = p(() => { const e = s.value, { readonly: r, disabled: o } = l; return { "app-date-picker": !0, "is-readonly": r || !1, "is-disabled": o || !1, "is-focus": e }; }), b = () => { a.value = void 0, n(a.value), i("clear"); }; return d.useClickOutside(v, c), { classNames: y, visible: s, onChange: n, handleShow: f, handleClear: b, handleSelectPresets: h }; }; export { D as useDatePicker };