@aplus-frontend/ui 0.0.21 → 0.0.23

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 (55) hide show
  1. package/es/index.mjs +34 -32
  2. package/es/src/ap-form/hooks/use-watch.d.ts +1 -1
  3. package/es/src/ap-form/modal-form/index.vue.mjs +41 -39
  4. package/es/src/ap-list/hooks/use-offline-list.d.ts +21 -0
  5. package/es/src/ap-list/hooks/use-offline-list.mjs +32 -0
  6. package/es/src/ap-list/index.d.ts +4 -0
  7. package/es/src/ap-list/index.mjs +2 -0
  8. package/es/src/ap-list/index.vue.d.ts +153 -0
  9. package/es/src/ap-list/index.vue.mjs +137 -0
  10. package/es/src/ap-list/index.vue2.mjs +4 -0
  11. package/es/src/ap-list/interface.d.ts +35 -2
  12. package/es/src/ap-list/interface.mjs +1 -0
  13. package/es/src/ap-list/style/index.css +5 -0
  14. package/es/src/ap-table/interface.d.ts +2 -2
  15. package/es/src/check-card/group.vue.d.ts +1 -1
  16. package/es/src/check-card/group.vue.mjs +1 -1
  17. package/es/src/check-card/index.vue.d.ts +1 -1
  18. package/es/src/check-card/index.vue2.mjs +40 -36
  19. package/es/src/check-card/interface.d.ts +1 -1
  20. package/es/src/editable-table/form-item.vue.d.ts +755 -105
  21. package/es/src/editable-table/form-item.vue.mjs +81 -64
  22. package/es/src/editable-table/index.vue.d.ts +527 -112
  23. package/es/src/editable-table/index.vue.mjs +93 -76
  24. package/es/src/editable-table/interface.d.ts +11 -5
  25. package/es/src/index.d.ts +1 -0
  26. package/es/src/index.mjs +230 -227
  27. package/es/src/theme/ap-list/index.css +5 -0
  28. package/lib/index.js +1 -1
  29. package/lib/src/ap-form/hooks/use-watch.d.ts +1 -1
  30. package/lib/src/ap-form/modal-form/index.vue.js +1 -1
  31. package/lib/src/ap-list/hooks/use-offline-list.d.ts +21 -0
  32. package/lib/src/ap-list/hooks/use-offline-list.js +1 -0
  33. package/lib/src/ap-list/index.d.ts +4 -0
  34. package/lib/src/ap-list/index.js +1 -0
  35. package/lib/src/ap-list/index.vue.d.ts +153 -0
  36. package/lib/src/ap-list/index.vue.js +1 -0
  37. package/lib/src/ap-list/index.vue2.js +1 -0
  38. package/lib/src/ap-list/interface.d.ts +35 -2
  39. package/lib/src/ap-list/interface.js +1 -0
  40. package/lib/src/ap-list/style/index.css +5 -0
  41. package/lib/src/ap-table/interface.d.ts +2 -2
  42. package/lib/src/check-card/group.vue.d.ts +1 -1
  43. package/lib/src/check-card/group.vue.js +1 -1
  44. package/lib/src/check-card/index.vue.d.ts +1 -1
  45. package/lib/src/check-card/index.vue2.js +1 -1
  46. package/lib/src/check-card/interface.d.ts +1 -1
  47. package/lib/src/editable-table/form-item.vue.d.ts +755 -105
  48. package/lib/src/editable-table/form-item.vue.js +1 -1
  49. package/lib/src/editable-table/index.vue.d.ts +527 -112
  50. package/lib/src/editable-table/index.vue.js +1 -1
  51. package/lib/src/editable-table/interface.d.ts +11 -5
  52. package/lib/src/index.d.ts +1 -0
  53. package/lib/src/index.js +1 -1
  54. package/lib/src/theme/ap-list/index.css +5 -0
  55. package/package.json +3 -3
@@ -1,16 +1,16 @@
1
- import { defineComponent as L, useSlots as z, ref as j, watch as I, unref as o, openBlock as p, createBlock as O, withCtx as i, createVNode as c, mergeProps as T, createSlots as K, createElementBlock as q, Fragment as A, createElementVNode as x, normalizeClass as G, toDisplayString as H, createCommentVNode as M, renderList as U, renderSlot as W, normalizeProps as $, guardReactiveProps as J } from "vue";
2
- import { Table as Q } from "ant-design-vue";
3
- import { ApForm as u } from "../ap-form/index.mjs";
4
- import { cloneDeep as C, omit as X } from "lodash-unified";
1
+ import { defineComponent as I, useSlots as K, ref as M, watch as q, unref as o, openBlock as w, createBlock as G, withCtx as f, createVNode as y, mergeProps as H, createSlots as U, createElementBlock as W, Fragment as $, createElementVNode as v, normalizeClass as J, toDisplayString as Q, createCommentVNode as X, renderList as Y, renderSlot as Z, normalizeProps as ee, guardReactiveProps as te } from "vue";
2
+ import { Table as ae } from "ant-design-vue";
3
+ import { ApForm as p } from "../ap-form/index.mjs";
4
+ import { isNumber as c, cloneDeep as h, omit as ne } from "lodash-unified";
5
5
  import "../config-provider/index.mjs";
6
6
  import "../hooks/index.mjs";
7
- import { isDef as Y } from "../utils/index.mjs";
8
- import Z from "./hooks/use-get-columns.mjs";
7
+ import { isDef as x } from "../utils/index.mjs";
8
+ import oe from "./hooks/use-get-columns.mjs";
9
9
  import "./style/index.css";
10
- import { useNamespace as ee } from "../config-provider/hooks/use-namespace.mjs";
11
- import { useGlobalConfig as ae } from "../config-provider/hooks/use-global-config.mjs";
12
- import { useControllableValue as te } from "../hooks/useControllableValue.mjs";
13
- const xe = /* @__PURE__ */ L({
10
+ import { useNamespace as le } from "../config-provider/hooks/use-namespace.mjs";
11
+ import { useGlobalConfig as re } from "../config-provider/hooks/use-global-config.mjs";
12
+ import { useControllableValue as se } from "../hooks/useControllableValue.mjs";
13
+ const ye = /* @__PURE__ */ I({
14
14
  name: "EditableTable",
15
15
  __name: "index",
16
16
  props: {
@@ -109,94 +109,111 @@ const xe = /* @__PURE__ */ L({
109
109
  onFieldChange: {}
110
110
  },
111
111
  emits: ["update:value"],
112
- setup(g, {
113
- expose: h,
114
- emit: w
112
+ setup(b, {
113
+ expose: R,
114
+ emit: B
115
115
  }) {
116
- const l = g, {
117
- b: m,
118
- em: y
119
- } = ee("editable-table"), v = ae("uiMode", "aplus"), b = z(), R = w, {
120
- value: s,
121
- updateValue: B
122
- } = te(l, R), d = j(), F = u.useWatch(l.name, d);
123
- I(() => F.value, (t) => {
116
+ const l = b, {
117
+ b: g,
118
+ em: F
119
+ } = le("editable-table"), D = re("uiMode", "aplus"), _ = K(), E = B, {
120
+ value: d,
121
+ updateValue: L
122
+ } = se(l, E), i = M(), k = p.useWatch(l.name, i);
123
+ q(() => k.value, (e) => {
124
124
  var n;
125
- B(t), (n = l.onChange) == null || n.call(l, t);
125
+ L(e), (n = l.onChange) == null || n.call(l, e);
126
126
  });
127
- const D = Z(l);
128
- function E() {
127
+ const N = oe(l);
128
+ function S() {
129
+ var e;
130
+ (e = i.value) == null || e.resetFields();
131
+ }
132
+ async function V(e, n) {
129
133
  var t;
130
- (t = d.value) == null || t.resetFields();
134
+ const a = await ((t = i.value) == null ? void 0 : t.validateFields(e, n));
135
+ return a == null ? void 0 : a[l.name];
131
136
  }
132
- async function _(t, n) {
133
- var a;
134
- const e = await ((a = d.value) == null ? void 0 : a.validateFields(t, n));
135
- return e == null ? void 0 : e[l.name];
137
+ function P(e, n) {
138
+ var r, s, u;
139
+ const a = ((r = o(d)) == null ? void 0 : r.length) || 0;
140
+ if (x(l.maxLength) && a >= l.maxLength)
141
+ return;
142
+ const t = [...o(d) || []];
143
+ x(n) ? t.splice(n, 0, {
144
+ ...e || {}
145
+ }) : t.push({
146
+ ...e || {}
147
+ }), (u = (s = i.value) == null ? void 0 : s.setFieldValue) == null || u.call(s, l.name, t);
136
148
  }
137
- function k(t) {
138
- var e, a, r;
139
- const n = ((e = o(s)) == null ? void 0 : e.length) || 0;
140
- Y(l.maxLength) && n >= l.maxLength || (r = (a = d.value) == null ? void 0 : a.setFieldValue) == null || r.call(a, l.name, [...o(s) || [], t || {}]);
149
+ function z(e, n = "suffix") {
150
+ var u, m, C;
151
+ const a = ((u = o(d)) == null ? void 0 : u.length) || 0, t = c(e) ? e : e.length;
152
+ if (x(l.maxLength) && a + t > l.maxLength)
153
+ return;
154
+ const r = [...o(d) || []], s = c(e) ? new Array(e).fill({}) : h(e);
155
+ n === "suffix" ? r.push(...s) : r.unshift(...s), (C = (m = i.value) == null ? void 0 : m.setFieldValue) == null || C.call(m, l.name, r);
141
156
  }
142
- function S(t) {
143
- var e, a;
144
- const n = C(o(s) || []);
145
- n.splice(t, 1), (a = (e = d.value) == null ? void 0 : e.setFieldValue) == null || a.call(e, l.name, [...n]);
157
+ function j(e) {
158
+ var t, r;
159
+ let n = h(o(d) || []);
160
+ const a = c(e) ? [e] : e;
161
+ n = n.filter((s, u) => !a.includes(u)), (r = (t = i.value) == null ? void 0 : t.setFieldValue) == null || r.call(t, l.name, n);
146
162
  }
147
- function V() {
148
- return o(s);
163
+ function A() {
164
+ return o(d);
149
165
  }
150
- function N(t) {
166
+ function O(e) {
151
167
  var n;
152
- return (n = o(s)) == null ? void 0 : n[t];
168
+ return (n = o(d)) == null ? void 0 : n[e];
153
169
  }
154
- function P(t, n) {
155
- var a, r;
156
- const e = C(o(s));
157
- e[t] && (e[t] = {
158
- ...e[t],
170
+ function T(e, n) {
171
+ var t, r;
172
+ const a = h(o(d));
173
+ a[e] && (a[e] = {
174
+ ...a[e],
159
175
  ...n
160
- }, (r = (a = d.value) == null ? void 0 : a.setFieldValue) == null || r.call(a, l.name, [...e]));
176
+ }, (r = (t = i.value) == null ? void 0 : t.setFieldValue) == null || r.call(t, l.name, [...a]));
161
177
  }
162
- return h({
163
- resetFields: E,
164
- validateFields: _,
165
- add: k,
166
- remove: S,
167
- getRowData: N,
168
- getRowsData: V,
169
- setRowData: P
170
- }), (t, n) => (p(), O(o(u), {
178
+ return R({
179
+ resetFields: S,
180
+ validateFields: V,
181
+ add: P,
182
+ remove: j,
183
+ getRowData: O,
184
+ getRowsData: A,
185
+ setRowData: T,
186
+ addMultiple: z
187
+ }), (e, n) => (w(), G(o(p), {
171
188
  "initial-values": {
172
- [l.name]: o(s)
189
+ [l.name]: o(d)
173
190
  },
174
191
  ref_key: "formRef",
175
- ref: d
192
+ ref: i
176
193
  }, {
177
- default: i(() => [c(o(u).FormItem, {
178
- name: t.name,
194
+ default: f(() => [y(o(p).FormItem, {
195
+ name: e.name,
179
196
  "no-style": ""
180
197
  }, {
181
- default: i(() => [c(o(Q), T(o(X)(l, ["name", "value", "onUpdate:value", "maxLength"]), {
182
- class: [o(m)(), o(v) === "admin" ? o(m)("admin") : null],
183
- columns: o(D),
184
- "data-source": o(s)
185
- }), K({
186
- headerCell: i(({
187
- column: e
198
+ default: f(() => [y(o(ae), H(o(ne)(l, ["name", "value", "onUpdate:value", "maxLength"]), {
199
+ class: [o(g)(), o(D) === "admin" ? o(g)("admin") : null],
200
+ columns: o(N),
201
+ "data-source": o(d)
202
+ }), U({
203
+ headerCell: f(({
204
+ column: a
188
205
  }) => {
189
- var a, r, f;
190
- return [(a = e == null ? void 0 : e.fieldProps) != null && a.required || (f = (r = e == null ? void 0 : e.fieldProps) == null ? void 0 : r.rules) != null && f.length ? (p(), q(A, {
206
+ var t, r, s;
207
+ return [(t = a == null ? void 0 : a.fieldProps) != null && t.required || (s = (r = a == null ? void 0 : a.fieldProps) == null ? void 0 : r.rules) != null && s.length ? (w(), W($, {
191
208
  key: 0
192
- }, [x("span", {
193
- class: G(o(y)("header-cell", "required"))
194
- }, "*", 2), x("span", null, H(e.title), 1)], 64)) : M("", !0)];
209
+ }, [v("span", {
210
+ class: J(o(F)("header-cell", "required"))
211
+ }, "*", 2), v("span", null, Q(a.title), 1)], 64)) : X("", !0)];
195
212
  }),
196
213
  _: 2
197
- }, [U(b, (e, a) => ({
198
- name: a,
199
- fn: i((r) => [W(t.$slots, a, $(J(r || {})))])
214
+ }, [Y(_, (a, t) => ({
215
+ name: t,
216
+ fn: f((r) => [Z(e.$slots, t, ee(te(r || {})))])
200
217
  }))]), 1040, ["class", "columns", "data-source"])]),
201
218
  _: 3
202
219
  }, 8, ["name"])]),
@@ -205,5 +222,5 @@ const xe = /* @__PURE__ */ L({
205
222
  }
206
223
  });
207
224
  export {
208
- xe as default
225
+ ye as default
209
226
  };
@@ -124,17 +124,23 @@ export type EditableTableExpose<ModelType = any, RecordType = any> = {
124
124
  */
125
125
  validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
126
126
  /**
127
- * 添加一行数据
128
- * @param defaultValue
129
- * @returns
127
+ * 添加单条数据
128
+ * @param defaultValue 默认值,如果需要设置`insertIndex`,可以设置`defaultValue`为`{}`
129
+ * @param insertIndex 数据插入的位置
130
+ */
131
+ add: (defaultValue?: Partial<RecordType>, insertIndex?: number) => void;
132
+ /**
133
+ * 添加多条数据
134
+ * @param list 添加的条数或数据
135
+ * @param insetIn 插入的位置(前/后)
130
136
  */
131
- add: (defaultValue?: Partial<RecordType>) => void;
137
+ addMultiple: (list: number | Partial<RecordType>[], insetIn?: 'prefix' | 'suffix') => void;
132
138
  /**
133
139
  * 删除一行数据
134
140
  * @param index
135
141
  * @returns
136
142
  */
137
- remove: (index: number) => void;
143
+ remove: (index: number | number[]) => void;
138
144
  /**
139
145
  * 获取所有行的数据
140
146
  * @returns
package/es/src/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export * from './ap-upload';
28
28
  export * from './ap-download';
29
29
  export * from './check-card';
30
30
  export * from './ap-modal';
31
+ export * from './ap-list';
31
32
  export * from './business';
32
33
  export * from './ap-table';
33
34
  export * from './editable-table';