@aplus-frontend/ui 7.20.1 → 7.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Select as
|
|
3
|
-
import { debounce as
|
|
1
|
+
import { defineComponent as Se, useSlots as xe, ref as N, shallowRef as Ve, computed as s, onMounted as ke, watch as Be, unref as l, createVNode as v, createElementBlock as T, createBlock as F, openBlock as y, toDisplayString as I, mergeProps as Ne, h as Ie, createSlots as Ae, withCtx as g, createElementVNode as A, normalizeClass as C, createCommentVNode as R, resolveDynamicComponent as z, withModifiers as _e, renderList as De, renderSlot as Me, normalizeProps as Le, guardReactiveProps as Pe } from "vue";
|
|
2
|
+
import { Form as qe, Select as Te, Flex as E, Checkbox as U, Spin as Re } from "@aplus-frontend/antdv";
|
|
3
|
+
import { debounce as ze, isFunction as j, isNil as K, isArray as $, omit as H, isNumber as Ee } from "lodash-unified";
|
|
4
4
|
import "../../config-provider/index.mjs";
|
|
5
5
|
import "../../utils/index.mjs";
|
|
6
|
-
import { useDevWarning as
|
|
6
|
+
import { useDevWarning as Ue } from "../../utils/warning.mjs";
|
|
7
7
|
import "../../hooks/index.mjs";
|
|
8
|
-
import { useDefaultPlaceholder as
|
|
9
|
-
import
|
|
10
|
-
import { useSelectOptions as
|
|
8
|
+
import { useDefaultPlaceholder as je } from "../hooks/use-default-placeholder.mjs";
|
|
9
|
+
import Ke from "../style/index.mjs";
|
|
10
|
+
import { useSelectOptions as $e } from "./use-select-options.mjs";
|
|
11
11
|
import { isDef as _ } from "../../utils/is.mjs";
|
|
12
12
|
import { useNamespace as W } from "../../config-provider/hooks/use-namespace.mjs";
|
|
13
|
-
import { useLocale as
|
|
14
|
-
import { useControllableValue as
|
|
15
|
-
const
|
|
13
|
+
import { useLocale as He } from "../../config-provider/hooks/use-locale.mjs";
|
|
14
|
+
import { useControllableValue as We } from "../../hooks/useControllableValue.mjs";
|
|
15
|
+
const Ge = {
|
|
16
16
|
key: 0
|
|
17
|
-
},
|
|
17
|
+
}, Je = ["onClick"], ct = /* @__PURE__ */ Se({
|
|
18
18
|
name: "ApFieldSelect",
|
|
19
19
|
__name: "index",
|
|
20
20
|
props: {
|
|
@@ -186,232 +186,235 @@ const je = {
|
|
|
186
186
|
emit: Q
|
|
187
187
|
}) {
|
|
188
188
|
let i = 0;
|
|
189
|
-
const
|
|
189
|
+
const O = xe(), t = G, {
|
|
190
190
|
deprecated: X
|
|
191
|
-
} =
|
|
191
|
+
} = Ue("ApFieldSelect");
|
|
192
192
|
X(!_(t.refetchOnFocus), "refetchOnFocus", "fetchOnFocus");
|
|
193
193
|
const {
|
|
194
|
-
b:
|
|
194
|
+
b: S
|
|
195
195
|
} = W("field-select"), {
|
|
196
196
|
b: f
|
|
197
|
-
} = W("field-select-popup-option"), Y =
|
|
197
|
+
} = W("field-select-popup-option"), Y = Ke("field"), Z = qe.useInjectFormItemContext(), D = N(!1), M = N(!1), {
|
|
198
198
|
t: L
|
|
199
|
-
} =
|
|
200
|
-
if (!
|
|
199
|
+
} = He(), ee = ze((e) => {
|
|
200
|
+
if (!j(t.request))
|
|
201
201
|
return;
|
|
202
202
|
i += 1;
|
|
203
203
|
const n = i;
|
|
204
|
-
w([]), r.value = !0, t.request(e).then((
|
|
205
|
-
i === n && (w(
|
|
204
|
+
w([]), r.value = !0, t.request(e).then((o) => {
|
|
205
|
+
i === n && (w(o), r.value = !1);
|
|
206
206
|
});
|
|
207
|
-
}, t.searchDelay),
|
|
208
|
-
const
|
|
209
|
-
return typeof n?.[
|
|
207
|
+
}, t.searchDelay), te = (e, n) => {
|
|
208
|
+
const o = t.fieldNames?.label || "label";
|
|
209
|
+
return typeof n?.[o] == "string" && n[o].toLowerCase().indexOf(e.toLowerCase()) > -1;
|
|
210
210
|
}, {
|
|
211
211
|
options: c,
|
|
212
212
|
updateOptions: w
|
|
213
|
-
} =
|
|
213
|
+
} = $e(t), x = Ve(), r = N(t?.loading || !1), ne = Q, oe = s(() => t.fetchOnFocus ?? t.refetchOnFocus), le = s(() => {
|
|
214
214
|
if (t.multiple)
|
|
215
215
|
return t.tokenSeparators ? "tags" : "multiple";
|
|
216
216
|
});
|
|
217
217
|
async function d(e = !0) {
|
|
218
|
-
if (!
|
|
218
|
+
if (!j(t.request))
|
|
219
219
|
return;
|
|
220
220
|
r.value = !0, i += 1;
|
|
221
221
|
const n = i;
|
|
222
222
|
try {
|
|
223
223
|
e && w([]);
|
|
224
|
-
const
|
|
224
|
+
const o = await t.request(void 0, t.params);
|
|
225
225
|
if (n !== i)
|
|
226
226
|
return;
|
|
227
|
-
w(
|
|
227
|
+
w(o);
|
|
228
228
|
} finally {
|
|
229
229
|
r.value = !1;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
function oe(e) {
|
|
233
|
-
!D.value && i === 0 && t.lazy === "first-focus" ? d() : ne.value && !r.value && d(!0), t.onFocus?.(e), D.value = !0;
|
|
234
|
-
}
|
|
235
232
|
function ae(e) {
|
|
233
|
+
!D.value && i === 0 && t.lazy === "first-focus" ? d() : oe.value && !r.value && d(!0), t.onFocus?.(e), D.value = !0;
|
|
234
|
+
}
|
|
235
|
+
function ue(e) {
|
|
236
236
|
if (!e) {
|
|
237
237
|
t.onDropdownVisibleChange?.(e);
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
240
240
|
!M.value && i === 0 && t.lazy === "first-open" ? d() : t.fetchOnOpen && !r.value && d(!0), t.onDropdownVisibleChange?.(e), M.value = !0;
|
|
241
241
|
}
|
|
242
|
-
|
|
242
|
+
function V(e) {
|
|
243
|
+
se(e), Z?.onFieldChange();
|
|
244
|
+
}
|
|
245
|
+
ke(() => {
|
|
243
246
|
if (!t.lazy) {
|
|
244
247
|
d();
|
|
245
248
|
return;
|
|
246
249
|
}
|
|
247
|
-
}),
|
|
250
|
+
}), Be(() => t.params, () => {
|
|
248
251
|
d();
|
|
249
252
|
}, {
|
|
250
253
|
deep: !0
|
|
251
254
|
});
|
|
252
255
|
const {
|
|
253
256
|
value: p,
|
|
254
|
-
updateValue:
|
|
255
|
-
} =
|
|
256
|
-
const e =
|
|
257
|
-
if (
|
|
257
|
+
updateValue: se
|
|
258
|
+
} = We(t, ne), re = je("Select", t), ie = s(() => {
|
|
259
|
+
const e = l(p);
|
|
260
|
+
if (K(e))
|
|
258
261
|
return t.emptyText;
|
|
259
|
-
const n = t.fieldNames?.label || "label",
|
|
260
|
-
return
|
|
261
|
-
}),
|
|
262
|
+
const n = t.fieldNames?.label || "label", o = t.fieldNames?.value || "value";
|
|
263
|
+
return $(e) ? e.map((a) => l(c).find((h) => h[o] === a)?.[n]).filter(Boolean).join("、") || t.emptyText : l(c).find((a) => a[o] === e)?.[n] || t.emptyText;
|
|
264
|
+
}), ce = s(() => {
|
|
262
265
|
const e = !!t?.showSearch, n = t.searchMode;
|
|
263
|
-
let
|
|
264
|
-
return e && (
|
|
266
|
+
let o = {};
|
|
267
|
+
return e && (o = n === "request" ? {
|
|
265
268
|
defaultActiveFirstOption: !1,
|
|
266
|
-
onSearch:
|
|
269
|
+
onSearch: ee,
|
|
267
270
|
notFoundContent: r.value ? void 0 : null,
|
|
268
271
|
filterOption: !1,
|
|
269
272
|
suffixIcon: null
|
|
270
273
|
} : {
|
|
271
|
-
filterOption:
|
|
274
|
+
filterOption: K(t?.filterOption) ? te : t?.filterOption
|
|
272
275
|
}), {
|
|
273
276
|
...H(t, ["mode", "value", "onUpdate:value", "onSearch", "request", "searchMode", "onFocus", "onBeforeSelect", "onDropdownVisibleChange"]),
|
|
274
|
-
placeholder:
|
|
275
|
-
...
|
|
277
|
+
placeholder: l(re),
|
|
278
|
+
...o
|
|
276
279
|
};
|
|
277
|
-
}),
|
|
278
|
-
function
|
|
279
|
-
|
|
280
|
+
}), de = s(() => c.value.map((e) => e[t.fieldNames?.value || "value"])), k = s(() => c.value.filter((e) => !e.disabled).map((e) => e[t.fieldNames?.value || "value"])), P = s(() => !t.multiple || _(t.maxCount) ? !1 : Ee(t.addAll) ? de.value.length >= t.addAll : !!t.addAll), fe = s(() => t.multiple && t.allowOnlySelect && (!_(t.maxCount) || t.maxCount >= 1));
|
|
281
|
+
function pe() {
|
|
282
|
+
x.value?.focus();
|
|
280
283
|
}
|
|
281
|
-
function
|
|
282
|
-
|
|
284
|
+
function me() {
|
|
285
|
+
x.value?.blur();
|
|
283
286
|
}
|
|
284
287
|
function m(e, n) {
|
|
285
|
-
const
|
|
286
|
-
return
|
|
288
|
+
const o = t.fieldNames?.[n] ?? n;
|
|
289
|
+
return o === "groupLabel" ? e[o] ?? e.label : e[o];
|
|
287
290
|
}
|
|
288
|
-
function
|
|
291
|
+
function he(e) {
|
|
289
292
|
const n = q(e);
|
|
290
|
-
|
|
293
|
+
V(t.multiple ? [n] : n), t.onChange?.([n], [e]);
|
|
291
294
|
}
|
|
292
|
-
function
|
|
293
|
-
return
|
|
295
|
+
function ve(e) {
|
|
296
|
+
return O.option ? v("div", {
|
|
294
297
|
class: f("custom")
|
|
295
|
-
}, [
|
|
298
|
+
}, [O.option(e)]) : v("span", {
|
|
296
299
|
class: f("label")
|
|
297
300
|
}, [m(e, e.options?.length ? "groupLabel" : "label")]);
|
|
298
301
|
}
|
|
299
|
-
const
|
|
300
|
-
const e =
|
|
301
|
-
return n.length > 0 && n.every((
|
|
302
|
-
}),
|
|
303
|
-
const e =
|
|
304
|
-
return
|
|
302
|
+
const ye = s(() => {
|
|
303
|
+
const e = l(p) || [], n = k.value;
|
|
304
|
+
return n.length > 0 && n.every((o) => b(e, o));
|
|
305
|
+
}), ge = s(() => {
|
|
306
|
+
const e = l(p) || [], n = k.value, o = n.filter((u) => b(e, u)).length;
|
|
307
|
+
return o > 0 && o < n.length;
|
|
305
308
|
});
|
|
306
309
|
function B(e, n) {
|
|
307
310
|
return (e.value ?? e) === n;
|
|
308
311
|
}
|
|
309
|
-
const
|
|
310
|
-
const n =
|
|
311
|
-
return
|
|
312
|
+
const Ce = (e) => {
|
|
313
|
+
const n = l(p), o = m(e, "value");
|
|
314
|
+
return $(n) ? !!n.find((u) => B(u, o)) : !1;
|
|
312
315
|
};
|
|
313
|
-
function
|
|
314
|
-
return e.find((
|
|
316
|
+
function b(e, n) {
|
|
317
|
+
return e.find((o) => B(o, n)) != null;
|
|
315
318
|
}
|
|
316
|
-
function
|
|
317
|
-
return e.findIndex((
|
|
319
|
+
function be(e, n) {
|
|
320
|
+
return e.findIndex((o) => B(o, n));
|
|
318
321
|
}
|
|
319
322
|
function q(e, n) {
|
|
320
|
-
const
|
|
323
|
+
const o = m(e, "label"), u = n ?? m(e, "value");
|
|
321
324
|
return t.labelInValue ? {
|
|
322
|
-
label: typeof
|
|
323
|
-
originLabel:
|
|
325
|
+
label: typeof o == "function" ? o() : o,
|
|
326
|
+
originLabel: o,
|
|
324
327
|
value: u,
|
|
325
328
|
key: e?.key ?? u
|
|
326
329
|
} : u;
|
|
327
330
|
}
|
|
328
|
-
function
|
|
329
|
-
const e = [...
|
|
330
|
-
n.length > 0 && n.every((a) =>
|
|
331
|
-
const h =
|
|
331
|
+
function we() {
|
|
332
|
+
const e = [...l(p) || []], n = k.value;
|
|
333
|
+
n.length > 0 && n.every((a) => b(e, a)) ? n.forEach((a) => {
|
|
334
|
+
const h = be(e, a);
|
|
332
335
|
~h && e.splice(h, 1);
|
|
333
336
|
}) : n.forEach((a) => {
|
|
334
|
-
if (
|
|
337
|
+
if (b(e, a))
|
|
335
338
|
return;
|
|
336
|
-
const h = c.value.find((
|
|
337
|
-
e.push(
|
|
339
|
+
const h = c.value.find((Oe) => m(Oe, "value") === a), Fe = q(h, a);
|
|
340
|
+
e.push(Fe);
|
|
338
341
|
});
|
|
339
|
-
const u = c.value.filter((a) =>
|
|
340
|
-
|
|
342
|
+
const u = c.value.filter((a) => b(e, m(a, "value")));
|
|
343
|
+
V([...e]), t.onChange?.([...e], u);
|
|
341
344
|
}
|
|
342
345
|
return J({
|
|
343
|
-
focus:
|
|
344
|
-
blur:
|
|
346
|
+
focus: pe,
|
|
347
|
+
blur: me,
|
|
345
348
|
request: d
|
|
346
|
-
}), (e, n) => e.mode === "read" ? (y(), T("span",
|
|
349
|
+
}), (e, n) => e.mode === "read" ? (y(), T("span", Ge, I(ie.value), 1)) : (y(), F(l(Te), Ne({
|
|
347
350
|
key: 1,
|
|
348
351
|
ref_key: "selectRef",
|
|
349
|
-
ref:
|
|
352
|
+
ref: x,
|
|
350
353
|
"allow-clear": ""
|
|
351
|
-
},
|
|
354
|
+
}, ce.value, {
|
|
352
355
|
mode: le.value,
|
|
353
|
-
value:
|
|
354
|
-
options:
|
|
356
|
+
value: l(p),
|
|
357
|
+
options: l(c),
|
|
355
358
|
loading: r.value,
|
|
356
|
-
"menu-item-selected-icon":
|
|
357
|
-
"popup-class-name": `${
|
|
358
|
-
"onUpdate:value":
|
|
359
|
-
onFocus:
|
|
360
|
-
onDropdownVisibleChange:
|
|
361
|
-
}),
|
|
362
|
-
option: g((
|
|
363
|
-
class:
|
|
364
|
-
}, [v(
|
|
359
|
+
"menu-item-selected-icon": Ie("span"),
|
|
360
|
+
"popup-class-name": `${l(S)("popup")} ${l(Y)}`,
|
|
361
|
+
"onUpdate:value": V,
|
|
362
|
+
onFocus: ae,
|
|
363
|
+
onDropdownVisibleChange: ue
|
|
364
|
+
}), Ae({
|
|
365
|
+
option: g((o) => [A("div", {
|
|
366
|
+
class: C(l(f)("outter"))
|
|
367
|
+
}, [v(l(E), {
|
|
365
368
|
justify: "space-between",
|
|
366
369
|
align: "center",
|
|
367
|
-
class:
|
|
370
|
+
class: C(l(f)("wrapper")),
|
|
368
371
|
gap: 8
|
|
369
372
|
}, {
|
|
370
|
-
default: g(() => [v(
|
|
373
|
+
default: g(() => [v(l(E), {
|
|
371
374
|
gap: 8,
|
|
372
375
|
align: "center",
|
|
373
|
-
class:
|
|
376
|
+
class: C(l(f)("content-wrapper"))
|
|
374
377
|
}, {
|
|
375
|
-
default: g(() => [P.value ? (y(),
|
|
378
|
+
default: g(() => [P.value ? (y(), F(l(U), {
|
|
376
379
|
key: 0,
|
|
377
|
-
checked:
|
|
378
|
-
}, null, 8, ["checked"])) : R("", !0), (y(),
|
|
380
|
+
checked: Ce(o)
|
|
381
|
+
}, null, 8, ["checked"])) : R("", !0), (y(), F(z(ve(o))))]),
|
|
379
382
|
_: 2
|
|
380
|
-
}, 1032, ["class"]),
|
|
383
|
+
}, 1032, ["class"]), fe.value && !o?.disabled ? (y(), T("span", {
|
|
381
384
|
key: 0,
|
|
382
|
-
class:
|
|
383
|
-
onClick:
|
|
384
|
-
},
|
|
385
|
+
class: C(l(f)("action")),
|
|
386
|
+
onClick: _e(() => he(o), ["stop"])
|
|
387
|
+
}, I(l(L)("ap.field.chooseOnly")), 11, Je)) : R("", !0)]),
|
|
385
388
|
_: 2
|
|
386
389
|
}, 1032, ["class"])], 2)]),
|
|
387
390
|
_: 2
|
|
388
|
-
}, [
|
|
391
|
+
}, [De(l(H)(O, ["option"]), (o, u) => ({
|
|
389
392
|
name: u,
|
|
390
|
-
fn: g((a) => [
|
|
393
|
+
fn: g((a) => [Me(e.$slots, u, Le(Pe(a || {})))])
|
|
391
394
|
})), r.value ? {
|
|
392
395
|
name: "notFoundContent",
|
|
393
|
-
fn: g(() => [v(
|
|
396
|
+
fn: g(() => [v(l(Re), {
|
|
394
397
|
size: "small"
|
|
395
398
|
})]),
|
|
396
399
|
key: "0"
|
|
397
400
|
} : void 0, P.value ? {
|
|
398
401
|
name: "dropdownRender",
|
|
399
402
|
fn: g(({
|
|
400
|
-
menuNode:
|
|
401
|
-
}) => [
|
|
403
|
+
menuNode: o
|
|
404
|
+
}) => [A("div", {
|
|
402
405
|
tabindex: -1,
|
|
403
|
-
class:
|
|
404
|
-
onClick:
|
|
405
|
-
}, [v(
|
|
406
|
-
checked:
|
|
407
|
-
indeterminate:
|
|
408
|
-
}, null, 8, ["checked", "indeterminate"]),
|
|
409
|
-
class:
|
|
410
|
-
},
|
|
406
|
+
class: C(l(S)("popup-all-option")),
|
|
407
|
+
onClick: we
|
|
408
|
+
}, [v(l(U), {
|
|
409
|
+
checked: ye.value,
|
|
410
|
+
indeterminate: ge.value
|
|
411
|
+
}, null, 8, ["checked", "indeterminate"]), A("span", {
|
|
412
|
+
class: C(l(S)("popup-all-option-label"))
|
|
413
|
+
}, I(l(L)("ap.field.selectAll")), 3)], 2), (y(), F(z(o)))]),
|
|
411
414
|
key: "1"
|
|
412
|
-
} : void 0]), 1040, ["mode", "value", "options", "loading", "menu-item-selected-icon", "popup-class-name"
|
|
415
|
+
} : void 0]), 1040, ["mode", "value", "options", "loading", "menu-item-selected-icon", "popup-class-name"]));
|
|
413
416
|
}
|
|
414
417
|
});
|
|
415
418
|
export {
|
|
416
|
-
|
|
419
|
+
ct as default
|
|
417
420
|
};
|
package/es/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "7.20.
|
|
1
|
+
declare const _default: "7.20.2";
|
|
2
2
|
export default _default;
|
package/es/src/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),f=require("@aplus-frontend/antdv"),r=require("lodash-unified");require("../../config-provider/index.js");require("../../utils/index.js");const se=require("../../utils/warning.js");require("../../hooks/index.js");const ce=require("../hooks/use-default-placeholder.js"),ie=require("../style/index.js"),de=require("./use-select-options.js"),F=require("../../utils/is.js"),I=require("../../config-provider/hooks/use-namespace.js"),fe=require("../../config-provider/hooks/use-locale.js"),pe=require("../../hooks/useControllableValue.js"),me={key:0},he=["onClick"],ve=e.defineComponent({name:"ApFieldSelect",__name:"index",props:{mode:{default:"edit"},class:{},style:{},emptyText:{default:"--"},customReadMode:{},defaultValue:{},notFoundContent:{},suffixIcon:{},itemIcon:{},size:{},bordered:{type:Boolean,default:void 0},showArrow:{type:Boolean,default:void 0},variant:{},maxCount:{},transitionName:{},choiceTransitionName:{},popupClassName:{},dropdownClassName:{},placement:{},status:{},children:{},listHeight:{},onMouseenter:{},onMouseleave:{},tabindex:{},onClick:{},onFocus:{},onBlur:{},onChange:{},onKeydown:{},onKeyup:{},onMousedown:{},onSelect:{},open:{type:Boolean,default:void 0},animation:{},direction:{},disabled:{type:Boolean,default:void 0},prefixCls:{},id:{},autofocus:{type:Boolean,default:void 0},getPopupContainer:{},virtual:{type:Boolean,default:void 0},dropdownMatchSelectWidth:{},placeholder:{},loading:{type:Boolean,default:void 0},prefix:{},clearIcon:{},allowClear:{type:Boolean,default:!0},fieldNames:{},inputValue:{},searchValue:{},autoClearSearchValue:{type:Boolean,default:void 0},onDeselect:{},onActive:{},filterOption:{},filterSort:{},optionFilterProp:{},optionLabelProp:{},options:{},defaultActiveFirstOption:{type:Boolean,default:void 0},listItemHeight:{},onClickOption:{},menuItemSelectedIcon:{},labelInValue:{type:Boolean,default:void 0},showSearch:{type:Boolean,default:void 0},tagRender:{},optionLabelRender:{},onClear:{},defaultOpen:{type:Boolean,default:void 0},onDropdownVisibleChange:{},maxTagTextLength:{},maxTagCount:{},maxTagPlaceholder:{},tokenSeparators:{},removeIcon:{},dropdownStyle:{},dropdownRender:{},dropdownAlign:{},showAction:{},onPopupScroll:{},onInputKeyDown:{},request:{},multiple:{type:Boolean,default:void 0},value:{},"onUpdate:value":{},searchMode:{default:"filter"},refetchOnFocus:{type:Boolean,default:!1},fetchOnFocus:{type:Boolean,default:void 0},fetchOnOpen:{type:Boolean},lazy:{type:[Boolean,String],default:!1},addAll:{type:[Boolean,Number],default:5},params:{},searchDelay:{default:300},allowOnlySelect:{type:Boolean,default:!0}},emits:["update:value"],setup(A,{expose:D,emit:_}){let c=0;const C=e.useSlots(),t=A,{deprecated:M}=se.useDevWarning("ApFieldSelect");M(!F.isDef(t.refetchOnFocus),"refetchOnFocus","fetchOnFocus");const{b}=I.useNamespace("field-select"),{b:p}=I.useNamespace("field-select-popup-option"),z=ie.default("field"),P=f.Form.useInjectFormItemContext(),S=e.ref(!1),B=e.ref(!1),{t:N}=fe.useLocale(),L=r.debounce(n=>{if(!r.isFunction(t.request))return;c+=1;const o=c;g([]),s.value=!0,t.request(n).then(l=>{c===o&&(g(l),s.value=!1)})},t.searchDelay),T=(n,o)=>{const l=t.fieldNames?.label||"label";return typeof o?.[l]=="string"&&o[l].toLowerCase().indexOf(n.toLowerCase())>-1},{options:i,updateOptions:g}=de.useSelectOptions(t),w=e.shallowRef(),s=e.ref(t?.loading||!1),R=_,E=e.computed(()=>t.fetchOnFocus??t.refetchOnFocus),U=e.computed(()=>{if(t.multiple)return t.tokenSeparators?"tags":"multiple"});async function d(n=!0){if(!r.isFunction(t.request))return;s.value=!0,c+=1;const o=c;try{n&&g([]);const l=await t.request(void 0,t.params);if(o!==c)return;g(l)}finally{s.value=!1}}function j(n){!S.value&&c===0&&t.lazy==="first-focus"?d():E.value&&!s.value&&d(!0),t.onFocus?.(n),S.value=!0}function K(n){if(!n){t.onDropdownVisibleChange?.(n);return}!B.value&&c===0&&t.lazy==="first-open"?d():t.fetchOnOpen&&!s.value&&d(!0),t.onDropdownVisibleChange?.(n),B.value=!0}function V(n){$(n),P?.onFieldChange()}e.onMounted(()=>{if(!t.lazy){d();return}}),e.watch(()=>t.params,()=>{d()},{deep:!0});const{value:m,updateValue:$}=pe.useControllableValue(t,R),H=ce.useDefaultPlaceholder("Select",t),W=e.computed(()=>{const n=e.unref(m);if(r.isNil(n))return t.emptyText;const o=t.fieldNames?.label||"label",l=t.fieldNames?.value||"value";return r.isArray(n)?n.map(a=>e.unref(i).find(v=>v[l]===a)?.[o]).filter(Boolean).join("、")||t.emptyText:e.unref(i).find(a=>a[l]===n)?.[o]||t.emptyText}),G=e.computed(()=>{const n=!!t?.showSearch,o=t.searchMode;let l={};return n&&(l=o==="request"?{defaultActiveFirstOption:!1,onSearch:L,notFoundContent:s.value?void 0:null,filterOption:!1,suffixIcon:null}:{filterOption:r.isNil(t?.filterOption)?T:t?.filterOption}),{...r.omit(t,["mode","value","onUpdate:value","onSearch","request","searchMode","onFocus","onBeforeSelect","onDropdownVisibleChange"]),placeholder:e.unref(H),...l}}),J=e.computed(()=>i.value.map(n=>n[t.fieldNames?.value||"value"])),k=e.computed(()=>i.value.filter(n=>!n.disabled).map(n=>n[t.fieldNames?.value||"value"])),O=e.computed(()=>!t.multiple||F.isDef(t.maxCount)?!1:r.isNumber(t.addAll)?J.value.length>=t.addAll:!!t.addAll),Q=e.computed(()=>t.multiple&&t.allowOnlySelect&&(!F.isDef(t.maxCount)||t.maxCount>=1));function X(){w.value?.focus()}function Y(){w.value?.blur()}function h(n,o){const l=t.fieldNames?.[o]??o;return l==="groupLabel"?n[l]??n.label:n[l]}function Z(n){const o=q(n);V(t.multiple?[o]:o),t.onChange?.([o],[n])}function ee(n){return C.option?e.createVNode("div",{class:p("custom")},[C.option(n)]):e.createVNode("span",{class:p("label")},[h(n,n.options?.length?"groupLabel":"label")])}const ne=e.computed(()=>{const n=e.unref(m)||[],o=k.value;return o.length>0&&o.every(l=>y(n,l))}),te=e.computed(()=>{const n=e.unref(m)||[],o=k.value,l=o.filter(u=>y(n,u)).length;return l>0&&l<o.length});function x(n,o){return(n.value??n)===o}const oe=n=>{const o=e.unref(m),l=h(n,"value");return r.isArray(o)?!!o.find(u=>x(u,l)):!1};function y(n,o){return n.find(l=>x(l,o))!=null}function le(n,o){return n.findIndex(l=>x(l,o))}function q(n,o){const l=h(n,"label"),u=o??h(n,"value");return t.labelInValue?{label:typeof l=="function"?l():l,originLabel:l,value:u,key:n?.key??u}:u}function ae(){const n=[...e.unref(m)||[]],o=k.value;o.length>0&&o.every(a=>y(n,a))?o.forEach(a=>{const v=le(n,a);~v&&n.splice(v,1)}):o.forEach(a=>{if(y(n,a))return;const v=i.value.find(re=>h(re,"value")===a),ue=q(v,a);n.push(ue)});const u=i.value.filter(a=>y(n,h(a,"value")));V([...n]),t.onChange?.([...n],u)}return D({focus:X,blur:Y,request:d}),(n,o)=>n.mode==="read"?(e.openBlock(),e.createElementBlock("span",me,e.toDisplayString(W.value),1)):(e.openBlock(),e.createBlock(e.unref(f.Select),e.mergeProps({key:1,ref_key:"selectRef",ref:w,"allow-clear":""},G.value,{mode:U.value,value:e.unref(m),options:e.unref(i),loading:s.value,"menu-item-selected-icon":e.h("span"),"popup-class-name":`${e.unref(b)("popup")} ${e.unref(z)}`,"onUpdate:value":V,onFocus:j,onDropdownVisibleChange:K}),e.createSlots({option:e.withCtx(l=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(p)("outter"))},[e.createVNode(e.unref(f.Flex),{justify:"space-between",align:"center",class:e.normalizeClass(e.unref(p)("wrapper")),gap:8},{default:e.withCtx(()=>[e.createVNode(e.unref(f.Flex),{gap:8,align:"center",class:e.normalizeClass(e.unref(p)("content-wrapper"))},{default:e.withCtx(()=>[O.value?(e.openBlock(),e.createBlock(e.unref(f.Checkbox),{key:0,checked:oe(l)},null,8,["checked"])):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(ee(l))))]),_:2},1032,["class"]),Q.value&&!l?.disabled?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(p)("action")),onClick:e.withModifiers(()=>Z(l),["stop"])},e.toDisplayString(e.unref(N)("ap.field.chooseOnly")),11,he)):e.createCommentVNode("",!0)]),_:2},1032,["class"])],2)]),_:2},[e.renderList(e.unref(r.omit)(C,["option"]),(l,u)=>({name:u,fn:e.withCtx(a=>[e.renderSlot(n.$slots,u,e.normalizeProps(e.guardReactiveProps(a||{})))])})),s.value?{name:"notFoundContent",fn:e.withCtx(()=>[e.createVNode(e.unref(f.Spin),{size:"small"})]),key:"0"}:void 0,O.value?{name:"dropdownRender",fn:e.withCtx(({menuNode:l})=>[e.createElementVNode("div",{tabindex:-1,class:e.normalizeClass(e.unref(b)("popup-all-option")),onClick:ae},[e.createVNode(e.unref(f.Checkbox),{checked:ne.value,indeterminate:te.value},null,8,["checked","indeterminate"]),e.createElementVNode("span",{class:e.normalizeClass(e.unref(b)("popup-all-option-label"))},e.toDisplayString(e.unref(N)("ap.field.selectAll")),3)],2),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l)))]),key:"1"}:void 0]),1040,["mode","value","options","loading","menu-item-selected-icon","popup-class-name"]))}});exports.default=ve;
|
package/lib/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "7.20.
|
|
1
|
+
declare const _default: "7.20.2";
|
|
2
2
|
export default _default;
|
package/lib/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="7.20.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="7.20.2";exports.default=e;
|