index15.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. import { t as fe, f as Ie, a as ze, r as X, i as Ae, I as b, _ as Re } from "./Search.js";
  2. import { u as ae, _ as F, c as j, a1 as $e, f as O, P as Te, aP as Pe, p as te, af as Ee, w as Y, aQ as _e, o as le, d as C, R as Fe, y as Ve, n as Be, V as Oe, b$ as Me } from "./index2.js";
  3. import { defineComponent as H, computed as B, createVNode as w, ref as M, onBeforeUnmount as re, watchEffect as oe, watch as ne, getCurrentInstance as ve, shallowRef as V, nextTick as ue } from "vue";
  4. import { F as Z, u as je } from "./FormItemContext.js";
  5. import { u as me } from "./index16.js";
  6. import { a as ge, g as pe } from "./statusUtils.js";
  7. import { B as ke } from "./BaseInput.js";
  8. const De = H({
  9. compatConfig: {
  10. MODE: 3
  11. },
  12. name: "AInputGroup",
  13. inheritAttrs: !1,
  14. props: {
  15. prefixCls: String,
  16. size: {
  17. type: String
  18. },
  19. compact: {
  20. type: Boolean,
  21. default: void 0
  22. }
  23. },
  24. setup(e, m) {
  25. let {
  26. slots: l,
  27. attrs: n
  28. } = m;
  29. const {
  30. prefixCls: i,
  31. direction: h,
  32. getPrefixCls: v
  33. } = ae("input-group", e), o = Z.useInject();
  34. Z.useProvide(o, {
  35. isFormItemInput: !1
  36. });
  37. const d = B(() => v("input")), [s, g] = me(d), u = B(() => {
  38. const a = i.value;
  39. return {
  40. [`${a}`]: !0,
  41. [g.value]: !0,
  42. [`${a}-lg`]: e.size === "large",
  43. [`${a}-sm`]: e.size === "small",
  44. [`${a}-compact`]: e.compact,
  45. [`${a}-rtl`]: h.value === "rtl"
  46. };
  47. });
  48. return () => {
  49. var a;
  50. return s(w("span", F(F({}, n), {}, {
  51. class: j(u.value, n.class)
  52. }), [(a = l.default) === null || a === void 0 ? void 0 : a.call(l)]));
  53. };
  54. }
  55. }), de = (e) => e != null && (Array.isArray(e) ? $e(e).length : !0);
  56. function He(e) {
  57. return de(e.addonBefore) || de(e.addonAfter);
  58. }
  59. const Ge = ["text", "input"], Le = H({
  60. compatConfig: {
  61. MODE: 3
  62. },
  63. name: "ClearableLabeledInput",
  64. inheritAttrs: !1,
  65. props: {
  66. prefixCls: String,
  67. inputType: Te.oneOf(Pe("text", "input")),
  68. value: O(),
  69. defaultValue: O(),
  70. allowClear: {
  71. type: Boolean,
  72. default: void 0
  73. },
  74. element: O(),
  75. handleReset: Function,
  76. disabled: {
  77. type: Boolean,
  78. default: void 0
  79. },
  80. direction: {
  81. type: String
  82. },
  83. size: {
  84. type: String
  85. },
  86. suffix: O(),
  87. prefix: O(),
  88. addonBefore: O(),
  89. addonAfter: O(),
  90. readonly: {
  91. type: Boolean,
  92. default: void 0
  93. },
  94. focused: {
  95. type: Boolean,
  96. default: void 0
  97. },
  98. bordered: {
  99. type: Boolean,
  100. default: !0
  101. },
  102. triggerFocus: {
  103. type: Function
  104. },
  105. hidden: Boolean,
  106. status: String,
  107. hashId: String
  108. },
  109. setup(e, m) {
  110. let {
  111. slots: l,
  112. attrs: n
  113. } = m;
  114. const i = Z.useInject(), h = (o) => {
  115. const {
  116. value: d,
  117. disabled: s,
  118. readonly: g,
  119. handleReset: u,
  120. suffix: a = l.suffix
  121. } = e, x = !s && !g && d, S = `${o}-clear-icon`;
  122. return w(Ee, {
  123. onClick: u,
  124. onMousedown: (T) => T.preventDefault(),
  125. class: j({
  126. [`${S}-hidden`]: !x,
  127. [`${S}-has-suffix`]: !!a
  128. }, S),
  129. role: "button"
  130. }, null);
  131. }, v = (o, d) => {
  132. const {
  133. value: s,
  134. allowClear: g,
  135. direction: u,
  136. bordered: a,
  137. hidden: x,
  138. status: S,
  139. addonAfter: T = l.addonAfter,
  140. addonBefore: f = l.addonBefore,
  141. hashId: $
  142. } = e, {
  143. status: y,
  144. hasFeedback: I
  145. } = i;
  146. if (!g)
  147. return te(d, {
  148. value: s,
  149. disabled: e.disabled
  150. });
  151. const z = j(`${o}-affix-wrapper`, `${o}-affix-wrapper-textarea-with-clear-btn`, ge(`${o}-affix-wrapper`, pe(y, S), I), {
  152. [`${o}-affix-wrapper-rtl`]: u === "rtl",
  153. [`${o}-affix-wrapper-borderless`]: !a,
  154. // className will go to addon wrapper
  155. [`${n.class}`]: !He({
  156. addonAfter: T,
  157. addonBefore: f
  158. }) && n.class
  159. }, $);
  160. return w("span", {
  161. class: z,
  162. style: n.style,
  163. hidden: x
  164. }, [te(d, {
  165. style: null,
  166. value: s,
  167. disabled: e.disabled
  168. }), h(o)]);
  169. };
  170. return () => {
  171. var o;
  172. const {
  173. prefixCls: d,
  174. inputType: s,
  175. element: g = (o = l.element) === null || o === void 0 ? void 0 : o.call(l)
  176. } = e;
  177. return s === Ge[0] ? v(d, g) : null;
  178. };
  179. }
  180. }), Ne = `
  181. min-height:0 !important;
  182. max-height:none !important;
  183. height:0 !important;
  184. visibility:hidden !important;
  185. overflow:hidden !important;
  186. position:absolute !important;
  187. z-index:-1000 !important;
  188. top:0 !important;
  189. right:0 !important;
  190. pointer-events: none !important;
  191. `, Ye = ["letter-spacing", "line-height", "padding-top", "padding-bottom", "font-family", "font-weight", "font-size", "font-variant", "text-rendering", "text-transform", "width", "text-indent", "padding-left", "padding-right", "border-width", "box-sizing", "word-break", "white-space"], Q = {};
  192. let R;
  193. function Ze(e) {
  194. let m = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
  195. const l = e.getAttribute("id") || e.getAttribute("data-reactid") || e.getAttribute("name");
  196. if (m && Q[l])
  197. return Q[l];
  198. const n = window.getComputedStyle(e), i = n.getPropertyValue("box-sizing") || n.getPropertyValue("-moz-box-sizing") || n.getPropertyValue("-webkit-box-sizing"), h = parseFloat(n.getPropertyValue("padding-bottom")) + parseFloat(n.getPropertyValue("padding-top")), v = parseFloat(n.getPropertyValue("border-bottom-width")) + parseFloat(n.getPropertyValue("border-top-width")), d = {
  199. sizingStyle: Ye.map((s) => `${s}:${n.getPropertyValue(s)}`).join(";"),
  200. paddingSize: h,
  201. borderSize: v,
  202. boxSizing: i
  203. };
  204. return m && l && (Q[l] = d), d;
  205. }
  206. function Ue(e) {
  207. let m = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
  208. R || (R = document.createElement("textarea"), R.setAttribute("tab-index", "-1"), R.setAttribute("aria-hidden", "true"), document.body.appendChild(R)), e.getAttribute("wrap") ? R.setAttribute("wrap", e.getAttribute("wrap")) : R.removeAttribute("wrap");
  209. const {
  210. paddingSize: i,
  211. borderSize: h,
  212. boxSizing: v,
  213. sizingStyle: o
  214. } = Ze(e, m);
  215. R.setAttribute("style", `${o};${Ne}`), R.value = e.value || e.placeholder || "";
  216. let d, s, g, u = R.scrollHeight;
  217. if (v === "border-box" ? u += h : v === "content-box" && (u -= i), l !== null || n !== null) {
  218. R.value = " ";
  219. const x = R.scrollHeight - i;
  220. l !== null && (d = x * l, v === "border-box" && (d = d + i + h), u = Math.max(d, u)), n !== null && (s = x * n, v === "border-box" && (s = s + i + h), g = u > s ? "" : "hidden", u = Math.min(s, u));
  221. }
  222. const a = {
  223. height: `${u}px`,
  224. overflowY: g,
  225. resize: "none"
  226. };
  227. return d && (a.minHeight = `${d}px`), s && (a.maxHeight = `${s}px`), a;
  228. }
  229. const q = 0, J = 1, ee = 2, Ke = H({
  230. compatConfig: {
  231. MODE: 3
  232. },
  233. name: "ResizableTextArea",
  234. inheritAttrs: !1,
  235. props: fe(),
  236. setup(e, m) {
  237. let {
  238. attrs: l,
  239. emit: n,
  240. expose: i
  241. } = m, h, v;
  242. const o = M(), d = M({}), s = M(ee);
  243. re(() => {
  244. Y.cancel(h), Y.cancel(v);
  245. });
  246. const g = () => {
  247. try {
  248. if (o.value && document.activeElement === o.value.input) {
  249. const c = o.value.getSelectionStart(), k = o.value.getSelectionEnd(), D = o.value.getScrollTop();
  250. o.value.setSelectionRange(c, k), o.value.setScrollTop(D);
  251. }
  252. } catch (c) {
  253. }
  254. }, u = M(), a = M();
  255. oe(() => {
  256. const c = e.autoSize || e.autosize;
  257. c ? (u.value = c.minRows, a.value = c.maxRows) : (u.value = void 0, a.value = void 0);
  258. });
  259. const x = B(() => !!(e.autoSize || e.autosize)), S = () => {
  260. s.value = q;
  261. };
  262. ne([() => e.value, u, a, x], () => {
  263. x.value && S();
  264. }, {
  265. immediate: !0
  266. });
  267. const T = M();
  268. ne([s, o], () => {
  269. if (o.value)
  270. if (s.value === q)
  271. s.value = J;
  272. else if (s.value === J) {
  273. const c = Ue(o.value.input, !1, u.value, a.value);
  274. s.value = ee, T.value = c;
  275. } else
  276. g();
  277. }, {
  278. immediate: !0,
  279. flush: "post"
  280. });
  281. const f = ve(), $ = M(), y = () => {
  282. Y.cancel($.value);
  283. }, I = (c) => {
  284. s.value === ee && (n("resize", c), x.value && (y(), $.value = Y(() => {
  285. S();
  286. })));
  287. };
  288. re(() => {
  289. y();
  290. }), i({
  291. resizeTextarea: () => {
  292. S();
  293. },
  294. textArea: B(() => {
  295. var c;
  296. return (c = o.value) === null || c === void 0 ? void 0 : c.input;
  297. }),
  298. instance: f
  299. }), _e(e.autosize === void 0, "Input.TextArea", "autosize is deprecated, please use autoSize instead.");
  300. const P = () => {
  301. const {
  302. prefixCls: c,
  303. disabled: k
  304. } = e, D = le(e, ["prefixCls", "onPressEnter", "autoSize", "autosize", "defaultValue", "allowClear", "type", "maxlength", "valueModifiers"]), U = j(c, l.class, {
  305. [`${c}-disabled`]: k
  306. }), G = x.value ? T.value : null, L = [l.style, d.value, G], _ = C(C(C({}, D), l), {
  307. style: L,
  308. class: U
  309. });
  310. return (s.value === q || s.value === J) && L.push({
  311. overflowX: "hidden",
  312. overflowY: "hidden"
  313. }), _.autofocus || delete _.autofocus, _.rows === 0 && delete _.rows, w(Fe, {
  314. onResize: I,
  315. disabled: !x.value
  316. }, {
  317. default: () => [w(ke, F(F({}, _), {}, {
  318. ref: o,
  319. tag: "textarea"
  320. }), null)]
  321. });
  322. };
  323. return () => P();
  324. }
  325. });
  326. function he(e, m) {
  327. return [...e || ""].slice(0, m).join("");
  328. }
  329. function ce(e, m, l, n) {
  330. let i = l;
  331. return e ? i = he(l, n) : [...m || ""].length < l.length && [...l || ""].length > n && (i = m), i;
  332. }
  333. const We = H({
  334. compatConfig: {
  335. MODE: 3
  336. },
  337. name: "ATextarea",
  338. inheritAttrs: !1,
  339. props: fe(),
  340. setup(e, m) {
  341. let {
  342. attrs: l,
  343. expose: n,
  344. emit: i
  345. } = m;
  346. var h;
  347. const v = je(), o = Z.useInject(), d = B(() => pe(o.status, e.status)), s = V((h = e.value) !== null && h !== void 0 ? h : e.defaultValue), g = V(), u = V(""), {
  348. prefixCls: a,
  349. size: x,
  350. direction: S
  351. } = ae("input", e), [T, f] = me(a), $ = Ve(), y = B(() => e.showCount === "" || e.showCount || !1), I = B(() => Number(e.maxlength) > 0), z = V(!1), P = V(), c = V(0), k = (t) => {
  352. z.value = !0, P.value = u.value, c.value = t.currentTarget.selectionStart, i("compositionstart", t);
  353. }, D = (t) => {
  354. var r;
  355. z.value = !1;
  356. let p = t.currentTarget.value;
  357. if (I.value) {
  358. const E = c.value >= e.maxlength + 1 || c.value === ((r = P.value) === null || r === void 0 ? void 0 : r.length);
  359. p = ce(E, P.value, p, e.maxlength);
  360. }
  361. p !== u.value && (_(p), X(t.currentTarget, t, K, p)), i("compositionend", t);
  362. }, U = ve();
  363. ne(() => e.value, () => {
  364. var t;
  365. "value" in U.vnode.props, s.value = (t = e.value) !== null && t !== void 0 ? t : "";
  366. });
  367. const G = (t) => {
  368. var r;
  369. ze((r = g.value) === null || r === void 0 ? void 0 : r.textArea, t);
  370. }, L = () => {
  371. var t, r;
  372. (r = (t = g.value) === null || t === void 0 ? void 0 : t.textArea) === null || r === void 0 || r.blur();
  373. }, _ = (t, r) => {
  374. s.value !== t && (e.value === void 0 ? s.value = t : ue(() => {
  375. var p, E, A;
  376. g.value.textArea.value !== u.value && ((A = (p = g.value) === null || p === void 0 ? void 0 : (E = p.instance).update) === null || A === void 0 || A.call(E));
  377. }), ue(() => {
  378. r && r();
  379. }));
  380. }, xe = (t) => {
  381. t.keyCode === 13 && i("pressEnter", t), i("keydown", t);
  382. }, be = (t) => {
  383. const {
  384. onBlur: r
  385. } = e;
  386. r == null || r(t), v.onFieldBlur();
  387. }, K = (t) => {
  388. i("update:value", t.target.value), i("change", t), i("input", t), v.onFieldChange();
  389. }, ye = (t) => {
  390. X(g.value.textArea, t, K), _("", () => {
  391. G();
  392. });
  393. }, se = (t) => {
  394. let r = t.target.value;
  395. if (s.value !== r) {
  396. if (I.value) {
  397. const p = t.target, E = p.selectionStart >= e.maxlength + 1 || p.selectionStart === r.length || !p.selectionStart;
  398. r = ce(E, u.value, r, e.maxlength);
  399. }
  400. X(t.currentTarget, t, K, r), _(r);
  401. }
  402. }, Se = () => {
  403. var t, r;
  404. const {
  405. class: p
  406. } = l, {
  407. bordered: E = !0
  408. } = e, A = C(C(C({}, le(e, ["allowClear"])), l), {
  409. class: [{
  410. [`${a.value}-borderless`]: !E,
  411. [`${p}`]: p && !y.value,
  412. [`${a.value}-sm`]: x.value === "small",
  413. [`${a.value}-lg`]: x.value === "large"
  414. }, ge(a.value, d.value), f.value],
  415. disabled: $.value,
  416. showCount: null,
  417. prefixCls: a.value,
  418. onInput: se,
  419. onChange: se,
  420. onBlur: be,
  421. onKeydown: xe,
  422. onCompositionstart: k,
  423. onCompositionend: D
  424. });
  425. return !((t = e.valueModifiers) === null || t === void 0) && t.lazy && delete A.onInput, w(Ke, F(F({}, A), {}, {
  426. id: (r = A == null ? void 0 : A.id) !== null && r !== void 0 ? r : v.id.value,
  427. ref: g,
  428. maxlength: e.maxlength,
  429. lazy: e.lazy
  430. }), null);
  431. };
  432. return n({
  433. focus: G,
  434. blur: L,
  435. resizableTextArea: g
  436. }), oe(() => {
  437. let t = Ie(s.value);
  438. !z.value && I.value && (e.value === null || e.value === void 0) && (t = he(t, e.maxlength)), u.value = t;
  439. }), () => {
  440. var t;
  441. const {
  442. maxlength: r,
  443. bordered: p = !0,
  444. hidden: E
  445. } = e, {
  446. style: A,
  447. class: Ce
  448. } = l, we = C(C(C({}, e), l), {
  449. prefixCls: a.value,
  450. inputType: "text",
  451. handleReset: ye,
  452. direction: S.value,
  453. bordered: p,
  454. style: y.value ? void 0 : A,
  455. hashId: f.value,
  456. disabled: (t = e.disabled) !== null && t !== void 0 ? t : $.value
  457. });
  458. let W = w(Le, F(F({}, we), {}, {
  459. value: u.value,
  460. status: e.status
  461. }), {
  462. element: Se
  463. });
  464. if (y.value || o.hasFeedback) {
  465. const ie = [...u.value].length;
  466. let N = "";
  467. typeof y.value == "object" ? N = y.value.formatter({
  468. value: u.value,
  469. count: ie,
  470. maxlength: r
  471. }) : N = `${ie}${I.value ? ` / ${r}` : ""}`, W = w("div", {
  472. hidden: E,
  473. class: j(`${a.value}-textarea`, {
  474. [`${a.value}-textarea-rtl`]: S.value === "rtl",
  475. [`${a.value}-textarea-show-count`]: y.value,
  476. [`${a.value}-textarea-in-form-item`]: o.isFormItemInput
  477. }, `${a.value}-textarea-show-count`, Ce, f.value),
  478. style: A,
  479. "data-count": typeof N != "object" ? N : void 0
  480. }, [W, o.hasFeedback && w("span", {
  481. class: `${a.value}-textarea-suffix`
  482. }, [o.feedbackIcon])]);
  483. }
  484. return T(W);
  485. };
  486. }
  487. });
  488. var Xe = function(e, m) {
  489. var l = {};
  490. for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && m.indexOf(n) < 0 && (l[n] = e[n]);
  491. if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, n = Object.getOwnPropertySymbols(e); i < n.length; i++)
  492. m.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[i]) && (l[n[i]] = e[n[i]]);
  493. return l;
  494. };
  495. const Qe = {
  496. click: "onClick",
  497. hover: "onMouseover"
  498. }, qe = (e) => e ? w(Oe, null, null) : w(Me, null, null), Je = H({
  499. compatConfig: {
  500. MODE: 3
  501. },
  502. name: "AInputPassword",
  503. inheritAttrs: !1,
  504. props: C(C({}, Ae()), {
  505. prefixCls: String,
  506. inputPrefixCls: String,
  507. action: {
  508. type: String,
  509. default: "click"
  510. },
  511. visibilityToggle: {
  512. type: Boolean,
  513. default: !0
  514. },
  515. visible: {
  516. type: Boolean,
  517. default: void 0
  518. },
  519. "onUpdate:visible": Function,
  520. iconRender: Function
  521. }),
  522. setup(e, m) {
  523. let {
  524. slots: l,
  525. attrs: n,
  526. expose: i,
  527. emit: h
  528. } = m;
  529. const v = V(!1), o = () => {
  530. const {
  531. disabled: f
  532. } = e;
  533. f || (v.value = !v.value, h("update:visible", v.value));
  534. };
  535. oe(() => {
  536. e.visible !== void 0 && (v.value = !!e.visible);
  537. });
  538. const d = V();
  539. i({
  540. focus: () => {
  541. var f;
  542. (f = d.value) === null || f === void 0 || f.focus();
  543. },
  544. blur: () => {
  545. var f;
  546. (f = d.value) === null || f === void 0 || f.blur();
  547. }
  548. });
  549. const u = (f) => {
  550. const {
  551. action: $,
  552. iconRender: y = l.iconRender || qe
  553. } = e, I = Qe[$] || "", z = y(v.value), P = {
  554. [I]: o,
  555. class: `${f}-icon`,
  556. key: "passwordIcon",
  557. onMousedown: (c) => {
  558. c.preventDefault();
  559. },
  560. onMouseup: (c) => {
  561. c.preventDefault();
  562. }
  563. };
  564. return te(Be(z) ? z : w("span", null, [z]), P);
  565. }, {
  566. prefixCls: a,
  567. getPrefixCls: x
  568. } = ae("input-password", e), S = B(() => x("input", e.inputPrefixCls)), T = () => {
  569. const {
  570. size: f,
  571. visibilityToggle: $
  572. } = e, y = Xe(e, ["size", "visibilityToggle"]), I = $ && u(a.value), z = j(a.value, n.class, {
  573. [`${a.value}-${f}`]: !!f
  574. }), P = C(C(C({}, le(y, ["suffix", "iconRender", "action"])), n), {
  575. type: v.value ? "text" : "password",
  576. class: z,
  577. prefixCls: S.value,
  578. suffix: I
  579. });
  580. return f && (P.size = f), w(b, F({
  581. ref: d
  582. }, P), l);
  583. };
  584. return () => T();
  585. }
  586. });
  587. b.Group = De;
  588. b.Search = Re;
  589. b.TextArea = We;
  590. b.Password = Je;
  591. b.install = function(e) {
  592. return e.component(b.name, b), e.component(b.Group.name, b.Group), e.component(b.Search.name, b.Search), e.component(b.TextArea.name, b.TextArea), e.component(b.Password.name, b.Password), e;
  593. };