UNPKG

tdesign-pro-component

Version:

ProComponents tdesign-vue-next + Vue3 + TS

206 lines (205 loc) 6.67 kB
import { a as z, w as F } from "./utils-DU1amZow.js"; import { defineComponent as $, ref as R, useSlots as A, onMounted as S, resolveComponent as y, openBlock as s, createBlock as b, mergeProps as I, withCtx as a, normalizeStyle as W, createSlots as h, createVNode as D, unref as P, isRef as g, renderSlot as t, createElementBlock as U, Fragment as M } from "vue"; import { u as E } from "./hooks-9GWkbKry.js"; const N = /* @__PURE__ */ $({ name: "ProFormDatepicker", __name: "ProFormDatepicker", props: { name: {}, modelValue: {}, label: {}, rules: {}, format: {}, formItemProps: {}, labelWidth: {}, labelAlign: { default: "left" }, append: {}, prepend: {}, size: {}, placeholder: {}, disabled: { type: Boolean }, range: { type: Boolean }, clearable: { type: Boolean }, allowInput: { type: Boolean }, datepickerProps: {}, style: {} }, emits: ["update:modelValue", "change", "pick", "confirm", "focus", "blur"], setup(_, { expose: w, emit: x }) { const i = x, e = _, o = E(e, "modelValue", i, e.modelValue ? e.modelValue : e.range ? [] : ""), d = R(), n = A(); S(() => { e.name || z("name is empty"); }); function f(l, r) { i("change", l, r); } function m(l) { i("pick", l); } function c(l) { i("focus", l); } function u(l) { i("blur", l); } function k(l) { i("confirm", l); } return w({ getValue: () => o.value }), (l, r) => { const V = y("t-date-picker"), v = y("t-input-adornment"), C = y("t-date-range-picker"), B = y("t-form-item"); return s(), b(B, I({ labelWidth: e.labelWidth, labelAlign: e.labelAlign, label: e.label, name: e.name, rules: e.rules }, e.formItemProps), { default: a(() => [ (n.prepend || n.append || e.prepend || e.append) && !e.range ? (s(), b(v, { key: 0, style: W(e.style), format: e.format, ref_key: "datePickerRef", ref: d, onChange: f, onPick: m, onBlur: u, onFocus: c, onConfirm: k, prepend: e.prepend, append: e.append }, h({ default: a(() => [ D(V, I({ style: e.style, format: e.format, size: e.size, ref_key: "datePickerRef", ref: d, onChange: f, onPick: m, onBlur: u, onFocus: c, onConfirm: k, modelValue: P(o), "onUpdate:modelValue": r[0] || (r[0] = (p) => g(o) ? o.value = p : null), disabled: e.disabled, placeholder: e.placeholder, "allow-input": e.allowInput }, e.datepickerProps, { clearable: e.clearable }), h({ _: 2 }, [ n.prefixIcon ? { name: "prefixIcon", fn: a(() => [ t(l.$slots, "prefixIcon") ]), key: "0" } : void 0, n.suffixIcon ? { name: "suffixIcon", fn: a(() => [ t(l.$slots, "suffixIcon") ]), key: "1" } : void 0 ]), 1040, ["style", "format", "size", "modelValue", "disabled", "placeholder", "allow-input", "clearable"]) ]), _: 2 }, [ n.prepend ? { name: "prepend", fn: a(() => [ t(l.$slots, "prepend") ]), key: "0" } : void 0, n.append ? { name: "append", fn: a(() => [ t(l.$slots, "append") ]), key: "1" } : void 0 ]), 1032, ["style", "format", "prepend", "append"])) : (s(), U(M, { key: 1 }, [ e.range ? (s(), b(C, I({ key: 1, style: e.style, format: e.format, size: e.size, ref_key: "datePickerRef", ref: d, onChange: f, onPick: m, onBlur: u, onFocus: c, onConfirm: k, modelValue: P(o), "onUpdate:modelValue": r[2] || (r[2] = (p) => g(o) ? o.value = p : null), disabled: e.disabled, placeholder: e.placeholder, "allow-input": e.allowInput }, e.datepickerProps, { clearable: e.clearable }), h({ _: 2 }, [ n.prefixIcon ? { name: "prefixIcon", fn: a(() => [ t(l.$slots, "prefixIcon") ]), key: "0" } : void 0, n.suffixIcon ? { name: "suffixIcon", fn: a(() => [ t(l.$slots, "suffixIcon") ]), key: "1" } : void 0 ]), 1040, ["style", "format", "size", "modelValue", "disabled", "placeholder", "allow-input", "clearable"])) : (s(), b(V, I({ key: 0, style: e.style, format: e.format, size: e.size, ref_key: "datePickerRef", ref: d, onChange: f, onPick: m, onBlur: u, onFocus: c, onConfirm: k, modelValue: P(o), "onUpdate:modelValue": r[1] || (r[1] = (p) => g(o) ? o.value = p : null), disabled: e.disabled, placeholder: e.placeholder, "allow-input": e.allowInput }, e.datepickerProps, { clearable: e.clearable }), h({ _: 2 }, [ n.prefixIcon ? { name: "prefixIcon", fn: a(() => [ t(l.$slots, "prefixIcon") ]), key: "0" } : void 0, n.suffixIcon ? { name: "suffixIcon", fn: a(() => [ t(l.$slots, "suffixIcon") ]), key: "1" } : void 0 ]), 1040, ["style", "format", "size", "modelValue", "disabled", "placeholder", "allow-input", "clearable"])) ], 64)) ]), _: 3 }, 16, ["labelWidth", "labelAlign", "label", "name", "rules"]); }; } }), H = F(N); export { H as P };