@aplus-frontend/ui
Version:
112 lines (111 loc) • 3.57 kB
JavaScript
import { defineComponent as x, ref as C, computed as N, unref as t, createElementBlock as n, createBlock as D, openBlock as r, createCommentVNode as d, createElementVNode as P, normalizeClass as f, renderSlot as s, toDisplayString as V, mergeProps as $, createSlots as R, renderList as A, withCtx as I, normalizeProps as U, guardReactiveProps as _ } from "vue";
import { InputNumber as z } from "@aplus-frontend/antdv";
import "../../hooks/index.mjs";
import { isNil as E, omit as M } from "lodash-unified";
import { roundWith as T, toDecimalMark as F } from "@fruits-chain/utils";
import { addZeroToDecimalPlaces as W } from "./helper.mjs";
import "../../config-provider/index.mjs";
import { useDefaultPlaceholder as w } from "../hooks/use-default-placeholder.mjs";
import { useNamespace as L } from "../../config-provider/hooks/use-namespace.mjs";
import { useControllableValue as O } from "../../hooks/useControllableValue.mjs";
const Z = { key: 0 }, te = /* @__PURE__ */ x({
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 },
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: {},
emptyText: { default: "--" },
thousands: { type: Boolean, default: !1 },
limitDecimalsRetain: { type: Boolean }
},
emits: ["update:value"],
setup(m, { expose: c, emit: y }) {
const v = y, { b: i } = L("field-number"), o = m, l = C(), { value: u, updateValue: h } = O(
o,
v
), B = w("Number", o), b = N(() => {
let e = t(u);
if (E(e))
return o.emptyText;
o.precision && (e = T(e, o.precision));
let a = o.thousands ? F(e) : String(e);
return o.precision && o.limitDecimalsRetain && (a = W(a, o.precision)), a;
});
function k() {
l.value?.focus();
}
function g() {
l.value?.blur();
}
return c({ focus: k, blur: g }), (e, a) => e.mode === "read" ? (r(), n("span", Z, [
e.$slots.prefix ? (r(), n("span", {
key: 0,
class: f(t(i)("label-left"))
}, [
s(e.$slots, "prefix")
], 2)) : d("", !0),
P("span", null, V(b.value), 1),
e.$slots.addonAfter ? (r(), n("span", {
key: 1,
class: f(t(i)("label-right"))
}, [
s(e.$slots, "addonAfter")
], 2)) : d("", !0)
])) : (r(), D(t(z), $({ key: 1 }, t(M)(o, ["value", "onUpdate:value"]), {
ref_key: "inputRef",
ref: l,
placeholder: t(B),
value: t(u),
"onUpdate:value": t(h)
}), R({ _: 2 }, [
A(e.$slots, (j, p) => ({
name: p,
fn: I((S) => [
s(e.$slots, p, U(_(S || {})))
])
}))
]), 1040, ["placeholder", "value", "onUpdate:value"]));
}
});
export {
te as default
};