@aplus-frontend/ui 0.6.0-beta.13 → 0.6.0-beta.15

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.
Files changed (48) hide show
  1. package/es/src/ap-grid/editable/form-item.vue.mjs +38 -35
  2. package/es/src/ap-grid/editable/index.vue.mjs +13 -10
  3. package/es/src/ap-grid/hooks/use-row-selection.d.ts +100 -0
  4. package/es/src/ap-grid/hooks/use-row-selection.mjs +122 -0
  5. package/es/src/ap-grid/index.vue.mjs +271 -222
  6. package/es/src/ap-grid/interface.d.ts +16 -0
  7. package/es/src/ap-grid/utils/table.mjs +15 -15
  8. package/es/src/ap-table/hooks/use-table-paging-ng.d.ts +6 -1
  9. package/es/src/ap-table/hooks/use-table-paging-ng.mjs +99 -96
  10. package/es/src/business/ap-copy/ApCopy.mjs +43 -43
  11. package/es/src/business/ap-label/group/ApLabelGroup.mjs +15 -16
  12. package/es/src/business/ap-label/interface.d.ts +2 -3
  13. package/es/src/business/ap-product-info/ApProductInfo.mjs +23 -24
  14. package/es/src/business/ap-table-modal/table-modal.vue2.mjs +43 -42
  15. package/es/src/business/ap-view/ap-view.vue.d.ts +4 -1
  16. package/es/src/business/ap-view/ap-view.vue2.mjs +96 -84
  17. package/es/src/business/ap-view/index.d.ts +12 -3
  18. package/es/src/business/ap-view/interface.d.ts +7 -0
  19. package/es/src/business/hooks/usePageListApGrid.mjs +17 -20
  20. package/es/src/version.d.ts +1 -1
  21. package/es/src/version.mjs +1 -1
  22. package/lib/src/ap-grid/editable/form-item.vue.js +1 -1
  23. package/lib/src/ap-grid/editable/index.vue.js +1 -1
  24. package/lib/src/ap-grid/hooks/use-row-selection.d.ts +100 -0
  25. package/lib/src/ap-grid/hooks/use-row-selection.js +1 -0
  26. package/lib/src/ap-grid/index.vue.js +1 -1
  27. package/lib/src/ap-grid/interface.d.ts +16 -0
  28. package/lib/src/ap-grid/utils/table.js +1 -1
  29. package/lib/src/ap-table/hooks/use-table-paging-ng.d.ts +6 -1
  30. package/lib/src/ap-table/hooks/use-table-paging-ng.js +1 -1
  31. package/lib/src/business/ap-copy/ApCopy.js +1 -1
  32. package/lib/src/business/ap-label/group/ApLabelGroup.js +1 -1
  33. package/lib/src/business/ap-label/interface.d.ts +2 -3
  34. package/lib/src/business/ap-product-info/ApProductInfo.js +1 -1
  35. package/lib/src/business/ap-table-modal/table-modal.vue2.js +1 -1
  36. package/lib/src/business/ap-view/ap-view.vue.d.ts +4 -1
  37. package/lib/src/business/ap-view/ap-view.vue2.js +1 -1
  38. package/lib/src/business/ap-view/index.d.ts +12 -3
  39. package/lib/src/business/ap-view/interface.d.ts +7 -0
  40. package/lib/src/business/hooks/usePageListApGrid.js +1 -1
  41. package/lib/src/version.d.ts +1 -1
  42. package/lib/src/version.js +1 -1
  43. package/package.json +4 -3
  44. package/theme/ap-copy/ap-copy.css +2 -0
  45. package/theme/ap-copy/ap-copy.less +2 -0
  46. package/theme/ap-table-modal/index.css +15 -13
  47. package/theme/ap-table-modal/index.less +15 -13
  48. package/theme/index.css +17 -13
@@ -1,4 +1,4 @@
1
- import { defineComponent as A, useSlots as H, toRef as W, ref as h, unref as r, watch as G, nextTick as U, createBlock as $, openBlock as q, mergeProps as y, withCtx as g, createVNode as J, createSlots as Q, renderList as X, renderSlot as Y, normalizeProps as Z, guardReactiveProps as I } from "vue";
1
+ import { defineComponent as P, useSlots as A, toRef as W, ref as h, unref as r, watch as G, nextTick as U, createBlock as $, openBlock as q, mergeProps as y, withCtx as g, createVNode as J, createSlots as Q, renderList as X, renderSlot as Y, normalizeProps as Z, guardReactiveProps as I } from "vue";
2
2
  import { ApForm as C } from "../../ap-form/index.mjs";
3
3
  import { isArray as w, isUndefined as M, isNumber as m, cloneDeep as ee, omit as oe } from "lodash-unified";
4
4
  import "../../config-provider/index.mjs";
@@ -7,9 +7,9 @@ import { useGetEditableColumns as te } from "../hooks/use-editable-columns.mjs";
7
7
  import "../index.vue2.mjs";
8
8
  import { useInjectForm as ae } from "../../ap-form/context.mjs";
9
9
  import { useNamespace as le } from "../../config-provider/hooks/use-namespace.mjs";
10
- import { useGlobalConfig as fe } from "../../config-provider/hooks/use-global-config.mjs";
11
- import ne from "../index.vue.mjs";
12
- const Ce = /* @__PURE__ */ A({
10
+ import { useGlobalConfig as ne } from "../../config-provider/hooks/use-global-config.mjs";
11
+ import fe from "../index.vue.mjs";
12
+ const Ce = /* @__PURE__ */ P({
13
13
  name: "EditableGrid",
14
14
  __name: "form-item",
15
15
  props: {
@@ -145,6 +145,9 @@ const Ce = /* @__PURE__ */ A({
145
145
  },
146
146
  expandable: {},
147
147
  value: {},
148
+ rowHighlightable: {
149
+ type: [Boolean, Function]
150
+ },
148
151
  columns: {},
149
152
  defaultValue: {},
150
153
  "onUpdate:value": {},
@@ -160,11 +163,11 @@ const Ce = /* @__PURE__ */ A({
160
163
  setup(x, {
161
164
  expose: R
162
165
  }) {
163
- const B = H(), l = x, {
166
+ const B = A(), l = x, {
164
167
  b: S
165
168
  } = le("editable-grid");
166
169
  function F(e, t) {
167
- return w(t) ? t.reduce((f, a) => f == null ? void 0 : f[a], e) : e == null ? void 0 : e[t];
170
+ return w(t) ? t.reduce((n, a) => n == null ? void 0 : n[a], e) : e == null ? void 0 : e[t];
168
171
  }
169
172
  const {
170
173
  internalInstance: o,
@@ -176,11 +179,11 @@ const Ce = /* @__PURE__ */ A({
176
179
  }, {
177
180
  deep: !0
178
181
  });
179
- const c = h(), D = fe("valueTypeMap"), V = te(l, D);
182
+ const c = h(), D = ne("valueTypeMap"), V = te(l, D);
180
183
  function L(e, t) {
181
- var n;
182
- const f = ((n = r(d)) == null ? void 0 : n.length) || 0;
183
- if (b(l.maxLength) && f >= l.maxLength)
184
+ var f;
185
+ const n = ((f = r(d)) == null ? void 0 : f.length) || 0;
186
+ if (b(l.maxLength) && n >= l.maxLength)
184
187
  return;
185
188
  const a = {
186
189
  ...e || {}
@@ -195,29 +198,29 @@ const Ce = /* @__PURE__ */ A({
195
198
  }
196
199
  function T(e, t = "suffix") {
197
200
  var s;
198
- const f = ((s = r(d)) == null ? void 0 : s.length) || 0, a = m(e) ? e : e.length;
199
- if (b(l.maxLength) && f + a > l.maxLength)
201
+ const n = ((s = r(d)) == null ? void 0 : s.length) || 0, a = m(e) ? e : e.length;
202
+ if (b(l.maxLength) && n + a > l.maxLength)
200
203
  return;
201
- const n = m(e) ? new Array(e).fill(0).map(() => ({})) : ee(e);
202
- o == null || o.setFieldValue(l.name, n, !0, (u, i) => {
204
+ const f = m(e) ? new Array(e).fill(0).map(() => ({})) : ee(e);
205
+ o == null || o.setFieldValue(l.name, f, !0, (u, i) => {
203
206
  if (!u[i]) {
204
- u[i] = [...n];
207
+ u[i] = [...f];
205
208
  return;
206
209
  }
207
- t === "suffix" ? u[i].push(...n) : u[i].unshift(...n);
210
+ t === "suffix" ? u[i].push(...f) : u[i].unshift(...f);
208
211
  });
209
212
  }
210
213
  function k(e) {
211
214
  const t = new Set(m(e) ? [e] : e);
212
- o == null || o.setFieldValue(l.name, void 0, !0, (f, a) => {
213
- f[a] = f[a].filter((n, s) => !t.has(s));
215
+ o == null || o.setFieldValue(l.name, void 0, !0, (n, a) => {
216
+ n[a] = n[a].filter((f, s) => !t.has(s));
214
217
  });
215
218
  }
216
219
  function _(e) {
217
- var f;
220
+ var n;
218
221
  const t = new Set(w(e) ? e : [e]);
219
- t.size !== 0 && ((f = o == null ? void 0 : o.setFieldValue) == null || f.call(o, l.name, void 0, !0, (a, n) => {
220
- a[n] = a[n].filter((s) => !t.has(s[l.rowKey]));
222
+ t.size !== 0 && ((n = o == null ? void 0 : o.setFieldValue) == null || n.call(o, l.name, void 0, !0, (a, f) => {
223
+ a[f] = a[f].filter((s) => !t.has(s[l.rowKey]));
221
224
  }));
222
225
  }
223
226
  function j() {
@@ -227,15 +230,15 @@ const Ce = /* @__PURE__ */ A({
227
230
  var t;
228
231
  return (t = r(d)) == null ? void 0 : t[e];
229
232
  }
230
- function O(e, t, f = !0) {
231
- o == null || o.setFieldValue(l.name, void 0, !0, (a, n) => {
232
- if (!(!a[n] || !a[n][e])) {
233
- if (!f) {
234
- const s = Object.keys(a[n][e]);
233
+ function O(e, t, n = !0) {
234
+ o == null || o.setFieldValue(l.name, void 0, !0, (a, f) => {
235
+ if (!(!a[f] || !a[f][e])) {
236
+ if (!n) {
237
+ const s = Object.keys(a[f][e]);
235
238
  for (const u of s)
236
- u !== l.rowKey && delete a[n][e][u];
239
+ u !== l.rowKey && delete a[f][e][u];
237
240
  }
238
- Object.assign(a[n][e], {
241
+ Object.assign(a[f][e], {
239
242
  ...t
240
243
  });
241
244
  }
@@ -245,11 +248,11 @@ const Ce = /* @__PURE__ */ A({
245
248
  o == null || o.setFieldValue(l.name, e);
246
249
  }
247
250
  function K(e) {
248
- var f;
251
+ var n;
249
252
  const t = e === "end" ? d.value.length - 1 : e;
250
- (f = c.value) == null || f.scrollToRow(t);
253
+ (n = c.value) == null || n.scrollToRow(t);
251
254
  }
252
- function P() {
255
+ function H() {
253
256
  var e;
254
257
  (e = o == null ? void 0 : o.setFieldValue) == null || e.call(o, l.name, []);
255
258
  }
@@ -262,13 +265,13 @@ const Ce = /* @__PURE__ */ A({
262
265
  addMultiple: T,
263
266
  scrollTo: K,
264
267
  setTableData: z,
265
- clear: P,
268
+ clear: H,
266
269
  removeByKey: _
267
270
  }), (e, t) => (q(), $(r(C).FormItem, y(e.formItem, {
268
271
  name: e.name,
269
272
  label: e.label
270
273
  }), {
271
- default: g(() => [J(ne, y(r(oe)(l, ["name", "value", "onUpdate:value", "maxLength", "onChange", "defaultValue", "formItem"]), {
274
+ default: g(() => [J(fe, y(r(oe)(l, ["name", "value", "onUpdate:value", "maxLength", "onChange", "defaultValue", "formItem"]), {
272
275
  ref_key: "tableRef",
273
276
  ref: c,
274
277
  class: r(S)(),
@@ -277,9 +280,9 @@ const Ce = /* @__PURE__ */ A({
277
280
  "search-form": !1
278
281
  }), Q({
279
282
  _: 2
280
- }, [X(B, (f, a) => ({
283
+ }, [X(B, (n, a) => ({
281
284
  name: a,
282
- fn: g((n) => [Y(e.$slots, a, Z(I(n || {})))])
285
+ fn: g((f) => [Y(e.$slots, a, Z(I(f || {})))])
283
286
  }))]), 1040, ["class", "columns", "data-source"])]),
284
287
  _: 3
285
288
  }, 16, ["name", "label"]));
@@ -146,6 +146,9 @@ const Re = /* @__PURE__ */ $({
146
146
  },
147
147
  expandable: {},
148
148
  value: {},
149
+ rowHighlightable: {
150
+ type: [Boolean, Function]
151
+ },
149
152
  columns: {},
150
153
  defaultValue: {},
151
154
  "onUpdate:value": {},
@@ -158,12 +161,12 @@ const Re = /* @__PURE__ */ $({
158
161
  },
159
162
  emits: ["update:value"],
160
163
  setup(B, {
161
- expose: S,
162
- emit: F
164
+ expose: F,
165
+ emit: S
163
166
  }) {
164
167
  const N = q(), o = B, {
165
168
  b: V
166
- } = re("editable-grid"), _ = F, w = v(), {
169
+ } = re("editable-grid"), _ = S, w = v(), {
167
170
  value: m,
168
171
  updateValue: L
169
172
  } = ue(o, _), i = v(), k = ie("valueTypeMap"), c = y.useWatch(o.name, i);
@@ -236,14 +239,14 @@ const Re = /* @__PURE__ */ $({
236
239
  s[n] = s[n].filter((r) => !t.has(r[o.rowKey]));
237
240
  }));
238
241
  }
239
- function I() {
242
+ function H() {
240
243
  return u(m);
241
244
  }
242
- function P(e) {
245
+ function I(e) {
243
246
  var t;
244
247
  (t = i.value) == null || t.setFieldValue(o.name, e);
245
248
  }
246
- function H(e) {
249
+ function P(e) {
247
250
  var t;
248
251
  return (t = u(m)) == null ? void 0 : t[e];
249
252
  }
@@ -271,18 +274,18 @@ const Re = /* @__PURE__ */ $({
271
274
  var e, t;
272
275
  (t = (e = i.value) == null ? void 0 : e.setFieldValue) == null || t.call(e, o.name, []);
273
276
  }
274
- return S({
277
+ return F({
275
278
  resetFields: E,
276
279
  validateFields: j,
277
280
  add: O,
278
281
  remove: A,
279
- getRowData: H,
280
- getRowsData: I,
282
+ getRowData: P,
283
+ getRowsData: H,
281
284
  setRowData: W,
282
285
  addMultiple: z,
283
286
  scrollTo: G,
284
287
  clear: U,
285
- setTableData: P,
288
+ setTableData: I,
286
289
  removeByKey: K
287
290
  }), (e, t) => (Q(), J(u(y), {
288
291
  ref_key: "formRef",
@@ -0,0 +1,100 @@
1
+ import { TableRowSelection } from '@aplus-frontend/antdv/lib/table/interface';
2
+ import { ComputedRef, Ref } from 'vue';
3
+ import { ApTableProps, ApTableRowSelection } from '../../ap-table';
4
+ import { Recordable } from '../../type';
5
+ export interface RowSelectionReturnType<RecordType = any> {
6
+ rowSelection: ComputedRef<TableRowSelection<RecordType>>;
7
+ selectedRows: Ref<Partial<RecordType>[]>;
8
+ /**
9
+ * 选中某行
10
+ * @param item
11
+ * @returns
12
+ */
13
+ select: (item: RecordType) => void;
14
+ /**
15
+ * 取消选中某行
16
+ * @param item
17
+ * @returns
18
+ */
19
+ unSelect: (item: RecordType) => void;
20
+ /**
21
+ * 某行是否被选中
22
+ * @param item
23
+ * @returns
24
+ */
25
+ isSelected: (item: RecordType) => boolean;
26
+ /**
27
+ * 选中当前所有数据
28
+ * @returns
29
+ */
30
+ selectAll: () => void;
31
+ /**
32
+ * 取消选中当前所有数据
33
+ * @returns
34
+ */
35
+ unSelectAll: () => void;
36
+ /**
37
+ * 清空所有选中
38
+ * @returns
39
+ */
40
+ clearAll: () => void;
41
+ /**
42
+ * 切换某行的选中状态
43
+ * @param item
44
+ * @returns
45
+ */
46
+ toggleSelect: (item: RecordType) => void;
47
+ /**
48
+ * 多项选中
49
+ * @param items
50
+ * @returns
51
+ */
52
+ selectMulti: (items: RecordType[]) => void;
53
+ /**
54
+ * 多项反选
55
+ * @param items
56
+ * @returns
57
+ */
58
+ unSelectMulti: (items: RecordType[]) => void;
59
+ /**
60
+ * VxeTable 表格checkbox-change事件
61
+ * @param item
62
+ * @param select
63
+ * @param partRowData
64
+ * @returns
65
+ */
66
+ selectChange: (item: RecordType, select: boolean, partRowData: RecordType[]) => void;
67
+ /**
68
+ * VxeTable 表格checkbox-all事件
69
+ * @param item
70
+ * @param select
71
+ * @param partRowData
72
+ * @returns
73
+ */
74
+ selectAllChange: (select: boolean, partRowData: RecordType[]) => void;
75
+ /**
76
+ * VxeTable 表格checkbox-range-change事件
77
+ * @param selected
78
+ * @param partRowData
79
+ * @returns
80
+ */
81
+ selectRangeChange: (selected: RecordType[], partRowData: RecordType[]) => void;
82
+ /**
83
+ * 通过key勾选多条数据
84
+ * @param keys
85
+ * @returns
86
+ */
87
+ selectMultiByKeys: (keys: (string | number)[]) => void;
88
+ }
89
+ type RowSelectionParams<T> = Omit<ApTableRowSelection<T>, 'mode'> & {
90
+ /**
91
+ * 数据源(如果是后端分页,则表示当页数据,否则是全量数据)
92
+ */
93
+ dataSource: Ref<T[]>;
94
+ /**
95
+ * 同Table的rowkey
96
+ */
97
+ rowKey: ApTableProps['rowKey'];
98
+ };
99
+ declare const useTableRowSelection: <RecordType = Recordable>(props: RowSelectionParams<RecordType>) => RowSelectionReturnType<RecordType>;
100
+ export default useTableRowSelection;
@@ -0,0 +1,122 @@
1
+ import { ref as k, computed as v, unref as a } from "vue";
2
+ import { isFunction as i, cloneDeep as M } from "lodash-unified";
3
+ function m(u, c) {
4
+ return !(c != null && c.length) || i(u) ? [] : c.map((f) => ({ [u]: f }));
5
+ }
6
+ const T = (u) => {
7
+ u.defaultSelectedRowKeys;
8
+ const c = k(
9
+ m(u.rowKey, u.defaultSelectedRowKeys)
10
+ );
11
+ function f(e, t) {
12
+ c.value = t;
13
+ }
14
+ const l = (e) => i(u.rowKey) ? u.rowKey(e) : e[u.rowKey], s = v(() => {
15
+ const e = /* @__PURE__ */ new Map();
16
+ return a(c).forEach((t) => {
17
+ e.set(l(t), t);
18
+ }), e;
19
+ });
20
+ function g(e) {
21
+ return a(s).has(l(e));
22
+ }
23
+ function h(e) {
24
+ const t = a(s);
25
+ t.set(l(e), e), c.value = [...t.values()];
26
+ }
27
+ function x(e) {
28
+ const t = a(s);
29
+ for (const n of e)
30
+ t.set(l(n), n);
31
+ c.value = [...t.values()];
32
+ }
33
+ function w(e) {
34
+ if (i(u.rowKey))
35
+ return;
36
+ const t = a(s);
37
+ for (const n of e) {
38
+ const o = a(u.dataSource).find(
39
+ (d) => l(d) === n
40
+ ), S = { [u.rowKey]: n };
41
+ t.set(String(n), o || S);
42
+ }
43
+ c.value = [...t.values()];
44
+ }
45
+ function y(e) {
46
+ const t = a(s);
47
+ t.delete(l(e)), c.value = [...t.values()];
48
+ }
49
+ function E(e) {
50
+ const t = a(s);
51
+ for (const n of e)
52
+ t.delete(l(n));
53
+ c.value = [...t.values()];
54
+ }
55
+ function r(e, t) {
56
+ const n = e;
57
+ for (const o of t)
58
+ n.set(l(o), o);
59
+ return n;
60
+ }
61
+ function K(e, t, n) {
62
+ const o = a(s);
63
+ t ? o.set(l(e), e) : o.delete(l(e)), r(o, n), c.value = [...o.values()];
64
+ }
65
+ function A(e, t) {
66
+ const n = M(a(s));
67
+ e ? a(u.dataSource).forEach((o) => {
68
+ n.set(l(o), o);
69
+ }) : a(u.dataSource).forEach((o) => {
70
+ n.delete(l(o));
71
+ }), r(n, t), c.value = [...n.values()];
72
+ }
73
+ function C(e, t) {
74
+ const n = M(a(s));
75
+ a(u.dataSource).forEach((o) => {
76
+ e.find((d) => l(d) === l(o)) ? n.set(l(o), o) : n.delete(l(o));
77
+ }), r(n, t), c.value = [...n.values()];
78
+ }
79
+ function R() {
80
+ const e = a(s);
81
+ a(u.dataSource).forEach((t) => {
82
+ e.set(l(t), t);
83
+ }), c.value = [...e.values()];
84
+ }
85
+ function D(e) {
86
+ const t = a(s), n = l(e);
87
+ t.has(n) ? t.delete(n) : t.set(n, e), c.value = [...t.values()];
88
+ }
89
+ function I() {
90
+ const e = a(s);
91
+ a(u.dataSource).forEach((t) => {
92
+ e.delete(l(t));
93
+ }), c.value = [...e.values()];
94
+ }
95
+ function b() {
96
+ c.value = [];
97
+ }
98
+ return {
99
+ select: h,
100
+ unSelect: y,
101
+ isSelected: g,
102
+ selectAll: R,
103
+ unSelectAll: I,
104
+ clearAll: b,
105
+ toggleSelect: D,
106
+ selectedRows: c,
107
+ selectMulti: x,
108
+ unSelectMulti: E,
109
+ rowSelection: v(() => ({
110
+ ...u,
111
+ onChange: f,
112
+ selectedRowKeys: a(c).map((e) => l(e))
113
+ })),
114
+ selectChange: K,
115
+ selectAllChange: A,
116
+ selectRangeChange: C,
117
+ selectMultiByKeys: w
118
+ };
119
+ };
120
+ export {
121
+ T as default
122
+ };