index21.js 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
  1. import { c as j, _ as O, M as A, l as et, w as Ae, d as v, K as le, O as F, N as Z, Q as xe, g as tt, v as nt, r as Oe, aB as rt, u as at, x as it, y as lt, o as ot, au as st, cd as ut, bm as Ve, p as dt, P as Se } from "./index2.js";
  2. import { defineComponent as Ee, ref as je, onBeforeUnmount as We, createVNode as b, shallowRef as M, computed as W, watch as ee } from "vue";
  3. import { i as ct } from "./isMobile.js";
  4. import { u as ft, F as pt, N as Be } from "./FormItemContext.js";
  5. import { g as mt, a as $e } from "./statusUtils.js";
  6. import { i as gt, g as He, d as Ge, e as vt, f as ht, h as bt, b as St, c as qe } from "./index16.js";
  7. function we() {
  8. return typeof BigInt == "function";
  9. }
  10. function te(e) {
  11. let t = e.trim(), n = t.startsWith("-");
  12. n && (t = t.slice(1)), t = t.replace(/(\.\d*[^0])0*$/, "$1").replace(/\.0*$/, "").replace(/^0+/, ""), t.startsWith(".") && (t = `0${t}`);
  13. const a = t || "0", o = a.split("."), i = o[0] || "0", d = o[1] || "0";
  14. i === "0" && d === "0" && (n = !1);
  15. const c = n ? "-" : "";
  16. return {
  17. negative: n,
  18. negativeStr: c,
  19. trimStr: a,
  20. integerStr: i,
  21. decimalStr: d,
  22. fullStr: `${c}${a}`
  23. };
  24. }
  25. function Ce(e) {
  26. const t = String(e);
  27. return !Number.isNaN(Number(t)) && t.includes("e");
  28. }
  29. function ne(e) {
  30. const t = String(e);
  31. if (Ce(e)) {
  32. let n = Number(t.slice(t.indexOf("e-") + 2));
  33. const a = t.match(/\.(\d+)/);
  34. return a != null && a[1] && (n += a[1].length), n;
  35. }
  36. return t.includes(".") && De(t) ? t.length - t.indexOf(".") - 1 : 0;
  37. }
  38. function _e(e) {
  39. let t = String(e);
  40. if (Ce(e)) {
  41. if (e > Number.MAX_SAFE_INTEGER)
  42. return String(we() ? BigInt(e).toString() : Number.MAX_SAFE_INTEGER);
  43. if (e < Number.MIN_SAFE_INTEGER)
  44. return String(we() ? BigInt(e).toString() : Number.MIN_SAFE_INTEGER);
  45. t = e.toFixed(ne(t));
  46. }
  47. return te(t).fullStr;
  48. }
  49. function De(e) {
  50. return typeof e == "number" ? !Number.isNaN(e) : e ? (
  51. // Normal type: 11.28
  52. /^\s*-?\d+(\.\d+)?\s*$/.test(e) || // Pre-number: 1.
  53. /^\s*-?\d+\.\s*$/.test(e) || // Post-number: .1
  54. /^\s*-?\.\d+\s*$/.test(e)
  55. ) : !1;
  56. }
  57. function Le(e) {
  58. return !e && e !== 0 && !Number.isNaN(e) || !String(e).trim();
  59. }
  60. class z {
  61. constructor(t) {
  62. if (this.origin = "", Le(t)) {
  63. this.empty = !0;
  64. return;
  65. }
  66. this.origin = String(t), this.number = Number(t);
  67. }
  68. negate() {
  69. return new z(-this.toNumber());
  70. }
  71. add(t) {
  72. if (this.isInvalidate())
  73. return new z(t);
  74. const n = Number(t);
  75. if (Number.isNaN(n))
  76. return this;
  77. const a = this.number + n;
  78. if (a > Number.MAX_SAFE_INTEGER)
  79. return new z(Number.MAX_SAFE_INTEGER);
  80. if (a < Number.MIN_SAFE_INTEGER)
  81. return new z(Number.MIN_SAFE_INTEGER);
  82. const o = Math.max(ne(this.number), ne(n));
  83. return new z(a.toFixed(o));
  84. }
  85. isEmpty() {
  86. return this.empty;
  87. }
  88. isNaN() {
  89. return Number.isNaN(this.number);
  90. }
  91. isInvalidate() {
  92. return this.isEmpty() || this.isNaN();
  93. }
  94. equals(t) {
  95. return this.toNumber() === (t == null ? void 0 : t.toNumber());
  96. }
  97. lessEquals(t) {
  98. return this.add(t.negate().toString()).toNumber() <= 0;
  99. }
  100. toNumber() {
  101. return this.number;
  102. }
  103. toString() {
  104. return (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0) ? this.isInvalidate() ? "" : _e(this.number) : this.origin;
  105. }
  106. }
  107. class U {
  108. constructor(t) {
  109. if (this.origin = "", Le(t)) {
  110. this.empty = !0;
  111. return;
  112. }
  113. if (this.origin = String(t), t === "-" || Number.isNaN(t)) {
  114. this.nan = !0;
  115. return;
  116. }
  117. let n = t;
  118. if (Ce(n) && (n = Number(n)), n = typeof n == "string" ? n : _e(n), De(n)) {
  119. const a = te(n);
  120. this.negative = a.negative;
  121. const o = a.trimStr.split(".");
  122. this.integer = BigInt(o[0]);
  123. const i = o[1] || "0";
  124. this.decimal = BigInt(i), this.decimalLen = i.length;
  125. } else
  126. this.nan = !0;
  127. }
  128. getMark() {
  129. return this.negative ? "-" : "";
  130. }
  131. getIntegerStr() {
  132. return this.integer.toString();
  133. }
  134. getDecimalStr() {
  135. return this.decimal.toString().padStart(this.decimalLen, "0");
  136. }
  137. /**
  138. * Align BigIntDecimal with same decimal length. e.g. 12.3 + 5 = 1230000
  139. * This is used for add function only.
  140. */
  141. alignDecimal(t) {
  142. const n = `${this.getMark()}${this.getIntegerStr()}${this.getDecimalStr().padEnd(t, "0")}`;
  143. return BigInt(n);
  144. }
  145. negate() {
  146. const t = new U(this.toString());
  147. return t.negative = !t.negative, t;
  148. }
  149. add(t) {
  150. if (this.isInvalidate())
  151. return new U(t);
  152. const n = new U(t);
  153. if (n.isInvalidate())
  154. return this;
  155. const a = Math.max(this.getDecimalStr().length, n.getDecimalStr().length), o = this.alignDecimal(a), i = n.alignDecimal(a), d = (o + i).toString(), {
  156. negativeStr: c,
  157. trimStr: f
  158. } = te(d), p = `${c}${f.padStart(a + 1, "0")}`;
  159. return new U(`${p.slice(0, -a)}.${p.slice(-a)}`);
  160. }
  161. isEmpty() {
  162. return this.empty;
  163. }
  164. isNaN() {
  165. return this.nan;
  166. }
  167. isInvalidate() {
  168. return this.isEmpty() || this.isNaN();
  169. }
  170. equals(t) {
  171. return this.toString() === (t == null ? void 0 : t.toString());
  172. }
  173. lessEquals(t) {
  174. return this.add(t.negate().toString()).toNumber() <= 0;
  175. }
  176. toNumber() {
  177. return this.isNaN() ? NaN : Number(this.toString());
  178. }
  179. toString() {
  180. return (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0) ? this.isInvalidate() ? "" : te(`${this.getMark()}${this.getIntegerStr()}.${this.getDecimalStr()}`).fullStr : this.origin;
  181. }
  182. }
  183. function D(e) {
  184. return we() ? new U(e) : new z(e);
  185. }
  186. function Ie(e, t, n) {
  187. let a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1;
  188. if (e === "")
  189. return "";
  190. const {
  191. negativeStr: o,
  192. integerStr: i,
  193. decimalStr: d
  194. } = te(e), c = `${t}${d}`, f = `${o}${i}`;
  195. if (n >= 0) {
  196. const p = Number(d[n]);
  197. if (p >= 5 && !a) {
  198. const s = D(e).add(`${o}0.${"0".repeat(n)}${10 - p}`);
  199. return Ie(s.toString(), t, n, a);
  200. }
  201. return n === 0 ? f : `${f}${t}${d.padEnd(n, "0").slice(0, n)}`;
  202. }
  203. return c === ".0" ? f : `${f}${c}`;
  204. }
  205. const $t = 200, Nt = 600, yt = Ee({
  206. compatConfig: {
  207. MODE: 3
  208. },
  209. name: "StepHandler",
  210. inheritAttrs: !1,
  211. props: {
  212. prefixCls: String,
  213. upDisabled: Boolean,
  214. downDisabled: Boolean,
  215. onStep: A()
  216. },
  217. slots: Object,
  218. setup(e, t) {
  219. let {
  220. slots: n,
  221. emit: a
  222. } = t;
  223. const o = je(), i = (c, f) => {
  224. c.preventDefault(), a("step", f);
  225. function p() {
  226. a("step", f), o.value = setTimeout(p, $t);
  227. }
  228. o.value = setTimeout(p, Nt);
  229. }, d = () => {
  230. clearTimeout(o.value);
  231. };
  232. return We(() => {
  233. d();
  234. }), () => {
  235. if (ct())
  236. return null;
  237. const {
  238. prefixCls: c,
  239. upDisabled: f,
  240. downDisabled: p
  241. } = e, s = `${c}-handler`, x = j(s, `${s}-up`, {
  242. [`${s}-up-disabled`]: f
  243. }), S = j(s, `${s}-down`, {
  244. [`${s}-down-disabled`]: p
  245. }), I = {
  246. unselectable: "on",
  247. role: "button",
  248. onMouseup: d,
  249. onMouseleave: d
  250. }, {
  251. upNode: $,
  252. downNode: E
  253. } = n;
  254. return b("div", {
  255. class: `${s}-wrap`
  256. }, [b("span", O(O({}, I), {}, {
  257. onMousedown: (P) => {
  258. i(P, !0);
  259. },
  260. "aria-label": "Increase Value",
  261. "aria-disabled": f,
  262. class: x
  263. }), [($ == null ? void 0 : $()) || b("span", {
  264. unselectable: "on",
  265. class: `${c}-handler-up-inner`
  266. }, null)]), b("span", O(O({}, I), {}, {
  267. onMousedown: (P) => {
  268. i(P, !1);
  269. },
  270. "aria-label": "Decrease Value",
  271. "aria-disabled": p,
  272. class: S
  273. }), [(E == null ? void 0 : E()) || b("span", {
  274. unselectable: "on",
  275. class: `${c}-handler-down-inner`
  276. }, null)])]);
  277. };
  278. }
  279. });
  280. function xt(e, t) {
  281. const n = je(null);
  282. function a() {
  283. try {
  284. const {
  285. selectionStart: i,
  286. selectionEnd: d,
  287. value: c
  288. } = e.value, f = c.substring(0, i), p = c.substring(d);
  289. n.value = {
  290. start: i,
  291. end: d,
  292. value: c,
  293. beforeTxt: f,
  294. afterTxt: p
  295. };
  296. } catch (i) {
  297. }
  298. }
  299. function o() {
  300. if (e.value && n.value && t.value)
  301. try {
  302. const {
  303. value: i
  304. } = e.value, {
  305. beforeTxt: d,
  306. afterTxt: c,
  307. start: f
  308. } = n.value;
  309. let p = i.length;
  310. if (i.endsWith(c))
  311. p = i.length - n.value.afterTxt.length;
  312. else if (i.startsWith(d))
  313. p = d.length;
  314. else {
  315. const s = d[f - 1], x = i.indexOf(s, f - 1);
  316. x !== -1 && (p = x + 1);
  317. }
  318. e.value.setSelectionRange(p, p);
  319. } catch (i) {
  320. et(!1, `Something warning of cursor restore. Please fire issue about this: ${i.message}`);
  321. }
  322. }
  323. return [a, o];
  324. }
  325. const wt = () => {
  326. const e = M(0), t = () => {
  327. Ae.cancel(e.value);
  328. };
  329. return We(() => {
  330. t();
  331. }), (n) => {
  332. t(), e.value = Ae(() => {
  333. n();
  334. });
  335. };
  336. };
  337. var It = function(e, t) {
  338. var n = {};
  339. for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && t.indexOf(a) < 0 && (n[a] = e[a]);
  340. if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var o = 0, a = Object.getOwnPropertySymbols(e); o < a.length; o++)
  341. t.indexOf(a[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, a[o]) && (n[a[o]] = e[a[o]]);
  342. return n;
  343. };
  344. const Te = (e, t) => e || t.isEmpty() ? t.toString() : t.toNumber(), Fe = (e) => {
  345. const t = D(e);
  346. return t.isInvalidate() ? null : t;
  347. }, Ue = () => ({
  348. /** value will show as string */
  349. stringMode: F(),
  350. defaultValue: Z([String, Number]),
  351. value: Z([String, Number]),
  352. prefixCls: xe(),
  353. min: Z([String, Number]),
  354. max: Z([String, Number]),
  355. step: Z([String, Number], 1),
  356. tabindex: Number,
  357. controls: F(!0),
  358. readonly: F(),
  359. disabled: F(),
  360. autofocus: F(),
  361. keyboard: F(!0),
  362. /** Parse display value to validate number */
  363. parser: A(),
  364. /** Transform `value` to display value show in input */
  365. formatter: A(),
  366. /** Syntactic sugar of `formatter`. Config precision of display. */
  367. precision: Number,
  368. /** Syntactic sugar of `formatter`. Config decimal separator of display. */
  369. decimalSeparator: String,
  370. onInput: A(),
  371. onChange: A(),
  372. onPressEnter: A(),
  373. onStep: A(),
  374. onBlur: A(),
  375. onFocus: A()
  376. }), Et = Ee({
  377. compatConfig: {
  378. MODE: 3
  379. },
  380. name: "InnerInputNumber",
  381. inheritAttrs: !1,
  382. props: v(v({}, Ue()), {
  383. lazy: Boolean
  384. }),
  385. slots: Object,
  386. setup(e, t) {
  387. let {
  388. attrs: n,
  389. slots: a,
  390. emit: o,
  391. expose: i
  392. } = t;
  393. const d = M(), c = M(!1), f = M(!1), p = M(!1), s = M(D(e.value));
  394. function x(r) {
  395. e.value === void 0 && (s.value = r);
  396. }
  397. const S = (r, l) => {
  398. if (!l)
  399. return e.precision >= 0 ? e.precision : Math.max(ne(r), ne(e.step));
  400. }, I = (r) => {
  401. const l = String(r);
  402. if (e.parser)
  403. return e.parser(l);
  404. let u = l;
  405. return e.decimalSeparator && (u = u.replace(e.decimalSeparator, ".")), u.replace(/[^\w.-]+/g, "");
  406. }, $ = M(""), E = (r, l) => {
  407. if (e.formatter)
  408. return e.formatter(r, {
  409. userTyping: l,
  410. input: String($.value)
  411. });
  412. let u = typeof r == "number" ? _e(r) : r;
  413. if (!l) {
  414. const m = S(u, l);
  415. if (De(u) && (e.decimalSeparator || m >= 0)) {
  416. const y = e.decimalSeparator || ".";
  417. u = Ie(u, y, m);
  418. }
  419. }
  420. return u;
  421. }, P = (() => {
  422. const r = e.value;
  423. return s.value.isInvalidate() && ["string", "number"].includes(typeof r) ? Number.isNaN(r) ? "" : r : E(s.value.toString(), !1);
  424. })();
  425. $.value = P;
  426. function C(r, l) {
  427. $.value = E(
  428. // Invalidate number is sometime passed by external control, we should let it go
  429. // Otherwise is controlled by internal interactive logic which check by userTyping
  430. // You can ref 'show limited value when input is not focused' test for more info.
  431. r.isInvalidate() ? r.toString(!1) : r.toString(!l),
  432. l
  433. );
  434. }
  435. const _ = W(() => Fe(e.max)), N = W(() => Fe(e.min)), w = W(() => !_.value || !s.value || s.value.isInvalidate() ? !1 : _.value.lessEquals(s.value)), V = W(() => !N.value || !s.value || s.value.isInvalidate() ? !1 : s.value.lessEquals(N.value)), [k, K] = xt(d, c), X = (r) => _.value && !r.lessEquals(_.value) ? _.value : N.value && !N.value.lessEquals(r) ? N.value : null, oe = (r) => !X(r), Q = (r, l) => {
  436. var u;
  437. let m = r, y = oe(m) || m.isEmpty();
  438. if (!m.isEmpty() && !l && (m = X(m) || m, y = !0), !e.readonly && !e.disabled && y) {
  439. const R = m.toString(), q = S(R, l);
  440. return q >= 0 && (m = D(Ie(R, ".", q))), m.equals(s.value) || (x(m), (u = e.onChange) === null || u === void 0 || u.call(e, m.isEmpty() ? null : Te(e.stringMode, m)), e.value === void 0 && C(m, l)), m;
  441. }
  442. return s.value;
  443. }, se = wt(), Y = (r) => {
  444. var l;
  445. if (k(), $.value = r, !p.value) {
  446. const u = I(r), m = D(u);
  447. m.isNaN() || Q(m, !0);
  448. }
  449. (l = e.onInput) === null || l === void 0 || l.call(e, r), se(() => {
  450. let u = r;
  451. e.parser || (u = r.replace(/。/g, ".")), u !== r && Y(u);
  452. });
  453. }, h = () => {
  454. p.value = !0;
  455. }, J = () => {
  456. p.value = !1, Y(d.value.value);
  457. }, H = (r) => {
  458. Y(r.target.value);
  459. }, G = (r) => {
  460. var l, u;
  461. if (r && w.value || !r && V.value)
  462. return;
  463. f.value = !1;
  464. let m = D(e.step);
  465. r || (m = m.negate());
  466. const y = (s.value || D(0)).add(m.toString()), R = Q(y, !1);
  467. (l = e.onStep) === null || l === void 0 || l.call(e, Te(e.stringMode, R), {
  468. offset: e.step,
  469. type: r ? "up" : "down"
  470. }), (u = d.value) === null || u === void 0 || u.focus();
  471. }, B = (r) => {
  472. const l = D(I($.value));
  473. let u = l;
  474. l.isNaN() ? u = s.value : u = Q(l, r), e.value !== void 0 ? C(s.value, !1) : u.isNaN() || C(u, !1);
  475. }, ue = () => {
  476. f.value = !0;
  477. }, de = (r) => {
  478. var l;
  479. const {
  480. which: u
  481. } = r;
  482. f.value = !0, u === le.ENTER && (p.value || (f.value = !1), B(!1), (l = e.onPressEnter) === null || l === void 0 || l.call(e, r)), e.keyboard !== !1 && !p.value && [le.UP, le.DOWN].includes(u) && (G(le.UP === u), r.preventDefault());
  483. }, ce = () => {
  484. f.value = !1;
  485. }, re = (r) => {
  486. B(!1), c.value = !1, f.value = !1, o("blur", r);
  487. };
  488. return ee(() => e.precision, () => {
  489. s.value.isInvalidate() || C(s.value, !1);
  490. }, {
  491. flush: "post"
  492. }), ee(() => e.value, () => {
  493. const r = D(e.value);
  494. s.value = r;
  495. const l = D(I($.value));
  496. (!r.equals(l) || !f.value || e.formatter) && C(r, f.value);
  497. }, {
  498. flush: "post"
  499. }), ee($, () => {
  500. e.formatter && K();
  501. }, {
  502. flush: "post"
  503. }), ee(() => e.disabled, (r) => {
  504. r && (c.value = !1);
  505. }), i({
  506. focus: () => {
  507. var r;
  508. (r = d.value) === null || r === void 0 || r.focus();
  509. },
  510. blur: () => {
  511. var r;
  512. (r = d.value) === null || r === void 0 || r.blur();
  513. }
  514. }), () => {
  515. const r = v(v({}, n), e), {
  516. prefixCls: l = "rc-input-number",
  517. min: u,
  518. max: m,
  519. step: y = 1,
  520. defaultValue: R,
  521. value: q,
  522. disabled: ae,
  523. readonly: ie,
  524. keyboard: g,
  525. controls: fe = !0,
  526. autofocus: T,
  527. stringMode: pe,
  528. parser: me,
  529. formatter: L,
  530. precision: ge,
  531. decimalSeparator: ve,
  532. onChange: he,
  533. onInput: Me,
  534. onPressEnter: Pe,
  535. onStep: Rt,
  536. lazy: ke,
  537. class: Ke,
  538. style: Xe
  539. } = r, Qe = It(r, ["prefixCls", "min", "max", "step", "defaultValue", "value", "disabled", "readonly", "keyboard", "controls", "autofocus", "stringMode", "parser", "formatter", "precision", "decimalSeparator", "onChange", "onInput", "onPressEnter", "onStep", "lazy", "class", "style"]), {
  540. upHandler: Ye,
  541. downHandler: Je
  542. } = a, Re = `${l}-input`, be = {};
  543. return ke ? be.onChange = H : be.onInput = H, b("div", {
  544. class: j(l, Ke, {
  545. [`${l}-focused`]: c.value,
  546. [`${l}-disabled`]: ae,
  547. [`${l}-readonly`]: ie,
  548. [`${l}-not-a-number`]: s.value.isNaN(),
  549. [`${l}-out-of-range`]: !s.value.isInvalidate() && !oe(s.value)
  550. }),
  551. style: Xe,
  552. onKeydown: de,
  553. onKeyup: ce
  554. }, [fe && b(yt, {
  555. prefixCls: l,
  556. upDisabled: w.value,
  557. downDisabled: V.value,
  558. onStep: G
  559. }, {
  560. upNode: Ye,
  561. downNode: Je
  562. }), b("div", {
  563. class: `${Re}-wrap`
  564. }, [b("input", O(O(O({
  565. autofocus: T,
  566. autocomplete: "off",
  567. role: "spinbutton",
  568. "aria-valuemin": u,
  569. "aria-valuemax": m,
  570. "aria-valuenow": s.value.isInvalidate() ? null : s.value.toString(),
  571. step: y
  572. }, Qe), {}, {
  573. ref: d,
  574. class: Re,
  575. value: $.value,
  576. disabled: ae,
  577. readonly: ie,
  578. onFocus: (Ze) => {
  579. c.value = !0, o("focus", Ze);
  580. }
  581. }, be), {}, {
  582. onBlur: re,
  583. onCompositionstart: h,
  584. onCompositionend: J,
  585. onBeforeinput: ue
  586. }), null)])]);
  587. };
  588. }
  589. });
  590. function Ne(e) {
  591. return e != null;
  592. }
  593. const Ct = (e) => {
  594. const {
  595. componentCls: t,
  596. lineWidth: n,
  597. lineType: a,
  598. colorBorder: o,
  599. borderRadius: i,
  600. fontSizeLG: d,
  601. controlHeightLG: c,
  602. controlHeightSM: f,
  603. colorError: p,
  604. inputPaddingHorizontalSM: s,
  605. colorTextDescription: x,
  606. motionDurationMid: S,
  607. colorPrimary: I,
  608. controlHeight: $,
  609. inputPaddingHorizontal: E,
  610. colorBgContainer: P,
  611. colorTextDisabled: C,
  612. borderRadiusSM: _,
  613. borderRadiusLG: N,
  614. controlWidth: w,
  615. handleVisible: V
  616. } = e;
  617. return [
  618. {
  619. [t]: v(v(v(v({}, Oe(e)), He(e)), Ge(e, t)), {
  620. display: "inline-block",
  621. width: w,
  622. margin: 0,
  623. padding: 0,
  624. border: `${n}px ${a} ${o}`,
  625. borderRadius: i,
  626. "&-rtl": {
  627. direction: "rtl",
  628. [`${t}-input`]: {
  629. direction: "rtl"
  630. }
  631. },
  632. "&-lg": {
  633. padding: 0,
  634. fontSize: d,
  635. borderRadius: N,
  636. [`input${t}-input`]: {
  637. height: c - 2 * n
  638. }
  639. },
  640. "&-sm": {
  641. padding: 0,
  642. borderRadius: _,
  643. [`input${t}-input`]: {
  644. height: f - 2 * n,
  645. padding: `0 ${s}px`
  646. }
  647. },
  648. "&:hover": v({}, qe(e)),
  649. "&-focused": v({}, St(e)),
  650. "&-disabled": v(v({}, bt(e)), {
  651. [`${t}-input`]: {
  652. cursor: "not-allowed"
  653. }
  654. }),
  655. // ===================== Out Of Range =====================
  656. "&-out-of-range": {
  657. input: {
  658. color: p
  659. }
  660. },
  661. // Style for input-group: input with label, with button or dropdown...
  662. "&-group": v(v(v({}, Oe(e)), ht(e)), {
  663. "&-wrapper": {
  664. display: "inline-block",
  665. textAlign: "start",
  666. verticalAlign: "top",
  667. [`${t}-affix-wrapper`]: {
  668. width: "100%"
  669. },
  670. // Size
  671. "&-lg": {
  672. [`${t}-group-addon`]: {
  673. borderRadius: N
  674. }
  675. },
  676. "&-sm": {
  677. [`${t}-group-addon`]: {
  678. borderRadius: _
  679. }
  680. }
  681. }
  682. }),
  683. [t]: {
  684. "&-input": v(v({
  685. width: "100%",
  686. height: $ - 2 * n,
  687. padding: `0 ${E}px`,
  688. textAlign: "start",
  689. backgroundColor: "transparent",
  690. border: 0,
  691. borderRadius: i,
  692. outline: 0,
  693. transition: `all ${S} linear`,
  694. appearance: "textfield",
  695. color: e.colorText,
  696. fontSize: "inherit",
  697. verticalAlign: "top"
  698. }, vt(e.colorTextPlaceholder)), {
  699. '&[type="number"]::-webkit-inner-spin-button, &[type="number"]::-webkit-outer-spin-button': {
  700. margin: 0,
  701. /* stylelint-disable-next-line property-no-vendor-prefix */
  702. webkitAppearance: "none",
  703. appearance: "none"
  704. }
  705. })
  706. }
  707. })
  708. },
  709. // Handler
  710. {
  711. [t]: {
  712. [`&:hover ${t}-handler-wrap, &-focused ${t}-handler-wrap`]: {
  713. opacity: 1
  714. },
  715. [`${t}-handler-wrap`]: {
  716. position: "absolute",
  717. insetBlockStart: 0,
  718. insetInlineEnd: 0,
  719. width: e.handleWidth,
  720. height: "100%",
  721. background: P,
  722. borderStartStartRadius: 0,
  723. borderStartEndRadius: i,
  724. borderEndEndRadius: i,
  725. borderEndStartRadius: 0,
  726. opacity: V === !0 ? 1 : 0,
  727. display: "flex",
  728. flexDirection: "column",
  729. alignItems: "stretch",
  730. transition: `opacity ${S} linear ${S}`,
  731. // Fix input number inside Menu makes icon too large
  732. // We arise the selector priority by nest selector here
  733. // https://github.com/ant-design/ant-design/issues/14367
  734. [`${t}-handler`]: {
  735. display: "flex",
  736. alignItems: "center",
  737. justifyContent: "center",
  738. flex: "auto",
  739. height: "40%",
  740. [`
  741. ${t}-handler-up-inner,
  742. ${t}-handler-down-inner
  743. `]: {
  744. marginInlineEnd: 0,
  745. fontSize: e.handleFontSize
  746. }
  747. }
  748. },
  749. [`${t}-handler`]: {
  750. height: "50%",
  751. overflow: "hidden",
  752. color: x,
  753. fontWeight: "bold",
  754. lineHeight: 0,
  755. textAlign: "center",
  756. cursor: "pointer",
  757. borderInlineStart: `${n}px ${a} ${o}`,
  758. transition: `all ${S} linear`,
  759. "&:active": {
  760. background: e.colorFillAlter
  761. },
  762. // Hover
  763. "&:hover": {
  764. height: "60%",
  765. [`
  766. ${t}-handler-up-inner,
  767. ${t}-handler-down-inner
  768. `]: {
  769. color: I
  770. }
  771. },
  772. "&-up-inner, &-down-inner": v(v({}, rt()), {
  773. color: x,
  774. transition: `all ${S} linear`,
  775. userSelect: "none"
  776. })
  777. },
  778. [`${t}-handler-up`]: {
  779. borderStartEndRadius: i
  780. },
  781. [`${t}-handler-down`]: {
  782. borderBlockStart: `${n}px ${a} ${o}`,
  783. borderEndEndRadius: i
  784. },
  785. // Disabled
  786. "&-disabled, &-readonly": {
  787. [`${t}-handler-wrap`]: {
  788. display: "none"
  789. },
  790. [`${t}-input`]: {
  791. color: "inherit"
  792. }
  793. },
  794. [`
  795. ${t}-handler-up-disabled,
  796. ${t}-handler-down-disabled
  797. `]: {
  798. cursor: "not-allowed"
  799. },
  800. [`
  801. ${t}-handler-up-disabled:hover &-handler-up-inner,
  802. ${t}-handler-down-disabled:hover &-handler-down-inner
  803. `]: {
  804. color: C
  805. }
  806. }
  807. },
  808. // Border-less
  809. {
  810. [`${t}-borderless`]: {
  811. borderColor: "transparent",
  812. boxShadow: "none",
  813. [`${t}-handler-down`]: {
  814. borderBlockStartWidth: 0
  815. }
  816. }
  817. }
  818. ];
  819. }, _t = (e) => {
  820. const {
  821. componentCls: t,
  822. inputPaddingHorizontal: n,
  823. inputAffixPadding: a,
  824. controlWidth: o,
  825. borderRadiusLG: i,
  826. borderRadiusSM: d
  827. } = e;
  828. return {
  829. [`${t}-affix-wrapper`]: v(v(v({}, He(e)), Ge(e, `${t}-affix-wrapper`)), {
  830. // or number handler will cover form status
  831. position: "relative",
  832. display: "inline-flex",
  833. width: o,
  834. padding: 0,
  835. paddingInlineStart: n,
  836. "&-lg": {
  837. borderRadius: i
  838. },
  839. "&-sm": {
  840. borderRadius: d
  841. },
  842. [`&:not(${t}-affix-wrapper-disabled):hover`]: v(v({}, qe(e)), {
  843. zIndex: 1
  844. }),
  845. "&-focused, &:focus": {
  846. zIndex: 1
  847. },
  848. "&-disabled": {
  849. [`${t}[disabled]`]: {
  850. background: "transparent"
  851. }
  852. },
  853. [`> div${t}`]: {
  854. width: "100%",
  855. border: "none",
  856. outline: "none",
  857. [`&${t}-focused`]: {
  858. boxShadow: "none !important"
  859. }
  860. },
  861. [`input${t}-input`]: {
  862. padding: 0
  863. },
  864. "&::before": {
  865. width: 0,
  866. visibility: "hidden",
  867. content: '"\\a0"'
  868. },
  869. [`${t}-handler-wrap`]: {
  870. zIndex: 2
  871. },
  872. [t]: {
  873. "&-prefix, &-suffix": {
  874. display: "flex",
  875. flex: "none",
  876. alignItems: "center",
  877. pointerEvents: "none"
  878. },
  879. "&-prefix": {
  880. marginInlineEnd: a
  881. },
  882. "&-suffix": {
  883. position: "absolute",
  884. insetBlockStart: 0,
  885. insetInlineEnd: 0,
  886. zIndex: 1,
  887. height: "100%",
  888. marginInlineEnd: n,
  889. marginInlineStart: a
  890. }
  891. }
  892. })
  893. };
  894. }, Dt = tt("InputNumber", (e) => {
  895. const t = gt(e);
  896. return [
  897. Ct(t),
  898. _t(t),
  899. // =====================================================
  900. // == Space Compact ==
  901. // =====================================================
  902. nt(t)
  903. ];
  904. }, (e) => ({
  905. controlWidth: 90,
  906. handleWidth: e.controlHeightSM - e.lineWidth * 2,
  907. handleFontSize: e.fontSize / 2,
  908. handleVisible: "auto"
  909. }));
  910. var Mt = function(e, t) {
  911. var n = {};
  912. for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && t.indexOf(a) < 0 && (n[a] = e[a]);
  913. if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var o = 0, a = Object.getOwnPropertySymbols(e); o < a.length; o++)
  914. t.indexOf(a[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, a[o]) && (n[a[o]] = e[a[o]]);
  915. return n;
  916. };
  917. const ze = Ue(), Pt = () => v(v({}, ze), {
  918. size: xe(),
  919. bordered: F(!0),
  920. placeholder: String,
  921. name: String,
  922. id: String,
  923. type: String,
  924. addonBefore: Se.any,
  925. addonAfter: Se.any,
  926. prefix: Se.any,
  927. "onUpdate:value": ze.onChange,
  928. valueModifiers: Object,
  929. status: xe()
  930. }), ye = Ee({
  931. compatConfig: {
  932. MODE: 3
  933. },
  934. name: "AInputNumber",
  935. inheritAttrs: !1,
  936. props: Pt(),
  937. // emits: ['focus', 'blur', 'change', 'input', 'update:value'],
  938. slots: Object,
  939. setup(e, t) {
  940. let {
  941. emit: n,
  942. expose: a,
  943. attrs: o,
  944. slots: i
  945. } = t;
  946. var d;
  947. const c = ft(), f = pt.useInject(), p = W(() => mt(f.status, e.status)), {
  948. prefixCls: s,
  949. size: x,
  950. direction: S,
  951. disabled: I
  952. } = at("input-number", e), {
  953. compactSize: $,
  954. compactItemClassnames: E
  955. } = it(s, S), P = lt(), C = W(() => {
  956. var h;
  957. return (h = I.value) !== null && h !== void 0 ? h : P.value;
  958. }), [_, N] = Dt(s), w = W(() => $.value || x.value), V = M((d = e.value) !== null && d !== void 0 ? d : e.defaultValue), k = M(!1);
  959. ee(() => e.value, () => {
  960. V.value = e.value;
  961. });
  962. const K = M(null), X = () => {
  963. var h;
  964. (h = K.value) === null || h === void 0 || h.focus();
  965. };
  966. a({
  967. focus: X,
  968. blur: () => {
  969. var h;
  970. (h = K.value) === null || h === void 0 || h.blur();
  971. }
  972. });
  973. const Q = (h) => {
  974. e.value === void 0 && (V.value = h), n("update:value", h), n("change", h), c.onFieldChange();
  975. }, se = (h) => {
  976. k.value = !1, n("blur", h), c.onFieldBlur();
  977. }, Y = (h) => {
  978. k.value = !0, n("focus", h);
  979. };
  980. return () => {
  981. var h, J, H, G;
  982. const {
  983. hasFeedback: B,
  984. isFormItemInput: ue,
  985. feedbackIcon: de
  986. } = f, ce = (h = e.id) !== null && h !== void 0 ? h : c.id.value, re = v(v(v({}, o), e), {
  987. id: ce,
  988. disabled: C.value
  989. }), {
  990. class: r,
  991. bordered: l,
  992. readonly: u,
  993. style: m,
  994. addonBefore: y = (J = i.addonBefore) === null || J === void 0 ? void 0 : J.call(i),
  995. addonAfter: R = (H = i.addonAfter) === null || H === void 0 ? void 0 : H.call(i),
  996. prefix: q = (G = i.prefix) === null || G === void 0 ? void 0 : G.call(i),
  997. valueModifiers: ae = {}
  998. } = re, ie = Mt(re, ["class", "bordered", "readonly", "style", "addonBefore", "addonAfter", "prefix", "valueModifiers"]), g = s.value, fe = j({
  999. [`${g}-lg`]: w.value === "large",
  1000. [`${g}-sm`]: w.value === "small",
  1001. [`${g}-rtl`]: S.value === "rtl",
  1002. [`${g}-readonly`]: u,
  1003. [`${g}-borderless`]: !l,
  1004. [`${g}-in-form-item`]: ue
  1005. }, $e(g, p.value), r, E.value, N.value);
  1006. let T = b(Et, O(O({}, ot(ie, ["size", "defaultValue"])), {}, {
  1007. ref: K,
  1008. lazy: !!ae.lazy,
  1009. value: V.value,
  1010. class: fe,
  1011. prefixCls: g,
  1012. readonly: u,
  1013. onChange: Q,
  1014. onBlur: se,
  1015. onFocus: Y
  1016. }), {
  1017. upHandler: i.upIcon ? () => b("span", {
  1018. class: `${g}-handler-up-inner`
  1019. }, [i.upIcon()]) : () => b(ut, {
  1020. class: `${g}-handler-up-inner`
  1021. }, null),
  1022. downHandler: i.downIcon ? () => b("span", {
  1023. class: `${g}-handler-down-inner`
  1024. }, [i.downIcon()]) : () => b(st, {
  1025. class: `${g}-handler-down-inner`
  1026. }, null)
  1027. });
  1028. const pe = Ne(y) || Ne(R), me = Ne(q);
  1029. if (me || B) {
  1030. const L = j(`${g}-affix-wrapper`, $e(`${g}-affix-wrapper`, p.value, B), {
  1031. [`${g}-affix-wrapper-focused`]: k.value,
  1032. [`${g}-affix-wrapper-disabled`]: C.value,
  1033. [`${g}-affix-wrapper-sm`]: w.value === "small",
  1034. [`${g}-affix-wrapper-lg`]: w.value === "large",
  1035. [`${g}-affix-wrapper-rtl`]: S.value === "rtl",
  1036. [`${g}-affix-wrapper-readonly`]: u,
  1037. [`${g}-affix-wrapper-borderless`]: !l,
  1038. // className will go to addon wrapper
  1039. [`${r}`]: !pe && r
  1040. }, N.value);
  1041. T = b("div", {
  1042. class: L,
  1043. style: m,
  1044. onClick: X
  1045. }, [me && b("span", {
  1046. class: `${g}-prefix`
  1047. }, [q]), T, B && b("span", {
  1048. class: `${g}-suffix`
  1049. }, [de])]);
  1050. }
  1051. if (pe) {
  1052. const L = `${g}-group`, ge = `${L}-addon`, ve = y ? b("div", {
  1053. class: ge
  1054. }, [y]) : null, he = R ? b("div", {
  1055. class: ge
  1056. }, [R]) : null, Me = j(`${g}-wrapper`, L, {
  1057. [`${L}-rtl`]: S.value === "rtl"
  1058. }, N.value), Pe = j(`${g}-group-wrapper`, {
  1059. [`${g}-group-wrapper-sm`]: w.value === "small",
  1060. [`${g}-group-wrapper-lg`]: w.value === "large",
  1061. [`${g}-group-wrapper-rtl`]: S.value === "rtl"
  1062. }, $e(`${s}-group-wrapper`, p.value, B), r, N.value);
  1063. T = b("div", {
  1064. class: Pe,
  1065. style: m
  1066. }, [b("div", {
  1067. class: Me
  1068. }, [ve && b(Ve, null, {
  1069. default: () => [b(Be, null, {
  1070. default: () => [ve]
  1071. })]
  1072. }), T, he && b(Ve, null, {
  1073. default: () => [b(Be, null, {
  1074. default: () => [he]
  1075. })]
  1076. })])]);
  1077. }
  1078. return _(dt(T, {
  1079. style: m
  1080. }));
  1081. };
  1082. }
  1083. }), zt = v(ye, {
  1084. install: (e) => (e.component(ye.name, ye), e)
  1085. });
  1086. export {
  1087. zt as _
  1088. };