index9.js 31 KB

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