@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.
- package/es/src/ap-form/ap-form-item-group/index.vue.mjs +23 -21
- package/es/src/ap-form/ap-form.vue.d.ts +7 -2
- package/es/src/ap-form/ap-form.vue2.mjs +85 -52
- package/es/src/ap-form/context.d.ts +14 -0
- package/es/src/ap-form/hooks/use-watch.d.ts +7 -0
- package/es/src/ap-form/hooks/use-watch.mjs +30 -0
- package/es/src/ap-form/index.d.ts +2 -0
- package/es/src/ap-form/index.mjs +13 -11
- package/es/src/ap-form/interface.d.ts +17 -7
- package/es/src/ap-form/modal-form/index.vue.d.ts +2 -2
- package/es/src/ap-form/modal-form/index.vue.mjs +1 -1
- package/es/src/ap-form/search-form/index.vue.mjs +27 -27
- package/es/src/ap-table/ap-table.vue.d.ts +2 -0
- package/es/src/ap-table/ap-table.vue.mjs +98 -93
- package/es/src/ap-table/interface.d.ts +18 -1
- package/es/src/pro-form/helper.mjs +7 -7
- package/es/src/theme/antd-global-overwrite/admin/alert.css +3 -0
- package/es/src/theme/antd-global-overwrite/admin/index.css +3 -0
- package/es/src/theme/antd-global-overwrite/aplus/alert.css +3 -0
- package/es/src/theme/antd-global-overwrite/aplus/index.css +3 -0
- package/es/src/utils/index.mjs +32 -32
- package/lib/src/ap-form/ap-form-item-group/index.vue.js +1 -1
- package/lib/src/ap-form/ap-form.vue.d.ts +7 -2
- package/lib/src/ap-form/ap-form.vue2.js +1 -1
- package/lib/src/ap-form/context.d.ts +14 -0
- package/lib/src/ap-form/hooks/use-watch.d.ts +7 -0
- package/lib/src/ap-form/hooks/use-watch.js +1 -0
- package/lib/src/ap-form/index.d.ts +2 -0
- package/lib/src/ap-form/index.js +1 -1
- package/lib/src/ap-form/interface.d.ts +17 -7
- package/lib/src/ap-form/modal-form/index.vue.d.ts +2 -2
- package/lib/src/ap-form/modal-form/index.vue.js +1 -1
- package/lib/src/ap-form/search-form/index.vue.js +1 -1
- package/lib/src/ap-table/ap-table.vue.d.ts +2 -0
- package/lib/src/ap-table/ap-table.vue.js +1 -1
- package/lib/src/ap-table/interface.d.ts +18 -1
- package/lib/src/pro-form/helper.js +1 -1
- package/lib/src/theme/antd-global-overwrite/admin/alert.css +3 -0
- package/lib/src/theme/antd-global-overwrite/admin/index.css +3 -0
- package/lib/src/theme/antd-global-overwrite/aplus/alert.css +3 -0
- package/lib/src/theme/antd-global-overwrite/aplus/index.css +3 -0
- package/lib/src/utils/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Typography as
|
|
3
|
-
import { ApForm as
|
|
4
|
-
import { apTableRenderItemMap as
|
|
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
|
|
7
|
-
import { isUndefined as
|
|
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
|
|
10
|
-
import { apColumnToColumn as
|
|
11
|
-
import { useLocale as
|
|
12
|
-
import { useNamespace as
|
|
13
|
-
import { useGlobalConfig as
|
|
14
|
-
const
|
|
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
|
-
},
|
|
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
|
|
128
|
+
const n = O, {
|
|
129
129
|
t: E
|
|
130
|
-
} =
|
|
131
|
-
e:
|
|
130
|
+
} = ye(), {
|
|
131
|
+
e: C,
|
|
132
132
|
b: g
|
|
133
|
-
} =
|
|
134
|
-
var
|
|
135
|
-
let e = ((
|
|
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
|
-
...
|
|
137
|
+
...pe(a),
|
|
138
138
|
customRender({
|
|
139
|
-
value:
|
|
139
|
+
value: o,
|
|
140
140
|
...r
|
|
141
141
|
}) {
|
|
142
142
|
let s;
|
|
143
143
|
if (a.customRender)
|
|
144
144
|
s = a.customRender({
|
|
145
|
-
value:
|
|
145
|
+
value: o,
|
|
146
146
|
...r,
|
|
147
147
|
column: a
|
|
148
148
|
});
|
|
149
149
|
else {
|
|
150
|
-
const w =
|
|
151
|
-
value:
|
|
150
|
+
const w = ie(a), q = le[w], K = me(a, {
|
|
151
|
+
value: o,
|
|
152
152
|
...r
|
|
153
153
|
});
|
|
154
|
-
s = d(
|
|
154
|
+
s = d(q, m(K, {
|
|
155
155
|
mode: "read"
|
|
156
156
|
}), null);
|
|
157
157
|
}
|
|
158
|
-
return A(a,
|
|
158
|
+
return A(a, o, s);
|
|
159
159
|
}
|
|
160
160
|
})), e;
|
|
161
|
-
}),
|
|
162
|
-
var e,
|
|
163
|
-
return ((a = (
|
|
164
|
-
let s = k(
|
|
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((
|
|
167
|
-
const r =
|
|
166
|
+
})) == null ? void 0 : a.map((o) => {
|
|
167
|
+
const r = ce(o, fe(o.fieldProps));
|
|
168
168
|
return {
|
|
169
|
-
...
|
|
169
|
+
...o,
|
|
170
170
|
fieldProps: {
|
|
171
|
-
label:
|
|
172
|
-
name:
|
|
171
|
+
label: o.title,
|
|
172
|
+
name: o.dataIndex,
|
|
173
173
|
...r || {},
|
|
174
174
|
// 格式化placeholder
|
|
175
|
-
placeholder:
|
|
175
|
+
placeholder: ge(E, o.valueType, r == null ? void 0 : r.placeholder)
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
178
|
})) || [];
|
|
179
|
-
}),
|
|
180
|
-
formRef:
|
|
181
|
-
submit:
|
|
182
|
-
reset:
|
|
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:
|
|
184
|
+
handleTableChange: D,
|
|
185
185
|
data: j
|
|
186
|
-
} =
|
|
186
|
+
} = re({
|
|
187
187
|
async request(e) {
|
|
188
|
-
var a,
|
|
189
|
-
const
|
|
190
|
-
return (
|
|
191
|
-
data: (
|
|
192
|
-
total: (
|
|
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:
|
|
196
|
-
sortFields:
|
|
197
|
-
defaultParams:
|
|
198
|
-
defaultData:
|
|
199
|
-
manual:
|
|
200
|
-
defaultCurrent:
|
|
201
|
-
defaultPageSize:
|
|
202
|
-
formatParams:
|
|
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
|
-
...
|
|
205
|
-
...
|
|
206
|
-
loading:
|
|
207
|
-
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,
|
|
210
|
-
return v.includes(e.valueType) ? a : e.copyable || e.ellipsis ? d(
|
|
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:
|
|
212
|
+
text: t,
|
|
213
213
|
tooltip: !1
|
|
214
214
|
} : !1,
|
|
215
215
|
ellipsis: e.ellipsis ? {
|
|
216
|
-
tooltip:
|
|
216
|
+
tooltip: t
|
|
217
217
|
} : !1,
|
|
218
218
|
content: a
|
|
219
219
|
}, null) : a;
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
var
|
|
223
|
-
(
|
|
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
|
|
227
|
-
(
|
|
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: () =>
|
|
231
|
-
reset: () =>
|
|
232
|
-
setSearchFormValues: M
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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:
|
|
242
|
+
class: h(e.card ? l(C)("search-wrapper") : null),
|
|
238
243
|
style: T(e.searchFormWrapperStyle)
|
|
239
|
-
}, [d(
|
|
244
|
+
}, [d(l(oe).SearchForm, m(e.searchForm || {}, {
|
|
240
245
|
ref_key: "formRef",
|
|
241
|
-
ref:
|
|
246
|
+
ref: b,
|
|
242
247
|
"custom-reset": "",
|
|
243
|
-
onSubmit:
|
|
244
|
-
onReset:
|
|
245
|
-
"submit-loading":
|
|
248
|
+
onSubmit: l(S),
|
|
249
|
+
onReset: l(R),
|
|
250
|
+
"submit-loading": l(i).loading
|
|
246
251
|
}), {
|
|
247
|
-
default: f(() => [(p(!0), c(
|
|
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:
|
|
260
|
+
class: h(e.card ? l(C)("table-wrapper") : null),
|
|
256
261
|
style: T(e.tableWrapperStyle)
|
|
257
|
-
}, [I(e.$slots, "title"), d(
|
|
258
|
-
class:
|
|
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:
|
|
265
|
+
onChange: l(D),
|
|
261
266
|
columns: y.value
|
|
262
|
-
}),
|
|
267
|
+
}), J({
|
|
263
268
|
headerCell: f(({
|
|
264
269
|
column: a,
|
|
265
|
-
title:
|
|
266
|
-
}) => [a.tooltip ? (p(), c("span",
|
|
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(
|
|
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(
|
|
280
|
-
name:
|
|
281
|
-
fn: f((r) => [I(e.$slots,
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
22
|
-
return e.includes("Input") || e.includes("Complete") ? r("ap.common.inputText")
|
|
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
|
-
|
|
40
|
-
|
|
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
|
-
|
|
45
|
+
a as setComponentRuleType,
|
|
46
46
|
n as simpleComponents
|
|
47
47
|
};
|
package/es/src/utils/index.mjs
CHANGED
|
@@ -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
|
|
4
|
-
return (
|
|
3
|
+
function m(t) {
|
|
4
|
+
return (t == null ? void 0 : t.parentNode) ?? document.body;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return typeof
|
|
6
|
+
function p(t) {
|
|
7
|
+
return typeof t < "u";
|
|
8
8
|
}
|
|
9
|
-
function d(
|
|
10
|
-
const
|
|
11
|
-
return Object.keys(
|
|
12
|
-
|
|
13
|
-
}),
|
|
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(
|
|
16
|
-
const r = Object.assign({},
|
|
17
|
-
for (let
|
|
18
|
-
const
|
|
19
|
-
(
|
|
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(
|
|
24
|
-
return /^[A-Z][A-Za-z]*$/.test(
|
|
23
|
+
function k(t) {
|
|
24
|
+
return /^[A-Z][A-Za-z]*$/.test(t);
|
|
25
25
|
}
|
|
26
|
-
function f(
|
|
27
|
-
if (Array.isArray(
|
|
28
|
-
return
|
|
29
|
-
if (typeof
|
|
30
|
-
const
|
|
31
|
-
for (const n in
|
|
32
|
-
|
|
33
|
-
return u(
|
|
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
|
|
35
|
+
return t;
|
|
36
36
|
}
|
|
37
|
-
function O(
|
|
38
|
-
const
|
|
39
|
-
for (const n of Object.keys(
|
|
40
|
-
a(
|
|
41
|
-
return
|
|
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
|
-
|
|
47
|
-
|
|
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"),
|
|
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:
|
|
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"),
|
|
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';
|
package/lib/src/ap-form/index.js
CHANGED
|
@@ -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
|
|
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?:
|
|
18
|
-
|
|
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?:
|
|
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;
|