@vue-ui-kit/ant 2.4.4 → 2.4.5

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.
package/dist/es/index.js CHANGED
@@ -3452,7 +3452,7 @@ function Xa(e, t) {
3452
3452
  let n = e.getBoundingClientRect(), r = window.innerWidth, i = window.innerHeight, a = Math.max(0, r - n.left - t.right), o = Math.max(0, i - n.top - t.bottom), s = e.parentElement;
3453
3453
  if (s) {
3454
3454
  let e = s.getBoundingClientRect();
3455
- e.width > 0 && (a = Math.min(a, e.width)), e.height > 0 && (o = Math.min(o, e.height));
3455
+ e.width > 0 && (a = Math.min(a, e.width));
3456
3456
  }
3457
3457
  e.style.width = `${a}px`, e.style.height = `${o}px`;
3458
3458
  }
@@ -3488,13 +3488,13 @@ function Qa(e, t, n) {
3488
3488
  var $a = { key: 0 }, eo = {
3489
3489
  key: 1,
3490
3490
  class: "p-toolbar-wrapper flex items-center w-full justify-between p-theme-bg pt-8px px-16px"
3491
- }, to = { class: "flex items-center flex-1 gap-4px" }, no = { key: 2 }, ro = { class: "flex items-center gap-4px" }, io = { class: "p-grid-table-body flex-1 min-h-0 overflow-hidden" }, ao = {
3491
+ }, to = { class: "flex items-center flex-1 gap-4px" }, no = { key: 2 }, ro = { class: "flex items-center gap-4px" }, io = {
3492
3492
  key: 0,
3493
3493
  class: "w-full pt-8px px-16px text-slate-5"
3494
- }, oo = {
3494
+ }, ao = {
3495
3495
  key: 1,
3496
3496
  class: "flex w-full items-center gap-12px pt-8px px-16px"
3497
- }, so = { class: "flex-1 min-w-0 text-slate-5 flex items-center" }, co = /* @__PURE__ */ l({
3497
+ }, oo = { class: "flex-1 min-w-0 text-slate-5 flex items-center" }, so = /* @__PURE__ */ l({
3498
3498
  __name: "PGrid",
3499
3499
  props: {
3500
3500
  selectConfig: {},
@@ -3523,7 +3523,11 @@ var $a = { key: 0 }, eo = {
3523
3523
  },
3524
3524
  fitHeight: { default: () => ca().fitHeight ?? 30 },
3525
3525
  fitCanvasHeight: {},
3526
- renderY: {}
3526
+ renderY: {},
3527
+ fitContent: {
3528
+ type: Boolean,
3529
+ default: !1
3530
+ }
3527
3531
  },
3528
3532
  emits: [
3529
3533
  "toolbarButtonClick",
@@ -3681,6 +3685,11 @@ var $a = { key: 0 }, eo = {
3681
3685
  le.value = f.renderY;
3682
3686
  return;
3683
3687
  }
3688
+ if (f.fitContent) {
3689
+ let e = typeof window < "u" ? window.innerHeight : 800, t = f.fitHeight ?? 30;
3690
+ le.value = Math.max(Math.floor(e * .6) - t, 160);
3691
+ return;
3692
+ }
3684
3693
  let e = se.value.clientHeight, t = ce.value?.offsetHeight ?? 0, n = Ge(se.value)?.getBoundingClientRect().height ?? 0, r = f.fitHeight ?? 30;
3685
3694
  le.value = Math.max(e - t - n - r, 100);
3686
3695
  });
@@ -3736,7 +3745,7 @@ var $a = { key: 0 }, eo = {
3736
3745
  return b(), i("div", p({
3737
3746
  ref_key: "boxEl",
3738
3747
  ref: ie,
3739
- class: ["p-wrapper flex flex-col gap-8px overflow-y-auto", l.autoBoxSize ? "min-h-0 min-w-0 flex-1 w-full" : "h-full"]
3748
+ class: ["p-wrapper flex flex-col gap-8px", l.fitContent ? "w-full h-auto" : l.autoBoxSize ? "overflow-y-auto min-h-0 min-w-0 flex-1 w-full" : "overflow-y-auto h-full"]
3740
3749
  }, A(ke)), [Te.value === "bad" ? (b(), i("div", $a, "请检查配置")) : (b(), i(e, { key: 1 }, [
3741
3750
  A(g)?.items?.some((e) => e.field && e.itemRender) ? (b(), i("div", {
3742
3751
  key: 0,
@@ -3860,8 +3869,8 @@ var $a = { key: 0 }, eo = {
3860
3869
  a("div", {
3861
3870
  ref_key: "tableWrapperEl",
3862
3871
  ref: se,
3863
- class: h(`p-pane flex-1 h-0 min-h-0 flex flex-col p-${A(te) ?? "inner"}-scroll`)
3864
- }, [a("div", io, [(b(), n(A(xe), p({
3872
+ class: h(l.fitContent ? "p-pane" : `p-pane flex-1 h-0 min-h-0 flex flex-col p-${A(te) ?? "inner"}-scroll`)
3873
+ }, [a("div", { class: h(l.fitContent ? "p-grid-table-body" : "p-grid-table-body flex-1 min-h-0 overflow-hidden") }, [(b(), n(A(xe), p({
3865
3874
  key: ge.value + "_table",
3866
3875
  "row-key": l.rowKey ?? "id",
3867
3876
  ref_key: "tableEl",
@@ -3908,11 +3917,11 @@ var $a = { key: 0 }, eo = {
3908
3917
  "data-source",
3909
3918
  "loading",
3910
3919
  "scroll"
3911
- ]))]), a("div", {
3920
+ ]))], 2), a("div", {
3912
3921
  ref_key: "tableFooterEl",
3913
3922
  ref: ce,
3914
3923
  class: "flex-shrink-0"
3915
- }, [Te.value !== "pagination" && De.value ? (b(), i("div", ao, " 已选:" + D(R.value.length), 1)) : Te.value === "pagination" ? (b(), i("div", oo, [a("div", so, [De.value ? (b(), i(e, { key: 0 }, [s(" 已选:" + D(R.value.length), 1)], 64)) : r("", !0)]), c(v, {
3924
+ }, [Te.value !== "pagination" && De.value ? (b(), i("div", io, " 已选:" + D(R.value.length), 1)) : Te.value === "pagination" ? (b(), i("div", ao, [a("div", oo, [De.value ? (b(), i(e, { key: 0 }, [s(" 已选:" + D(R.value.length), 1)], 64)) : r("", !0)]), c(v, {
3916
3925
  size: "small",
3917
3926
  responsive: !1,
3918
3927
  "show-size-changer": !0,
@@ -3930,7 +3939,7 @@ var $a = { key: 0 }, eo = {
3930
3939
  ], 64))], 16);
3931
3940
  };
3932
3941
  }
3933
- }), lo = /* @__PURE__ */ Re((/* @__PURE__ */ H(((e, t) => {
3942
+ }), co = /* @__PURE__ */ Re((/* @__PURE__ */ H(((e, t) => {
3934
3943
  (function() {
3935
3944
  try {
3936
3945
  if (typeof document < "u") {
@@ -10142,7 +10151,7 @@ var $a = { key: 0 }, eo = {
10142
10151
  }
10143
10152
  return $t;
10144
10153
  });
10145
- })))(), 1), uo = /* @__PURE__ */ l((e, { emit: t }) => {
10154
+ })))(), 1), lo = /* @__PURE__ */ l((e, { emit: t }) => {
10146
10155
  let { cellRender: n, renderTableParams: r } = e, { row: i, field: a } = r;
10147
10156
  if (a) {
10148
10157
  let e = S(i[a]);
@@ -10152,7 +10161,7 @@ var $a = { key: 0 }, eo = {
10152
10161
  name: "RenderEditCell",
10153
10162
  props: ["cellRender", "renderTableParams"],
10154
10163
  emits: ["blur"]
10155
- }), fo = /* @__PURE__ */ l({
10164
+ }), uo = /* @__PURE__ */ l({
10156
10165
  __name: "PCanvasTable",
10157
10166
  props: {
10158
10167
  columns: {},
@@ -10211,7 +10220,7 @@ var $a = { key: 0 }, eo = {
10211
10220
  children: e.children?.map((e) => ce(e))
10212
10221
  });
10213
10222
  y(() => {
10214
- D.value && (v = new lo.default(D.value, {
10223
+ D.value && (v = new co.default(D.value, {
10215
10224
  config: g.value.config,
10216
10225
  columns: f.columns.map((e) => ce(e)),
10217
10226
  data: f.data,
@@ -10287,7 +10296,7 @@ var $a = { key: 0 }, eo = {
10287
10296
  "style",
10288
10297
  "value",
10289
10298
  "cell"
10290
- ])) : A(Fa).renders[P.value]?.renderEdit ? (b(), n(A(uo), {
10299
+ ])) : A(Fa).renders[P.value]?.renderEdit ? (b(), n(A(lo), {
10291
10300
  key: 1,
10292
10301
  "cell-render": ne[M.value.key],
10293
10302
  class: "ev-editor-wrapper",
@@ -10337,13 +10346,13 @@ var $a = { key: 0 }, eo = {
10337
10346
  }, 8, ["spinning"]);
10338
10347
  };
10339
10348
  }
10340
- }), po = { key: 0 }, mo = {
10349
+ }), fo = { key: 0 }, po = {
10341
10350
  key: 1,
10342
10351
  class: "p-canvas-toolbar-wrapper flex items-center w-full justify-between p-theme-bg pt-8px px-16px"
10343
- }, ho = { class: "flex items-center flex-1 gap-4px" }, go = { key: 2 }, _o = { class: "flex items-center gap-4px" }, vo = {
10352
+ }, mo = { class: "flex items-center flex-1 gap-4px" }, ho = { key: 2 }, go = { class: "flex items-center gap-4px" }, _o = {
10344
10353
  key: 0,
10345
10354
  class: "w-full text-slate-5 pl-4"
10346
- }, yo = /* @__PURE__ */ l({
10355
+ }, vo = /* @__PURE__ */ l({
10347
10356
  __name: "PCanvasGrid",
10348
10357
  props: {
10349
10358
  staticConfig: {},
@@ -10549,7 +10558,7 @@ var $a = { key: 0 }, eo = {
10549
10558
  ref_key: "boxEl",
10550
10559
  ref: _e,
10551
10560
  class: "h-full p-wrapper flex flex-col gap-8px overflow-y-auto"
10552
- }, A(_)), [ce.value === "bad" ? (b(), i("div", po, "请检查配置")) : (b(), i(e, { key: 1 }, [
10561
+ }, A(_)), [ce.value === "bad" ? (b(), i("div", fo, "请检查配置")) : (b(), i(e, { key: 1 }, [
10553
10562
  A(k)?.items?.some((e) => e.field && e.itemRender) ? (b(), i("div", {
10554
10563
  key: 0,
10555
10564
  class: "p-pane p-form-wrapper",
@@ -10575,7 +10584,7 @@ var $a = { key: 0 }, eo = {
10575
10584
  }, 16, ["model"]))]),
10576
10585
  _: 1
10577
10586
  }, 8, ["spinning"])], 512)) : r("", !0),
10578
- A(P) ? (b(), i("div", mo, [a("div", ho, [A(P).buttons && A(P).buttons.length > 0 ? (b(!0), i(e, { key: 0 }, C(A(P).buttons, (t, a) => (b(), i(e, { key: a }, [t.dropdowns && t.dropdowns.length ? (b(), n(v, { key: 0 }, {
10587
+ A(P) ? (b(), i("div", po, [a("div", mo, [A(P).buttons && A(P).buttons.length > 0 ? (b(!0), i(e, { key: 0 }, C(A(P).buttons, (t, a) => (b(), i(e, { key: a }, [t.dropdowns && t.dropdowns.length ? (b(), n(v, { key: 0 }, {
10579
10588
  overlay: F(() => [c(f, { onClick: je }, {
10580
10589
  default: F(() => [(b(!0), i(e, null, C(t.dropdowns, (e) => (b(), n(d, { key: e.code }, {
10581
10590
  default: F(() => [s(D(e.content), 1)]),
@@ -10640,7 +10649,7 @@ var $a = { key: 0 }, eo = {
10640
10649
  "ghost",
10641
10650
  "block",
10642
10651
  "onClick"
10643
- ])) : (b(), i("div", go))], 64))), 128)) : r("", !0)]), a("span", _o, [A(P).tools && A(P).tools.length > 0 ? (b(!0), i(e, { key: 0 }, C(A(P).tools, (e, t) => (b(), n(A(I), {
10652
+ ])) : (b(), i("div", ho))], 64))), 128)) : r("", !0)]), a("span", go, [A(P).tools && A(P).tools.length > 0 ? (b(!0), i(e, { key: 0 }, C(A(P).tools, (e, t) => (b(), n(A(I), {
10644
10653
  key: t,
10645
10654
  type: e.type,
10646
10655
  size: e.size ?? "middle",
@@ -10673,8 +10682,8 @@ var $a = { key: 0 }, eo = {
10673
10682
  ref: be,
10674
10683
  class: h("p-pane flex-1 h-0 p-inner-scroll")
10675
10684
  }, [
10676
- A(L)?.selectable && A(L).showCount ? (b(), i("div", vo, " 已选:" + D(De.value.length), 1)) : r("", !0),
10677
- c(fo, {
10685
+ A(L)?.selectable && A(L).showCount ? (b(), i("div", _o, " 已选:" + D(De.value.length), 1)) : r("", !0),
10686
+ c(uo, {
10678
10687
  ref_key: "canvasTableRef",
10679
10688
  ref: ge,
10680
10689
  columns: ze.value,
@@ -10711,7 +10720,7 @@ var $a = { key: 0 }, eo = {
10711
10720
  ], 64))], 16);
10712
10721
  };
10713
10722
  }
10714
- }), bo = /* @__PURE__ */ l({
10723
+ }), yo = /* @__PURE__ */ l({
10715
10724
  __name: "PGroupBlock",
10716
10725
  props: {
10717
10726
  name: {},
@@ -10726,7 +10735,7 @@ var $a = { key: 0 }, eo = {
10726
10735
  ref: a
10727
10736
  }, c.value, { data: A(o) }), null, 16, ["name", "data"]));
10728
10737
  }
10729
- }), xo = /* @__PURE__ */ l({
10738
+ }), bo = /* @__PURE__ */ l({
10730
10739
  __name: "CollapseCard",
10731
10740
  props: {
10732
10741
  defaultCollapsed: {
@@ -10775,7 +10784,7 @@ var $a = { key: 0 }, eo = {
10775
10784
  }))]), 1032, ["title"]));
10776
10785
  };
10777
10786
  }
10778
- }), So = /* @__PURE__ */ l({
10787
+ }), xo = /* @__PURE__ */ l({
10779
10788
  __name: "PFormGroup",
10780
10789
  props: /* @__PURE__ */ f({
10781
10790
  name: {},
@@ -10913,7 +10922,7 @@ var $a = { key: 0 }, eo = {
10913
10922
  })));
10914
10923
  return (t, u) => {
10915
10924
  let d = T("a-spin");
10916
- return b(), n(xo, {
10925
+ return b(), n(bo, {
10917
10926
  ref_key: "rootRef",
10918
10927
  ref: h,
10919
10928
  title: l.title,
@@ -10964,7 +10973,7 @@ var $a = { key: 0 }, eo = {
10964
10973
  default: F(() => [c(A(Ae))]),
10965
10974
  _: 2
10966
10975
  }, 1024)) : r("", !0)]),
10967
- default: F(() => [(b(), n(bo, {
10976
+ default: F(() => [(b(), n(yo, {
10968
10977
  ref_for: !0,
10969
10978
  ref_key: "blockInstance",
10970
10979
  ref: y,
@@ -10996,7 +11005,7 @@ var $a = { key: 0 }, eo = {
10996
11005
  ]);
10997
11006
  };
10998
11007
  }
10999
- }), Co = { class: "w-full text-right p-2" }, wo = /* @__PURE__ */ l({
11008
+ }), So = { class: "w-full text-right p-2" }, Co = /* @__PURE__ */ l({
11000
11009
  __name: "PromisePicker",
11001
11010
  props: {
11002
11011
  gridSetting: {},
@@ -11013,65 +11022,70 @@ var $a = { key: 0 }, eo = {
11013
11022
  }
11014
11023
  },
11015
11024
  setup(e, { expose: r }) {
11016
- let i = S(), l = S(!1), u = e, d = t(() => u.gridSetting.selectConfig?.multiple), f, h, g, v = x({ modal: !1 }), C = () => {
11025
+ let i = S(), l = e, u = t(() => l.gridSetting.selectConfig?.multiple), d = t(() => ({
11026
+ fitContent: !0,
11027
+ ...l.gridSetting
11028
+ })), f = {
11029
+ display: "flex",
11030
+ flexDirection: "column",
11031
+ minHeight: 0,
11032
+ maxHeight: "min(80dvh, calc(100dvh - 200px))",
11033
+ overflow: "hidden"
11034
+ }, m, h, g, _ = x({ modal: !1 }), v = () => {
11017
11035
  g && g();
11018
- }, w = () => {
11019
- v.modal = !1, g && g();
11020
- }, T = ({ row: e, field: t }) => {
11021
- f && !d.value && u.beforePick(e).then(() => {
11022
- v.modal = !1, f({
11036
+ }, y = () => {
11037
+ _.modal = !1, g && g();
11038
+ }, C = ({ row: e, field: t }) => {
11039
+ m && !u.value && l.beforePick(e).then(() => {
11040
+ _.modal = !1, m({
11023
11041
  row: e,
11024
11042
  field: t
11025
11043
  });
11026
11044
  });
11027
- }, E = () => {
11045
+ }, w = () => {
11028
11046
  let e = i.value?.selectedRecords ?? [];
11029
- e.length === 0 && !u.multipleAllowEmpty ? Ka("请选择数据") : u.beforePick(e).then(() => {
11030
- v.modal = !1, h(e);
11047
+ e.length === 0 && !l.multipleAllowEmpty ? Ka("请选择数据") : l.beforePick(e).then(() => {
11048
+ _.modal = !1, h(e);
11031
11049
  });
11032
11050
  };
11033
- return y(() => {}), r({
11051
+ return r({
11034
11052
  pick: () => new Promise((e, t) => {
11035
- f = e, g = t, l.value = !1, v.modal = !0, m(() => {
11036
- l.value = !0;
11037
- });
11053
+ m = e, g = t, _.modal = !0;
11038
11054
  }),
11039
11055
  pickMultiple: () => new Promise((e, t) => {
11040
- h = e, g = t, l.value = !1, v.modal = !0, m(() => {
11041
- l.value = !0;
11042
- });
11056
+ h = e, g = t, _.modal = !0;
11043
11057
  }),
11044
11058
  grid: i,
11045
11059
  hide: () => {
11046
- v.modal = !1;
11060
+ _.modal = !1;
11047
11061
  }
11048
11062
  }), (t, r) => (b(), n(A(ue), {
11049
- open: v.modal,
11050
- "onUpdate:open": r[0] ||= (e) => v.modal = e,
11063
+ open: _.modal,
11064
+ "onUpdate:open": r[0] ||= (e) => _.modal = e,
11051
11065
  "destroy-on-close": "",
11052
11066
  title: e.title,
11053
11067
  width: e.width,
11054
- footer: d.value ? void 0 : null,
11055
- onCancel: C,
11068
+ footer: u.value ? void 0 : null,
11069
+ onCancel: v,
11056
11070
  "body-style": e.bodyStyle
11057
11071
  }, o({
11058
- default: F(() => [a("div", { style: _({ minHeight: l.value ? "unset" : "642px" }) }, [c(co, p(e.gridSetting, {
11072
+ default: F(() => [a("div", { style: f }, [c(so, p(d.value, {
11059
11073
  ref_key: "gridEl",
11060
11074
  ref: i,
11061
- onPick: T
11062
- }), null, 16)], 4)]),
11075
+ onPick: C
11076
+ }), null, 16)])]),
11063
11077
  _: 2
11064
- }, [d.value ? {
11078
+ }, [u.value ? {
11065
11079
  name: "footer",
11066
- fn: F(() => [a("div", Co, [a("span", null, [c(A(I), {
11080
+ fn: F(() => [a("div", So, [a("span", null, [c(A(I), {
11067
11081
  class: "mr-4",
11068
- onClick: w
11082
+ onClick: y
11069
11083
  }, {
11070
11084
  default: F(() => [...r[1] ||= [s(" 取消 ", -1)]]),
11071
11085
  _: 1
11072
11086
  }), c(A(I), {
11073
11087
  type: "primary",
11074
- onClick: E
11088
+ onClick: w
11075
11089
  }, {
11076
11090
  default: F(() => [...r[2] ||= [s(" 确定 ", -1)]]),
11077
11091
  _: 1
@@ -11088,16 +11102,16 @@ var $a = { key: 0 }, eo = {
11088
11102
  });
11089
11103
  //#endregion
11090
11104
  //#region src/index.ts
11091
- function To(e) {
11105
+ function wo(e) {
11092
11106
  e && ia(e);
11093
11107
  }
11094
- var Eo = {
11108
+ var To = {
11095
11109
  install(e) {
11096
- e.component("PForm", Va), e.component("PGrid", co), e.component("PCanvasTable", fo), e.component("PCanvasGrid", yo), e.component("PFormGroup", So), e.component("PGroupBlock", bo), e.component("PromisePicker", wo);
11110
+ e.component("PForm", Va), e.component("PGrid", so), e.component("PCanvasTable", uo), e.component("PCanvasGrid", vo), e.component("PFormGroup", xo), e.component("PGroupBlock", yo), e.component("PromisePicker", Co);
11097
11111
  },
11098
11112
  addFormatter: Sa,
11099
11113
  addRender: Pa,
11100
- setup: To
11114
+ setup: wo
11101
11115
  };
11102
11116
  //#endregion
11103
- export { yo as PCanvasGrid, fo as PCanvasTable, Va as PForm, So as PFormGroup, co as PGrid, bo as PGroupBlock, wo as PromisePicker, Sa as addFormatter, Pa as addRender, Xa as applyViewportRestSize, da as cleanCol, Qa as createAutoViewportBoxController, Eo as default, fa as defaultItemResponsive, pa as defaultLabelCol, ha as get24rest, _a as getButtonResponsive, aa as getTooltipRenderer, oa as getUIKitConfig, ma as labelColDict, Ja as parseAutoViewportBoxOffset, ua as resetUIKitConfig, ia as setUIKitConfig, To as setup, va as watchPreviousDeep };
11117
+ export { vo as PCanvasGrid, uo as PCanvasTable, Va as PForm, xo as PFormGroup, so as PGrid, yo as PGroupBlock, Co as PromisePicker, Sa as addFormatter, Pa as addRender, Xa as applyViewportRestSize, da as cleanCol, Qa as createAutoViewportBoxController, To as default, fa as defaultItemResponsive, pa as defaultLabelCol, ha as get24rest, _a as getButtonResponsive, aa as getTooltipRenderer, oa as getUIKitConfig, ma as labelColDict, Ja as parseAutoViewportBoxOffset, ua as resetUIKitConfig, ia as setUIKitConfig, wo as setup, va as watchPreviousDeep };
package/dist/index.d.ts CHANGED
@@ -59,8 +59,15 @@ export declare interface AjaxConfig<F extends Recordable = Recordable> {
59
59
  declare type Align = 'left' | 'center' | 'right';
60
60
 
61
61
  /**
62
- * 宽/高先按「视口内从元素左上角到右/下边缘」计算,再与**直接父元素**布局框取较小值,
63
- * 避免嵌套在侧栏 + flex 列等窄容器里仍按整屏宽度赋值,从而撑出页面级横向滚动条。
62
+ * 宽/高先按「视口内从元素左上角到右/下边缘」计算。
63
+ *
64
+ * 宽度会再与**直接父元素**布局框取较小值,避免嵌套在侧栏 + flex 列等窄容器里仍按整屏宽度赋值,
65
+ * 从而撑出页面级横向滚动条。
66
+ *
67
+ * 高度不做 parent 截断:autoBoxSize 的语义就是「一直撑到视口底」。若对 parent 取 min,
68
+ * 遇到「父容器没有明确高度、靠子元素内容撑开」的常见布局(外层未写死高度,p-grid 根节点
69
+ * 自身决定可视高度),会形成循环依赖(子依赖父、父又靠子撑开),导致高度被截成极小值,
70
+ * 反映到 PGrid 上就是表体下方出现大面积空白。
64
71
  */
65
72
  export declare function applyViewportRestSize(el: HTMLElement, offset: AutoViewportBoxOffset): void;
66
73
 
@@ -2574,6 +2581,15 @@ export declare type PGridProps<D extends Recordable = Recordable, F extends Reco
2574
2581
  * 虚拟列表 Y区计算高度
2575
2582
  */
2576
2583
  renderY?: number;
2584
+ /**
2585
+ * 适应「外层高度由内容撑开」的布局(典型如弹窗 `PromisePicker`)。
2586
+ *
2587
+ * 开启后:
2588
+ * - 根容器/表体宿主不再 `flex:1` 强行撑满(避免父无固定高度时塌陷到 0);
2589
+ * - `a-table` 的纵向 `scroll.y` 作为「最多滚动到多少」的上限,由 `renderY` 显式指定;
2590
+ * 若不传 `renderY`,使用基于视口的默认值。内容少时不会出现行区域下方的大片空白。
2591
+ */
2592
+ fitContent?: boolean;
2577
2593
  };
2578
2594
 
2579
2595
  export declare const PGroupBlock: <F extends Recordable = Recordable>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal_4<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-ui-kit/ant",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "Vue3 UI Kit based on Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -256,6 +256,15 @@ export type PGridProps<D extends Recordable = Recordable, F extends Recordable =
256
256
  * 虚拟列表 Y区计算高度
257
257
  */
258
258
  renderY?: number;
259
+ /**
260
+ * 适应「外层高度由内容撑开」的布局(典型如弹窗 `PromisePicker`)。
261
+ *
262
+ * 开启后:
263
+ * - 根容器/表体宿主不再 `flex:1` 强行撑满(避免父无固定高度时塌陷到 0);
264
+ * - `a-table` 的纵向 `scroll.y` 作为「最多滚动到多少」的上限,由 `renderY` 显式指定;
265
+ * 若不传 `renderY`,使用基于视口的默认值。内容少时不会出现行区域下方的大片空白。
266
+ */
267
+ fitContent?: boolean;
259
268
  };
260
269
 
261
270
  export interface RenderOptions {
@@ -62,6 +62,7 @@
62
62
  fitHeight: () => getGridDefaults().fitHeight ?? 30,
63
63
  striped: () => getGridDefaults().striped ?? false,
64
64
  autoBoxSize: false,
65
+ fitContent: false,
65
66
  });
66
67
 
67
68
  const {
@@ -484,6 +485,13 @@
484
485
  renderHeight.value = props.renderY as number;
485
486
  return;
486
487
  }
488
+ // 内容撑开模式(弹窗等):scroll.y 作为上限,内容不足时 a-table-body 按自然高度展示。
489
+ if (props.fitContent) {
490
+ const vh = typeof window !== 'undefined' ? window.innerHeight : 800;
491
+ const reserve = props.fitHeight ?? 30;
492
+ renderHeight.value = Math.max(Math.floor(vh * 0.6) - reserve, 160);
493
+ return;
494
+ }
487
495
  const wrapperH = tableWrapperEl.value.clientHeight;
488
496
  const footerH = tableFooterEl.value?.offsetHeight ?? 0;
489
497
  const tableHeaderEl = resolveTableHeaderEl(tableWrapperEl.value);
@@ -605,8 +613,12 @@
605
613
  <div
606
614
  ref="boxEl"
607
615
  :class="[
608
- 'p-wrapper flex flex-col gap-8px overflow-y-auto',
609
- autoBoxSize ? 'min-h-0 min-w-0 flex-1 w-full' : 'h-full',
616
+ 'p-wrapper flex flex-col gap-8px',
617
+ fitContent
618
+ ? 'w-full h-auto'
619
+ : autoBoxSize
620
+ ? 'overflow-y-auto min-h-0 min-w-0 flex-1 w-full'
621
+ : 'overflow-y-auto h-full',
610
622
  ]"
611
623
  v-bind="attrs"
612
624
  >
@@ -722,9 +734,17 @@
722
734
  </div>
723
735
  <div
724
736
  ref="tableWrapperEl"
725
- :class="`p-pane flex-1 h-0 min-h-0 flex flex-col p-${scrollMode ?? 'inner'}-scroll`"
737
+ :class="
738
+ fitContent
739
+ ? 'p-pane'
740
+ : `p-pane flex-1 h-0 min-h-0 flex flex-col p-${scrollMode ?? 'inner'}-scroll`
741
+ "
726
742
  >
727
- <div class="p-grid-table-body flex-1 min-h-0 overflow-hidden">
743
+ <div
744
+ :class="
745
+ fitContent ? 'p-grid-table-body' : 'p-grid-table-body flex-1 min-h-0 overflow-hidden'
746
+ "
747
+ >
728
748
  <a-table
729
749
  :key="renderTableKey + '_table'"
730
750
  :row-key="rowKey ?? 'id'"
@@ -4,15 +4,14 @@
4
4
  name="PromisePicker"
5
5
  generic="D extends Recordable = Recordable, F extends Recordable = Recordable"
6
6
  >
7
- import { reactive, ref, computed, onMounted, nextTick } from 'vue';
8
- import { PGridInstance, PromisePickerProps } from '#/antProxy';
7
+ import { PGridInstance, PGridProps, PromisePickerProps } from '#/antProxy';
9
8
  import PGrid from '@/components/PGrid.vue';
10
9
  import { $warning } from '@/hooks/useMessage';
11
10
  import { Button as AButton, Modal as AModal } from 'ant-design-vue';
11
+ import { computed, reactive, ref } from 'vue';
12
12
 
13
13
  const gridEl = ref<PGridInstance<D>>();
14
14
 
15
- const rendered = ref(false);
16
15
  const props = withDefaults(defineProps<PromisePickerProps<D, F>>(), {
17
16
  title: '数据选择',
18
17
  width: '70%',
@@ -21,6 +20,24 @@
21
20
  beforePick: () => Promise.resolve(),
22
21
  });
23
22
  const isMultiple = computed(() => props.gridSetting.selectConfig?.multiple);
23
+ /**
24
+ * 合并内置的 `fitContent: true`:
25
+ * - 弹窗容器由内容撑开,外层不写死高度;
26
+ * - 数据少时按内容自然高显示,避免出现大面积空白;
27
+ * - 数据多时由外层 `max-height` 限制总高度,表格内部 `scroll.y` 作为上限滚动。
28
+ * 用户在 `gridSetting` 中若显式传入 `fitContent`/`renderY` 可覆盖。
29
+ */
30
+ const mergedGridSetting = computed<PGridProps<D, F>>(() => ({
31
+ fitContent: true,
32
+ ...props.gridSetting,
33
+ }));
34
+ const pickerBodyStyle = {
35
+ display: 'flex',
36
+ flexDirection: 'column',
37
+ minHeight: 0,
38
+ maxHeight: 'min(80dvh, calc(100dvh - 200px))',
39
+ overflow: 'hidden',
40
+ } as const;
24
41
  let resolvePromise: (
25
42
  value: { row: D; field?: string } | PromiseLike<{ row: D; field?: string }>,
26
43
  ) => void;
@@ -61,27 +78,18 @@
61
78
  });
62
79
  }
63
80
  };
64
- onMounted(() => {});
65
81
  defineExpose({
66
82
  pick: () =>
67
83
  new Promise<{ row: D; field?: string } | D[]>((resolve, reject) => {
68
84
  resolvePromise = resolve;
69
85
  rejectPromise = reject;
70
- rendered.value = false;
71
86
  visible.modal = true;
72
- nextTick(() => {
73
- rendered.value = true;
74
- });
75
87
  }),
76
88
  pickMultiple: () =>
77
89
  new Promise<{ row: D; field?: string } | D[]>((resolve, reject) => {
78
90
  multipleResolver = resolve;
79
91
  rejectPromise = reject;
80
- rendered.value = false;
81
92
  visible.modal = true;
82
- nextTick(() => {
83
- rendered.value = true;
84
- });
85
93
  }),
86
94
  grid: gridEl,
87
95
  hide: () => {
@@ -99,8 +107,8 @@
99
107
  @cancel="handleCancel"
100
108
  :body-style="bodyStyle"
101
109
  >
102
- <div :style="{ minHeight: rendered ? 'unset' : '642px' }">
103
- <p-grid v-bind="gridSetting" ref="gridEl" @pick="selectRow" />
110
+ <div :style="pickerBodyStyle">
111
+ <p-grid v-bind="mergedGridSetting" ref="gridEl" @pick="selectRow" />
104
112
  </div>
105
113
  <template v-if="isMultiple" #footer>
106
114
  <div class="w-full text-right p-2">
@@ -58,8 +58,15 @@ function findResizeAncestor(start: Element | null): Element {
58
58
  }
59
59
 
60
60
  /**
61
- * 宽/高先按「视口内从元素左上角到右/下边缘」计算,再与**直接父元素**布局框取较小值,
62
- * 避免嵌套在侧栏 + flex 列等窄容器里仍按整屏宽度赋值,从而撑出页面级横向滚动条。
61
+ * 宽/高先按「视口内从元素左上角到右/下边缘」计算。
62
+ *
63
+ * 宽度会再与**直接父元素**布局框取较小值,避免嵌套在侧栏 + flex 列等窄容器里仍按整屏宽度赋值,
64
+ * 从而撑出页面级横向滚动条。
65
+ *
66
+ * 高度不做 parent 截断:autoBoxSize 的语义就是「一直撑到视口底」。若对 parent 取 min,
67
+ * 遇到「父容器没有明确高度、靠子元素内容撑开」的常见布局(外层未写死高度,p-grid 根节点
68
+ * 自身决定可视高度),会形成循环依赖(子依赖父、父又靠子撑开),导致高度被截成极小值,
69
+ * 反映到 PGrid 上就是表体下方出现大面积空白。
63
70
  */
64
71
  export function applyViewportRestSize(el: HTMLElement, offset: AutoViewportBoxOffset): void {
65
72
  const rect = el.getBoundingClientRect();
@@ -67,7 +74,7 @@ export function applyViewportRestSize(el: HTMLElement, offset: AutoViewportBoxOf
67
74
  const vh = window.innerHeight;
68
75
 
69
76
  let targetW = Math.max(0, vw - rect.left - offset.right);
70
- let targetH = Math.max(0, vh - rect.top - offset.bottom);
77
+ const targetH = Math.max(0, vh - rect.top - offset.bottom);
71
78
 
72
79
  const parent = el.parentElement;
73
80
  if (parent) {
@@ -75,9 +82,6 @@ export function applyViewportRestSize(el: HTMLElement, offset: AutoViewportBoxOf
75
82
  if (pr.width > 0) {
76
83
  targetW = Math.min(targetW, pr.width);
77
84
  }
78
- if (pr.height > 0) {
79
- targetH = Math.min(targetH, pr.height);
80
- }
81
85
  }
82
86
 
83
87
  el.style.width = `${targetW}px`;