UNPKG

@aplus-frontend/ui

Version:

119 lines (118 loc) 3.8 kB
import { defineComponent as N, shallowRef as x, computed as D, unref as t, createElementBlock as s, createBlock as P, openBlock as l, normalizeClass as i, createCommentVNode as m, createElementVNode as R, renderSlot as u, toDisplayString as V, mergeProps as $, createSlots as I, renderList as M, withCtx as A, normalizeProps as U, guardReactiveProps as z } from "vue"; import { InputNumber as E } from "@aplus-frontend/antdv"; import { isNil as T, omit as w } from "lodash-unified"; import { roundWith as F, toDecimalMark as O } from "../../utils/format.mjs"; import "../../config-provider/index.mjs"; import "../../hooks/index.mjs"; import { useDefaultPlaceholder as W } from "../hooks/use-default-placeholder.mjs"; import L from "../style/index.mjs"; import { addZeroToDecimalPlaces as Z } from "./helper.mjs"; import { useNamespace as _ } from "../../config-provider/hooks/use-namespace.mjs"; import { useControllableValue as j } from "../../hooks/useControllableValue.mjs"; const le = /* @__PURE__ */ N({ name: "ApFieldNumber", __name: "index", props: { mode: {}, class: {}, style: {}, size: {}, bordered: { type: Boolean, default: !0 }, placeholder: {}, name: {}, id: {}, type: {}, addonBefore: {}, addonAfter: {}, prefix: {}, suffix: {}, "onUpdate:value": {}, valueModifiers: {}, status: {}, variant: {}, changeOnWheel: { type: Boolean, default: void 0 }, changeOnBlur: { type: Boolean, default: void 0 }, stringMode: { type: Boolean }, defaultValue: {}, value: {}, prefixCls: {}, min: { default: -1 / 0 }, max: { default: 1 / 0 }, step: { default: 1 }, tabindex: {}, controls: { type: Boolean, default: !0 }, readonly: { type: Boolean }, disabled: { type: Boolean, default: void 0 }, autofocus: { type: Boolean }, keyboard: { type: Boolean, default: !0 }, parser: {}, formatter: {}, precision: {}, decimalSeparator: {}, onInput: {}, onChange: {}, onPressEnter: {}, onStep: {}, onBlur: {}, onFocus: {}, inputMode: {}, emptyText: { default: "--" }, thousands: { type: Boolean, default: !1 }, limitDecimalsRetain: { type: Boolean } }, emits: ["update:value"], setup(f, { expose: c, emit: y }) { const v = y, { b: r } = _("field-number"), h = L("field"), o = f, n = x(), { value: p, updateValue: B } = j( o, v ), b = W("Number", o), g = D(() => { let e = t(p); if (T(e)) return o.emptyText; o.precision && (e = F(e, o.precision)); let a = o.thousands ? O(e) : String(e); return o.precision && o.limitDecimalsRetain && (a = Z(a, o.precision)), a; }); function k() { n.value?.focus(); } function S() { n.value?.blur(); } return c({ focus: k, blur: S }), (e, a) => e.mode === "read" ? (l(), s("span", { key: 0, class: i([t(r)(), t(h)]) }, [ e.$slots.prefix ? (l(), s("span", { key: 0, class: i(t(r)("label-left")) }, [ u(e.$slots, "prefix") ], 2)) : m("", !0), R("span", null, V(g.value), 1), e.$slots.addonAfter ? (l(), s("span", { key: 1, class: i(t(r)("label-right")) }, [ u(e.$slots, "addonAfter") ], 2)) : m("", !0) ], 2)) : (l(), P(t(E), $({ key: 1 }, t(w)(o, ["value", "onUpdate:value", "mode"]), { ref_key: "inputRef", ref: n, placeholder: t(b), value: t(p), mode: e.inputMode, "onUpdate:value": t(B) }), I({ _: 2 }, [ M(e.$slots, (q, d) => ({ name: d, fn: A((C) => [ u(e.$slots, d, U(z(C || {}))) ]) })) ]), 1040, ["placeholder", "value", "mode", "onUpdate:value"])); } }); export { le as default };