@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 Oe, useSlots as Se, ref as N, shallowRef as Fe, computed as s, onMounted as Ve, watch as ke, unref as o, createVNode as v, createElementBlock as T, createBlock as O, openBlock as y, toDisplayString as A, mergeProps as xe, h as Be, createSlots as Ne, withCtx as g, createElementVNode as I, normalizeClass as b, createCommentVNode as R, resolveDynamicComponent as z, withModifiers as Ae, renderList as Ie, renderSlot as _e, normalizeProps as De, guardReactiveProps as Me } from "vue";
2
- import { Select as Le, Flex as E, Checkbox as U, Spin as Pe } from "@aplus-frontend/antdv";
3
- import { debounce as qe, isFunction as K, isNil as $, isArray as j, omit as H, isNumber as Te } from "lodash-unified";
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 Re } from "../../utils/warning.mjs";
6
+ import { useDevWarning as Ue } from "../../utils/warning.mjs";
7
7
  import "../../hooks/index.mjs";
8
- import { useDefaultPlaceholder as ze } from "../hooks/use-default-placeholder.mjs";
9
- import Ee from "../style/index.mjs";
10
- import { useSelectOptions as Ue } from "./use-select-options.mjs";
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 Ke } from "../../config-provider/hooks/use-locale.mjs";
14
- import { useControllableValue as $e } from "../../hooks/useControllableValue.mjs";
15
- const je = {
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
- }, He = ["onClick"], st = /* @__PURE__ */ Oe({
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 S = Se(), t = G, {
189
+ const O = xe(), t = G, {
190
190
  deprecated: X
191
- } = Re("ApFieldSelect");
191
+ } = Ue("ApFieldSelect");
192
192
  X(!_(t.refetchOnFocus), "refetchOnFocus", "fetchOnFocus");
193
193
  const {
194
- b: F
194
+ b: S
195
195
  } = W("field-select"), {
196
196
  b: f
197
- } = W("field-select-popup-option"), Y = Ee("field"), D = N(!1), M = N(!1), {
197
+ } = W("field-select-popup-option"), Y = Ke("field"), Z = qe.useInjectFormItemContext(), D = N(!1), M = N(!1), {
198
198
  t: L
199
- } = Ke(), Z = qe((e) => {
200
- if (!K(t.request))
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((l) => {
205
- i === n && (w(l), r.value = !1);
204
+ w([]), r.value = !0, t.request(e).then((o) => {
205
+ i === n && (w(o), r.value = !1);
206
206
  });
207
- }, t.searchDelay), ee = (e, n) => {
208
- const l = t.fieldNames?.label || "label";
209
- return typeof n?.[l] == "string" && n[l].toLowerCase().indexOf(e.toLowerCase()) > -1;
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
- } = Ue(t), V = Fe(), r = N(t?.loading || !1), te = Q, ne = s(() => t.fetchOnFocus ?? t.refetchOnFocus), le = s(() => {
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 (!K(t.request))
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 l = await t.request(void 0, t.params);
224
+ const o = await t.request(void 0, t.params);
225
225
  if (n !== i)
226
226
  return;
227
- w(l);
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
- Ve(() => {
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
- }), ke(() => t.params, () => {
250
+ }), Be(() => t.params, () => {
248
251
  d();
249
252
  }, {
250
253
  deep: !0
251
254
  });
252
255
  const {
253
256
  value: p,
254
- updateValue: k
255
- } = $e(t, te), ue = ze("Select", t), se = s(() => {
256
- const e = o(p);
257
- if ($(e))
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", l = t.fieldNames?.value || "value";
260
- return j(e) ? e.map((a) => o(c).find((h) => h[l] === a)?.[n]).filter(Boolean).join("、") || t.emptyText : o(c).find((a) => a[l] === e)?.[n] || t.emptyText;
261
- }), re = s(() => {
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 l = {};
264
- return e && (l = n === "request" ? {
266
+ let o = {};
267
+ return e && (o = n === "request" ? {
265
268
  defaultActiveFirstOption: !1,
266
- onSearch: Z,
269
+ onSearch: ee,
267
270
  notFoundContent: r.value ? void 0 : null,
268
271
  filterOption: !1,
269
272
  suffixIcon: null
270
273
  } : {
271
- filterOption: $(t?.filterOption) ? ee : t?.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: o(ue),
275
- ...l
277
+ placeholder: l(re),
278
+ ...o
276
279
  };
277
- }), ie = s(() => c.value.map((e) => e[t.fieldNames?.value || "value"])), x = s(() => c.value.filter((e) => !e.disabled).map((e) => e[t.fieldNames?.value || "value"])), P = s(() => !t.multiple || _(t.maxCount) ? !1 : Te(t.addAll) ? ie.value.length >= t.addAll : !!t.addAll), ce = s(() => t.multiple && t.allowOnlySelect && (!_(t.maxCount) || t.maxCount >= 1));
278
- function de() {
279
- V.value?.focus();
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 fe() {
282
- V.value?.blur();
284
+ function me() {
285
+ x.value?.blur();
283
286
  }
284
287
  function m(e, n) {
285
- const l = t.fieldNames?.[n] ?? n;
286
- return l === "groupLabel" ? e[l] ?? e.label : e[l];
288
+ const o = t.fieldNames?.[n] ?? n;
289
+ return o === "groupLabel" ? e[o] ?? e.label : e[o];
287
290
  }
288
- function pe(e) {
291
+ function he(e) {
289
292
  const n = q(e);
290
- k(t.multiple ? [n] : n), t.onChange?.([n], [e]);
293
+ V(t.multiple ? [n] : n), t.onChange?.([n], [e]);
291
294
  }
292
- function me(e) {
293
- return S.option ? v("div", {
295
+ function ve(e) {
296
+ return O.option ? v("div", {
294
297
  class: f("custom")
295
- }, [S.option(e)]) : v("span", {
298
+ }, [O.option(e)]) : v("span", {
296
299
  class: f("label")
297
300
  }, [m(e, e.options?.length ? "groupLabel" : "label")]);
298
301
  }
299
- const he = s(() => {
300
- const e = o(p) || [], n = x.value;
301
- return n.length > 0 && n.every((l) => C(e, l));
302
- }), ve = s(() => {
303
- const e = o(p) || [], n = x.value, l = n.filter((u) => C(e, u)).length;
304
- return l > 0 && l < n.length;
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 ye = (e) => {
310
- const n = o(p), l = m(e, "value");
311
- return j(n) ? !!n.find((u) => B(u, l)) : !1;
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 C(e, n) {
314
- return e.find((l) => B(l, n)) != null;
316
+ function b(e, n) {
317
+ return e.find((o) => B(o, n)) != null;
315
318
  }
316
- function ge(e, n) {
317
- return e.findIndex((l) => B(l, n));
319
+ function be(e, n) {
320
+ return e.findIndex((o) => B(o, n));
318
321
  }
319
322
  function q(e, n) {
320
- const l = m(e, "label"), u = n ?? m(e, "value");
323
+ const o = m(e, "label"), u = n ?? m(e, "value");
321
324
  return t.labelInValue ? {
322
- label: typeof l == "function" ? l() : l,
323
- originLabel: l,
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 be() {
329
- const e = [...o(p) || []], n = x.value;
330
- n.length > 0 && n.every((a) => C(e, a)) ? n.forEach((a) => {
331
- const h = ge(e, a);
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 (C(e, a))
337
+ if (b(e, a))
335
338
  return;
336
- const h = c.value.find((we) => m(we, "value") === a), Ce = q(h, a);
337
- e.push(Ce);
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) => C(e, m(a, "value")));
340
- k([...e]), t.onChange?.([...e], u);
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: de,
344
- blur: fe,
346
+ focus: pe,
347
+ blur: me,
345
348
  request: d
346
- }), (e, n) => e.mode === "read" ? (y(), T("span", je, A(se.value), 1)) : (y(), O(o(Le), xe({
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: V,
352
+ ref: x,
350
353
  "allow-clear": ""
351
- }, re.value, {
354
+ }, ce.value, {
352
355
  mode: le.value,
353
- value: o(p),
354
- options: o(c),
356
+ value: l(p),
357
+ options: l(c),
355
358
  loading: r.value,
356
- "menu-item-selected-icon": Be("span"),
357
- "popup-class-name": `${o(F)("popup")} ${o(Y)}`,
358
- "onUpdate:value": o(k),
359
- onFocus: oe,
360
- onDropdownVisibleChange: ae
361
- }), Ne({
362
- option: g((l) => [I("div", {
363
- class: b(o(f)("outter"))
364
- }, [v(o(E), {
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: b(o(f)("wrapper")),
370
+ class: C(l(f)("wrapper")),
368
371
  gap: 8
369
372
  }, {
370
- default: g(() => [v(o(E), {
373
+ default: g(() => [v(l(E), {
371
374
  gap: 8,
372
375
  align: "center",
373
- class: b(o(f)("content-wrapper"))
376
+ class: C(l(f)("content-wrapper"))
374
377
  }, {
375
- default: g(() => [P.value ? (y(), O(o(U), {
378
+ default: g(() => [P.value ? (y(), F(l(U), {
376
379
  key: 0,
377
- checked: ye(l)
378
- }, null, 8, ["checked"])) : R("", !0), (y(), O(z(me(l))))]),
380
+ checked: Ce(o)
381
+ }, null, 8, ["checked"])) : R("", !0), (y(), F(z(ve(o))))]),
379
382
  _: 2
380
- }, 1032, ["class"]), ce.value && !l?.disabled ? (y(), T("span", {
383
+ }, 1032, ["class"]), fe.value && !o?.disabled ? (y(), T("span", {
381
384
  key: 0,
382
- class: b(o(f)("action")),
383
- onClick: Ae(() => pe(l), ["stop"])
384
- }, A(o(L)("ap.field.chooseOnly")), 11, He)) : R("", !0)]),
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
- }, [Ie(o(H)(S, ["option"]), (l, u) => ({
391
+ }, [De(l(H)(O, ["option"]), (o, u) => ({
389
392
  name: u,
390
- fn: g((a) => [_e(e.$slots, u, De(Me(a || {})))])
393
+ fn: g((a) => [Me(e.$slots, u, Le(Pe(a || {})))])
391
394
  })), r.value ? {
392
395
  name: "notFoundContent",
393
- fn: g(() => [v(o(Pe), {
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: l
401
- }) => [I("div", {
403
+ menuNode: o
404
+ }) => [A("div", {
402
405
  tabindex: -1,
403
- class: b(o(F)("popup-all-option")),
404
- onClick: be
405
- }, [v(o(U), {
406
- checked: he.value,
407
- indeterminate: ve.value
408
- }, null, 8, ["checked", "indeterminate"]), I("span", {
409
- class: b(o(F)("popup-all-option-label"))
410
- }, A(o(L)("ap.field.selectAll")), 3)], 2), (y(), O(z(l)))]),
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", "onUpdate:value"]));
415
+ } : void 0]), 1040, ["mode", "value", "options", "loading", "menu-item-selected-icon", "popup-class-name"]));
413
416
  }
414
417
  });
415
418
  export {
416
- st as default
419
+ ct as default
417
420
  };
@@ -1,2 +1,2 @@
1
- declare const _default: "7.20.1";
1
+ declare const _default: "7.20.2";
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
- const e = "7.20.1";
1
+ const e = "7.20.2";
2
2
  export {
3
3
  e as default
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),v=require("@aplus-frontend/antdv"),r=require("lodash-unified");require("../../config-provider/index.js");require("../../utils/index.js");const ue=require("../../utils/warning.js");require("../../hooks/index.js");const re=require("../hooks/use-default-placeholder.js"),se=require("../style/index.js"),ce=require("./use-select-options.js"),x=require("../../utils/is.js"),A=require("../../config-provider/hooks/use-namespace.js"),ie=require("../../config-provider/hooks/use-locale.js"),de=require("../../hooks/useControllableValue.js"),fe={key:0},pe=["onClick"],me=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(D,{expose:I,emit:_}){let c=0;const C=e.useSlots(),t=D,{deprecated:M}=ue.useDevWarning("ApFieldSelect");M(!x.isDef(t.refetchOnFocus),"refetchOnFocus","fetchOnFocus");const{b}=A.useNamespace("field-select"),{b:f}=A.useNamespace("field-select-popup-option"),z=se.default("field"),B=e.ref(!1),N=e.ref(!1),{t:O}=ie.useLocale(),P=r.debounce(n=>{if(!r.isFunction(t.request))return;c+=1;const l=c;g([]),s.value=!0,t.request(n).then(o=>{c===l&&(g(o),s.value=!1)})},t.searchDelay),L=(n,l)=>{const o=t.fieldNames?.label||"label";return typeof l?.[o]=="string"&&l[o].toLowerCase().indexOf(n.toLowerCase())>-1},{options:i,updateOptions:g}=ce.useSelectOptions(t),w=e.shallowRef(),s=e.ref(t?.loading||!1),T=_,R=e.computed(()=>t.fetchOnFocus??t.refetchOnFocus),E=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 l=c;try{n&&g([]);const o=await t.request(void 0,t.params);if(l!==c)return;g(o)}finally{s.value=!1}}function U(n){!B.value&&c===0&&t.lazy==="first-focus"?d():R.value&&!s.value&&d(!0),t.onFocus?.(n),B.value=!0}function j(n){if(!n){t.onDropdownVisibleChange?.(n);return}!N.value&&c===0&&t.lazy==="first-open"?d():t.fetchOnOpen&&!s.value&&d(!0),t.onDropdownVisibleChange?.(n),N.value=!0}e.onMounted(()=>{if(!t.lazy){d();return}}),e.watch(()=>t.params,()=>{d()},{deep:!0});const{value:p,updateValue:k}=de.useControllableValue(t,T),K=re.useDefaultPlaceholder("Select",t),$=e.computed(()=>{const n=e.unref(p);if(r.isNil(n))return t.emptyText;const l=t.fieldNames?.label||"label",o=t.fieldNames?.value||"value";return r.isArray(n)?n.map(a=>e.unref(i).find(h=>h[o]===a)?.[l]).filter(Boolean).join("、")||t.emptyText:e.unref(i).find(a=>a[o]===n)?.[l]||t.emptyText}),H=e.computed(()=>{const n=!!t?.showSearch,l=t.searchMode;let o={};return n&&(o=l==="request"?{defaultActiveFirstOption:!1,onSearch:P,notFoundContent:s.value?void 0:null,filterOption:!1,suffixIcon:null}:{filterOption:r.isNil(t?.filterOption)?L:t?.filterOption}),{...r.omit(t,["mode","value","onUpdate:value","onSearch","request","searchMode","onFocus","onBeforeSelect","onDropdownVisibleChange"]),placeholder:e.unref(K),...o}}),W=e.computed(()=>i.value.map(n=>n[t.fieldNames?.value||"value"])),V=e.computed(()=>i.value.filter(n=>!n.disabled).map(n=>n[t.fieldNames?.value||"value"])),F=e.computed(()=>!t.multiple||x.isDef(t.maxCount)?!1:r.isNumber(t.addAll)?W.value.length>=t.addAll:!!t.addAll),G=e.computed(()=>t.multiple&&t.allowOnlySelect&&(!x.isDef(t.maxCount)||t.maxCount>=1));function J(){w.value?.focus()}function Q(){w.value?.blur()}function m(n,l){const o=t.fieldNames?.[l]??l;return o==="groupLabel"?n[o]??n.label:n[o]}function X(n){const l=q(n);k(t.multiple?[l]:l),t.onChange?.([l],[n])}function Y(n){return C.option?e.createVNode("div",{class:f("custom")},[C.option(n)]):e.createVNode("span",{class:f("label")},[m(n,n.options?.length?"groupLabel":"label")])}const Z=e.computed(()=>{const n=e.unref(p)||[],l=V.value;return l.length>0&&l.every(o=>y(n,o))}),ee=e.computed(()=>{const n=e.unref(p)||[],l=V.value,o=l.filter(u=>y(n,u)).length;return o>0&&o<l.length});function S(n,l){return(n.value??n)===l}const ne=n=>{const l=e.unref(p),o=m(n,"value");return r.isArray(l)?!!l.find(u=>S(u,o)):!1};function y(n,l){return n.find(o=>S(o,l))!=null}function te(n,l){return n.findIndex(o=>S(o,l))}function q(n,l){const o=m(n,"label"),u=l??m(n,"value");return t.labelInValue?{label:typeof o=="function"?o():o,originLabel:o,value:u,key:n?.key??u}:u}function le(){const n=[...e.unref(p)||[]],l=V.value;l.length>0&&l.every(a=>y(n,a))?l.forEach(a=>{const h=te(n,a);~h&&n.splice(h,1)}):l.forEach(a=>{if(y(n,a))return;const h=i.value.find(ae=>m(ae,"value")===a),oe=q(h,a);n.push(oe)});const u=i.value.filter(a=>y(n,m(a,"value")));k([...n]),t.onChange?.([...n],u)}return I({focus:J,blur:Q,request:d}),(n,l)=>n.mode==="read"?(e.openBlock(),e.createElementBlock("span",fe,e.toDisplayString($.value),1)):(e.openBlock(),e.createBlock(e.unref(v.Select),e.mergeProps({key:1,ref_key:"selectRef",ref:w,"allow-clear":""},H.value,{mode:E.value,value:e.unref(p),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":e.unref(k),onFocus:U,onDropdownVisibleChange:j}),e.createSlots({option:e.withCtx(o=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(f)("outter"))},[e.createVNode(e.unref(v.Flex),{justify:"space-between",align:"center",class:e.normalizeClass(e.unref(f)("wrapper")),gap:8},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Flex),{gap:8,align:"center",class:e.normalizeClass(e.unref(f)("content-wrapper"))},{default:e.withCtx(()=>[F.value?(e.openBlock(),e.createBlock(e.unref(v.Checkbox),{key:0,checked:ne(o)},null,8,["checked"])):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(Y(o))))]),_:2},1032,["class"]),G.value&&!o?.disabled?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(f)("action")),onClick:e.withModifiers(()=>X(o),["stop"])},e.toDisplayString(e.unref(O)("ap.field.chooseOnly")),11,pe)):e.createCommentVNode("",!0)]),_:2},1032,["class"])],2)]),_:2},[e.renderList(e.unref(r.omit)(C,["option"]),(o,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(v.Spin),{size:"small"})]),key:"0"}:void 0,F.value?{name:"dropdownRender",fn:e.withCtx(({menuNode:o})=>[e.createElementVNode("div",{tabindex:-1,class:e.normalizeClass(e.unref(b)("popup-all-option")),onClick:le},[e.createVNode(e.unref(v.Checkbox),{checked:Z.value,indeterminate:ee.value},null,8,["checked","indeterminate"]),e.createElementVNode("span",{class:e.normalizeClass(e.unref(b)("popup-all-option-label"))},e.toDisplayString(e.unref(O)("ap.field.selectAll")),3)],2),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o)))]),key:"1"}:void 0]),1040,["mode","value","options","loading","menu-item-selected-icon","popup-class-name","onUpdate:value"]))}});exports.default=me;
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;
@@ -1,2 +1,2 @@
1
- declare const _default: "7.20.1";
1
+ declare const _default: "7.20.2";
2
2
  export default _default;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="7.20.1";exports.default=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="7.20.2";exports.default=e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aplus-frontend/ui",
3
- "version": "7.20.1",
3
+ "version": "7.20.2",
4
4
  "main": "./lib/index.js",
5
5
  "type": "module",
6
6
  "typings": "./lib/index.d.ts",