index13.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  1. import { c as pe, o as be, _ as W, n as he, K, J as Be, a8 as ze, d as E, bu as Q, bv as _e, i as Me, q as Ne, P as ue, j as Ge, u as Ke, x as We, y as Ue, B as Xe, C as qe, bw as Je, M as Qe, Q as fe, O as Ye, N as Pe } from "./index2.js";
  2. import { provide as Ze, inject as et, defineComponent as Oe, computed as S, reactive as tt, watch as ye, toRaw as ke, nextTick as Ae, createVNode as $, Fragment as nt, shallowRef as se, watchEffect as me, toRef as Z, ref as Te } from "vue";
  3. import { u as lt, T as ot, i as Le, d as Se, a as at, f as it, e as st, t as ut, B as rt, b as ct, c as dt, g as ft } from "./index4.js";
  4. import { c as vt } from "./createRef.js";
  5. import { L as mt } from "./List.js";
  6. import { u as pt } from "./useMemo.js";
  7. import { u as Ee } from "./useMergedState.js";
  8. import { u as ht, F as bt } from "./FormItemContext.js";
  9. import { g as gt, a as yt } from "./statusUtils.js";
  10. function St() {
  11. return /(mac\sos|macintosh)/i.test(navigator.appVersion);
  12. }
  13. const Re = Symbol("SelectContextKey");
  14. function Ot(e) {
  15. return Ze(Re, e);
  16. }
  17. function wt() {
  18. return et(Re, {});
  19. }
  20. var Ct = function(e, d) {
  21. var b = {};
  22. for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && d.indexOf(o) < 0 && (b[o] = e[o]);
  23. if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var n = 0, o = Object.getOwnPropertySymbols(e); n < o.length; n++)
  24. d.indexOf(o[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[n]) && (b[o[n]] = e[o[n]]);
  25. return b;
  26. };
  27. function Fe(e) {
  28. return typeof e == "string" || typeof e == "number";
  29. }
  30. const It = Oe({
  31. compatConfig: {
  32. MODE: 3
  33. },
  34. name: "OptionList",
  35. inheritAttrs: !1,
  36. setup(e, d) {
  37. let {
  38. expose: b,
  39. slots: o
  40. } = d;
  41. const n = lt(), u = wt(), m = S(() => `${n.prefixCls}-item`), f = pt(() => u.flattenOptions, [() => n.open, () => u.flattenOptions], (l) => l[0]), p = vt(), g = (l) => {
  42. l.preventDefault();
  43. }, h = (l) => {
  44. p.current && p.current.scrollTo(typeof l == "number" ? {
  45. index: l
  46. } : l);
  47. }, O = function(l) {
  48. let y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
  49. const _ = f.value.length;
  50. for (let v = 0; v < _; v += 1) {
  51. const N = (l + v * y + _) % _, {
  52. group: j,
  53. data: H
  54. } = f.value[N];
  55. if (!j && !H.disabled)
  56. return N;
  57. }
  58. return -1;
  59. }, F = tt({
  60. activeIndex: O(0)
  61. }), I = function(l) {
  62. let y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
  63. F.activeIndex = l;
  64. const _ = {
  65. source: y ? "keyboard" : "mouse"
  66. }, v = f.value[l];
  67. if (!v) {
  68. u.onActiveValue(null, -1, _);
  69. return;
  70. }
  71. u.onActiveValue(v.value, l, _);
  72. };
  73. ye([() => f.value.length, () => n.searchValue], () => {
  74. I(u.defaultActiveFirstOption !== !1 ? O(0) : -1);
  75. }, {
  76. immediate: !0
  77. });
  78. const w = (l) => u.rawValues.has(l) && n.mode !== "combobox";
  79. ye([() => n.open, () => n.searchValue], () => {
  80. if (!n.multiple && n.open && u.rawValues.size === 1) {
  81. const l = Array.from(u.rawValues)[0], y = ke(f.value).findIndex((_) => {
  82. let {
  83. data: v
  84. } = _;
  85. return v[u.fieldNames.value] === l;
  86. });
  87. y !== -1 && (I(y), Ae(() => {
  88. h(y);
  89. }));
  90. }
  91. n.open && Ae(() => {
  92. var l;
  93. (l = p.current) === null || l === void 0 || l.scrollTo(void 0);
  94. });
  95. }, {
  96. immediate: !0,
  97. flush: "post"
  98. });
  99. const C = (l) => {
  100. l !== void 0 && u.onSelect(l, {
  101. selected: !u.rawValues.has(l)
  102. }), n.multiple || n.toggleOpen(!1);
  103. }, V = (l) => typeof l.label == "function" ? l.label() : l.label;
  104. function k(l) {
  105. const y = f.value[l];
  106. if (!y) return null;
  107. const _ = y.data || {}, {
  108. value: v
  109. } = _, {
  110. group: N
  111. } = y, j = Be(_, !0), H = V(y);
  112. return y ? $("div", W(W({
  113. "aria-label": typeof H == "string" && !N ? H : null
  114. }, j), {}, {
  115. key: l,
  116. role: N ? "presentation" : "option",
  117. id: `${n.id}_list_${l}`,
  118. "aria-selected": w(v)
  119. }), [v]) : null;
  120. }
  121. return b({
  122. onKeydown: (l) => {
  123. const {
  124. which: y,
  125. ctrlKey: _
  126. } = l;
  127. switch (y) {
  128. case K.N:
  129. case K.P:
  130. case K.UP:
  131. case K.DOWN: {
  132. let v = 0;
  133. if (y === K.UP ? v = -1 : y === K.DOWN ? v = 1 : St() && _ && (y === K.N ? v = 1 : y === K.P && (v = -1)), v !== 0) {
  134. const N = O(F.activeIndex + v, v);
  135. h(N), I(N, !0);
  136. }
  137. break;
  138. }
  139. case K.ENTER: {
  140. const v = f.value[F.activeIndex];
  141. v && !v.data.disabled ? C(v.value) : C(void 0), n.open && l.preventDefault();
  142. break;
  143. }
  144. case K.ESC:
  145. n.toggleOpen(!1), n.open && l.stopPropagation();
  146. }
  147. },
  148. onKeyup: () => {
  149. },
  150. scrollTo: (l) => {
  151. h(l);
  152. }
  153. }), () => {
  154. const {
  155. id: l,
  156. notFoundContent: y,
  157. onPopupScroll: _
  158. } = n, {
  159. menuItemSelectedIcon: v,
  160. fieldNames: N,
  161. virtual: j,
  162. listHeight: H,
  163. listItemHeight: oe
  164. } = u, X = o.option, {
  165. activeIndex: L
  166. } = F, re = Object.keys(N).map((T) => N[T]);
  167. return f.value.length === 0 ? $("div", {
  168. role: "listbox",
  169. id: `${l}_list`,
  170. class: `${m.value}-empty`,
  171. onMousedown: g
  172. }, [y]) : $(nt, null, [$("div", {
  173. role: "listbox",
  174. id: `${l}_list`,
  175. style: {
  176. height: 0,
  177. width: 0,
  178. overflow: "hidden"
  179. }
  180. }, [k(L - 1), k(L), k(L + 1)]), $(mt, {
  181. itemKey: "key",
  182. ref: p,
  183. data: f.value,
  184. height: H,
  185. itemHeight: oe,
  186. fullHeight: !1,
  187. onMousedown: g,
  188. onScroll: _,
  189. virtual: j
  190. }, {
  191. default: (T, ee) => {
  192. var te;
  193. const {
  194. group: ae,
  195. groupOption: ce,
  196. data: r,
  197. value: D
  198. } = T, {
  199. key: R
  200. } = r, z = typeof T.label == "function" ? T.label() : T.label;
  201. if (ae) {
  202. const le = (te = r.title) !== null && te !== void 0 ? te : Fe(z) && z;
  203. return $("div", {
  204. class: pe(m.value, `${m.value}-group`),
  205. title: le
  206. }, [X ? X(r) : z !== void 0 ? z : R]);
  207. }
  208. const {
  209. disabled: q,
  210. title: ie,
  211. children: ne,
  212. style: de,
  213. class: t,
  214. className: a
  215. } = r, i = Ct(r, ["disabled", "title", "children", "style", "class", "className"]), c = be(i, re), s = w(D), A = `${m.value}-option`, J = pe(m.value, A, t, a, {
  216. [`${A}-grouped`]: ce,
  217. [`${A}-active`]: L === ee && !q,
  218. [`${A}-disabled`]: q,
  219. [`${A}-selected`]: s
  220. }), B = V(T), G = !v || typeof v == "function" || s, M = typeof B == "number" ? B : B || D;
  221. let ve = Fe(M) ? M.toString() : void 0;
  222. return ie !== void 0 && (ve = ie), $("div", W(W({}, c), {}, {
  223. "aria-selected": s,
  224. class: J,
  225. title: ve,
  226. onMousemove: (le) => {
  227. i.onMousemove && i.onMousemove(le), !(L === ee || q) && I(ee);
  228. },
  229. onClick: (le) => {
  230. q || C(D), i.onClick && i.onClick(le);
  231. },
  232. style: de
  233. }), [$("div", {
  234. class: `${A}-content`
  235. }, [X ? X(r) : M]), he(v) || s, G && $(ot, {
  236. class: `${m.value}-option-state`,
  237. customizeIcon: v,
  238. customizeIconProps: {
  239. isSelected: s
  240. }
  241. }, {
  242. default: () => [s ? "✓" : null]
  243. })]);
  244. }
  245. })]);
  246. };
  247. }
  248. });
  249. var Vt = function(e, d) {
  250. var b = {};
  251. for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && d.indexOf(o) < 0 && (b[o] = e[o]);
  252. if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var n = 0, o = Object.getOwnPropertySymbols(e); n < o.length; n++)
  253. d.indexOf(o[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[n]) && (b[o[n]] = e[o[n]]);
  254. return b;
  255. };
  256. function xt(e) {
  257. const d = e, {
  258. key: b,
  259. children: o
  260. } = d, n = d.props, {
  261. value: u,
  262. disabled: m
  263. } = n, f = Vt(n, ["value", "disabled"]), p = o == null ? void 0 : o.default;
  264. return E({
  265. key: b,
  266. value: u !== void 0 ? u : b,
  267. children: p,
  268. disabled: m || m === ""
  269. }, f);
  270. }
  271. function we(e) {
  272. let d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
  273. return ze(e).map((o, n) => {
  274. var u;
  275. if (!he(o) || !o.type)
  276. return null;
  277. const {
  278. type: {
  279. isSelectOptGroup: m
  280. },
  281. key: f,
  282. children: p,
  283. props: g
  284. } = o;
  285. if (d || !m)
  286. return xt(o);
  287. const h = p && p.default ? p.default() : void 0, O = (g == null ? void 0 : g.label) || ((u = p.label) === null || u === void 0 ? void 0 : u.call(p)) || f;
  288. return E(E({
  289. key: `__RC_SELECT_GRP__${f === null ? n : String(f)}__`
  290. }, g), {
  291. label: O,
  292. options: we(h || [])
  293. });
  294. }).filter((o) => o);
  295. }
  296. function _t(e, d, b) {
  297. const o = se(), n = se(), u = se(), m = se([]);
  298. return ye([e, d], () => {
  299. e.value ? m.value = ke(e.value).slice() : m.value = we(d.value);
  300. }, {
  301. immediate: !0,
  302. deep: !0
  303. }), me(() => {
  304. const f = m.value, p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), h = b.value;
  305. function O(F) {
  306. let I = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
  307. for (let w = 0; w < F.length; w += 1) {
  308. const C = F[w];
  309. !C[h.options] || I ? (p.set(C[h.value], C), g.set(C[h.label], C)) : O(C[h.options], !0);
  310. }
  311. }
  312. O(f), o.value = f, n.value = p, u.value = g;
  313. }), {
  314. options: o,
  315. valueOptions: n,
  316. labelOptions: u
  317. };
  318. }
  319. function Ce(e) {
  320. return Array.isArray(e) ? e : e !== void 0 ? [e] : [];
  321. }
  322. const Nt = typeof window != "undefined" && window.document && window.document.documentElement;
  323. process.env.NODE_ENV;
  324. function Pt(e) {
  325. const {
  326. mode: d,
  327. options: b,
  328. children: o,
  329. backfill: n,
  330. allowClear: u,
  331. placeholder: m,
  332. getInputElement: f,
  333. showSearch: p,
  334. onSearch: g,
  335. defaultOpen: h,
  336. autofocus: O,
  337. labelInValue: F,
  338. value: I,
  339. inputValue: w,
  340. optionLabelProp: C
  341. } = e, V = Le(d), k = p !== void 0 ? p : V || d === "combobox", U = b || we(o);
  342. if (Q(d !== "tags" || U.every((P) => !P.disabled), "Please avoid setting option to disabled in tags mode since user can always type text as tag."), Q(d !== "combobox" || !C, "`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."), Q(d === "combobox" || !n, "`backfill` only works with `combobox` mode."), Q(d === "combobox" || !f, "`getInputElement` only work with `combobox` mode."), _e(d !== "combobox" || !f || !u || !m, "Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."), g && !k && d !== "combobox" && d !== "tags" && Q(!1, "`onSearch` should work with `showSearch` instead of use alone."), _e(!h || O, "`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autofocus` if needed."), I != null) {
  343. const P = Ce(I);
  344. Q(!F || P.every((x) => typeof x == "object" && ("key" in x || "value" in x)), "`value` should in shape of `{ value: string | number, label?: any }` when you set `labelInValue` to `true`"), Q(!V || Array.isArray(I), "`value` should be array when `mode` is `multiple` or `tags`");
  345. }
  346. if (o) {
  347. let P = null;
  348. o.some((x) => {
  349. var l;
  350. if (!he(x) || !x.type)
  351. return !1;
  352. const {
  353. type: y
  354. } = x;
  355. return y.isSelectOption ? !1 : y.isSelectOptGroup ? !(((l = x.children) === null || l === void 0 ? void 0 : l.default()) || []).every((N) => !he(N) || !x.type || N.type.isSelectOption ? !0 : (P = N.type, !1)) : (P = y, !0);
  356. }), P && Q(!1, `\`children\` should be \`Select.Option\` or \`Select.OptGroup\` instead of \`${P.displayName || P.name || P}\`.`), Q(w === void 0, "`inputValue` is deprecated, please use `searchValue` instead.");
  357. }
  358. }
  359. function ge(e, d) {
  360. return Ce(e).join("").toUpperCase().includes(d);
  361. }
  362. const At = (e, d, b, o, n) => S(() => {
  363. const u = b.value, m = n == null ? void 0 : n.value, f = o == null ? void 0 : o.value;
  364. if (!u || f === !1)
  365. return e.value;
  366. const {
  367. options: p,
  368. label: g,
  369. value: h
  370. } = d.value, O = [], F = typeof f == "function", I = u.toUpperCase(), w = F ? f : (V, k) => m ? ge(k[m], I) : k[p] ? ge(k[g !== "children" ? g : "label"], I) : ge(k[h], I), C = F ? (V) => Se(V) : (V) => V;
  371. return e.value.forEach((V) => {
  372. if (V[p]) {
  373. if (w(u, C(V)))
  374. O.push(V);
  375. else {
  376. const U = V[p].filter((P) => w(u, C(P)));
  377. U.length && O.push(E(E({}, V), {
  378. [p]: U
  379. }));
  380. }
  381. return;
  382. }
  383. w(u, C(V)) && O.push(V);
  384. }), O;
  385. }), Et = (e, d) => {
  386. const b = se({
  387. values: /* @__PURE__ */ new Map(),
  388. options: /* @__PURE__ */ new Map()
  389. });
  390. return [S(() => {
  391. const {
  392. values: u,
  393. options: m
  394. } = b.value, f = e.value.map((h) => {
  395. var O;
  396. return h.label === void 0 ? E(E({}, h), {
  397. label: (O = u.get(h.value)) === null || O === void 0 ? void 0 : O.label
  398. }) : h;
  399. }), p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
  400. return f.forEach((h) => {
  401. p.set(h.value, h), g.set(h.value, d.value.get(h.value) || m.get(h.value));
  402. }), b.value.values = p, b.value.options = g, f;
  403. }), (u) => d.value.get(u) || b.value.options.get(u)];
  404. }, Ft = ["inputValue"];
  405. function $e() {
  406. return E(E({}, ct()), {
  407. prefixCls: String,
  408. id: String,
  409. backfill: {
  410. type: Boolean,
  411. default: void 0
  412. },
  413. // >>> Field Names
  414. fieldNames: Object,
  415. // >>> Search
  416. /** @deprecated Use `searchValue` instead */
  417. inputValue: String,
  418. searchValue: String,
  419. onSearch: Function,
  420. autoClearSearchValue: {
  421. type: Boolean,
  422. default: void 0
  423. },
  424. // >>> Select
  425. onSelect: Function,
  426. onDeselect: Function,
  427. // >>> Options
  428. /**
  429. * In Select, `false` means do nothing.
  430. * In TreeSelect, `false` will highlight match item.
  431. * It's by design.
  432. */
  433. filterOption: {
  434. type: [Boolean, Function],
  435. default: void 0
  436. },
  437. filterSort: Function,
  438. optionFilterProp: String,
  439. optionLabelProp: String,
  440. options: Array,
  441. defaultActiveFirstOption: {
  442. type: Boolean,
  443. default: void 0
  444. },
  445. virtual: {
  446. type: Boolean,
  447. default: void 0
  448. },
  449. listHeight: Number,
  450. listItemHeight: Number,
  451. // >>> Icon
  452. menuItemSelectedIcon: ue.any,
  453. mode: String,
  454. labelInValue: {
  455. type: Boolean,
  456. default: void 0
  457. },
  458. value: ue.any,
  459. defaultValue: ue.any,
  460. onChange: Function,
  461. children: Array
  462. });
  463. }
  464. function Dt(e) {
  465. return !e || typeof e != "object";
  466. }
  467. const Mt = Oe({
  468. compatConfig: {
  469. MODE: 3
  470. },
  471. name: "VcSelect",
  472. inheritAttrs: !1,
  473. props: Me($e(), {
  474. prefixCls: "vc-select",
  475. autoClearSearchValue: !0,
  476. listHeight: 200,
  477. listItemHeight: 20,
  478. dropdownMatchSelectWidth: !0
  479. }),
  480. setup(e, d) {
  481. let {
  482. expose: b,
  483. attrs: o,
  484. slots: n
  485. } = d;
  486. const u = at(Z(e, "id")), m = S(() => Le(e.mode)), f = S(() => !!(!e.options && e.children)), p = S(() => e.filterOption === void 0 && e.mode === "combobox" ? !1 : e.filterOption), g = S(() => it(e.fieldNames, f.value)), [h, O] = Ee("", {
  487. value: S(() => e.searchValue !== void 0 ? e.searchValue : e.inputValue),
  488. postState: (t) => t || ""
  489. }), F = _t(Z(e, "options"), Z(e, "children"), g), {
  490. valueOptions: I,
  491. labelOptions: w,
  492. options: C
  493. } = F, V = (t) => Ce(t).map((i) => {
  494. var c, s;
  495. let A, J, B, G;
  496. Dt(i) ? A = i : (B = i.key, J = i.label, A = (c = i.value) !== null && c !== void 0 ? c : B);
  497. const M = I.value.get(A);
  498. return M && (J === void 0 && (J = M == null ? void 0 : M[e.optionLabelProp || g.value.label]), B === void 0 && (B = (s = M == null ? void 0 : M.key) !== null && s !== void 0 ? s : A), G = M == null ? void 0 : M.disabled), {
  499. label: J,
  500. value: A,
  501. key: B,
  502. disabled: G,
  503. option: M
  504. };
  505. }), [k, U] = Ee(e.defaultValue, {
  506. value: Z(e, "value")
  507. }), P = S(() => {
  508. var t;
  509. const a = V(k.value);
  510. return e.mode === "combobox" && !(!((t = a[0]) === null || t === void 0) && t.value) ? [] : a;
  511. }), [x, l] = Et(P, I), y = S(() => {
  512. if (!e.mode && x.value.length === 1) {
  513. const t = x.value[0];
  514. if (t.value === null && (t.label === null || t.label === void 0))
  515. return [];
  516. }
  517. return x.value.map((t) => {
  518. var a;
  519. return E(E({}, t), {
  520. label: (a = typeof t.label == "function" ? t.label() : t.label) !== null && a !== void 0 ? a : t.value
  521. });
  522. });
  523. }), _ = S(() => new Set(x.value.map((t) => t.value)));
  524. me(() => {
  525. var t;
  526. if (e.mode === "combobox") {
  527. const a = (t = x.value[0]) === null || t === void 0 ? void 0 : t.value;
  528. a != null && O(String(a));
  529. }
  530. }, {
  531. flush: "post"
  532. });
  533. const v = (t, a) => {
  534. const i = a != null ? a : t;
  535. return {
  536. [g.value.value]: t,
  537. [g.value.label]: i
  538. };
  539. }, N = se();
  540. me(() => {
  541. if (e.mode !== "tags") {
  542. N.value = C.value;
  543. return;
  544. }
  545. const t = C.value.slice(), a = (i) => I.value.has(i);
  546. [...x.value].sort((i, c) => i.value < c.value ? -1 : 1).forEach((i) => {
  547. const c = i.value;
  548. a(c) || t.push(v(c, i.label));
  549. }), N.value = t;
  550. });
  551. const j = At(N, g, h, p, Z(e, "optionFilterProp")), H = S(() => e.mode !== "tags" || !h.value || j.value.some((t) => t[e.optionFilterProp || "value"] === h.value) ? j.value : [v(h.value), ...j.value]), oe = S(() => e.filterSort ? [...H.value].sort((t, a) => e.filterSort(t, a)) : H.value), X = S(() => st(oe.value, {
  552. fieldNames: g.value,
  553. childrenAsData: f.value
  554. })), L = (t) => {
  555. const a = V(t);
  556. if (U(a), e.onChange && // Trigger event only when value changed
  557. (a.length !== x.value.length || a.some((i, c) => {
  558. var s;
  559. return ((s = x.value[c]) === null || s === void 0 ? void 0 : s.value) !== (i == null ? void 0 : i.value);
  560. }))) {
  561. const i = e.labelInValue ? a.map((s) => E(E({}, s), {
  562. originLabel: s.label,
  563. label: typeof s.label == "function" ? s.label() : s.label
  564. })) : a.map((s) => s.value), c = a.map((s) => Se(l(s.value)));
  565. e.onChange(
  566. // Value
  567. m.value ? i : i[0],
  568. // Option
  569. m.value ? c : c[0]
  570. );
  571. }
  572. }, [re, T] = Ne(null), [ee, te] = Ne(0), ae = S(() => e.defaultActiveFirstOption !== void 0 ? e.defaultActiveFirstOption : e.mode !== "combobox"), ce = function(t, a) {
  573. let {
  574. source: i = "keyboard"
  575. } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
  576. te(a), e.backfill && e.mode === "combobox" && t !== null && i === "keyboard" && T(String(t));
  577. }, r = (t, a) => {
  578. const i = () => {
  579. var c;
  580. const s = l(t), A = s == null ? void 0 : s[g.value.label];
  581. return [e.labelInValue ? {
  582. label: typeof A == "function" ? A() : A,
  583. originLabel: A,
  584. value: t,
  585. key: (c = s == null ? void 0 : s.key) !== null && c !== void 0 ? c : t
  586. } : t, Se(s)];
  587. };
  588. if (a && e.onSelect) {
  589. const [c, s] = i();
  590. e.onSelect(c, s);
  591. } else if (!a && e.onDeselect) {
  592. const [c, s] = i();
  593. e.onDeselect(c, s);
  594. }
  595. }, D = (t, a) => {
  596. let i;
  597. const c = m.value ? a.selected : !0;
  598. c ? i = m.value ? [...x.value, t] : [t] : i = x.value.filter((s) => s.value !== t), L(i), r(t, c), e.mode === "combobox" ? T("") : (!m.value || e.autoClearSearchValue) && (O(""), T(""));
  599. }, R = (t, a) => {
  600. L(t), (a.type === "remove" || a.type === "clear") && a.values.forEach((i) => {
  601. r(i.value, !1);
  602. });
  603. }, z = (t, a) => {
  604. var i;
  605. if (O(t), T(null), a.source === "submit") {
  606. const c = (t || "").trim();
  607. if (c) {
  608. const s = Array.from(/* @__PURE__ */ new Set([..._.value, c]));
  609. L(s), r(c, !0), O("");
  610. }
  611. return;
  612. }
  613. a.source !== "blur" && (e.mode === "combobox" && L(t), (i = e.onSearch) === null || i === void 0 || i.call(e, t));
  614. }, q = (t) => {
  615. let a = t;
  616. e.mode !== "tags" && (a = t.map((c) => {
  617. const s = w.value.get(c);
  618. return s == null ? void 0 : s.value;
  619. }).filter((c) => c !== void 0));
  620. const i = Array.from(/* @__PURE__ */ new Set([..._.value, ...a]));
  621. L(i), i.forEach((c) => {
  622. r(c, !0);
  623. });
  624. }, ie = S(() => e.virtual !== !1 && e.dropdownMatchSelectWidth !== !1);
  625. Ot(ut(E(E({}, F), {
  626. flattenOptions: X,
  627. onActiveValue: ce,
  628. defaultActiveFirstOption: ae,
  629. onSelect: D,
  630. menuItemSelectedIcon: Z(e, "menuItemSelectedIcon"),
  631. rawValues: _,
  632. fieldNames: g,
  633. virtual: ie,
  634. listHeight: Z(e, "listHeight"),
  635. listItemHeight: Z(e, "listItemHeight"),
  636. childrenAsData: f
  637. }))), process.env.NODE_ENV !== "production" && me(() => {
  638. Pt(e);
  639. }, {
  640. flush: "post"
  641. });
  642. const ne = Te();
  643. b({
  644. focus() {
  645. var t;
  646. (t = ne.value) === null || t === void 0 || t.focus();
  647. },
  648. blur() {
  649. var t;
  650. (t = ne.value) === null || t === void 0 || t.blur();
  651. },
  652. scrollTo(t) {
  653. var a;
  654. (a = ne.value) === null || a === void 0 || a.scrollTo(t);
  655. }
  656. });
  657. const de = S(() => be(e, [
  658. "id",
  659. "mode",
  660. "prefixCls",
  661. "backfill",
  662. "fieldNames",
  663. // Search
  664. "inputValue",
  665. "searchValue",
  666. "onSearch",
  667. "autoClearSearchValue",
  668. // Select
  669. "onSelect",
  670. "onDeselect",
  671. "dropdownMatchSelectWidth",
  672. // Options
  673. "filterOption",
  674. "filterSort",
  675. "optionFilterProp",
  676. "optionLabelProp",
  677. "options",
  678. "children",
  679. "defaultActiveFirstOption",
  680. "menuItemSelectedIcon",
  681. "virtual",
  682. "listHeight",
  683. "listItemHeight",
  684. // Value
  685. "value",
  686. "defaultValue",
  687. "labelInValue",
  688. "onChange"
  689. ]));
  690. return () => $(rt, W(W(W({}, de.value), o), {}, {
  691. id: u,
  692. prefixCls: e.prefixCls,
  693. ref: ne,
  694. omitDomProps: Ft,
  695. mode: e.mode,
  696. displayValues: y.value,
  697. onDisplayValuesChange: R,
  698. searchValue: h.value,
  699. onSearch: z,
  700. onSearchSplit: q,
  701. dropdownMatchSelectWidth: e.dropdownMatchSelectWidth,
  702. OptionList: It,
  703. emptyOptions: !X.value.length,
  704. activeValue: re.value,
  705. activeDescendantId: `${u}_list_${ee.value}`
  706. }), n);
  707. }
  708. }), Ie = () => null;
  709. Ie.isSelectOption = !0;
  710. Ie.displayName = "ASelectOption";
  711. const Ve = () => null;
  712. Ve.isSelectOptGroup = !0;
  713. Ve.displayName = "ASelectOptGroup";
  714. const kt = () => E(E({}, be($e(), ["inputIcon", "mode", "getInputElement", "getRawInputElement", "backfill"])), {
  715. value: Pe([Array, Object, String, Number]),
  716. defaultValue: Pe([Array, Object, String, Number]),
  717. notFoundContent: ue.any,
  718. suffixIcon: ue.any,
  719. itemIcon: ue.any,
  720. size: fe(),
  721. mode: fe(),
  722. bordered: Ye(!0),
  723. transitionName: String,
  724. choiceTransitionName: fe(""),
  725. popupClassName: String,
  726. /** @deprecated Please use `popupClassName` instead */
  727. dropdownClassName: String,
  728. placement: fe(),
  729. status: fe(),
  730. "onUpdate:value": Qe()
  731. }), De = "SECRET_COMBOBOX_MODE_DO_NOT_USE", Y = Oe({
  732. compatConfig: {
  733. MODE: 3
  734. },
  735. name: "ASelect",
  736. Option: Ie,
  737. OptGroup: Ve,
  738. inheritAttrs: !1,
  739. props: Me(kt(), {
  740. listHeight: 256,
  741. listItemHeight: 24
  742. }),
  743. SECRET_COMBOBOX_MODE_DO_NOT_USE: De,
  744. slots: Object,
  745. setup(e, d) {
  746. let {
  747. attrs: b,
  748. emit: o,
  749. slots: n,
  750. expose: u
  751. } = d;
  752. const m = Te(), f = ht(), p = bt.useInject(), g = S(() => gt(p.status, e.status)), h = () => {
  753. var r;
  754. (r = m.value) === null || r === void 0 || r.focus();
  755. }, O = () => {
  756. var r;
  757. (r = m.value) === null || r === void 0 || r.blur();
  758. }, F = (r) => {
  759. var D;
  760. (D = m.value) === null || D === void 0 || D.scrollTo(r);
  761. }, I = S(() => {
  762. const {
  763. mode: r
  764. } = e;
  765. if (r !== "combobox")
  766. return r === De ? "combobox" : r;
  767. });
  768. process.env.NODE_ENV !== "production" && Ge(!e.dropdownClassName, "Select", "`dropdownClassName` is deprecated. Please use `popupClassName` instead.");
  769. const {
  770. prefixCls: w,
  771. direction: C,
  772. renderEmpty: V,
  773. size: k,
  774. getPrefixCls: U,
  775. getPopupContainer: P,
  776. disabled: x,
  777. select: l
  778. } = Ke("select", e), {
  779. compactSize: y,
  780. compactItemClassnames: _
  781. } = We(w, C), v = S(() => y.value || k.value), N = Ue(), j = S(() => {
  782. var r;
  783. return (r = x.value) !== null && r !== void 0 ? r : N.value;
  784. }), [H, oe] = dt(w), X = S(() => U()), L = S(() => e.placement !== void 0 ? e.placement : C.value === "rtl" ? "bottomRight" : "bottomLeft"), re = S(() => Xe(X.value, qe(L.value), e.transitionName)), T = S(() => pe({
  785. [`${w.value}-lg`]: v.value === "large",
  786. [`${w.value}-sm`]: v.value === "small",
  787. [`${w.value}-rtl`]: C.value === "rtl",
  788. [`${w.value}-borderless`]: !e.bordered,
  789. [`${w.value}-in-form-item`]: p.isFormItemInput
  790. }, yt(w.value, g.value, p.hasFeedback), _.value, oe.value)), ee = function() {
  791. for (var r = arguments.length, D = new Array(r), R = 0; R < r; R++)
  792. D[R] = arguments[R];
  793. o("update:value", D[0]), o("change", ...D), f.onFieldChange();
  794. }, te = (r) => {
  795. o("blur", r), f.onFieldBlur();
  796. };
  797. u({
  798. blur: O,
  799. focus: h,
  800. scrollTo: F
  801. });
  802. const ae = S(() => I.value === "multiple" || I.value === "tags"), ce = S(() => e.showArrow !== void 0 ? e.showArrow : e.loading || !(ae.value || I.value === "combobox"));
  803. return () => {
  804. var r, D, R, z;
  805. const {
  806. notFoundContent: q,
  807. listHeight: ie = 256,
  808. listItemHeight: ne = 24,
  809. popupClassName: de,
  810. dropdownClassName: t,
  811. virtual: a,
  812. dropdownMatchSelectWidth: i,
  813. id: c = f.id.value,
  814. placeholder: s = (r = n.placeholder) === null || r === void 0 ? void 0 : r.call(n),
  815. showArrow: A
  816. } = e, {
  817. hasFeedback: J,
  818. feedbackIcon: B
  819. } = p;
  820. let G;
  821. q !== void 0 ? G = q : n.notFoundContent ? G = n.notFoundContent() : I.value === "combobox" ? G = null : G = (V == null ? void 0 : V("Select")) || $(Je, {
  822. componentName: "Select"
  823. }, null);
  824. const {
  825. suffixIcon: M,
  826. itemIcon: ve,
  827. removeIcon: le,
  828. clearIcon: je
  829. } = ft(E(E({}, e), {
  830. multiple: ae.value,
  831. prefixCls: w.value,
  832. hasFeedback: J,
  833. feedbackIcon: B,
  834. showArrow: ce.value
  835. }), n), xe = be(e, ["prefixCls", "suffixIcon", "itemIcon", "removeIcon", "clearIcon", "size", "bordered", "status"]), He = pe(de || t, {
  836. [`${w.value}-dropdown-${C.value}`]: C.value === "rtl"
  837. }, oe.value);
  838. return H($(Mt, W(W(W({
  839. ref: m,
  840. virtual: a,
  841. dropdownMatchSelectWidth: i
  842. }, xe), b), {}, {
  843. showSearch: (D = e.showSearch) !== null && D !== void 0 ? D : (R = l == null ? void 0 : l.value) === null || R === void 0 ? void 0 : R.showSearch,
  844. placeholder: s,
  845. listHeight: ie,
  846. listItemHeight: ne,
  847. mode: I.value,
  848. prefixCls: w.value,
  849. direction: C.value,
  850. inputIcon: M,
  851. menuItemSelectedIcon: ve,
  852. removeIcon: le,
  853. clearIcon: je,
  854. notFoundContent: G,
  855. class: [T.value, b.class],
  856. getPopupContainer: P == null ? void 0 : P.value,
  857. dropdownClassName: He,
  858. onChange: ee,
  859. onBlur: te,
  860. id: c,
  861. dropdownRender: xe.dropdownRender || n.dropdownRender,
  862. transitionName: re.value,
  863. children: (z = n.default) === null || z === void 0 ? void 0 : z.call(n),
  864. tagRender: e.tagRender || n.tagRender,
  865. optionLabelRender: n.optionLabel,
  866. maxTagPlaceholder: e.maxTagPlaceholder || n.maxTagPlaceholder,
  867. showArrow: J || A,
  868. disabled: j.value
  869. }), {
  870. option: n.option
  871. }));
  872. };
  873. }
  874. });
  875. Y.install = function(e) {
  876. return e.component(Y.name, Y), e.component(Y.Option.displayName, Y.Option), e.component(Y.OptGroup.displayName, Y.OptGroup), e;
  877. };
  878. const Kt = Y.Option;
  879. Y.OptGroup;
  880. export {
  881. Y as S,
  882. Kt as a,
  883. kt as s
  884. };