@aplus-frontend/ui 0.0.4 → 0.0.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.
Files changed (43) hide show
  1. package/es/src/ap-form/ap-form-item-group/index.vue.mjs +23 -21
  2. package/es/src/ap-form/ap-form.vue.d.ts +7 -2
  3. package/es/src/ap-form/ap-form.vue2.mjs +85 -52
  4. package/es/src/ap-form/context.d.ts +14 -0
  5. package/es/src/ap-form/hooks/use-watch.d.ts +7 -0
  6. package/es/src/ap-form/hooks/use-watch.mjs +30 -0
  7. package/es/src/ap-form/index.d.ts +2 -0
  8. package/es/src/ap-form/index.mjs +13 -11
  9. package/es/src/ap-form/interface.d.ts +17 -7
  10. package/es/src/ap-form/modal-form/index.vue.d.ts +2 -2
  11. package/es/src/ap-form/modal-form/index.vue.mjs +1 -1
  12. package/es/src/ap-form/search-form/index.vue.mjs +27 -27
  13. package/es/src/ap-table/ap-table.vue.d.ts +2 -0
  14. package/es/src/ap-table/ap-table.vue.mjs +98 -93
  15. package/es/src/ap-table/interface.d.ts +18 -1
  16. package/es/src/pro-form/helper.mjs +7 -7
  17. package/es/src/theme/antd-global-overwrite/admin/alert.css +3 -0
  18. package/es/src/theme/antd-global-overwrite/admin/index.css +3 -0
  19. package/es/src/theme/antd-global-overwrite/aplus/alert.css +3 -0
  20. package/es/src/theme/antd-global-overwrite/aplus/index.css +3 -0
  21. package/es/src/utils/index.mjs +32 -32
  22. package/lib/src/ap-form/ap-form-item-group/index.vue.js +1 -1
  23. package/lib/src/ap-form/ap-form.vue.d.ts +7 -2
  24. package/lib/src/ap-form/ap-form.vue2.js +1 -1
  25. package/lib/src/ap-form/context.d.ts +14 -0
  26. package/lib/src/ap-form/hooks/use-watch.d.ts +7 -0
  27. package/lib/src/ap-form/hooks/use-watch.js +1 -0
  28. package/lib/src/ap-form/index.d.ts +2 -0
  29. package/lib/src/ap-form/index.js +1 -1
  30. package/lib/src/ap-form/interface.d.ts +17 -7
  31. package/lib/src/ap-form/modal-form/index.vue.d.ts +2 -2
  32. package/lib/src/ap-form/modal-form/index.vue.js +1 -1
  33. package/lib/src/ap-form/search-form/index.vue.js +1 -1
  34. package/lib/src/ap-table/ap-table.vue.d.ts +2 -0
  35. package/lib/src/ap-table/ap-table.vue.js +1 -1
  36. package/lib/src/ap-table/interface.d.ts +18 -1
  37. package/lib/src/pro-form/helper.js +1 -1
  38. package/lib/src/theme/antd-global-overwrite/admin/alert.css +3 -0
  39. package/lib/src/theme/antd-global-overwrite/admin/index.css +3 -0
  40. package/lib/src/theme/antd-global-overwrite/aplus/alert.css +3 -0
  41. package/lib/src/theme/antd-global-overwrite/aplus/index.css +3 -0
  42. package/lib/src/utils/index.js +1 -1
  43. package/package.json +2 -2
@@ -1,19 +1,19 @@
1
- import { defineComponent as K, computed as u, createVNode as d, mergeProps as m, unref as n, watch as $, openBlock as p, createElementBlock as c, normalizeClass as b, normalizeStyle as T, withCtx as f, Fragment as H, renderList as x, createBlock as G, resolveDynamicComponent as Q, createCommentVNode as B, createElementVNode as P, renderSlot as I, createSlots as U, toDisplayString as J, normalizeProps as X, guardReactiveProps as Y } from "vue";
2
- import { Typography as Z, Table as ee, Tooltip as ae } from "ant-design-vue";
3
- import { ApForm as te } from "../ap-form/index.mjs";
4
- import { apTableRenderItemMap as oe, noRenderAsFormItemValueList as v, apTableFormItemMap as ne } from "./constants.mjs";
1
+ import { defineComponent as $, computed as u, createVNode as d, mergeProps as m, unref as l, watch as H, openBlock as p, createElementBlock as c, normalizeClass as h, normalizeStyle as T, withCtx as f, Fragment as G, renderList as x, createBlock as Q, resolveDynamicComponent as U, createCommentVNode as B, createElementVNode as P, renderSlot as I, createSlots as J, toDisplayString as X, normalizeProps as Y, guardReactiveProps as Z } from "vue";
2
+ import { Typography as ee, Table as ae, Tooltip as te } from "ant-design-vue";
3
+ import { ApForm as oe } from "../ap-form/index.mjs";
4
+ import { apTableRenderItemMap as le, noRenderAsFormItemValueList as v, apTableFormItemMap as ne } from "./constants.mjs";
5
5
  import "../config-provider/index.mjs";
6
- import { useTablePaging as le } from "./hooks/use-table-paging.mjs";
7
- import { isUndefined as re, omit as de } from "lodash-unified";
6
+ import { useTablePaging as re } from "./hooks/use-table-paging.mjs";
7
+ import { isUndefined as de, omit as se } from "lodash-unified";
8
8
  import "./style/ap-table.css";
9
- import { QuestionCircleOutlined as se } from "@ant-design/icons-vue";
10
- import { apColumnToColumn as ue, getTableRenderType as pe, getTableRenderProps as ie, getColumnOrder as k, updateFormProps as me, getFieldProps as ce, getPlaceholder as fe } from "./utils.mjs";
11
- import { useLocale as ge } from "../config-provider/hooks/use-locale.mjs";
12
- import { useNamespace as ye } from "../config-provider/hooks/use-namespace.mjs";
13
- import { useGlobalConfig as be } from "../config-provider/hooks/use-global-config.mjs";
14
- const he = {
9
+ import { QuestionCircleOutlined as ue } from "@ant-design/icons-vue";
10
+ import { apColumnToColumn as pe, getTableRenderType as ie, getTableRenderProps as me, getColumnOrder as k, updateFormProps as ce, getFieldProps as fe, getPlaceholder as ge } from "./utils.mjs";
11
+ import { useLocale as ye } from "../config-provider/hooks/use-locale.mjs";
12
+ import { useNamespace as be } from "../config-provider/hooks/use-namespace.mjs";
13
+ import { useGlobalConfig as he } from "../config-provider/hooks/use-global-config.mjs";
14
+ const Ce = {
15
15
  key: 0
16
- }, ze = /* @__PURE__ */ K({
16
+ }, Ee = /* @__PURE__ */ $({
17
17
  name: "ApTable",
18
18
  __name: "ap-table",
19
19
  props: {
@@ -125,126 +125,131 @@ const he = {
125
125
  setup(O, {
126
126
  expose: z
127
127
  }) {
128
- const l = O, {
128
+ const n = O, {
129
129
  t: E
130
- } = ge(), {
131
- e: h,
130
+ } = ye(), {
131
+ e: C,
132
132
  b: g
133
- } = ye("ap-table"), L = be("uiMode"), y = u(() => {
134
- var o;
135
- let e = ((o = l.columns) == null ? void 0 : o.filter((a) => !a.hideInTable)) || [];
133
+ } = be("ap-table"), L = he("uiMode"), y = u(() => {
134
+ var t;
135
+ let e = ((t = n.columns) == null ? void 0 : t.filter((a) => !a.hideInTable)) || [];
136
136
  return e = e.map((a) => ({
137
- ...ue(a),
137
+ ...pe(a),
138
138
  customRender({
139
- value: t,
139
+ value: o,
140
140
  ...r
141
141
  }) {
142
142
  let s;
143
143
  if (a.customRender)
144
144
  s = a.customRender({
145
- value: t,
145
+ value: o,
146
146
  ...r,
147
147
  column: a
148
148
  });
149
149
  else {
150
- const w = pe(a), _ = oe[w], q = ie(a, {
151
- value: t,
150
+ const w = ie(a), q = le[w], K = me(a, {
151
+ value: o,
152
152
  ...r
153
153
  });
154
- s = d(_, m(q, {
154
+ s = d(q, m(K, {
155
155
  mode: "read"
156
156
  }), null);
157
157
  }
158
- return A(a, t, s);
158
+ return A(a, o, s);
159
159
  }
160
160
  })), e;
161
- }), C = u(() => {
162
- var e, o, a;
163
- return ((a = (o = (e = l.columns) == null ? void 0 : e.filter((t) => !t.hideInSearch && t.dataIndex && (t.valueType || t.customRenderFormItem) && !v.includes(t.valueType))) == null ? void 0 : o.sort((t, r) => {
164
- let s = k(t.order);
161
+ }), F = u(() => {
162
+ var e, t, a;
163
+ return ((a = (t = (e = n.columns) == null ? void 0 : e.filter((o) => !o.hideInSearch && o.dataIndex && (o.valueType || o.customRenderFormItem) && !v.includes(o.valueType))) == null ? void 0 : t.sort((o, r) => {
164
+ let s = k(o.order);
165
165
  return k(r.order) - s;
166
- })) == null ? void 0 : a.map((t) => {
167
- const r = me(t, ce(t.fieldProps));
166
+ })) == null ? void 0 : a.map((o) => {
167
+ const r = ce(o, fe(o.fieldProps));
168
168
  return {
169
- ...t,
169
+ ...o,
170
170
  fieldProps: {
171
- label: t.title,
172
- name: t.dataIndex,
171
+ label: o.title,
172
+ name: o.dataIndex,
173
173
  ...r || {},
174
174
  // 格式化placeholder
175
- placeholder: fe(E, t.valueType, r == null ? void 0 : r.placeholder)
175
+ placeholder: ge(E, o.valueType, r == null ? void 0 : r.placeholder)
176
176
  }
177
177
  };
178
178
  })) || [];
179
- }), N = u(() => n(y).filter((e) => e.sorter === !0).map((e) => e.dataIndex)), D = u(() => n(y).filter((e) => e.filters && !e.onFilter).map((e) => e.dataIndex)), {
180
- formRef: F,
181
- submit: R,
182
- reset: S,
179
+ }), V = u(() => l(y).filter((e) => e.sorter === !0).map((e) => e.dataIndex)), N = u(() => l(y).filter((e) => e.filters && !e.onFilter).map((e) => e.dataIndex)), {
180
+ formRef: b,
181
+ submit: S,
182
+ reset: R,
183
183
  tableProps: i,
184
- handleTableChange: V,
184
+ handleTableChange: D,
185
185
  data: j
186
- } = le({
186
+ } = re({
187
187
  async request(e) {
188
- var a, t;
189
- const o = await ((a = l.request) == null ? void 0 : a.call(l, e));
190
- return (t = l.onLoad) == null || t.call(l, (o == null ? void 0 : o.data) || []), {
191
- data: (o == null ? void 0 : o.data) || [],
192
- total: (o == null ? void 0 : o.total) || 0
188
+ var a, o;
189
+ const t = await ((a = n.request) == null ? void 0 : a.call(n, e));
190
+ return (o = n.onLoad) == null || o.call(n, (t == null ? void 0 : t.data) || []), {
191
+ data: (t == null ? void 0 : t.data) || [],
192
+ total: (t == null ? void 0 : t.total) || 0
193
193
  };
194
194
  },
195
- filterFields: n(D),
196
- sortFields: n(N),
197
- defaultParams: l.params,
198
- defaultData: l.defaultData,
199
- manual: l.manual,
200
- defaultCurrent: l.pagination ? l.pagination.defaultCurrent : void 0,
201
- defaultPageSize: l.pagination ? l.pagination.defaultPageSize : void 0,
202
- formatParams: l.beforeSearchSubmit
195
+ filterFields: l(N),
196
+ sortFields: l(V),
197
+ defaultParams: n.params,
198
+ defaultData: n.defaultData,
199
+ manual: n.manual,
200
+ defaultCurrent: n.pagination ? n.pagination.defaultCurrent : void 0,
201
+ defaultPageSize: n.pagination ? n.pagination.defaultPageSize : void 0,
202
+ formatParams: n.beforeSearchSubmit
203
203
  }), W = u(() => ({
204
- ...l,
205
- ...n(i),
206
- loading: re(l.loading) ? n(i).loading : l.loading,
207
- pagination: l.pagination === !1 ? !1 : n(i).pagination
204
+ ...n,
205
+ ...l(i),
206
+ loading: de(n.loading) ? l(i).loading : n.loading,
207
+ pagination: n.pagination === !1 ? !1 : l(i).pagination
208
208
  }));
209
- function A(e, o, a) {
210
- return v.includes(e.valueType) ? a : e.copyable || e.ellipsis ? d(Z.Text, {
209
+ function A(e, t, a) {
210
+ return v.includes(e.valueType) ? a : e.copyable || e.ellipsis ? d(ee.Text, {
211
211
  copyable: e.copyable ? {
212
- text: o,
212
+ text: t,
213
213
  tooltip: !1
214
214
  } : !1,
215
215
  ellipsis: e.ellipsis ? {
216
- tooltip: o
216
+ tooltip: t
217
217
  } : !1,
218
218
  content: a
219
219
  }, null) : a;
220
220
  }
221
- $(() => n(j).loading, (e) => {
222
- var o;
223
- (o = l.onLoadingChange) == null || o.call(l, e);
221
+ H(() => l(j).loading, (e) => {
222
+ var t;
223
+ (t = n.onLoadingChange) == null || t.call(n, e);
224
224
  });
225
225
  function M(e) {
226
- var o, a, t;
227
- (t = (a = (o = F.value) == null ? void 0 : o.apForm) == null ? void 0 : a.setFieldsValue) == null || t.call(a, e);
226
+ var t, a, o;
227
+ (o = (a = (t = b.value) == null ? void 0 : t.apForm) == null ? void 0 : a.setFieldsValue) == null || o.call(a, e);
228
+ }
229
+ function _() {
230
+ var e, t, a;
231
+ return (a = (t = (e = b.value) == null ? void 0 : e.apForm) == null ? void 0 : t.getFieldsValue) == null ? void 0 : a.call(t, !0);
228
232
  }
229
233
  return z({
230
- submit: () => R(),
231
- reset: () => S(),
232
- setSearchFormValues: M
233
- }), (e, o) => (p(), c("div", {
234
- class: b(e.card ? null : n(g)("wrapper"))
235
- }, [e.searchForm !== !1 && C.value.length > 0 ? (p(), c("div", {
234
+ submit: () => S(),
235
+ reset: () => R(),
236
+ setSearchFormValues: M,
237
+ getSearchFormValues: _
238
+ }), (e, t) => (p(), c("div", {
239
+ class: h(e.card ? null : l(g)("wrapper"))
240
+ }, [e.searchForm !== !1 && F.value.length > 0 ? (p(), c("div", {
236
241
  key: 0,
237
- class: b(e.card ? n(h)("search-wrapper") : null),
242
+ class: h(e.card ? l(C)("search-wrapper") : null),
238
243
  style: T(e.searchFormWrapperStyle)
239
- }, [d(n(te).SearchForm, m(e.searchForm || {}, {
244
+ }, [d(l(oe).SearchForm, m(e.searchForm || {}, {
240
245
  ref_key: "formRef",
241
- ref: F,
246
+ ref: b,
242
247
  "custom-reset": "",
243
- onSubmit: n(R),
244
- onReset: n(S),
245
- "submit-loading": n(i).loading
248
+ onSubmit: l(S),
249
+ onReset: l(R),
250
+ "submit-loading": l(i).loading
246
251
  }), {
247
- default: f(() => [(p(!0), c(H, null, x(C.value, (a) => (p(), G(Q(a.customRenderFormItem ? a.customRenderFormItem(a) : n(ne)[a.valueType || "text"]), m({
252
+ default: f(() => [(p(!0), c(G, null, x(F.value, (a) => (p(), Q(U(a.customRenderFormItem ? a.customRenderFormItem(a) : l(ne)[a.valueType || "text"]), m({
248
253
  key: a.dataIndex,
249
254
  ref_for: !0
250
255
  }, a.fieldProps || {}, {
@@ -252,22 +257,22 @@ const he = {
252
257
  }), null, 16, ["span"]))), 128))]),
253
258
  _: 1
254
259
  }, 16, ["onSubmit", "onReset", "submit-loading"])], 6)) : B("", !0), P("div", {
255
- class: b(e.card ? n(h)("table-wrapper") : null),
260
+ class: h(e.card ? l(C)("table-wrapper") : null),
256
261
  style: T(e.tableWrapperStyle)
257
- }, [I(e.$slots, "title"), d(n(ee), m({
258
- class: n(L) === "admin" ? n(g)("table-admin") : n(g)("table")
262
+ }, [I(e.$slots, "title"), d(l(ae), m({
263
+ class: l(L) === "admin" ? l(g)("table-admin") : l(g)("table")
259
264
  }, W.value, {
260
- onChange: n(V),
265
+ onChange: l(D),
261
266
  columns: y.value
262
- }), U({
267
+ }), J({
263
268
  headerCell: f(({
264
269
  column: a,
265
- title: t
266
- }) => [a.tooltip ? (p(), c("span", he, [P("span", null, J(t), 1), d(n(ae), {
270
+ title: o
271
+ }) => [a.tooltip ? (p(), c("span", Ce, [P("span", null, X(o), 1), d(l(te), {
267
272
  title: a.tooltip,
268
273
  placement: "bottom"
269
274
  }, {
270
- default: f(() => [d(n(se), {
275
+ default: f(() => [d(l(ue), {
271
276
  style: {
272
277
  color: "#0070ff",
273
278
  "padding-left": "4px"
@@ -276,12 +281,12 @@ const he = {
276
281
  _: 2
277
282
  }, 1032, ["title"])])) : B("", !0)]),
278
283
  _: 2
279
- }, [x(n(de)(e.$slots, "title"), (a, t) => ({
280
- name: t,
281
- fn: f((r) => [I(e.$slots, t, X(Y(r || {})))])
284
+ }, [x(l(se)(e.$slots, "title"), (a, o) => ({
285
+ name: o,
286
+ fn: f((r) => [I(e.$slots, o, Y(Z(r || {})))])
282
287
  }))]), 1040, ["class", "onChange", "columns"])], 6)], 2));
283
288
  }
284
289
  });
285
290
  export {
286
- ze as default
291
+ Ee as default
287
292
  };
@@ -196,9 +196,26 @@ export type ApTableProps<RecordType = any, ParamsType = any, ValueType extends k
196
196
  */
197
197
  size?: 'middle' | 'small';
198
198
  };
199
- export type ApTableExpose = {
199
+ export type ApTableExpose<SearchParamsType = Recordable> = {
200
+ /**
201
+ * 查询表单提交
202
+ */
200
203
  submit: () => void;
204
+ /**
205
+ * 查询表单重置
206
+ */
201
207
  reset: () => void;
208
+ /**
209
+ * 设置查询表单的值
210
+ * @param fields
211
+ * @returns
212
+ */
213
+ setSearchFormValues: (fields: Partial<SearchParamsType>) => void;
214
+ /**
215
+ * 获取查询表单值
216
+ * @returns
217
+ */
218
+ getSearchFormValues: () => Partial<SearchParamsType>;
202
219
  };
203
220
  export type FixedApColumnType<ValueType extends keyof ApTableValueFields = 'text', RecordType = any> = Omit<ApColumnType<ValueType, RecordType>, 'filters'> & {
204
221
  filters?: ColumnType<RecordType>['filters'];
@@ -3,12 +3,12 @@ const n = ["Divider", "BasicTitle"];
3
3
  function p(e) {
4
4
  return n.includes(e || "");
5
5
  }
6
- function d(e, i, r) {
6
+ function a(e, i, r) {
7
7
  Reflect.has(e, "type") || (["DatePicker", "MonthPicker", "WeekPicker", "TimePicker"].includes(
8
8
  i
9
9
  ) ? e.type = r ? "string" : "object" : ["RangePicker", "Upload", "CheckboxGroup", "TimePicker"].includes(i) ? e.type = "array" : ["InputNumber"].includes(i) && (e.type = "number"));
10
10
  }
11
- const a = [
11
+ const l = [
12
12
  "ApiTransfer",
13
13
  "ApiTree",
14
14
  "ApiTreeSelect",
@@ -18,8 +18,8 @@ const a = [
18
18
  "RadioButtonGroup",
19
19
  "ApiSelect"
20
20
  ];
21
- function l(e, i = "", r) {
22
- return e.includes("Input") || e.includes("Complete") ? r("ap.common.inputText") + i : e.includes("Picker") || e.includes("Select") || e.includes("Cascader") || e.includes("Checkbox") || e.includes("Radio") || e.includes("Switch") ? r("ap.common.chooseText") + i : "";
21
+ function d(e, i = "", r) {
22
+ return e.includes("Input") || e.includes("Complete") ? r("ap.common.inputText") : e.includes("Picker") || e.includes("Select") || e.includes("Cascader") || e.includes("Checkbox") || e.includes("Radio") || e.includes("Switch") ? r("ap.common.chooseText") : "";
23
23
  }
24
24
  const u = ["DatePicker", "MonthPicker", "WeekPicker", "TimePicker"];
25
25
  function c() {
@@ -36,12 +36,12 @@ function T(e, i) {
36
36
  return e && s.includes(e) && i && t(i) ? `${i}` : i;
37
37
  }
38
38
  export {
39
- a as NO_AUTO_LINK_COMPONENTS,
40
- l as createPlaceholderMessage,
39
+ l as NO_AUTO_LINK_COMPONENTS,
40
+ d as createPlaceholderMessage,
41
41
  f as dateItemType,
42
42
  s as defaultValueComponents,
43
43
  T as handleInputNumberValue,
44
44
  p as isIncludeSimpleComponents,
45
- d as setComponentRuleType,
45
+ a as setComponentRuleType,
46
46
  n as simpleComponents
47
47
  };
@@ -4,6 +4,9 @@
4
4
  padding: 6px 12px;
5
5
  border-radius: 4px;
6
6
  }
7
+ .ant-alert .ant-alert-close-icon {
8
+ line-height: 18px;
9
+ }
7
10
  .ant-alert .ant-alert-icon {
8
11
  font-size: 16px;
9
12
  transform: translateY(1px);
@@ -4,6 +4,9 @@
4
4
  padding: 6px 12px;
5
5
  border-radius: 4px;
6
6
  }
7
+ .ant-alert .ant-alert-close-icon {
8
+ line-height: 18px;
9
+ }
7
10
  .ant-alert .ant-alert-icon {
8
11
  font-size: 16px;
9
12
  transform: translateY(1px);
@@ -4,6 +4,9 @@
4
4
  padding: 6px 12px;
5
5
  border-radius: 4px;
6
6
  }
7
+ .ant-alert .ant-alert-close-icon {
8
+ line-height: 18px;
9
+ }
7
10
  .ant-alert .ant-alert-icon {
8
11
  font-size: 16px;
9
12
  transform: translateY(1px);
@@ -4,6 +4,9 @@
4
4
  padding: 6px 12px;
5
5
  border-radius: 4px;
6
6
  }
7
+ .ant-alert .ant-alert-close-icon {
8
+ line-height: 18px;
9
+ }
7
10
  .ant-alert .ant-alert-icon {
8
11
  font-size: 16px;
9
12
  transform: translateY(1px);
@@ -1,50 +1,50 @@
1
1
  import { unref as s, markRaw as u } from "vue";
2
2
  import { isUndefined as a } from "lodash-unified";
3
- function p(e) {
4
- return (e == null ? void 0 : e.parentNode) ?? document.body;
3
+ function m(t) {
4
+ return (t == null ? void 0 : t.parentNode) ?? document.body;
5
5
  }
6
- function m(e) {
7
- return typeof e < "u";
6
+ function p(t) {
7
+ return typeof t < "u";
8
8
  }
9
- function d(e) {
10
- const t = {};
11
- return Object.keys(e).map((n) => {
12
- t[n] = s(e[n]);
13
- }), t;
9
+ function d(t) {
10
+ const e = {};
11
+ return Object.keys(t).map((n) => {
12
+ e[n] = s(t[n]);
13
+ }), e;
14
14
  }
15
- function g(e, t = [], n) {
16
- const r = Object.assign({}, e), i = Object.keys(r);
17
- for (let c = 0; c < i.length; c += 1) {
18
- const o = i[c];
19
- (t.includes(o) || n != null && n(o, r[o])) && delete r[o];
15
+ function g(t, e = [], n) {
16
+ const r = Object.assign({}, t), c = Object.keys(r);
17
+ for (let o = 0; o < c.length; o += 1) {
18
+ const i = c[o];
19
+ (e.includes(i) || n != null && n(i, r[i])) && delete r[i];
20
20
  }
21
21
  return r;
22
22
  }
23
- function k(e) {
24
- return /^[A-Z][A-Za-z]*$/.test(e);
23
+ function k(t) {
24
+ return /^[A-Z][A-Za-z]*$/.test(t);
25
25
  }
26
- function f(e) {
27
- if (Array.isArray(e))
28
- return e.map((t) => f(t));
29
- if (typeof e == "object" && e !== null) {
30
- const t = {};
31
- for (const n in e)
32
- t[n] = f(e[n]);
33
- return u(t);
26
+ function f(t) {
27
+ if (Array.isArray(t))
28
+ return t.map((e) => f(e));
29
+ if (typeof t == "object" && t !== null) {
30
+ const e = {};
31
+ for (const n in t)
32
+ e[n] = f(t[n]);
33
+ return u(e);
34
34
  }
35
- return e;
35
+ return t;
36
36
  }
37
- function O(e) {
38
- const t = { ...e };
39
- for (const n of Object.keys(t))
40
- a(t[n]) && delete t[n];
41
- return console.log("copy", t), t;
37
+ function O(t) {
38
+ const e = { ...t };
39
+ for (const n of Object.keys(e))
40
+ a(e[n]) && delete e[n];
41
+ return e;
42
42
  }
43
43
  export {
44
44
  f as convertReactiveToRaw,
45
45
  d as getDynamicProps,
46
- p as getPopupContainer,
47
- m as isDef,
46
+ m as getPopupContainer,
47
+ p as isDef,
48
48
  k as isPascalCase,
49
49
  O as omitUndefined,
50
50
  g as omitWhen
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("ant-design-vue"),k=require("lodash-unified"),y=require("../constant.js"),s=require("./helper.js");require("../../config-provider/index.js");require("../style/ap-form-item-group.css");const C=require("../../config-provider/hooks/use-namespace.js");function _(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!e.isVNode(r)}const h=e.defineComponent({name:"ApFormItemGroup",__name:"index",props:{align:{},justify:{},prefixCls:{},gutter:{default:16},wrap:{type:Boolean,default:void 0},countPerRow:{default:3}},setup(r){const{b:u}=C.useNamespace("ap-form-item-group"),{countPerRow:p,...d}=r,c=e.useSlots();e.watch(()=>c.default(),t=>{a.value=s.genRealChildren(t)});const a=e.shallowRef(s.genRealChildren(c.default())),f=e.computed(()=>e.unref(a).map((t,l)=>{const o=t.props,n=k.pick(o,y.apFormItemColPropKeys),m=n!=null&&n.span?{}:s.buildColSpan(p),g=!!(o!=null&&o.hidden);return e.createVNode(i.Col,e.mergeProps({key:l},m,n,{class:g?u("col-hidden"):""}),_(t)?t:{default:()=>[t]})}));return(t,l)=>(e.openBlock(),e.createBlock(e.unref(i.Row),e.mergeProps({class:e.unref(u)()},d),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(o,n)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o),{key:n}))),128))]),_:1},16,["class"]))}});exports.default=h;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("ant-design-vue"),C=require("lodash-unified"),h=require("../constant.js"),u=require("./helper.js");require("../../config-provider/index.js");require("../style/ap-form-item-group.css");const k=require("../../config-provider/hooks/use-namespace.js");function y(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!e.isVNode(r)}const _=e.defineComponent({name:"ApFormItemGroup",__name:"index",props:{align:{},justify:{},prefixCls:{},gutter:{default:16},wrap:{type:Boolean,default:void 0},countPerRow:{default:3}},setup(r){const{b:l}=k.useNamespace("ap-form-item-group"),{countPerRow:p,...d}=r,s=e.useSlots();e.watch(()=>s.default(),t=>{a.value=u.genRealChildren(t)}),e.onBeforeUpdate(()=>{a.value=u.genRealChildren(s.default())});const a=e.shallowRef(u.genRealChildren(s.default())),f=e.computed(()=>e.unref(a).map((t,c)=>{const o=t.props,n=C.pick(o,h.apFormItemColPropKeys),m=n!=null&&n.span?{}:u.buildColSpan(p),g=!!(o!=null&&o.hidden);return e.createVNode(i.Col,e.mergeProps({key:c},m,n,{class:g?l("col-hidden"):""}),y(t)?t:{default:()=>[t]})}));return(t,c)=>(e.openBlock(),e.createBlock(e.unref(i.Row),e.mergeProps({class:e.unref(l)()},d),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(o,n)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o),{key:n}))),128))]),_:1},16,["class"]))}});exports.default=_;
@@ -1,7 +1,11 @@
1
- import { ApFormProps } from './interface';
1
+ import { ApFormProps, WatchFunc } from './interface';
2
2
  import { InternalNamePath, NamePath, ValidateOptions, FormLabelAlign } from 'ant-design-vue/es/form/interface';
3
3
  import { DefineComponent, ComponentOptionsMixin, PublicProps, ExtractPropTypes, PropType } from 'vue';
4
4
 
5
+ /**
6
+ * 订阅事件
7
+ */
8
+ declare function registerWatch(callback: WatchFunc): () => void;
5
9
  declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ApFormProps>, {
6
10
  layout: string;
7
11
  hideRequiredMark: boolean;
@@ -23,7 +27,8 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
23
27
  }> | undefined;
24
28
  scrollToField: (name: NamePath, options?: {}) => void;
25
29
  setFieldsValue: (values: Record<string, any>) => void;
26
- setFieldValue: (key: string, newValue: any) => void;
30
+ setFieldValue: (key: any, newValue: any) => void;
31
+ registerWatch: typeof registerWatch;
27
32
  }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ApFormProps>, {
28
33
  layout: string;
29
34
  hideRequiredMark: boolean;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),c=require("ant-design-vue"),f=require("./context.js"),F=require("lodash-unified"),p=a.defineComponent({__name:"ap-form",props:{initialValues:{},layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinish:{},onFinishFailed:{},onValidate:{}},setup(d,{expose:n}){const s=d;function u(e,l){if(F.isArray(e)){let t=r;for(let i=0;i<e.length-1;i++)t=t[e[i]];t[e[e.length-1]]=l}else r[e]=l}const o=a.ref(),r=a.reactive(s.initialValues||{});return f.useProvideForm({model:a.computed(()=>r),updateModel:u}),n({resetFields:e=>{var l;(l=o.value)==null||l.resetFields(e)},clearValidate:e=>{var l;(l=o.value)==null||l.clearValidate(e)},validateFields:(e,l)=>{var t;return(t=o.value)==null?void 0:t.validateFields(e,l)},getFieldsValue:e=>{var l;return(l=o.value)==null?void 0:l.getFieldsValue(e)},validate:(e,l)=>{var t;return(t=o.value)==null?void 0:t.validate(e,l)},scrollToField:(e,l={})=>{var t;(t=o.value)==null||t.scrollToField(e,l)},setFieldsValue:e=>{Object.assign(r,e)},setFieldValue:(e,l)=>{r[e]=l}}),(e,l)=>(a.openBlock(),a.createBlock(a.unref(c.Form),a.mergeProps({ref_key:"formRef",ref:o},s,{model:r}),{default:a.withCtx(()=>[a.renderSlot(e.$slots,"default")]),_:3},16,["model"]))}});exports.default=p;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),q=require("ant-design-vue"),M=require("./context.js"),C=require("lodash-unified"),T=a.defineComponent({__name:"ap-form",props:{layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinish:{},onFinishFailed:{},onValidate:{},initialValues:{}},setup(_,{expose:b}){const i=_;function B(e,t){var m;if(C.isArray(e)){let d=o;for(let c=0;c<e.length-1;c++)d=d[e[c]];d[e[e.length-1]]=t}else o[e]=t;let l=C.isArray(e)?e[0]:e;(m=i.onValuesChange)==null||m.call(i,{[l]:o[l]},o),n()}const r=a.ref(),o=a.reactive(i.initialValues||{});let s=[];const f=e=>{var t;(t=r.value)==null||t.resetFields(e),n()},g=e=>{var t;(t=r.value)==null||t.clearValidate(e)},h=(e,t)=>{var l;return(l=r.value)==null?void 0:l.validateFields(e,t)},u=e=>{var t;return(t=r.value)==null?void 0:t.getFieldsValue(e)},p=(e,t)=>{var l;return(l=r.value)==null?void 0:l.validate(e,t)},v=(e,t={})=>{var l;(l=r.value)==null||l.scrollToField(e,t)},F=e=>{Object.assign(o,e),n()},y=(e,t)=>{o[e]=t,n()};function V(e){return s.push(e),()=>{s=s.filter(t=>t!==e)}}function n(){if(s.length){const e=u(!0);s.forEach(t=>{t(e)})}}return M.useProvideForm({model:a.computed(()=>o),updateModel:B,formInstance:{resetFields:f,clearValidate:g,validateFields:h,getFieldsValue:u,validate:p,scrollToField:v,setFieldsValue:F,setFieldValue:y,registerWatch:V}}),b({resetFields:f,clearValidate:g,validateFields:h,getFieldsValue:u,validate:p,scrollToField:v,setFieldsValue:F,setFieldValue:y,registerWatch:V}),(e,t)=>(a.openBlock(),a.createBlock(a.unref(q.Form),a.mergeProps({ref_key:"formRef",ref:r},i,{model:o}),{default:a.withCtx(()=>[a.renderSlot(e.$slots,"default")]),_:3},16,["model"]))}});exports.default=T;
@@ -1,9 +1,23 @@
1
1
  import { NamePath } from 'ant-design-vue/es/form/interface';
2
2
  import { ComputedRef, InjectionKey } from 'vue';
3
+ import { ApFormExpose } from './interface';
3
4
 
4
5
  type ApFormContextProps<ModelType> = {
6
+ /**
7
+ * Form数据源
8
+ */
5
9
  model?: ComputedRef<ModelType>;
10
+ /**
11
+ * 更新数据源的方法
12
+ * @param name
13
+ * @param value
14
+ * @returns
15
+ */
6
16
  updateModel?: (name: NamePath, value: any) => void;
17
+ /**
18
+ * ApForm内部实例
19
+ */
20
+ formInstance?: ApFormExpose;
7
21
  };
8
22
  export declare const ApFormContextKey: InjectionKey<ApFormContextProps<any>>;
9
23
  export declare function useProvideForm<ModelType>(state: ApFormContextProps<ModelType>): void;
@@ -0,0 +1,7 @@
1
+ import { NamePath } from 'ant-design-vue/es/form/interface';
2
+ import { ApFormExpose } from '../interface';
3
+ import { Ref } from 'vue';
4
+
5
+ type ApFormIns = ApFormExpose;
6
+ declare const useWatch: <ValueType = any>(name: NamePath, form?: Ref<ApFormIns | undefined>) => Ref<ValueType | undefined>;
7
+ export default useWatch;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("../context.js"),a=require("vue"),h=require("lodash-unified");function S(t,e){return h.isArray(e)?e.reduce((r,n)=>r==null?void 0:r[n],t):t==null?void 0:t[e]}function d(t){try{return JSON.stringify(t)}catch{return Math.random()}}const y=(t,e)=>{const{formInstance:r}=g.useInjectForm(),n=a.ref();let u="";return a.watchEffect(o=>{const c=(e==null?void 0:e.value)||r;if(!c)return;const l=c.registerWatch(f=>{const s=S(f,t),i=d(s);i!==u&&(n.value=s,u=i)});o(l)}),n};exports.default=y;
@@ -4,6 +4,7 @@ import { default as ApFormItemGroup } from './ap-form-item-group/index.vue';
4
4
  import { default as ApFormList } from './ap-form-list.vue';
5
5
  import { default as ApFormSearchForm } from './search-form/index.vue';
6
6
  import { default as ApFormModalForm } from './modal-form/index.vue';
7
+ import { default as useWatch } from './hooks/use-watch';
7
8
 
8
9
  type ApFormMixedProps = typeof _ApForm & {
9
10
  FormItem: typeof ApFormItem;
@@ -11,6 +12,7 @@ type ApFormMixedProps = typeof _ApForm & {
11
12
  FormList: typeof ApFormList;
12
13
  SearchForm: typeof ApFormSearchForm;
13
14
  ModalForm: typeof ApFormModalForm;
15
+ useWatch: typeof useWatch;
14
16
  };
15
17
  declare const ApForm: ApFormMixedProps;
16
18
  export * from './items';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./ap-form.vue.js");require("./ap-form-item.vue2.js");require("./ap-form-item-group/index.vue2.js");require("./ap-form-list.vue2.js");require("./search-form/index.vue2.js");require("./modal-form/index.vue2.js");require("./items/index.js");require("./interface.js");const p=require("./ap-form.vue2.js"),r=require("./ap-form-item.vue.js"),t=require("./ap-form-item-group/index.vue.js"),u=require("./ap-form-list.vue.js"),_=require("./search-form/index.vue.js"),o=require("./modal-form/index.vue.js"),e=p.default;e.FormItem=r.default;e.FormItemGroup=t.default;e.FormList=u.default;e.SearchForm=_.default;e.ModalForm=o.default;exports.ApFormItem=r.default;exports.ApFormItemGroup=t.default;exports.ApFormList=u.default;exports.ApFormSearchForm=_.default;exports.ApFormModalForm=o.default;exports.ApForm=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./ap-form.vue.js");require("./ap-form-item.vue2.js");require("./ap-form-item-group/index.vue2.js");require("./ap-form-list.vue2.js");require("./search-form/index.vue2.js");require("./modal-form/index.vue2.js");const p=require("./hooks/use-watch.js");require("./items/index.js");require("./interface.js");const i=require("./ap-form.vue2.js"),r=require("./ap-form-item.vue.js"),t=require("./ap-form-item-group/index.vue.js"),u=require("./ap-form-list.vue.js"),_=require("./search-form/index.vue.js"),o=require("./modal-form/index.vue.js"),e=i.default;e.FormItem=r.default;e.FormItemGroup=t.default;e.FormList=u.default;e.SearchForm=_.default;e.ModalForm=o.default;e.useWatch=p.default;exports.ApFormItem=r.default;exports.ApFormItemGroup=t.default;exports.ApFormList=u.default;exports.ApFormSearchForm=_.default;exports.ApFormModalForm=o.default;exports.ApForm=e;
@@ -1,6 +1,7 @@
1
1
  import { ButtonProps, ColProps, FormItemProps, FormProps, ModalProps, RowProps } from 'ant-design-vue';
2
2
  import { FormItemExpose } from 'ant-design-vue/es/form/FormItem';
3
- import { NamePath, ValidateOptions } from 'ant-design-vue/es/form/interface';
3
+ import { InternalNamePath, NamePath, ValidateOptions } from 'ant-design-vue/es/form/interface';
4
+ import { Recordable } from '../type';
4
5
 
5
6
  export type ApFormColProps = Omit<ColProps, 'prefixCls'>;
6
7
  export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
@@ -13,18 +14,27 @@ export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
13
14
  export type ApFormItemGroupProps = RowProps & {
14
15
  countPerRow?: number;
15
16
  };
16
- export type ApFormProps = {
17
- initialValues?: Record<string, any>;
18
- } & Omit<FormProps, 'model'>;
17
+ export type ApFormProps = Omit<FormProps, 'model'> & {
18
+ initialValues?: Recordable;
19
+ /**
20
+ * 字段值更新时触发
21
+ * @param changedValues 更改的字段值
22
+ * @param allValues 更改后的字段值
23
+ * @returns
24
+ */
25
+ onValuesChange?: (changedValues: Recordable, allValues: Recordable) => void;
26
+ };
27
+ export type WatchFunc = (values?: Recordable) => void;
19
28
  export type ApFormExpose<ModelType = any> = {
20
29
  setFieldsValue?: (fields: Partial<ModelType>) => void;
21
30
  setFieldValue?: (key: keyof ModelType, value: any) => void;
22
31
  resetFields: (name?: NamePath) => void;
23
32
  clearValidate: (name?: NamePath) => void;
24
- validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>>;
25
- getFieldsValue: (nameList?: (string | number)[] | true) => Partial<ModelType>;
26
- validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>>;
33
+ validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
34
+ getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<ModelType> | undefined;
35
+ validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
27
36
  scrollToField: (name: NamePath, options?: any) => void;
37
+ registerWatch: (callback: WatchFunc) => () => void;
28
38
  };
29
39
  export type ApFormItemExpose = FormItemExpose & {
30
40
  getFieldValue: () => any;