@aplus-frontend/ui 0.5.35 → 0.5.37

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,13 +1,13 @@
1
- import { defineComponent as H, ref as J, unref as t, computed as d, watch as Q, createBlock as S, openBlock as i, normalizeClass as u, withCtx as f, createElementVNode as X, normalizeStyle as h, renderSlot as l, createElementBlock as p, createCommentVNode as Y, createVNode as v, Fragment as I, renderList as Z, mergeProps as _ } from "vue";
2
- import { Empty as E, Spin as x, Pagination as ee } from "@aplus-frontend/antdv";
3
- import { useTablePaging as te } from "../ap-table/hooks/use-table-paging-ng.mjs";
1
+ import { defineComponent as X, ref as Y, unref as e, computed as p, watch as Z, createElementBlock as s, openBlock as i, normalizeStyle as v, normalizeClass as l, renderSlot as u, createElementVNode as _, createCommentVNode as I, createVNode as g, Fragment as E, createBlock as O, withCtx as h, renderList as x, mergeProps as ee } from "vue";
2
+ import { Empty as V, Spin as te, Pagination as ae } from "@aplus-frontend/antdv";
3
+ import { useTablePaging as ne } from "../ap-table/hooks/use-table-paging-ng.mjs";
4
4
  import "../config-provider/index.mjs";
5
- import { isUndefined as O, isNumber as ae, omit as ne } from "lodash-unified";
6
- import { useOfflineList as re } from "./hooks/use-offline-list.mjs";
5
+ import { isUndefined as F, isNumber as re, omit as oe } from "lodash-unified";
6
+ import { useOfflineList as ie } from "./hooks/use-offline-list.mjs";
7
7
  import "vue-virtual-scroller/dist/vue-virtual-scroller.css";
8
- import { RecycleScroller as oe, DynamicScroller as ie, DynamicScrollerItem as le } from "vue-virtual-scroller";
9
- import { useNamespace as se } from "../config-provider/hooks/use-namespace.mjs";
10
- const he = /* @__PURE__ */ H({
8
+ import { RecycleScroller as le, DynamicScroller as se, DynamicScrollerItem as ue } from "vue-virtual-scroller";
9
+ import { useNamespace as ce } from "../config-provider/hooks/use-namespace.mjs";
10
+ const be = /* @__PURE__ */ X({
11
11
  __name: "index",
12
12
  props: {
13
13
  dataSource: {},
@@ -24,22 +24,23 @@ const he = /* @__PURE__ */ H({
24
24
  contentStyle: { type: [Boolean, null, String, Object, Array] },
25
25
  footerWarpperStyle: { type: [Boolean, null, String, Object, Array] },
26
26
  virtual: { default: void 0 },
27
- rowKey: {}
27
+ rowKey: {},
28
+ adaptive: { type: Boolean, default: !1 }
28
29
  },
29
- setup(V, { expose: F }) {
30
- const L = E.PRESENTED_IMAGE_SIMPLE, n = V, { b: m, e: N } = se("ap-list"), b = J(), {
30
+ setup(L, { expose: N }) {
31
+ const R = V.PRESENTED_IMAGE_SIMPLE, n = L, { b: m, e: y, bm: T, m: $ } = ce("ap-list"), b = Y(), {
31
32
  formRef: k,
32
- submit: D,
33
- reset: w,
34
- handleTableChange: R,
35
- data: g,
36
- refresh: T,
37
- refreshByDelete: $,
38
- tableProps: z
39
- } = te({
40
- async request(e) {
33
+ submit: w,
34
+ reset: B,
35
+ handleTableChange: j,
36
+ data: S,
37
+ refresh: q,
38
+ refreshByDelete: A,
39
+ tableProps: D
40
+ } = ne({
41
+ async request(t) {
41
42
  var r;
42
- const a = await ((r = n.request) == null ? void 0 : r.call(n, e));
43
+ const a = await ((r = n.request) == null ? void 0 : r.call(n, t));
43
44
  return {
44
45
  data: (a == null ? void 0 : a.data) || [],
45
46
  total: (a == null ? void 0 : a.total) || 0
@@ -50,143 +51,149 @@ const he = /* @__PURE__ */ H({
50
51
  manual: n.manual,
51
52
  pagination: n.pagination,
52
53
  formatParams: n.beforeSearchSubmit
53
- }), j = { form: k }, {
54
- pagination: B,
55
- dataSource: q,
56
- onChange: A
57
- } = re(n);
58
- function K(e, a) {
59
- if (t(c)) {
60
- A(e, a);
54
+ }), K = { form: k }, {
55
+ pagination: z,
56
+ dataSource: M,
57
+ onChange: W
58
+ } = ie(n);
59
+ function G(t, a) {
60
+ if (e(f)) {
61
+ W(t, a);
61
62
  return;
62
63
  }
63
- R(
64
- { current: e, pageSize: a },
64
+ j(
65
+ { current: t, pageSize: a },
65
66
  {},
66
67
  {},
67
68
  { currentDataSource: [], action: "paginate" }
68
69
  );
69
70
  }
70
- const s = d(() => t(c) ? t(q) : t(g).records), y = d(() => O(n.loading) ? t(g).loading : n.loading), M = d(() => {
71
- var e, a;
72
- return n.pagination === !1 || n.virtual ? !1 : ((e = n.pagination) == null ? void 0 : e.hideOnSinglePage) !== !0 ? !0 : t(c) ? (((a = n.dataSource) == null ? void 0 : a.length) || 0) > t(B).pageSize : t(g).total > t(z).pagination.pageSize;
73
- }), c = d(() => !O(n.dataSource));
74
- Q(
75
- () => t(y),
76
- (e) => {
71
+ const c = p(() => e(f) ? e(M) : e(S).records), d = p(() => F(n.loading) ? e(S).loading : n.loading), U = p(() => {
72
+ var t, a;
73
+ return n.pagination === !1 || n.virtual ? !1 : ((t = n.pagination) == null ? void 0 : t.hideOnSinglePage) !== !0 ? !0 : e(f) ? (((a = n.dataSource) == null ? void 0 : a.length) || 0) > e(z).pageSize : e(S).total > e(D).pagination.pageSize;
74
+ }), f = p(() => !F(n.dataSource));
75
+ Z(
76
+ () => e(d),
77
+ (t) => {
77
78
  var a;
78
- (a = n.onLoadingChange) == null || a.call(n, e);
79
+ (a = n.onLoadingChange) == null || a.call(n, t);
79
80
  }
80
81
  );
81
- function W(e) {
82
+ function H(t) {
82
83
  var a, r;
83
- (r = (a = b.value) == null ? void 0 : a.querySelector(e || ":first-child")) == null || r.scrollIntoView({ behavior: "smooth", block: "center" });
84
+ (r = (a = b.value) == null ? void 0 : a.querySelector(t || ":first-child")) == null || r.scrollIntoView({ behavior: "smooth", block: "center" });
84
85
  }
85
- function G(e = !1) {
86
+ function J(t = !1) {
86
87
  var o;
87
- const a = (o = k.value) == null ? void 0 : o.apForm, r = e ? a == null ? void 0 : a.getFieldsValueTransformed : a == null ? void 0 : a.getFieldsValue;
88
+ const a = (o = k.value) == null ? void 0 : o.apForm, r = t ? a == null ? void 0 : a.getFieldsValueTransformed : a == null ? void 0 : a.getFieldsValue;
88
89
  return (r == null ? void 0 : r()) || {};
89
90
  }
90
- return F({
91
- submit: () => D(),
92
- reset: () => w(),
93
- refresh: () => T(),
94
- refreshByDelete: (e) => $(e),
95
- scrollToFirstRow: W,
96
- getSearchFormValuesIfSetted: G
97
- }), (e, a) => (i(), S(t(x), {
98
- spinning: y.value,
99
- class: u(t(m)("spin"))
100
- }, {
101
- default: f(() => [
102
- X("div", {
103
- class: u(t(m)()),
104
- style: h(e.containerStyle)
91
+ return N({
92
+ submit: () => w(),
93
+ reset: () => B(),
94
+ refresh: () => q(),
95
+ refreshByDelete: (t) => A(t),
96
+ scrollToFirstRow: H,
97
+ getSearchFormValuesIfSetted: J
98
+ }), (t, a) => (i(), s("div", {
99
+ class: l([e(m)(), { [e($)("adaptive")]: t.adaptive }]),
100
+ style: v(t.containerStyle)
101
+ }, [
102
+ u(t.$slots, "header", {
103
+ formIns: K,
104
+ submit: e(w),
105
+ reset: e(B)
106
+ }),
107
+ _("div", {
108
+ class: l([
109
+ e(m)("content-container"),
110
+ { [e(T)("content-container", "spinning")]: d.value }
111
+ ])
112
+ }, [
113
+ d.value ? (i(), s("div", {
114
+ key: 0,
115
+ class: l(e(y)("spin-wrapper"))
105
116
  }, [
106
- l(e.$slots, "header", {
107
- formIns: j,
108
- submit: t(D),
109
- reset: t(w)
110
- }),
111
- s.value.length === 0 ? l(e.$slots, "empty", {
112
- key: 0,
113
- loading: y.value
114
- }, () => [
115
- v(t(E), { image: t(L) }, null, 8, ["image"])
116
- ]) : (i(), p("div", {
117
- key: 1,
118
- ref_key: "contentRef",
119
- ref: b,
120
- style: h(e.contentStyle)
121
- }, [
122
- e.virtual ? (i(), p(I, { key: 0 }, [
123
- t(ae)(e.virtual) ? (i(), S(t(oe), {
124
- key: 0,
125
- class: u(t(m)("scroll-wrapper")),
126
- items: s.value,
127
- "item-size": e.virtual,
128
- "key-field": n.rowKey || "id"
129
- }, {
130
- default: f(({ item: r, index: o }) => [
131
- l(e.$slots, "renderItem", {
132
- item: r,
133
- index: o
134
- })
135
- ]),
136
- _: 3
137
- }, 8, ["class", "items", "item-size", "key-field"])) : (i(), S(t(ie), {
138
- key: 1,
139
- items: s.value,
140
- "min-item-size": e.virtual.minItemSize,
141
- class: u(t(m)("scroll-wrapper"))
142
- }, {
143
- default: f(({ item: r, index: o, active: U }) => {
144
- var C, P;
145
- return [
146
- v(t(le), {
147
- item: r,
148
- active: U,
149
- "data-index": o,
150
- "size-dependencies": (P = (C = e.virtual).sizeDependencies) == null ? void 0 : P.call(C, r)
151
- }, {
152
- default: f(() => [
153
- l(e.$slots, "renderItem", {
154
- item: r,
155
- index: o
156
- })
157
- ]),
158
- _: 2
159
- }, 1032, ["item", "active", "data-index", "size-dependencies"])
160
- ];
161
- }),
162
- _: 3
163
- }, 8, ["items", "min-item-size", "class"]))
164
- ], 64)) : l(e.$slots, "renderContent", {
117
+ g(e(te), { spinning: d.value }, null, 8, ["spinning"])
118
+ ], 2)) : I("", !0),
119
+ c.value.length === 0 ? u(t.$slots, "empty", {
120
+ key: 1,
121
+ loading: d.value
122
+ }, () => [
123
+ g(e(V), { image: e(R) }, null, 8, ["image"])
124
+ ]) : (i(), s("div", {
125
+ key: 2,
126
+ ref_key: "contentRef",
127
+ ref: b,
128
+ style: v(t.contentStyle),
129
+ class: l(e(y)("content"))
130
+ }, [
131
+ t.virtual ? (i(), s(E, { key: 0 }, [
132
+ e(re)(t.virtual) ? (i(), O(e(le), {
133
+ key: 0,
134
+ class: l(e(m)("scroll-wrapper")),
135
+ items: c.value,
136
+ "item-size": t.virtual,
137
+ "key-field": n.rowKey || "id"
138
+ }, {
139
+ default: h(({ item: r, index: o }) => [
140
+ u(t.$slots, "renderItem", {
141
+ item: r,
142
+ index: o
143
+ })
144
+ ]),
145
+ _: 3
146
+ }, 8, ["class", "items", "item-size", "key-field"])) : (i(), O(e(se), {
165
147
  key: 1,
166
- dataSource: s.value
167
- }, () => [
168
- (i(!0), p(I, null, Z(s.value, (r, o) => l(e.$slots, "renderItem", {
169
- item: r,
170
- index: o
171
- })), 256))
172
- ])
173
- ], 4)),
174
- M.value ? (i(), p("div", {
175
- key: 2,
176
- class: u(t(N)("footer")),
177
- style: h(e.footerWarpperStyle)
178
- }, [
179
- v(t(ee), _(
180
- c.value ? t(B) : t(ne)(t(z).pagination, ["showTotal"]),
181
- { onChange: K }
182
- ), null, 16)
183
- ], 6)) : Y("", !0)
184
- ], 6)
185
- ]),
186
- _: 3
187
- }, 8, ["spinning", "class"]));
148
+ items: c.value,
149
+ "min-item-size": t.virtual.minItemSize,
150
+ class: l(e(m)("scroll-wrapper"))
151
+ }, {
152
+ default: h(({ item: r, index: o, active: Q }) => {
153
+ var C, P;
154
+ return [
155
+ g(e(ue), {
156
+ item: r,
157
+ active: Q,
158
+ "data-index": o,
159
+ "size-dependencies": (P = (C = t.virtual).sizeDependencies) == null ? void 0 : P.call(C, r)
160
+ }, {
161
+ default: h(() => [
162
+ u(t.$slots, "renderItem", {
163
+ item: r,
164
+ index: o
165
+ })
166
+ ]),
167
+ _: 2
168
+ }, 1032, ["item", "active", "data-index", "size-dependencies"])
169
+ ];
170
+ }),
171
+ _: 3
172
+ }, 8, ["items", "min-item-size", "class"]))
173
+ ], 64)) : u(t.$slots, "renderContent", {
174
+ key: 1,
175
+ dataSource: c.value
176
+ }, () => [
177
+ (i(!0), s(E, null, x(c.value, (r, o) => u(t.$slots, "renderItem", {
178
+ item: r,
179
+ index: o
180
+ })), 256))
181
+ ])
182
+ ], 6))
183
+ ], 2),
184
+ U.value ? (i(), s("div", {
185
+ key: 0,
186
+ class: l(e(y)("footer")),
187
+ style: v(t.footerWarpperStyle)
188
+ }, [
189
+ g(e(ae), ee(
190
+ f.value ? e(z) : e(oe)(e(D).pagination, ["showTotal"]),
191
+ { onChange: G }
192
+ ), null, 16)
193
+ ], 6)) : I("", !0)
194
+ ], 6));
188
195
  }
189
196
  });
190
197
  export {
191
- he as default
198
+ be as default
192
199
  };
@@ -86,6 +86,10 @@ export type ApListProps<RecordType = any, ParamsType = Recordable> = {
86
86
  * @default "id"
87
87
  */
88
88
  rowKey?: string;
89
+ /**
90
+ * 是否自适应外部容器高度(无数据时充满容器、数据超出时内部滚动)
91
+ */
92
+ adaptive?: boolean;
89
93
  };
90
94
  export type ApListExpose = {
91
95
  /**
@@ -27,16 +27,16 @@ const Ae = ({
27
27
  request: f,
28
28
  defaultParams: L = {},
29
29
  defaultData: v = [],
30
- formatParams: y,
31
- paramsValueTypeMap: O,
32
- resetFieldsIgnores: R,
30
+ formatParams: O,
31
+ paramsValueTypeMap: R,
32
+ resetFieldsIgnores: y,
33
33
  filterFields: J,
34
34
  sortFields: K,
35
35
  namespace: M = "ap-table",
36
36
  pagination: S
37
37
  }) => {
38
38
  let b = 0, i = {};
39
- const Q = Se(S), $ = (e) => y ? y(e) : e, z = ae(), c = j(ze(S)), {
39
+ const Q = Se(S), $ = (e) => O ? O(e) : e, z = ae(), c = j(ze(S)), {
40
40
  getColumnSFConfig: G,
41
41
  setSF: W,
42
42
  clearAll: Z,
@@ -46,7 +46,7 @@ const Ae = ({
46
46
  t: T
47
47
  } = me(), {
48
48
  b: P
49
- } = he(M), a = j({
49
+ } = he(M), o = j({
50
50
  total: v.length,
51
51
  records: v,
52
52
  loading: !1
@@ -56,32 +56,30 @@ const Ae = ({
56
56
  }, I = async (e) => {
57
57
  var r;
58
58
  const t = $(e), n = Date.now();
59
- b = n, a.loading = !0;
59
+ b = n, o.loading = !0;
60
60
  try {
61
- const o = await f({
61
+ const a = await f({
62
62
  ...m(L),
63
63
  ...t
64
64
  });
65
- b === n && (a.total = o.total || ((r = o.data) == null ? void 0 : r.length) || 0, a.records = [...o.data || []]);
65
+ b === n && (o.total = a.total || ((r = a.data) == null ? void 0 : r.length) || 0, o.records = [...a.data || []], o.loading = !1);
66
66
  } catch {
67
- b === n && (a.records = [], a.total = 0);
68
- } finally {
69
- a.loading = !1;
67
+ b === n && (o.records = [], o.total = 0, o.loading = !1);
70
68
  }
71
69
  }, V = (e) => {
72
70
  const t = {};
73
71
  return Object.entries(e).forEach(([n, r]) => {
74
- if (t[n] = r, O && r) {
75
- const o = O[n];
76
- o && (t[n] = le(o, r));
72
+ if (t[n] = r, R && r) {
73
+ const a = R[n];
74
+ a && (t[n] = le(a, r));
77
75
  }
78
76
  }), t;
79
77
  }, Y = async (e) => {
80
- var r, o, l, g, d;
78
+ var r, a, l, g, d;
81
79
  const t = w(), n = {};
82
80
  Object.entries(t).forEach(([p, F]) => {
83
- R && R.indexOf(p) > -1 && (n[p] = F);
84
- }), await ((o = (r = z.value) == null ? void 0 : r.apForm) == null ? void 0 : o.resetFields()), (d = (g = (l = z.value) == null ? void 0 : l.apForm) == null ? void 0 : g.setFieldsValue) == null || d.call(g, n), se(() => {
81
+ y && y.indexOf(p) > -1 && (n[p] = F);
82
+ }), await ((a = (r = z.value) == null ? void 0 : r.apForm) == null ? void 0 : a.resetFields()), (d = (g = (l = z.value) == null ? void 0 : l.apForm) == null ? void 0 : g.setFieldsValue) == null || d.call(g, n), se(() => {
85
83
  e == null || e();
86
84
  });
87
85
  }, C = (e) => {
@@ -113,7 +111,7 @@ const Ae = ({
113
111
  const {
114
112
  current: t,
115
113
  pageSize: n
116
- } = c, r = a.total - e, o = Math.ceil(r / n), l = t > o ? o : t;
114
+ } = c, r = o.total - e, a = Math.ceil(r / n), l = t > a ? a : t;
117
115
  k({
118
116
  current: l > 0 ? l : 1
119
117
  });
@@ -122,8 +120,8 @@ const Ae = ({
122
120
  var p, F;
123
121
  const r = w();
124
122
  c.current = e.current, c.pageSize = e.pageSize, W(t, n);
125
- const o = q(n) ? [...n] : [n], l = {};
126
- for (const u of o)
123
+ const a = q(n) ? [...n] : [n], l = {};
124
+ for (const u of a)
127
125
  (p = m(K)) != null && p.includes(u.columnKey || u.field) && u.order && (l[fe(u.columnKey || u.field)] = u.order);
128
126
  const g = {};
129
127
  for (const u of Object.keys(t))
@@ -158,16 +156,16 @@ const Ae = ({
158
156
  deep: !0
159
157
  });
160
158
  const ne = A(() => {
161
- if (a.total === 0)
159
+ if (o.total === 0)
162
160
  return "-";
163
161
  const {
164
162
  current: e,
165
163
  pageSize: t
166
164
  } = c;
167
- return `${e}/${Math.ceil(a.total / t)}`;
165
+ return `${e}/${Math.ceil(o.total / t)}`;
168
166
  });
169
167
  function re(e) {
170
- q(e) && (a.records = e, a.total = e.length);
168
+ q(e) && (o.records = e, o.total = e.length);
171
169
  }
172
170
  const oe = A(() => {
173
171
  const {
@@ -175,19 +173,19 @@ const Ae = ({
175
173
  showTotal: t,
176
174
  showQuickJumper: n,
177
175
  showSizeChanger: r,
178
- pageSizeOptions: o
176
+ pageSizeOptions: a
179
177
  } = Q;
180
178
  return {
181
- loading: a.loading,
179
+ loading: o.loading,
182
180
  pagination: {
183
181
  current: c.current,
184
182
  pageSize: c.pageSize,
185
- total: a.total,
183
+ total: o.total,
186
184
  showSizeChanger: N(r) ? r : !e,
187
185
  showQuickJumper: N(n) ? n : !e,
188
186
  showLessItems: e,
189
187
  size: "default",
190
- pageSizeOptions: pe(o) ? ["10", "20", "50", "100"] : o,
188
+ pageSizeOptions: pe(a) ? ["10", "20", "50", "100"] : a,
191
189
  showTotal: t ? (l) => x("span", {
192
190
  class: P("pagination-total-wrapper")
193
191
  }, [T("ap.apTable.pagination.totalLeftPrefix"), " ", x("span", {
@@ -199,7 +197,7 @@ const Ae = ({
199
197
  }, [m(ne)]), " ", T("ap.apTable.pagination.totalRightSuffix")])]) : void 0
200
198
  },
201
199
  onChange: _,
202
- dataSource: a.records
200
+ dataSource: o.records
203
201
  };
204
202
  });
205
203
  return {
@@ -208,12 +206,12 @@ const Ae = ({
208
206
  reset: ee,
209
207
  refresh: U,
210
208
  refreshByDelete: te,
211
- data: a,
209
+ data: o,
212
210
  current: c.current,
213
211
  pageSize: c.pageSize,
214
212
  handleTableChange: _,
215
213
  tableProps: oe,
216
- dataSource: A(() => a.records),
214
+ dataSource: A(() => o.records),
217
215
  setDataSource: re,
218
216
  getColumnSFConfig: G,
219
217
  sortedInfo: H,
@@ -165,7 +165,7 @@ const Re = /* @__PURE__ */ $({
165
165
  const o = ((u = r(m)) == null ? void 0 : u.length) || 0, a = g(e) ? e : e.length;
166
166
  if (F(n.maxLength) && o + a > n.maxLength)
167
167
  return;
168
- const l = g(e) ? new Array(e).fill({}) : le(e);
168
+ const l = g(e) ? new Array(e).fill(0).map(() => ({})) : le(e);
169
169
  (d = (s = i.value) == null ? void 0 : s.setFieldValue) == null || d.call(s, n.name, l, !0, (f, p) => {
170
170
  if (!f[p]) {
171
171
  f[p] = [...l];
@@ -21,6 +21,10 @@ export type EditableColumnType<RecordType = any, ExtraValueType = 'text', ValueT
21
21
  * 是否省略自动溢出,自动溢出省略,为对象时可设置省略行数、是否可展开、添加后缀等
22
22
  */
23
23
  ellipsis?: boolean | EllipsisConfig;
24
+ /**
25
+ * 是否渲染必填标记(只渲染标记不生成校验规则)
26
+ */
27
+ markRequired?: boolean;
24
28
  /**
25
29
  * 是否可编辑
26
30
  */