| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732 |
- import { a1 as _e, d as O, Q as Se, P as W, p as Q, c as z, _ as M, o as L, bX as re, u as pe, x as Ne, y as Be, af as Oe, bm as ue, at as $e, D as Ie } from "./index2.js";
- import { defineComponent as J, ref as te, createVNode as g, shallowRef as K, watch as se, computed as q, onMounted as ve, Fragment as me, nextTick as ie, onBeforeUpdate as Pe, onBeforeUnmount as Fe } from "vue";
- import { u as Ae, F as je, N as de } from "./FormItemContext.js";
- import { g as Ee, a as ee } from "./statusUtils.js";
- import { B as ze } from "./BaseInput.js";
- import { u as Re } from "./index16.js";
- import { i as Te } from "./isPlainObject.js";
- const H = (e) => e != null && (Array.isArray(e) ? _e(e).length : !0);
- function ne(e) {
- return H(e.prefix) || H(e.suffix) || H(e.allowClear);
- }
- function X(e) {
- return H(e.addonBefore) || H(e.addonAfter);
- }
- function fe(e) {
- return typeof e == "undefined" || e === null ? "" : String(e);
- }
- function ce(e, v, t, a) {
- if (!t)
- return;
- const o = v;
- if (v.type === "click") {
- Object.defineProperty(o, "target", {
- writable: !0
- }), Object.defineProperty(o, "currentTarget", {
- writable: !0
- });
- const f = e.cloneNode(!0);
- o.target = f, o.currentTarget = f, f.value = "", t(o);
- return;
- }
- if (a !== void 0) {
- Object.defineProperty(o, "target", {
- writable: !0
- }), Object.defineProperty(o, "currentTarget", {
- writable: !0
- }), o.target = e, o.currentTarget = e, e.value = a, t(o);
- return;
- }
- t(o);
- }
- function ke(e, v) {
- if (!e) return;
- e.focus(v);
- const {
- cursor: t
- } = v || {};
- if (t) {
- const a = e.value.length;
- switch (t) {
- case "start":
- e.setSelectionRange(0, 0);
- break;
- case "end":
- e.setSelectionRange(a, a);
- break;
- default:
- e.setSelectionRange(0, a);
- }
- }
- }
- const Me = () => ({
- addonBefore: W.any,
- addonAfter: W.any,
- prefix: W.any,
- suffix: W.any,
- clearIcon: W.any,
- affixWrapperClassName: String,
- groupClassName: String,
- wrapperClassName: String,
- inputClassName: String,
- allowClear: {
- type: Boolean,
- default: void 0
- }
- }), ge = () => O(O({}, Me()), {
- value: {
- type: [String, Number, Symbol],
- default: void 0
- },
- defaultValue: {
- type: [String, Number, Symbol],
- default: void 0
- },
- inputElement: W.any,
- prefixCls: String,
- disabled: {
- type: Boolean,
- default: void 0
- },
- focused: {
- type: Boolean,
- default: void 0
- },
- triggerFocus: Function,
- readonly: {
- type: Boolean,
- default: void 0
- },
- handleReset: Function,
- hidden: {
- type: Boolean,
- default: void 0
- }
- }), ye = () => O(O({}, ge()), {
- id: String,
- placeholder: {
- type: [String, Number]
- },
- autocomplete: String,
- type: Se("text"),
- name: String,
- size: {
- type: String
- },
- autofocus: {
- type: Boolean,
- default: void 0
- },
- lazy: {
- type: Boolean,
- default: !0
- },
- maxlength: Number,
- loading: {
- type: Boolean,
- default: void 0
- },
- bordered: {
- type: Boolean,
- default: void 0
- },
- showCount: {
- type: [Boolean, Object]
- },
- htmlSize: Number,
- onPressEnter: Function,
- onKeydown: Function,
- onKeyup: Function,
- onFocus: Function,
- onBlur: Function,
- onChange: Function,
- onInput: Function,
- "onUpdate:value": Function,
- onCompositionstart: Function,
- onCompositionend: Function,
- valueModifiers: Object,
- hidden: {
- type: Boolean,
- default: void 0
- },
- status: String
- }), Ve = J({
- name: "BaseInput",
- inheritAttrs: !1,
- props: ge(),
- setup(e, v) {
- let {
- slots: t,
- attrs: a
- } = v;
- const o = te(), f = (m) => {
- var c;
- if (!((c = o.value) === null || c === void 0) && c.contains(m.target)) {
- const {
- triggerFocus: S
- } = e;
- S == null || S();
- }
- }, d = () => {
- var m;
- const {
- allowClear: c,
- value: S,
- disabled: b,
- readonly: P,
- handleReset: $,
- suffix: T = t.suffix,
- prefixCls: F
- } = e;
- if (!c)
- return null;
- const N = !b && !P && S, p = `${F}-clear-icon`, A = ((m = t.clearIcon) === null || m === void 0 ? void 0 : m.call(t)) || "*";
- return g("span", {
- onClick: $,
- onMousedown: (x) => x.preventDefault(),
- class: z({
- [`${p}-hidden`]: !N,
- [`${p}-has-suffix`]: !!T
- }, p),
- role: "button",
- tabindex: -1
- }, [A]);
- };
- return () => {
- var m, c;
- const {
- focused: S,
- value: b,
- disabled: P,
- allowClear: $,
- readonly: T,
- hidden: F,
- prefixCls: N,
- prefix: p = (m = t.prefix) === null || m === void 0 ? void 0 : m.call(t),
- suffix: A = (c = t.suffix) === null || c === void 0 ? void 0 : c.call(t),
- addonAfter: x = t.addonAfter,
- addonBefore: B = t.addonBefore,
- inputElement: V,
- affixWrapperClassName: r,
- wrapperClassName: C,
- groupClassName: n
- } = e;
- let i = Q(V, {
- value: b,
- hidden: F
- });
- if (ne({
- prefix: p,
- suffix: A,
- allowClear: $
- })) {
- const u = `${N}-affix-wrapper`, y = z(u, {
- [`${u}-disabled`]: P,
- [`${u}-focused`]: S,
- [`${u}-readonly`]: T,
- [`${u}-input-with-clear-btn`]: A && $ && b
- }, !X({
- addonAfter: x,
- addonBefore: B
- }) && a.class, r), I = (A || $) && g("span", {
- class: `${N}-suffix`
- }, [d(), A]);
- i = g("span", {
- class: y,
- style: a.style,
- hidden: !X({
- addonAfter: x,
- addonBefore: B
- }) && F,
- onMousedown: f,
- ref: o
- }, [p && g("span", {
- class: `${N}-prefix`
- }, [p]), Q(V, {
- style: null,
- value: b,
- hidden: null
- }), I]);
- }
- if (X({
- addonAfter: x,
- addonBefore: B
- })) {
- const u = `${N}-group`, y = `${u}-addon`, I = z(`${N}-wrapper`, u, C), k = z(`${N}-group-wrapper`, a.class, n);
- return g("span", {
- class: k,
- style: a.style,
- hidden: F
- }, [g("span", {
- class: I
- }, [B && g("span", {
- class: y
- }, [B]), Q(i, {
- style: null,
- hidden: null
- }), x && g("span", {
- class: y
- }, [x])])]);
- }
- return i;
- };
- }
- });
- var De = function(e, v) {
- var t = {};
- for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && v.indexOf(a) < 0 && (t[a] = e[a]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var o = 0, a = Object.getOwnPropertySymbols(e); o < a.length; o++)
- v.indexOf(a[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, a[o]) && (t[a[o]] = e[a[o]]);
- return t;
- };
- const We = J({
- name: "VCInput",
- inheritAttrs: !1,
- props: ye(),
- setup(e, v) {
- let {
- slots: t,
- attrs: a,
- expose: o,
- emit: f
- } = v;
- const d = K(e.value === void 0 ? e.defaultValue : e.value), m = K(!1), c = K(), S = K();
- se(() => e.value, () => {
- d.value = e.value;
- }), se(() => e.disabled, () => {
- e.disabled && (m.value = !1);
- });
- const b = (n) => {
- c.value && ke(c.value.input, n);
- }, P = () => {
- var n;
- (n = c.value.input) === null || n === void 0 || n.blur();
- }, $ = (n, i, u) => {
- var y;
- (y = c.value.input) === null || y === void 0 || y.setSelectionRange(n, i, u);
- }, T = () => {
- var n;
- (n = c.value.input) === null || n === void 0 || n.select();
- };
- o({
- focus: b,
- blur: P,
- input: q(() => {
- var n;
- return (n = c.value.input) === null || n === void 0 ? void 0 : n.input;
- }),
- stateValue: d,
- setSelectionRange: $,
- select: T
- });
- const F = (n) => {
- f("change", n);
- }, N = (n, i) => {
- d.value !== n && (e.value === void 0 ? d.value = n : ie(() => {
- var u;
- c.value.input.value !== d.value && ((u = S.value) === null || u === void 0 || u.$forceUpdate());
- }), ie(() => {
- i && i();
- }));
- }, p = (n) => {
- const {
- value: i
- } = n.target;
- if (d.value === i) return;
- const u = n.target.value;
- ce(c.value.input, n, F), N(u);
- }, A = (n) => {
- n.keyCode === 13 && f("pressEnter", n), f("keydown", n);
- }, x = (n) => {
- m.value = !0, f("focus", n);
- }, B = (n) => {
- m.value = !1, f("blur", n);
- }, V = (n) => {
- ce(c.value.input, n, F), N("", () => {
- b();
- });
- }, r = () => {
- var n, i;
- const {
- addonBefore: u = t.addonBefore,
- addonAfter: y = t.addonAfter,
- disabled: I,
- valueModifiers: k = {},
- htmlSize: l,
- autocomplete: s,
- prefixCls: h,
- inputClassName: w,
- prefix: j = (n = t.prefix) === null || n === void 0 ? void 0 : n.call(t),
- suffix: E = (i = t.suffix) === null || i === void 0 ? void 0 : i.call(t),
- allowClear: R,
- type: G = "text"
- } = e, U = L(e, [
- "prefixCls",
- "onPressEnter",
- "addonBefore",
- "addonAfter",
- "prefix",
- "suffix",
- "allowClear",
- // Input elements must be either controlled or uncontrolled,
- // specify either the value prop, or the defaultValue prop, but not both.
- "defaultValue",
- "size",
- "bordered",
- "htmlSize",
- "lazy",
- "showCount",
- "valueModifiers",
- "showCount",
- "affixWrapperClassName",
- "groupClassName",
- "inputClassName",
- "wrapperClassName"
- ]), D = O(O(O({}, U), a), {
- autocomplete: s,
- onChange: p,
- onInput: p,
- onFocus: x,
- onBlur: B,
- onKeydown: A,
- class: z(h, {
- [`${h}-disabled`]: I
- }, w, !X({
- addonAfter: y,
- addonBefore: u
- }) && !ne({
- prefix: j,
- suffix: E,
- allowClear: R
- }) && a.class),
- ref: c,
- key: "ant-input",
- size: l,
- type: G,
- lazy: e.lazy
- });
- return k.lazy && delete D.onInput, D.autofocus || delete D.autofocus, g(ze, L(D, ["size"]), null);
- }, C = () => {
- var n;
- const {
- maxlength: i,
- suffix: u = (n = t.suffix) === null || n === void 0 ? void 0 : n.call(t),
- showCount: y,
- prefixCls: I
- } = e, k = Number(i) > 0;
- if (u || y) {
- const l = [...fe(d.value)].length, s = typeof y == "object" ? y.formatter({
- count: l,
- maxlength: i
- }) : `${l}${k ? ` / ${i}` : ""}`;
- return g(me, null, [!!y && g("span", {
- class: z(`${I}-show-count-suffix`, {
- [`${I}-show-count-has-suffix`]: !!u
- })
- }, [s]), u]);
- }
- return null;
- };
- return ve(() => {
- process.env.NODE_ENV === "test" && e.autofocus && b();
- }), () => {
- const {
- prefixCls: n,
- disabled: i
- } = e, u = De(e, ["prefixCls", "disabled"]);
- return g(Ve, M(M(M({}, u), a), {}, {
- ref: S,
- prefixCls: n,
- inputElement: r(),
- handleReset: V,
- value: fe(d.value),
- focused: m.value,
- triggerFocus: b,
- suffix: C(),
- disabled: i
- }), t);
- };
- }
- }), ae = () => L(ye(), ["wrapperClassName", "groupClassName", "inputClassName", "affixWrapperClassName"]), Ze = () => O(O({}, L(ae(), ["prefix", "addonBefore", "addonAfter", "suffix"])), {
- rows: Number,
- autosize: {
- type: [Boolean, Object],
- default: void 0
- },
- autoSize: {
- type: [Boolean, Object],
- default: void 0
- },
- onResize: {
- type: Function
- },
- onCompositionstart: re(),
- onCompositionend: re(),
- valueModifiers: Object
- });
- var Ue = function(e, v) {
- var t = {};
- for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && v.indexOf(a) < 0 && (t[a] = e[a]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var o = 0, a = Object.getOwnPropertySymbols(e); o < a.length; o++)
- v.indexOf(a[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, a[o]) && (t[a[o]] = e[a[o]]);
- return t;
- };
- const Ke = J({
- compatConfig: {
- MODE: 3
- },
- name: "AInput",
- inheritAttrs: !1,
- props: ae(),
- setup(e, v) {
- let {
- slots: t,
- attrs: a,
- expose: o,
- emit: f
- } = v;
- const d = te(), m = Ae(), c = je.useInject(), S = q(() => Ee(c.status, e.status)), {
- direction: b,
- prefixCls: P,
- size: $,
- autocomplete: T
- } = pe("input", e), {
- compactSize: F,
- compactItemClassnames: N
- } = Ne(P, b), p = q(() => F.value || $.value), [A, x] = Re(P), B = Be();
- o({
- focus: (l) => {
- var s;
- (s = d.value) === null || s === void 0 || s.focus(l);
- },
- blur: () => {
- var l;
- (l = d.value) === null || l === void 0 || l.blur();
- },
- input: d,
- setSelectionRange: (l, s, h) => {
- var w;
- (w = d.value) === null || w === void 0 || w.setSelectionRange(l, s, h);
- },
- select: () => {
- var l;
- (l = d.value) === null || l === void 0 || l.select();
- }
- });
- const i = te([]), u = () => {
- i.value.push(setTimeout(() => {
- var l, s, h, w;
- !((l = d.value) === null || l === void 0) && l.input && ((s = d.value) === null || s === void 0 ? void 0 : s.input.getAttribute("type")) === "password" && (!((h = d.value) === null || h === void 0) && h.input.hasAttribute("value")) && ((w = d.value) === null || w === void 0 || w.input.removeAttribute("value"));
- }));
- };
- ve(() => {
- u();
- }), Pe(() => {
- i.value.forEach((l) => clearTimeout(l));
- }), Fe(() => {
- i.value.forEach((l) => clearTimeout(l));
- });
- const y = (l) => {
- u(), f("blur", l), m.onFieldBlur();
- }, I = (l) => {
- u(), f("focus", l);
- }, k = (l) => {
- f("update:value", l.target.value), f("change", l), f("input", l), m.onFieldChange();
- };
- return () => {
- var l, s, h, w, j, E;
- const {
- hasFeedback: R,
- feedbackIcon: G
- } = c, {
- allowClear: U,
- bordered: D = !0,
- prefix: Y = (l = t.prefix) === null || l === void 0 ? void 0 : l.call(t),
- suffix: Z = (s = t.suffix) === null || s === void 0 ? void 0 : s.call(t),
- addonAfter: oe = (h = t.addonAfter) === null || h === void 0 ? void 0 : h.call(t),
- addonBefore: le = (w = t.addonBefore) === null || w === void 0 ? void 0 : w.call(t),
- id: be = (j = m.id) === null || j === void 0 ? void 0 : j.value
- } = e, xe = Ue(e, ["allowClear", "bordered", "prefix", "suffix", "addonAfter", "addonBefore", "id"]), Ce = (R || Z) && g(me, null, [Z, R && G]), _ = P.value, he = ne({
- prefix: Y,
- suffix: Z
- }) || !!R, we = t.clearIcon || (() => g(Oe, null, null));
- return A(g(We, M(M(M({}, a), L(xe, ["onUpdate:value", "onChange", "onInput"])), {}, {
- onChange: k,
- id: be,
- disabled: (E = e.disabled) !== null && E !== void 0 ? E : B.value,
- ref: d,
- prefixCls: _,
- autocomplete: T.value,
- onBlur: y,
- onFocus: I,
- prefix: Y,
- suffix: Ce,
- allowClear: U,
- addonAfter: oe && g(ue, null, {
- default: () => [g(de, null, {
- default: () => [oe]
- })]
- }),
- addonBefore: le && g(ue, null, {
- default: () => [g(de, null, {
- default: () => [le]
- })]
- }),
- class: [a.class, N.value],
- inputClassName: z({
- [`${_}-sm`]: p.value === "small",
- [`${_}-lg`]: p.value === "large",
- [`${_}-rtl`]: b.value === "rtl",
- [`${_}-borderless`]: !D
- }, !he && ee(_, S.value), x.value),
- affixWrapperClassName: z({
- [`${_}-affix-wrapper-sm`]: p.value === "small",
- [`${_}-affix-wrapper-lg`]: p.value === "large",
- [`${_}-affix-wrapper-rtl`]: b.value === "rtl",
- [`${_}-affix-wrapper-borderless`]: !D
- }, ee(`${_}-affix-wrapper`, S.value, R), x.value),
- wrapperClassName: z({
- [`${_}-group-rtl`]: b.value === "rtl"
- }, x.value),
- groupClassName: z({
- [`${_}-group-wrapper-sm`]: p.value === "small",
- [`${_}-group-wrapper-lg`]: p.value === "large",
- [`${_}-group-wrapper-rtl`]: b.value === "rtl"
- }, ee(`${_}-group-wrapper`, S.value, R), x.value)
- }), O(O({}, t), {
- clearIcon: we
- })));
- };
- }
- });
- var Le = function(e, v) {
- var t = {};
- for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && v.indexOf(a) < 0 && (t[a] = e[a]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var o = 0, a = Object.getOwnPropertySymbols(e); o < a.length; o++)
- v.indexOf(a[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, a[o]) && (t[a[o]] = e[a[o]]);
- return t;
- };
- const et = J({
- compatConfig: {
- MODE: 3
- },
- name: "AInputSearch",
- inheritAttrs: !1,
- props: O(O({}, ae()), {
- inputPrefixCls: String,
- // 不能设置默认值 https://github.com/vueComponent/ant-design-vue/issues/1916
- enterButton: W.any,
- onSearch: {
- type: Function
- }
- }),
- setup(e, v) {
- let {
- slots: t,
- attrs: a,
- expose: o,
- emit: f
- } = v;
- const d = K(), m = K(!1);
- o({
- focus: () => {
- var r;
- (r = d.value) === null || r === void 0 || r.focus();
- },
- blur: () => {
- var r;
- (r = d.value) === null || r === void 0 || r.blur();
- }
- });
- const b = (r) => {
- f("update:value", r.target.value), r && r.target && r.type === "click" && f("search", r.target.value, r), f("change", r);
- }, P = (r) => {
- var C;
- document.activeElement === ((C = d.value) === null || C === void 0 ? void 0 : C.input) && r.preventDefault();
- }, $ = (r) => {
- var C, n;
- f("search", (n = (C = d.value) === null || C === void 0 ? void 0 : C.input) === null || n === void 0 ? void 0 : n.stateValue, r);
- }, T = (r) => {
- m.value || e.loading || $(r);
- }, F = (r) => {
- m.value = !0, f("compositionstart", r);
- }, N = (r) => {
- m.value = !1, f("compositionend", r);
- }, {
- prefixCls: p,
- getPrefixCls: A,
- direction: x,
- size: B
- } = pe("input-search", e), V = q(() => A("input", e.inputPrefixCls));
- return () => {
- var r, C, n, i;
- const {
- disabled: u,
- loading: y,
- addonAfter: I = (r = t.addonAfter) === null || r === void 0 ? void 0 : r.call(t),
- suffix: k = (C = t.suffix) === null || C === void 0 ? void 0 : C.call(t)
- } = e, l = Le(e, ["disabled", "loading", "addonAfter", "suffix"]);
- let {
- enterButton: s = (i = (n = t.enterButton) === null || n === void 0 ? void 0 : n.call(t)) !== null && i !== void 0 ? i : !1
- } = e;
- s = s || s === "";
- const h = typeof s == "boolean" ? g($e, null, null) : null, w = `${p.value}-button`, j = Array.isArray(s) ? s[0] : s;
- let E;
- const R = j.type && Te(j.type) && j.type.__ANT_BUTTON;
- if (R || j.tagName === "button")
- E = Q(j, O({
- onMousedown: P,
- onClick: $,
- key: "enterButton"
- }, R ? {
- class: w,
- size: B.value
- } : {}), !1);
- else {
- const U = h && !s;
- E = g(Ie, {
- class: w,
- type: s ? "primary" : void 0,
- size: B.value,
- disabled: u,
- key: "enterButton",
- onMousedown: P,
- onClick: $,
- loading: y,
- icon: U ? h : null
- }, {
- default: () => [U ? null : h || s]
- });
- }
- I && (E = [E, I]);
- const G = z(p.value, {
- [`${p.value}-rtl`]: x.value === "rtl",
- [`${p.value}-${B.value}`]: !!B.value,
- [`${p.value}-with-button`]: !!s
- }, a.class);
- return g(Ke, M(M(M({
- ref: d
- }, L(l, ["onUpdate:value", "onSearch", "enterButton"])), a), {}, {
- onPressEnter: T,
- onCompositionstart: F,
- onCompositionend: N,
- size: B.value,
- prefixCls: V.value,
- addonAfter: E,
- suffix: k,
- onChange: b,
- class: G,
- disabled: u
- }), t);
- };
- }
- });
- export {
- Ke as I,
- et as _,
- ke as a,
- fe as f,
- ae as i,
- ce as r,
- Ze as t
- };
|