@qin-ui/antd-vue-pro 2.4.4 → 2.5.0
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/AI-CONTEXT.md +26 -2
- package/README.md +44 -37
- package/api.json +24 -9
- package/es/antd-vue-pro.css +15 -15
- package/es/components/component-provider/components/index.vue.d.ts +3 -3
- package/es/components/component-provider/components/index.vue.d.ts.map +1 -1
- package/es/components/component-provider/constants/index.d.ts +20 -4
- package/es/components/component-provider/constants/index.d.ts.map +1 -1
- package/es/components/component-provider/types/index.d.ts +8 -4
- package/es/components/component-provider/types/index.d.ts.map +1 -1
- package/es/components/form/components/BaseField/index.vue.d.ts +7 -1
- package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -1
- package/es/components/form/components/BaseField/utils/index.d.ts +18 -0
- package/es/components/form/components/BaseField/utils/index.d.ts.map +1 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts +3 -0
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -1
- package/es/components/form/components/ContainerFragment/index.vue.d.ts +1 -0
- package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -1
- package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -1
- package/es/components/form/components/SlotComponent/index.vue.d.ts +1 -0
- package/es/components/form/components/SlotComponent/index.vue.d.ts.map +1 -1
- package/es/components/form/components/index.d.ts +4 -0
- package/es/components/form/components/index.d.ts.map +1 -1
- package/es/components/form/constants/index.d.ts.map +1 -1
- package/es/components/form/hooks/useFields.d.ts +2 -0
- package/es/components/form/hooks/useFields.d.ts.map +1 -1
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts +10 -0
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -1
- package/es/components/form/index.d.ts +2 -2
- package/es/components/form/index.d.ts.map +1 -1
- package/es/components/form/types/index.d.ts +75 -44
- package/es/components/form/types/index.d.ts.map +1 -1
- package/es/components/form/utils/fieldKey.d.ts +13 -0
- package/es/components/form/utils/fieldKey.d.ts.map +1 -0
- package/es/components/table/components/ColumnControl.vue.d.ts +3 -0
- package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -1
- package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -1
- package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -1
- package/es/components/table/components/ProTable.vue.d.ts +8 -1
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
- package/es/components/table/components/SearchForm.vue.d.ts +10 -2
- package/es/components/table/components/SearchForm.vue.d.ts.map +1 -1
- package/es/components/table/components/SizeControl.vue.d.ts +7 -2
- package/es/components/table/components/SizeControl.vue.d.ts.map +1 -1
- package/es/components/table/hooks/useTable.d.ts.map +1 -1
- package/es/components/table/index.d.ts +4 -1
- package/es/components/table/index.d.ts.map +1 -1
- package/es/components/table/types/index.d.ts +14 -6
- package/es/components/table/types/index.d.ts.map +1 -1
- package/es/index.d.ts +8 -4
- package/es/index.d.ts.map +1 -1
- package/es/index.js +528 -343
- package/es/index.js.map +1 -1
- package/es/locale/index.d.ts +2 -0
- package/es/locale/index.d.ts.map +1 -1
- package/es/shared/core/index.d.ts +1 -1
- package/es/shared/core/index.d.ts.map +1 -1
- package/es/shared/ui/index.d.ts +15 -3
- package/es/shared/ui/index.d.ts.map +1 -1
- package/package.json +7 -4
- package/src/components/component-provider/components/index.vue +26 -12
- package/src/components/component-provider/constants/index.ts +33 -6
- package/src/components/component-provider/types/index.ts +17 -9
- package/src/components/form/components/BaseField/index.vue +48 -16
- package/src/components/form/components/BaseField/utils/index.ts +19 -1
- package/src/components/form/components/BaseFormItem/index.vue +65 -17
- package/src/components/form/components/ContainerFragment/index.vue +3 -1
- package/src/components/form/components/ProForm/index.vue +30 -18
- package/src/components/form/components/SlotComponent/index.vue +14 -4
- package/src/components/form/components/index.ts +8 -1
- package/src/components/form/constants/index.ts +3 -4
- package/src/components/form/hooks/useFields.ts +3 -1
- package/src/components/form/hooks/useGroupFieldAttrs.ts +34 -27
- package/src/components/form/index.ts +1 -3
- package/src/components/form/types/index.ts +79 -46
- package/src/components/form/utils/fieldKey.ts +27 -0
- package/src/components/table/components/ColumnControl.vue +21 -5
- package/src/components/table/components/DefaultSearchFormContainer.vue +5 -0
- package/src/components/table/components/DefaultTableContainer.vue +5 -0
- package/src/components/table/components/ProTable.vue +239 -66
- package/src/components/table/components/SearchForm.vue +58 -21
- package/src/components/table/components/SizeControl.vue +21 -1
- package/src/components/table/hooks/useTable.ts +1 -1
- package/src/components/table/index.ts +8 -3
- package/src/components/table/types/index.ts +15 -7
- package/src/index.ts +12 -5
- package/src/locale/index.ts +2 -0
- package/src/shared/core/index.ts +11 -0
- package/src/shared/ui/index.ts +22 -4
- package/tsconfig.json +22 -0
package/es/index.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import "./antd-vue-pro.css";
|
|
2
|
-
import {
|
|
2
|
+
import { defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, inject, computed, toValue, ref, createCommentVNode, createSlots, renderList, createVNode, toRaw, resolveComponent, unref, provide, useSlots, shallowRef, onUpdated, triggerRef, createElementVNode, withModifiers, normalizeStyle, nextTick, mergeModels, useModel, watch, getCurrentInstance, onMounted, normalizeClass, guardReactiveProps } from "vue";
|
|
3
3
|
import { Transfer, TreeSelect, Slider, Switch, RadioGroup, CheckboxGroup, TimePicker, RangePicker, DatePicker, Cascader, Select, InputNumber, InputPassword, InputSearch, Textarea, Input, Row, Col, FormItem, Form, Space, Button, theme, Dropdown, Menu, MenuItem, Checkbox, MenuDivider, Table } from "ant-design-vue";
|
|
4
|
-
import {
|
|
4
|
+
import { useForm as useForm$1, resolveLocaleName, zhTW, enUS, zhCN, format, useReactiveAttrs, cloneDeep, getObject, InjectionFormSlotsKey, isPlainObject, resolveFieldIdentity, isObjectItem, toPath, createFormProxy, InjectionFormKey, omitBy, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, useSearchFormExpand, pick, isPromise, useTable as useTable$1, omit } from "@qin-ui/pro-components-core";
|
|
5
5
|
import { enUS as enUS2, useFormData, zhCN as zhCN2, zhTW as zhTW2 } from "@qin-ui/pro-components-core";
|
|
6
|
-
import { colProps } from "ant-design-vue/es/grid/Col";
|
|
7
|
-
import { formItemProps, useInjectFormItemContext } from "ant-design-vue/es/form";
|
|
8
6
|
import { useConfigContextInject } from "ant-design-vue/es/config-provider/context";
|
|
9
|
-
import {
|
|
7
|
+
import { useInjectFormItemContext, useProvideFormItemContext } from "ant-design-vue/es/form/FormItemContext";
|
|
8
|
+
import { useInjectDisabled, useProviderDisabled } from "ant-design-vue/es/config-provider/DisabledContext";
|
|
9
|
+
import { colProps } from "ant-design-vue/es/grid/Col";
|
|
10
|
+
import { formItemProps } from "ant-design-vue/es/form";
|
|
10
11
|
import { tableProps } from "ant-design-vue/es/table";
|
|
11
12
|
const getPopupContainer = (triggerNode) => {
|
|
12
13
|
var _a;
|
|
13
14
|
return ((_a = triggerNode.closest) == null ? void 0 : _a.call(triggerNode, "form[class*='-form']")) || (typeof document !== "undefined" ? document.body : void 0);
|
|
14
15
|
};
|
|
15
16
|
const INJECT_COMPONENTS = Symbol("INJECT_COMPONENTS");
|
|
17
|
+
const INJECT_COMPONENT_VARS = Symbol("COMPONENT_VARS");
|
|
16
18
|
const INJECT_CONFIG = {
|
|
17
19
|
"pro-table": {
|
|
18
20
|
injectionKey: Symbol(""),
|
|
21
|
+
// 列 / 数据源取自组件绑定或 `:table` 实例,加载态由组件自身状态驱动
|
|
22
|
+
ignoreProps: ["loading", "columns", "dataSource"],
|
|
19
23
|
default: {
|
|
20
24
|
pagination: {
|
|
21
25
|
showSizeChanger: true,
|
|
@@ -32,6 +36,8 @@ const INJECT_CONFIG = {
|
|
|
32
36
|
},
|
|
33
37
|
"pro-form": {
|
|
34
38
|
injectionKey: Symbol(""),
|
|
39
|
+
// 表单实例由 `:form` 显式传入
|
|
40
|
+
ignoreProps: ["form"],
|
|
35
41
|
default: { grid: { gutter: { xs: 8, sm: 16, md: 16, lg: 24 } } }
|
|
36
42
|
},
|
|
37
43
|
"pro-form-item": {
|
|
@@ -148,6 +154,40 @@ const ensureInjectConfig = (key) => {
|
|
|
148
154
|
DYNAMIC_INJECT_CONFIG[key] = created;
|
|
149
155
|
return created;
|
|
150
156
|
};
|
|
157
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
158
|
+
...{ name: "ContainerFragment", inheritAttrs: false },
|
|
159
|
+
__name: "index",
|
|
160
|
+
props: {
|
|
161
|
+
component: { type: [Object, Function], default: void 0 }
|
|
162
|
+
},
|
|
163
|
+
setup(__props) {
|
|
164
|
+
const props = __props;
|
|
165
|
+
return (_ctx, _cache) => {
|
|
166
|
+
return props.component ? (openBlock(), createBlock(resolveDynamicComponent(props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
|
|
167
|
+
default: withCtx(() => [
|
|
168
|
+
renderSlot(_ctx.$slots, "default")
|
|
169
|
+
]),
|
|
170
|
+
_: 3
|
|
171
|
+
}, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
176
|
+
...{ name: "SlotComponent", inheritAttrs: false },
|
|
177
|
+
__name: "index",
|
|
178
|
+
props: {
|
|
179
|
+
component: { type: [Object, Function, String, Number, Boolean, null], default: void 0 }
|
|
180
|
+
},
|
|
181
|
+
setup(__props) {
|
|
182
|
+
const props = __props;
|
|
183
|
+
const isRenderable = (c) => c !== null && c !== void 0 && (typeof c === "function" || typeof c === "object");
|
|
184
|
+
return (_ctx, _cache) => {
|
|
185
|
+
return isRenderable(props.component) ? (openBlock(), createBlock(resolveDynamicComponent(props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
186
|
+
createTextVNode(toDisplayString(props.component), 1)
|
|
187
|
+
], 64));
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
});
|
|
151
191
|
const FORM_ITEM_SLOT_KEYS = [
|
|
152
192
|
"label",
|
|
153
193
|
"extra",
|
|
@@ -172,216 +212,6 @@ const componentMap = {
|
|
|
172
212
|
"tree-select": TreeSelect,
|
|
173
213
|
"transfer": Transfer
|
|
174
214
|
};
|
|
175
|
-
const formItemPropKeys = Object.keys(formItemProps()).concat([
|
|
176
|
-
"formItemContainer"
|
|
177
|
-
]);
|
|
178
|
-
const gridItemPropKeys = Object.keys(colProps());
|
|
179
|
-
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
180
|
-
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
181
|
-
const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
|
|
182
|
-
function useGroupFieldAttrs(validFields) {
|
|
183
|
-
const config = INJECT_CONFIG["pro-form-item"];
|
|
184
|
-
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
185
|
-
return computed(() => {
|
|
186
|
-
const rawInject = toValue(injectFormItemProps) || {};
|
|
187
|
-
return validFields.value.map((field) => {
|
|
188
|
-
let gridItemProps2 = {};
|
|
189
|
-
let formItemProps2 = {};
|
|
190
|
-
const componentProps = { slots: {} };
|
|
191
|
-
const formItemSlots = {};
|
|
192
|
-
if (isPlainObject(field)) {
|
|
193
|
-
const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, formItemContainer, ...rest } = field;
|
|
194
|
-
const {
|
|
195
|
-
class: injectClassName,
|
|
196
|
-
style: injectStyle,
|
|
197
|
-
span: injectSpan,
|
|
198
|
-
xs,
|
|
199
|
-
sm,
|
|
200
|
-
md,
|
|
201
|
-
lg,
|
|
202
|
-
xl,
|
|
203
|
-
xxl,
|
|
204
|
-
formItemContainer: injectFormItemContainer,
|
|
205
|
-
...injectRest
|
|
206
|
-
} = rawInject;
|
|
207
|
-
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, xxl, span: injectSpan };
|
|
208
|
-
gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
|
|
209
|
-
const container = formItemContainer ?? injectFormItemContainer;
|
|
210
|
-
formItemProps2 = mergeProps(
|
|
211
|
-
injectRest,
|
|
212
|
-
{ class: injectClassName, style: injectStyle },
|
|
213
|
-
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
214
|
-
formItemDataAttrs
|
|
215
|
-
);
|
|
216
|
-
Object.keys(rest).forEach((k) => {
|
|
217
|
-
if (gridItemPropKeySet.has(k)) {
|
|
218
|
-
gridItemProps2[k] = rest[k];
|
|
219
|
-
} else if (formItemPropKeySet.has(k)) {
|
|
220
|
-
formItemProps2[k] = rest[k];
|
|
221
|
-
} else {
|
|
222
|
-
componentProps[k] = rest[k];
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
Object.assign(componentProps, componentDataAttrs);
|
|
226
|
-
Object.keys(slots).forEach((k) => {
|
|
227
|
-
if (formItemSlotKeySet.has(k)) {
|
|
228
|
-
formItemSlots[k] = slots[k];
|
|
229
|
-
} else {
|
|
230
|
-
componentProps.slots[k] = slots[k];
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
const raw2 = toValue(name) ?? toValue(path);
|
|
234
|
-
return {
|
|
235
|
-
path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
|
|
236
|
-
gridItemProps: gridItemProps2,
|
|
237
|
-
formItemProps: formItemProps2,
|
|
238
|
-
formItemSlots,
|
|
239
|
-
componentProps,
|
|
240
|
-
formItemContainer: container,
|
|
241
|
-
rawField: field
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
|
|
245
|
-
return {
|
|
246
|
-
path: Array.isArray(raw) ? raw.join(".") : raw || "",
|
|
247
|
-
gridItemProps: gridItemProps2,
|
|
248
|
-
formItemProps: formItemProps2,
|
|
249
|
-
formItemSlots,
|
|
250
|
-
componentProps,
|
|
251
|
-
rawField: field
|
|
252
|
-
};
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
257
|
-
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
258
|
-
__name: "index",
|
|
259
|
-
props: {
|
|
260
|
-
grid: { type: [Boolean, Object], default: void 0 },
|
|
261
|
-
fields: { default: () => [] },
|
|
262
|
-
disabled: { type: Boolean, default: void 0 }
|
|
263
|
-
},
|
|
264
|
-
setup(__props) {
|
|
265
|
-
const props = __props;
|
|
266
|
-
const validFields = computed(
|
|
267
|
-
() => (
|
|
268
|
-
// hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
|
|
269
|
-
(props.fields ?? []).filter((field) => !toValue(field.hidden))
|
|
270
|
-
)
|
|
271
|
-
);
|
|
272
|
-
useProviderDisabled(computed(() => props.disabled));
|
|
273
|
-
const config = INJECT_CONFIG["pro-form"];
|
|
274
|
-
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
275
|
-
const injectGrid = computed(() => {
|
|
276
|
-
var _a;
|
|
277
|
-
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
278
|
-
});
|
|
279
|
-
const enableGrid = computed(() => {
|
|
280
|
-
if (props.grid !== void 0) return !!props.grid;
|
|
281
|
-
return !!injectGrid.value;
|
|
282
|
-
});
|
|
283
|
-
const computedGridProps = computed(() => {
|
|
284
|
-
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
285
|
-
});
|
|
286
|
-
const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
287
|
-
const componentInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
288
|
-
const setFormItemRef = (field, el, formItemProps2) => {
|
|
289
|
-
if (!field || typeof field !== "object") return;
|
|
290
|
-
const raw = toRaw(field);
|
|
291
|
-
if (el) {
|
|
292
|
-
formItemInstanceMap.set(raw, el);
|
|
293
|
-
raw.getFormItemRef = () => formItemInstanceMap.get(raw);
|
|
294
|
-
raw.getFormItemComputedProps = () => formItemProps2;
|
|
295
|
-
} else {
|
|
296
|
-
formItemInstanceMap.delete(raw);
|
|
297
|
-
delete raw.getFormItemRef;
|
|
298
|
-
delete raw.getFormItemComputedProps;
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
const setComponentRef = (field, el) => {
|
|
302
|
-
if (!field || typeof field !== "object") return;
|
|
303
|
-
const raw = toRaw(field);
|
|
304
|
-
if (el) {
|
|
305
|
-
componentInstanceMap.set(raw, el);
|
|
306
|
-
raw.getComponentRef = () => {
|
|
307
|
-
var _a;
|
|
308
|
-
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
|
|
309
|
-
};
|
|
310
|
-
raw.getComponentComputedProps = () => {
|
|
311
|
-
var _a;
|
|
312
|
-
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
|
|
313
|
-
};
|
|
314
|
-
} else {
|
|
315
|
-
componentInstanceMap.delete(raw);
|
|
316
|
-
delete raw.getComponentRef;
|
|
317
|
-
delete raw.getComponentComputedProps;
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
const groupedFields = useGroupFieldAttrs(validFields);
|
|
321
|
-
return (_ctx, _cache) => {
|
|
322
|
-
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
323
|
-
return openBlock(), createBlock(unref(_sfc_main$c), mergeProps({
|
|
324
|
-
component: enableGrid.value ? unref(Row) : void 0
|
|
325
|
-
}, computedGridProps.value), {
|
|
326
|
-
default: withCtx(() => [
|
|
327
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item, index2) => {
|
|
328
|
-
return openBlock(), createBlock(unref(_sfc_main$c), mergeProps({
|
|
329
|
-
key: item.path || index2,
|
|
330
|
-
component: enableGrid.value ? unref(Col) : void 0
|
|
331
|
-
}, { ref_for: true }, item.gridItemProps), {
|
|
332
|
-
default: withCtx(() => [
|
|
333
|
-
createVNode(unref(_sfc_main$c), {
|
|
334
|
-
component: item.formItemContainer,
|
|
335
|
-
path: item.path
|
|
336
|
-
}, {
|
|
337
|
-
default: withCtx(() => [
|
|
338
|
-
createVNode(unref(FormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
339
|
-
ref_for: true,
|
|
340
|
-
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
341
|
-
name: unref(toPath)(item.path),
|
|
342
|
-
path: item.path
|
|
343
|
-
}), createSlots({
|
|
344
|
-
default: withCtx(() => [
|
|
345
|
-
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
346
|
-
key: 0,
|
|
347
|
-
grid: item.rawField.grid ?? props.grid,
|
|
348
|
-
fields: item.rawField.fields,
|
|
349
|
-
disabled: toValue(item.rawField.disabled)
|
|
350
|
-
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
351
|
-
key: 1,
|
|
352
|
-
ref_for: true,
|
|
353
|
-
ref: (el) => setComponentRef(item.rawField, el)
|
|
354
|
-
}, { ref_for: true }, item.componentProps, {
|
|
355
|
-
path: item.path
|
|
356
|
-
}), null, 16, ["path"]))
|
|
357
|
-
]),
|
|
358
|
-
_: 2
|
|
359
|
-
}, [
|
|
360
|
-
renderList(item.formItemSlots, (slot, name) => {
|
|
361
|
-
return {
|
|
362
|
-
name,
|
|
363
|
-
fn: withCtx((scoped) => [
|
|
364
|
-
createVNode(unref(_sfc_main$b), mergeProps({
|
|
365
|
-
path: item.path,
|
|
366
|
-
component: slot
|
|
367
|
-
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
368
|
-
])
|
|
369
|
-
};
|
|
370
|
-
})
|
|
371
|
-
]), 1040, ["name", "path"])
|
|
372
|
-
]),
|
|
373
|
-
_: 2
|
|
374
|
-
}, 1032, ["component", "path"])
|
|
375
|
-
]),
|
|
376
|
-
_: 2
|
|
377
|
-
}, 1040, ["component"]);
|
|
378
|
-
}), 128))
|
|
379
|
-
]),
|
|
380
|
-
_: 1
|
|
381
|
-
}, 16, ["component"]);
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
215
|
function useForm(...args) {
|
|
386
216
|
return useForm$1(...args);
|
|
387
217
|
}
|
|
@@ -435,27 +265,41 @@ const useLocale = () => {
|
|
|
435
265
|
};
|
|
436
266
|
return { t, lang };
|
|
437
267
|
};
|
|
438
|
-
const _sfc_main$
|
|
268
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
439
269
|
...{ name: "BaseField", inheritAttrs: false },
|
|
440
270
|
__name: "index",
|
|
441
271
|
props: {
|
|
442
272
|
component: { default: void 0 },
|
|
443
273
|
path: { default: "" }
|
|
444
274
|
},
|
|
445
|
-
|
|
275
|
+
emits: ["field-value-change"],
|
|
276
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
277
|
+
const cloneDeepIfObject = (val) => (
|
|
278
|
+
// 原始值直接传递,引用值克隆快照
|
|
279
|
+
typeof val === "object" && val !== null ? cloneDeep(val) : val
|
|
280
|
+
);
|
|
446
281
|
const props = __props;
|
|
447
282
|
const { t } = useLocale();
|
|
448
283
|
const form = useForm(false);
|
|
449
284
|
const componentRef = ref();
|
|
285
|
+
const emit = __emit;
|
|
450
286
|
const formItemContext = useInjectFormItemContext();
|
|
451
|
-
|
|
452
|
-
formItemContext.
|
|
287
|
+
useProvideFormItemContext({
|
|
288
|
+
id: formItemContext.id,
|
|
289
|
+
onFieldBlur: formItemContext.onFieldBlur,
|
|
290
|
+
onFieldChange: () => {
|
|
291
|
+
},
|
|
292
|
+
clearValidate: formItemContext.clearValidate
|
|
293
|
+
});
|
|
294
|
+
const triggerFormItemChange = (value2) => {
|
|
295
|
+
emit("field-value-change", value2);
|
|
453
296
|
};
|
|
454
|
-
const attrs =
|
|
297
|
+
const attrs = useReactiveAttrs();
|
|
455
298
|
const pickerVal = attrs.picker;
|
|
456
299
|
const injectConfigKey = typeof props.component === "string" ? [props.component, pickerVal].filter(Boolean).join(".") : "";
|
|
457
300
|
const componentInjectConfig = injectConfigKey ? getInjectConfig(injectConfigKey) : void 0;
|
|
458
301
|
const rawInjectComponentProps = componentInjectConfig ? inject(componentInjectConfig.injectionKey, componentInjectConfig.default) : void 0;
|
|
302
|
+
const componentVars = inject(INJECT_COMPONENT_VARS, void 0);
|
|
459
303
|
const value = computed({
|
|
460
304
|
get() {
|
|
461
305
|
var _a;
|
|
@@ -472,11 +316,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
472
316
|
const { valueFormatter } = groupedAttrs.value;
|
|
473
317
|
const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
|
|
474
318
|
if (setFormatter) {
|
|
475
|
-
const oldVal = setFormatter.length > 1 ?
|
|
319
|
+
const oldVal = setFormatter.length > 1 ? cloneDeepIfObject((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
|
|
476
320
|
newVal = setFormatter(val, oldVal);
|
|
477
321
|
}
|
|
478
322
|
(_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
|
|
479
|
-
triggerFormItemChange();
|
|
323
|
+
triggerFormItemChange(newVal);
|
|
480
324
|
const { onUpdateValue } = groupedAttrs.value;
|
|
481
325
|
if (typeof onUpdateValue === "function") {
|
|
482
326
|
onUpdateValue(val);
|
|
@@ -487,7 +331,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
487
331
|
});
|
|
488
332
|
const parentDisabled = useInjectDisabled();
|
|
489
333
|
const groupedAttrs = computed(() => {
|
|
490
|
-
|
|
334
|
+
var _a;
|
|
335
|
+
const currentInjectProps = {
|
|
336
|
+
...toValue(rawInjectComponentProps) || {},
|
|
337
|
+
...getObject((_a = toValue(componentVars)) == null ? void 0 : _a[injectConfigKey])
|
|
338
|
+
};
|
|
491
339
|
const initProps = getInitProps(
|
|
492
340
|
{ component: props.component, picker: attrs.picker },
|
|
493
341
|
currentInjectProps,
|
|
@@ -511,14 +359,14 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
511
359
|
onUpdateValue
|
|
512
360
|
};
|
|
513
361
|
});
|
|
514
|
-
const
|
|
362
|
+
const injectedFormSlots = inject(InjectionFormSlotsKey, void 0);
|
|
515
363
|
const customComponents = inject(INJECT_COMPONENTS, {});
|
|
516
364
|
const is = computed(() => {
|
|
517
|
-
var _a;
|
|
518
|
-
const teleportSlot = props.path && (
|
|
365
|
+
var _a, _b;
|
|
366
|
+
const teleportSlot = props.path && ((_a = injectedFormSlots == null ? void 0 : injectedFormSlots.value) == null ? void 0 : _a[props.path]);
|
|
519
367
|
if (teleportSlot) return teleportSlot;
|
|
520
368
|
if (typeof props.component === "string") {
|
|
521
|
-
const resolved = ((
|
|
369
|
+
const resolved = ((_b = toValue(customComponents)) == null ? void 0 : _b[props.component]) || componentMap[props.component];
|
|
522
370
|
if (resolved) return resolved;
|
|
523
371
|
warnUnknownComponent(props.component);
|
|
524
372
|
return props.component;
|
|
@@ -530,7 +378,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
530
378
|
getComponentComputedProps: () => groupedAttrs.value.attrs
|
|
531
379
|
});
|
|
532
380
|
return (_ctx, _cache) => {
|
|
533
|
-
return openBlock(), createBlock(
|
|
381
|
+
return openBlock(), createBlock(_sfc_main$e, {
|
|
534
382
|
component: groupedAttrs.value.componentContainer,
|
|
535
383
|
path: props.path
|
|
536
384
|
}, {
|
|
@@ -546,7 +394,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
546
394
|
return {
|
|
547
395
|
name,
|
|
548
396
|
fn: withCtx((scoped) => [
|
|
549
|
-
createVNode(
|
|
397
|
+
createVNode(_sfc_main$d, mergeProps({
|
|
550
398
|
path: props.path
|
|
551
399
|
}, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
552
400
|
])
|
|
@@ -559,36 +407,252 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
559
407
|
};
|
|
560
408
|
}
|
|
561
409
|
});
|
|
562
|
-
const
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
default: withCtx(() => [
|
|
573
|
-
renderSlot(_ctx.$slots, "default")
|
|
574
|
-
]),
|
|
575
|
-
_: 3
|
|
576
|
-
}, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
|
|
577
|
-
};
|
|
410
|
+
const fieldKeyMap = /* @__PURE__ */ new WeakMap();
|
|
411
|
+
let fieldKeySeed = 0;
|
|
412
|
+
const getFieldKey = (field) => {
|
|
413
|
+
if (field === null || typeof field !== "object")
|
|
414
|
+
return `raw_${String(field)}`;
|
|
415
|
+
const raw = toRaw(field);
|
|
416
|
+
let key = fieldKeyMap.get(raw);
|
|
417
|
+
if (key === void 0) {
|
|
418
|
+
key = ++fieldKeySeed;
|
|
419
|
+
fieldKeyMap.set(raw, key);
|
|
578
420
|
}
|
|
579
|
-
|
|
421
|
+
return key;
|
|
422
|
+
};
|
|
423
|
+
const formItemPropKeys = Object.keys(formItemProps()).concat([
|
|
424
|
+
"formItemContainer"
|
|
425
|
+
]);
|
|
426
|
+
const gridItemPropKeys = Object.keys(colProps());
|
|
427
|
+
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
428
|
+
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
429
|
+
const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
|
|
430
|
+
function useGroupFieldAttrs(validFields) {
|
|
431
|
+
const config = INJECT_CONFIG["pro-form-item"];
|
|
432
|
+
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
433
|
+
return computed(() => {
|
|
434
|
+
const rawInject = toValue(injectFormItemProps) || {};
|
|
435
|
+
return validFields.value.map((field) => {
|
|
436
|
+
let gridItemProps2 = {};
|
|
437
|
+
let formItemProps2 = {};
|
|
438
|
+
const componentProps = { slots: {} };
|
|
439
|
+
const formItemSlots = {};
|
|
440
|
+
if (isPlainObject(field)) {
|
|
441
|
+
const { path: _path, name: _name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, formItemContainer, ...rest } = field;
|
|
442
|
+
const { class: injectClassName, style: injectStyle, span: injectSpan, xs, sm, md, lg, xl, xxl, formItemContainer: injectFormItemContainer, ...injectRest } = rawInject;
|
|
443
|
+
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, xxl, span: injectSpan };
|
|
444
|
+
gridItemProps2 = fields ? { ...initGridItemProps, span: span ?? 24 } : initGridItemProps;
|
|
445
|
+
const container = formItemContainer ?? injectFormItemContainer;
|
|
446
|
+
formItemProps2 = mergeProps(
|
|
447
|
+
injectRest,
|
|
448
|
+
{ class: injectClassName, style: injectStyle },
|
|
449
|
+
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
450
|
+
formItemDataAttrs
|
|
451
|
+
);
|
|
452
|
+
Object.keys(rest).forEach((k) => {
|
|
453
|
+
if (gridItemPropKeySet.has(k)) {
|
|
454
|
+
gridItemProps2[k] = rest[k];
|
|
455
|
+
} else if (formItemPropKeySet.has(k)) {
|
|
456
|
+
formItemProps2[k] = rest[k];
|
|
457
|
+
} else {
|
|
458
|
+
componentProps[k] = rest[k];
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
Object.assign(componentProps, componentDataAttrs);
|
|
462
|
+
Object.keys(slots).forEach((k) => {
|
|
463
|
+
if (formItemSlotKeySet.has(k)) {
|
|
464
|
+
formItemSlots[k] = slots[k];
|
|
465
|
+
} else {
|
|
466
|
+
componentProps.slots[k] = slots[k];
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
if (formItemSlots.label && formItemProps2.label !== void 0) {
|
|
470
|
+
delete formItemProps2.label;
|
|
471
|
+
}
|
|
472
|
+
const raw2 = resolveFieldIdentity(field);
|
|
473
|
+
return {
|
|
474
|
+
path: raw2,
|
|
475
|
+
gridItemProps: gridItemProps2,
|
|
476
|
+
formItemProps: formItemProps2,
|
|
477
|
+
formItemSlots,
|
|
478
|
+
componentProps,
|
|
479
|
+
formItemContainer: container,
|
|
480
|
+
rawField: field,
|
|
481
|
+
renderKey: getFieldKey(field)
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
const raw = resolveFieldIdentity(field);
|
|
485
|
+
return {
|
|
486
|
+
path: raw,
|
|
487
|
+
gridItemProps: gridItemProps2,
|
|
488
|
+
formItemProps: formItemProps2,
|
|
489
|
+
formItemSlots,
|
|
490
|
+
componentProps,
|
|
491
|
+
rawField: field,
|
|
492
|
+
renderKey: getFieldKey(field)
|
|
493
|
+
};
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
}
|
|
580
497
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
581
|
-
...{ name: "
|
|
498
|
+
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
582
499
|
__name: "index",
|
|
583
500
|
props: {
|
|
584
|
-
|
|
501
|
+
grid: { type: [Boolean, Object], default: void 0 },
|
|
502
|
+
fields: { default: () => [] },
|
|
503
|
+
disabled: { type: Boolean, default: void 0 }
|
|
585
504
|
},
|
|
586
505
|
setup(__props) {
|
|
587
506
|
const props = __props;
|
|
507
|
+
const validFields = computed(
|
|
508
|
+
() => (
|
|
509
|
+
// hidden 支持 Ref / ComputedRef 响应式形态(统一使用 toValue 取值)
|
|
510
|
+
(props.fields ?? []).filter(
|
|
511
|
+
(field) => isObjectItem(field) && !toValue(field.hidden)
|
|
512
|
+
)
|
|
513
|
+
)
|
|
514
|
+
);
|
|
515
|
+
useProviderDisabled(computed(() => props.disabled));
|
|
516
|
+
const config = INJECT_CONFIG["pro-form"];
|
|
517
|
+
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
518
|
+
const injectGrid = computed(() => {
|
|
519
|
+
var _a;
|
|
520
|
+
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
521
|
+
});
|
|
522
|
+
const enableGrid = computed(() => {
|
|
523
|
+
if (props.grid !== void 0) return !!props.grid;
|
|
524
|
+
return !!injectGrid.value;
|
|
525
|
+
});
|
|
526
|
+
const computedGridProps = computed(() => {
|
|
527
|
+
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
528
|
+
});
|
|
529
|
+
const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
530
|
+
const componentInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
531
|
+
const warnedFrozenFields = /* @__PURE__ */ new WeakSet();
|
|
532
|
+
const defineFieldAccessors = (raw, accessors) => {
|
|
533
|
+
try {
|
|
534
|
+
for (const [key, getter] of Object.entries(accessors)) {
|
|
535
|
+
Object.defineProperty(raw, key, {
|
|
536
|
+
value: getter,
|
|
537
|
+
enumerable: false,
|
|
538
|
+
configurable: true,
|
|
539
|
+
writable: true
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
} catch {
|
|
543
|
+
if (!warnedFrozenFields.has(raw)) {
|
|
544
|
+
warnedFrozenFields.add(raw);
|
|
545
|
+
console.warn(
|
|
546
|
+
"[pro-components] 字段配置对象不可写(如被 Object.freeze),getFormItemRef / getComponentRef 等实例访问器挂载失败。"
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
const onFieldValueChange = (item) => {
|
|
552
|
+
var _a, _b;
|
|
553
|
+
if (((_a = item.formItemProps) == null ? void 0 : _a.autoLink) === false) return;
|
|
554
|
+
const instance = formItemInstanceMap.get(toRaw(item.rawField));
|
|
555
|
+
(_b = instance == null ? void 0 : instance.onFieldChange) == null ? void 0 : _b.call(instance);
|
|
556
|
+
};
|
|
557
|
+
const setFormItemRef = (field, el, formItemProps2) => {
|
|
558
|
+
if (!field || typeof field !== "object") return;
|
|
559
|
+
const raw = toRaw(field);
|
|
560
|
+
if (el) {
|
|
561
|
+
formItemInstanceMap.set(raw, el);
|
|
562
|
+
defineFieldAccessors(raw, {
|
|
563
|
+
getFormItemRef: () => formItemInstanceMap.get(raw),
|
|
564
|
+
getFormItemComputedProps: () => formItemProps2
|
|
565
|
+
});
|
|
566
|
+
} else {
|
|
567
|
+
formItemInstanceMap.delete(raw);
|
|
568
|
+
delete raw.getFormItemRef;
|
|
569
|
+
delete raw.getFormItemComputedProps;
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
const setComponentRef = (field, el) => {
|
|
573
|
+
if (!field || typeof field !== "object") return;
|
|
574
|
+
const raw = toRaw(field);
|
|
575
|
+
if (el) {
|
|
576
|
+
componentInstanceMap.set(raw, el);
|
|
577
|
+
defineFieldAccessors(raw, {
|
|
578
|
+
getComponentRef: () => {
|
|
579
|
+
var _a;
|
|
580
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
|
|
581
|
+
},
|
|
582
|
+
getComponentComputedProps: () => {
|
|
583
|
+
var _a;
|
|
584
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
} else {
|
|
588
|
+
componentInstanceMap.delete(raw);
|
|
589
|
+
delete raw.getComponentRef;
|
|
590
|
+
delete raw.getComponentComputedProps;
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
const groupedFields = useGroupFieldAttrs(validFields);
|
|
588
594
|
return (_ctx, _cache) => {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
595
|
+
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
596
|
+
return openBlock(), createBlock(_sfc_main$e, mergeProps({
|
|
597
|
+
component: enableGrid.value ? unref(Row) : void 0
|
|
598
|
+
}, computedGridProps.value), {
|
|
599
|
+
default: withCtx(() => [
|
|
600
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item) => {
|
|
601
|
+
return openBlock(), createBlock(_sfc_main$e, mergeProps({
|
|
602
|
+
key: item.renderKey,
|
|
603
|
+
component: enableGrid.value ? unref(Col) : void 0
|
|
604
|
+
}, { ref_for: true }, item.gridItemProps), {
|
|
605
|
+
default: withCtx(() => [
|
|
606
|
+
createVNode(_sfc_main$e, {
|
|
607
|
+
component: item.formItemContainer,
|
|
608
|
+
path: item.path
|
|
609
|
+
}, {
|
|
610
|
+
default: withCtx(() => [
|
|
611
|
+
createVNode(unref(FormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
612
|
+
ref_for: true,
|
|
613
|
+
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
614
|
+
name: unref(toPath)(item.path),
|
|
615
|
+
path: item.path
|
|
616
|
+
}), createSlots({
|
|
617
|
+
default: withCtx(() => [
|
|
618
|
+
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
619
|
+
key: 0,
|
|
620
|
+
grid: item.rawField.grid ?? props.grid,
|
|
621
|
+
fields: item.rawField.fields,
|
|
622
|
+
disabled: toValue(item.rawField.disabled)
|
|
623
|
+
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(_sfc_main$c, mergeProps({
|
|
624
|
+
key: 1,
|
|
625
|
+
ref_for: true,
|
|
626
|
+
ref: (el) => setComponentRef(item.rawField, el)
|
|
627
|
+
}, { ref_for: true }, item.componentProps, {
|
|
628
|
+
path: item.path,
|
|
629
|
+
onFieldValueChange: ($event) => onFieldValueChange(item)
|
|
630
|
+
}), null, 16, ["path", "onFieldValueChange"]))
|
|
631
|
+
]),
|
|
632
|
+
_: 2
|
|
633
|
+
}, [
|
|
634
|
+
renderList(item.formItemSlots, (slot, name) => {
|
|
635
|
+
return {
|
|
636
|
+
name,
|
|
637
|
+
fn: withCtx((scoped) => [
|
|
638
|
+
createVNode(_sfc_main$d, mergeProps({
|
|
639
|
+
path: item.path,
|
|
640
|
+
component: slot
|
|
641
|
+
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
642
|
+
])
|
|
643
|
+
};
|
|
644
|
+
})
|
|
645
|
+
]), 1040, ["name", "path"])
|
|
646
|
+
]),
|
|
647
|
+
_: 2
|
|
648
|
+
}, 1032, ["component", "path"])
|
|
649
|
+
]),
|
|
650
|
+
_: 2
|
|
651
|
+
}, 1040, ["component"]);
|
|
652
|
+
}), 128))
|
|
653
|
+
]),
|
|
654
|
+
_: 1
|
|
655
|
+
}, 16, ["component"]);
|
|
592
656
|
};
|
|
593
657
|
}
|
|
594
658
|
});
|
|
@@ -596,15 +660,13 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
596
660
|
...{ name: "ProForm", inheritAttrs: false },
|
|
597
661
|
__name: "index",
|
|
598
662
|
props: {
|
|
599
|
-
grid: { type: [Boolean, Object], default:
|
|
663
|
+
grid: { type: [Boolean, Object], default: void 0 },
|
|
600
664
|
form: { default: void 0 }
|
|
601
665
|
},
|
|
602
666
|
setup(__props) {
|
|
603
667
|
const props = __props;
|
|
604
|
-
const fallbackForm =
|
|
605
|
-
const currentForm = computed(
|
|
606
|
-
() => props.form ?? fallbackForm
|
|
607
|
-
);
|
|
668
|
+
const fallbackForm = useForm();
|
|
669
|
+
const currentForm = computed(() => props.form ?? fallbackForm);
|
|
608
670
|
const formProxy = createFormProxy(() => currentForm.value);
|
|
609
671
|
provide(InjectionFormKey, formProxy);
|
|
610
672
|
const fields = computed(() => {
|
|
@@ -623,6 +685,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
623
685
|
let formInstanceCounter = 0;
|
|
624
686
|
const formInstanceKeyMap = /* @__PURE__ */ new WeakMap();
|
|
625
687
|
const getFormKey = (f) => {
|
|
688
|
+
if (f == null) return 0;
|
|
626
689
|
if (!formInstanceKeyMap.has(f)) {
|
|
627
690
|
formInstanceKeyMap.set(f, ++formInstanceCounter);
|
|
628
691
|
}
|
|
@@ -631,17 +694,24 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
631
694
|
const formKey = computed(() => getFormKey(currentForm.value));
|
|
632
695
|
const config = INJECT_CONFIG["pro-form"];
|
|
633
696
|
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
634
|
-
const attrs =
|
|
697
|
+
const attrs = useReactiveAttrs();
|
|
635
698
|
const injectAttrs = computed(() => {
|
|
636
699
|
const raw = toValue(injectFormConfig);
|
|
637
700
|
const { grid: _injectGrid, ...rest } = raw || {};
|
|
638
701
|
return rest;
|
|
639
702
|
});
|
|
640
703
|
const formAttrs = computed(() => {
|
|
641
|
-
return mergeProps(
|
|
704
|
+
return mergeProps(
|
|
705
|
+
injectAttrs.value,
|
|
706
|
+
omitBy(camelizeProperties(attrs), (value) => value === void 0)
|
|
707
|
+
);
|
|
642
708
|
});
|
|
643
709
|
const slots = useSlots();
|
|
644
|
-
|
|
710
|
+
const formSlotsRef = shallowRef(slots);
|
|
711
|
+
onUpdated(() => {
|
|
712
|
+
triggerRef(formSlotsRef);
|
|
713
|
+
});
|
|
714
|
+
provide(InjectionFormSlotsKey, formSlotsRef);
|
|
645
715
|
return (_ctx, _cache) => {
|
|
646
716
|
return openBlock(), createBlock(unref(Form), mergeProps({
|
|
647
717
|
key: formKey.value,
|
|
@@ -649,7 +719,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
649
719
|
model: formData.value
|
|
650
720
|
}, formAttrs.value, { class: "pro-form" }), {
|
|
651
721
|
default: withCtx(() => [
|
|
652
|
-
createVNode(
|
|
722
|
+
createVNode(_sfc_main$b, {
|
|
653
723
|
fields: fields.value,
|
|
654
724
|
grid: props.grid
|
|
655
725
|
}, null, 8, ["fields", "grid"]),
|
|
@@ -693,7 +763,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
693
763
|
...{ name: "SearchForm" },
|
|
694
764
|
__name: "SearchForm",
|
|
695
765
|
props: {
|
|
696
|
-
form: {
|
|
766
|
+
form: {},
|
|
697
767
|
layout: { default: "grid" },
|
|
698
768
|
expand: { type: [Boolean, Object], default: true },
|
|
699
769
|
searchButton: { type: [Object, Function, Boolean], default: void 0 },
|
|
@@ -730,13 +800,27 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
730
800
|
const onReset = () => {
|
|
731
801
|
emit("reset");
|
|
732
802
|
};
|
|
733
|
-
|
|
803
|
+
let searchTriggeredInTick = false;
|
|
804
|
+
const emitSearch = () => {
|
|
805
|
+
searchTriggeredInTick = true;
|
|
806
|
+
nextTick(() => {
|
|
807
|
+
searchTriggeredInTick = false;
|
|
808
|
+
});
|
|
734
809
|
emit("search");
|
|
735
810
|
};
|
|
811
|
+
const onSearchSubmit = () => {
|
|
812
|
+
if (searchTriggeredInTick) return;
|
|
813
|
+
emitSearch();
|
|
814
|
+
};
|
|
815
|
+
const onSearchClick = () => {
|
|
816
|
+
if (searchTriggeredInTick) return;
|
|
817
|
+
emitSearch();
|
|
818
|
+
};
|
|
736
819
|
return (_ctx, _cache) => {
|
|
737
|
-
return openBlock(), createBlock(
|
|
820
|
+
return openBlock(), createBlock(_sfc_main$a, mergeProps(layoutProps.value, {
|
|
738
821
|
form: props.form,
|
|
739
|
-
class: "pro-table_search-form transition"
|
|
822
|
+
class: "pro-table_search-form transition",
|
|
823
|
+
onSubmit: withModifiers(onSearchSubmit, ["prevent"])
|
|
740
824
|
}), {
|
|
741
825
|
default: withCtx(() => [
|
|
742
826
|
createVNode(unref(Space), {
|
|
@@ -761,17 +845,16 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
761
845
|
}))
|
|
762
846
|
], 64)) : createCommentVNode("", true)
|
|
763
847
|
], true),
|
|
764
|
-
renderSlot(_ctx.$slots, "search-button", { onSearch }, () => [
|
|
848
|
+
renderSlot(_ctx.$slots, "search-button", { onSearch: onSearchClick }, () => [
|
|
765
849
|
props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
766
850
|
props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(props.searchButton), {
|
|
767
851
|
key: 0,
|
|
768
|
-
onClick:
|
|
852
|
+
onClick: onSearchClick
|
|
769
853
|
})) : (openBlock(), createBlock(unref(Button), {
|
|
770
854
|
key: 1,
|
|
771
855
|
class: "pro-table_search-form_search-button",
|
|
772
856
|
type: "primary",
|
|
773
|
-
"html-type": "submit"
|
|
774
|
-
onClick: onSearch
|
|
857
|
+
"html-type": "submit"
|
|
775
858
|
}, {
|
|
776
859
|
default: withCtx(() => [
|
|
777
860
|
createTextVNode(toDisplayString(unref(t)("table.query")), 1)
|
|
@@ -815,7 +898,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
815
898
|
};
|
|
816
899
|
}
|
|
817
900
|
});
|
|
818
|
-
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-
|
|
901
|
+
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-bf6cca54"]]);
|
|
819
902
|
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
820
903
|
__name: "DefaultSearchFormContainer",
|
|
821
904
|
setup(__props) {
|
|
@@ -830,7 +913,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
830
913
|
};
|
|
831
914
|
}
|
|
832
915
|
});
|
|
833
|
-
const DefaultSearchFormContainer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-
|
|
916
|
+
const DefaultSearchFormContainer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-570a1898"]]);
|
|
834
917
|
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
835
918
|
__name: "DefaultTableContainer",
|
|
836
919
|
setup(__props) {
|
|
@@ -845,7 +928,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
845
928
|
};
|
|
846
929
|
}
|
|
847
930
|
});
|
|
848
|
-
const DefaultTableContainer = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-
|
|
931
|
+
const DefaultTableContainer = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-e5c97b2f"]]);
|
|
849
932
|
const _sfc_main$5 = {};
|
|
850
933
|
const _hoisted_1$2 = {
|
|
851
934
|
focusable: "false",
|
|
@@ -864,19 +947,22 @@ function _sfc_render$1(_ctx, _cache) {
|
|
|
864
947
|
const ColumnHeightOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$1]]);
|
|
865
948
|
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
866
949
|
__name: "SizeControl",
|
|
867
|
-
props: {
|
|
950
|
+
props: /* @__PURE__ */ mergeModels({
|
|
951
|
+
effectiveSize: { default: void 0 }
|
|
952
|
+
}, {
|
|
868
953
|
"size": {},
|
|
869
954
|
"sizeModifiers": {}
|
|
870
|
-
},
|
|
955
|
+
}),
|
|
871
956
|
emits: ["update:size"],
|
|
872
957
|
setup(__props) {
|
|
873
958
|
const { t } = useLocale();
|
|
874
959
|
const configContext = useConfigContextInject();
|
|
960
|
+
const props = __props;
|
|
875
961
|
const size = useModel(__props, "size");
|
|
876
962
|
const currentSize = computed(
|
|
877
963
|
() => {
|
|
878
964
|
var _a;
|
|
879
|
-
return size.value ?? ((_a = configContext.componentSize) == null ? void 0 : _a.value) ?? "large";
|
|
965
|
+
return props.effectiveSize ?? size.value ?? ((_a = configContext.componentSize) == null ? void 0 : _a.value) ?? "large";
|
|
880
966
|
}
|
|
881
967
|
);
|
|
882
968
|
const onSizeChange = (val) => {
|
|
@@ -916,7 +1002,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
916
1002
|
};
|
|
917
1003
|
}
|
|
918
1004
|
});
|
|
919
|
-
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
1005
|
+
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-950f061f"]]);
|
|
920
1006
|
const _sfc_main$3 = {};
|
|
921
1007
|
const _hoisted_1$1 = {
|
|
922
1008
|
focusable: "false",
|
|
@@ -947,7 +1033,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
947
1033
|
const checkAll = ref(false);
|
|
948
1034
|
const indeterminate = ref(false);
|
|
949
1035
|
const checkedColumnsOptions = computed(
|
|
950
|
-
() => props.columns.flatMap((item) => {
|
|
1036
|
+
() => props.columns.filter(isObjectItem).flatMap((item) => {
|
|
951
1037
|
var _a, _b, _c, _d, _e, _f;
|
|
952
1038
|
const rawKey = item.key ?? (Array.isArray(item.dataIndex) ? item.dataIndex.join(".") : item.dataIndex);
|
|
953
1039
|
if (!rawKey || !item.title) return [];
|
|
@@ -959,7 +1045,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
959
1045
|
return {
|
|
960
1046
|
label,
|
|
961
1047
|
value: key,
|
|
962
|
-
checked: !item.hidden || disabled,
|
|
1048
|
+
checked: !toValue(item.hidden) || disabled,
|
|
963
1049
|
disabled
|
|
964
1050
|
};
|
|
965
1051
|
})
|
|
@@ -974,11 +1060,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
974
1060
|
);
|
|
975
1061
|
},
|
|
976
1062
|
set(val) {
|
|
1063
|
+
const checkedSet = new Set(val);
|
|
977
1064
|
checkedColumnsOptions.value.forEach((item) => {
|
|
978
1065
|
var _a, _b;
|
|
979
|
-
if (item.disabled) return;
|
|
1066
|
+
if (item.disabled || item.checked === checkedSet.has(item.value)) return;
|
|
980
1067
|
(_b = (_a = props.table) == null ? void 0 : _a.setColumn) == null ? void 0 : _b.call(_a, item.value, {
|
|
981
|
-
hidden: !
|
|
1068
|
+
hidden: !checkedSet.has(item.value)
|
|
982
1069
|
});
|
|
983
1070
|
});
|
|
984
1071
|
}
|
|
@@ -1097,7 +1184,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1097
1184
|
};
|
|
1098
1185
|
}
|
|
1099
1186
|
});
|
|
1100
|
-
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
1187
|
+
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-58650608"]]);
|
|
1101
1188
|
const _hoisted_1 = { class: "pro-table_header" };
|
|
1102
1189
|
const _hoisted_2 = {
|
|
1103
1190
|
key: 0,
|
|
@@ -1152,18 +1239,40 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1152
1239
|
container: container ? container : void 0
|
|
1153
1240
|
};
|
|
1154
1241
|
});
|
|
1155
|
-
const
|
|
1156
|
-
|
|
1157
|
-
|
|
1242
|
+
const searchFormProps = computed(() => {
|
|
1243
|
+
const {
|
|
1244
|
+
container: _container,
|
|
1245
|
+
hidden: _hidden,
|
|
1246
|
+
...rest
|
|
1247
|
+
} = computedSearchFormConfig.value;
|
|
1248
|
+
return rest;
|
|
1158
1249
|
});
|
|
1250
|
+
const attrs = useReactiveAttrs();
|
|
1159
1251
|
const size = useModel(__props, "size");
|
|
1160
1252
|
const loading = useModel(__props, "loading");
|
|
1161
1253
|
let searchSequence = 0;
|
|
1254
|
+
const SEARCH_WARN_MESSAGES = {
|
|
1255
|
+
duplicate: "同时配置了 :search prop 与 @search 监听,@search 监听不会被执行,请仅保留其一。",
|
|
1256
|
+
"not-promise": "search 未返回 Promise,本次查询不参与 loading 竞态管理(在途请求的 loading 状态保持不变)。"
|
|
1257
|
+
};
|
|
1258
|
+
const warnedSearchReasons = /* @__PURE__ */ new Set();
|
|
1259
|
+
const warnSearchConfig = (reason) => {
|
|
1260
|
+
if (warnedSearchReasons.has(reason)) return;
|
|
1261
|
+
warnedSearchReasons.add(reason);
|
|
1262
|
+
console.warn(`[ProTable] ${SEARCH_WARN_MESSAGES[reason]}`);
|
|
1263
|
+
};
|
|
1162
1264
|
const _search = async () => {
|
|
1163
|
-
|
|
1265
|
+
const search = props.search || attrs.onSearch;
|
|
1266
|
+
if (props.search && attrs.onSearch) {
|
|
1267
|
+
warnSearchConfig("duplicate");
|
|
1268
|
+
}
|
|
1269
|
+
if (!search) return;
|
|
1270
|
+
const searchPromise = search();
|
|
1271
|
+
if (!isPromise(searchPromise)) {
|
|
1272
|
+
warnSearchConfig("not-promise");
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1164
1275
|
const seq = ++searchSequence;
|
|
1165
|
-
const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
|
|
1166
|
-
if (!isPromise(searchPromise)) return;
|
|
1167
1276
|
loading.value = true;
|
|
1168
1277
|
try {
|
|
1169
1278
|
await searchPromise;
|
|
@@ -1207,13 +1316,37 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1207
1316
|
(_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current: 1 });
|
|
1208
1317
|
_search();
|
|
1209
1318
|
};
|
|
1319
|
+
const instance = getCurrentInstance();
|
|
1320
|
+
const isBoundProp = (name) => {
|
|
1321
|
+
const vnodeProps = (instance == null ? void 0 : instance.vnode.props) || {};
|
|
1322
|
+
const kebab = name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
1323
|
+
return name in vnodeProps || kebab in vnodeProps || `onUpdate:${name}` in vnodeProps;
|
|
1324
|
+
};
|
|
1325
|
+
const camelAttrs = computed(
|
|
1326
|
+
() => camelizeProperties(attrs)
|
|
1327
|
+
);
|
|
1328
|
+
const resolveOwnedProp = (name) => {
|
|
1329
|
+
const attrValue = camelAttrs.value[name];
|
|
1330
|
+
return isBoundProp(name) ? props[name] ?? attrValue : attrValue;
|
|
1331
|
+
};
|
|
1332
|
+
const hasExplicitColumns = computed(
|
|
1333
|
+
() => resolveOwnedProp("columns") !== void 0
|
|
1334
|
+
);
|
|
1335
|
+
const effectiveSize = computed(() => {
|
|
1336
|
+
return size.value ?? injectAttrs.value.size;
|
|
1337
|
+
});
|
|
1210
1338
|
const computedTableProps = computed(() => {
|
|
1211
|
-
|
|
1339
|
+
const merged = {
|
|
1212
1340
|
...injectAttrs.value,
|
|
1213
|
-
...
|
|
1214
|
-
|
|
1215
|
-
|
|
1341
|
+
...omitBy(
|
|
1342
|
+
pick(camelAttrs.value, tableProperties),
|
|
1343
|
+
(value) => value === void 0
|
|
1344
|
+
)
|
|
1216
1345
|
};
|
|
1346
|
+
delete merged.onChange;
|
|
1347
|
+
merged.size = effectiveSize.value;
|
|
1348
|
+
merged.loading = void 0;
|
|
1349
|
+
return merged;
|
|
1217
1350
|
});
|
|
1218
1351
|
const computedTableContainer = computed(() => {
|
|
1219
1352
|
const container = props.tableContainer ?? injectProps.value.tableContainer ?? DefaultTableContainer;
|
|
@@ -1221,13 +1354,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1221
1354
|
});
|
|
1222
1355
|
const getIndex = (i) => {
|
|
1223
1356
|
var _a;
|
|
1357
|
+
const pagination = computedPagination.value;
|
|
1358
|
+
if (pagination === false) return i + 1;
|
|
1224
1359
|
const pageParam = (_a = props.table) == null ? void 0 : _a.pageParam;
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
return (current - 1) * pageSize + i + 1;
|
|
1229
|
-
}
|
|
1230
|
-
return i + 1;
|
|
1360
|
+
const current = pagination.current ?? (pageParam == null ? void 0 : pageParam.current) ?? 1;
|
|
1361
|
+
const pageSize = pagination.pageSize ?? (pageParam == null ? void 0 : pageParam.pageSize) ?? 10;
|
|
1362
|
+
return (current - 1) * pageSize + i + 1;
|
|
1231
1363
|
};
|
|
1232
1364
|
const indexColumn = computed(() => ({
|
|
1233
1365
|
title: t("table.index"),
|
|
@@ -1238,34 +1370,61 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1238
1370
|
}));
|
|
1239
1371
|
const computedColumns = computed(() => {
|
|
1240
1372
|
var _a;
|
|
1241
|
-
const cols =
|
|
1373
|
+
const cols = resolveOwnedProp("columns") ?? toValue((_a = props.table) == null ? void 0 : _a.columns) ?? [];
|
|
1242
1374
|
const needIndex = props.addIndexColumn ?? injectProps.value.addIndexColumn;
|
|
1243
1375
|
return needIndex ? [indexColumn.value, ...cols] : cols;
|
|
1244
1376
|
});
|
|
1377
|
+
const filterVisibleColumns = (columns, ancestors = /* @__PURE__ */ new Set()) => {
|
|
1378
|
+
const list = [];
|
|
1379
|
+
let changed = false;
|
|
1380
|
+
for (const column of columns) {
|
|
1381
|
+
if (!isObjectItem(column) || toValue(column.hidden)) {
|
|
1382
|
+
changed = true;
|
|
1383
|
+
continue;
|
|
1384
|
+
}
|
|
1385
|
+
if (Array.isArray(column.children) && column.children.length > 0) {
|
|
1386
|
+
if (ancestors.has(column)) {
|
|
1387
|
+
changed = true;
|
|
1388
|
+
continue;
|
|
1389
|
+
}
|
|
1390
|
+
ancestors.add(column);
|
|
1391
|
+
const filtered = filterVisibleColumns(column.children, ancestors);
|
|
1392
|
+
ancestors.delete(column);
|
|
1393
|
+
if (filtered.changed) {
|
|
1394
|
+
changed = true;
|
|
1395
|
+
list.push({ ...column, children: filtered.list });
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
list.push(column);
|
|
1400
|
+
}
|
|
1401
|
+
return { list, changed };
|
|
1402
|
+
};
|
|
1245
1403
|
const visibleComputedColumns = computed(() => {
|
|
1246
|
-
return computedColumns.value
|
|
1404
|
+
return filterVisibleColumns(computedColumns.value).list;
|
|
1247
1405
|
});
|
|
1248
1406
|
const computedDataSource = computed(() => {
|
|
1249
1407
|
var _a;
|
|
1250
|
-
return
|
|
1408
|
+
return resolveOwnedProp("dataSource") ?? toValue((_a = props.table) == null ? void 0 : _a.dataSource) ?? [];
|
|
1251
1409
|
});
|
|
1252
1410
|
const computedPagination = computed(() => {
|
|
1253
|
-
var _a, _b, _c
|
|
1254
|
-
|
|
1255
|
-
if (
|
|
1411
|
+
var _a, _b, _c;
|
|
1412
|
+
const attrsPagination = resolveOwnedProp("pagination");
|
|
1413
|
+
if (attrsPagination === false) return false;
|
|
1414
|
+
if (isPlainObject(attrsPagination)) {
|
|
1256
1415
|
const globalPagination = injectAttrs.value.pagination === false ? {} : injectAttrs.value.pagination;
|
|
1257
1416
|
return {
|
|
1258
1417
|
...globalPagination,
|
|
1259
1418
|
...(_a = props.table) == null ? void 0 : _a.pageParam,
|
|
1260
|
-
...
|
|
1261
|
-
showTotal: (
|
|
1419
|
+
...attrsPagination,
|
|
1420
|
+
showTotal: (attrsPagination == null ? void 0 : attrsPagination.showTotal) ?? (globalPagination == null ? void 0 : globalPagination.showTotal) ?? ((total) => t("pagination.total", { total }))
|
|
1262
1421
|
};
|
|
1263
1422
|
}
|
|
1264
1423
|
if (injectAttrs.value.pagination === false) return false;
|
|
1265
1424
|
return {
|
|
1266
1425
|
...injectAttrs.value.pagination,
|
|
1267
|
-
...(
|
|
1268
|
-
showTotal: ((
|
|
1426
|
+
...(_b = props.table) == null ? void 0 : _b.pageParam,
|
|
1427
|
+
showTotal: ((_c = injectAttrs.value.pagination) == null ? void 0 : _c.showTotal) ?? ((total) => t("pagination.total", { total }))
|
|
1269
1428
|
};
|
|
1270
1429
|
});
|
|
1271
1430
|
const onTableChange = (...args) => {
|
|
@@ -1278,9 +1437,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1278
1437
|
var _a, _b, _c, _d;
|
|
1279
1438
|
const searchFields = (_b = (_a = props.table) == null ? void 0 : _a.searchForm) == null ? void 0 : _b.fields;
|
|
1280
1439
|
const fieldList = (Array.isArray(searchFields) ? searchFields : searchFields == null ? void 0 : searchFields.value) ?? [];
|
|
1281
|
-
return !!(((_c = computedSearchFormConfig.value) == null ? void 0 : _c.hidden) !== true && ((_d = props.table) == null ? void 0 : _d.searchForm) && fieldList.filter((item) => !toValue(item.hidden)).length > 0);
|
|
1440
|
+
return !!(((_c = computedSearchFormConfig.value) == null ? void 0 : _c.hidden) !== true && ((_d = props.table) == null ? void 0 : _d.searchForm) && fieldList.filter((item) => isObjectItem(item) && !toValue(item.hidden)).length > 0);
|
|
1282
1441
|
});
|
|
1283
|
-
const
|
|
1442
|
+
const resolvedControl = computed(() => {
|
|
1284
1443
|
const controlConfig = props.control ?? injectProps.value.control;
|
|
1285
1444
|
if (controlConfig === true) {
|
|
1286
1445
|
return { sizeControl: true, columnControl: true };
|
|
@@ -1293,6 +1452,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1293
1452
|
columnControl: (controlConfig == null ? void 0 : controlConfig.columnControl) ?? false
|
|
1294
1453
|
};
|
|
1295
1454
|
});
|
|
1455
|
+
const computedControl = computed(
|
|
1456
|
+
() => hasExplicitColumns.value && resolvedControl.value.columnControl ? { ...resolvedControl.value, columnControl: false } : resolvedControl.value
|
|
1457
|
+
);
|
|
1296
1458
|
const columnControlConfig = computed(() => {
|
|
1297
1459
|
const cc = computedControl.value.columnControl;
|
|
1298
1460
|
return typeof cc === "object" ? cc : void 0;
|
|
@@ -1311,27 +1473,30 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1311
1473
|
class: normalizeClass(["pro-table", unref(attrs).class]),
|
|
1312
1474
|
style: normalizeStyle(unref(attrs).style)
|
|
1313
1475
|
}, [
|
|
1314
|
-
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(
|
|
1476
|
+
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(_sfc_main$e, {
|
|
1315
1477
|
key: 0,
|
|
1316
1478
|
component: computedSearchFormConfig.value.container
|
|
1317
1479
|
}, {
|
|
1318
|
-
default: withCtx(() =>
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1480
|
+
default: withCtx(() => {
|
|
1481
|
+
var _a;
|
|
1482
|
+
return [
|
|
1483
|
+
renderSlot(_ctx.$slots, "search-form", normalizeProps(guardReactiveProps({ form: (_a = props.table) == null ? void 0 : _a.searchForm, search: searchPage1st, reset })), () => {
|
|
1484
|
+
var _a2;
|
|
1485
|
+
return [
|
|
1486
|
+
((_a2 = props.table) == null ? void 0 : _a2.searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
|
|
1487
|
+
key: 0,
|
|
1488
|
+
form: props.table.searchForm
|
|
1489
|
+
}, searchFormProps.value, {
|
|
1490
|
+
onSearch: searchPage1st,
|
|
1491
|
+
onReset: reset
|
|
1492
|
+
}), null, 16, ["form"])) : createCommentVNode("", true)
|
|
1493
|
+
];
|
|
1494
|
+
}, true)
|
|
1495
|
+
];
|
|
1496
|
+
}),
|
|
1332
1497
|
_: 3
|
|
1333
1498
|
}, 8, ["component"])) : createCommentVNode("", true),
|
|
1334
|
-
createVNode(
|
|
1499
|
+
createVNode(_sfc_main$e, { component: computedTableContainer.value }, {
|
|
1335
1500
|
default: withCtx(() => [
|
|
1336
1501
|
createElementVNode("div", _hoisted_1, [
|
|
1337
1502
|
_ctx.$slots["button-bar"] ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
@@ -1341,22 +1506,29 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1341
1506
|
renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
|
|
1342
1507
|
])) : createCommentVNode("", true),
|
|
1343
1508
|
computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
1344
|
-
createVNode(
|
|
1509
|
+
createVNode(SizeControl, {
|
|
1345
1510
|
size: size.value,
|
|
1346
|
-
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
|
|
1347
|
-
|
|
1511
|
+
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event),
|
|
1512
|
+
"effective-size": effectiveSize.value
|
|
1513
|
+
}, null, 8, ["size", "effective-size"])
|
|
1348
1514
|
])) : createCommentVNode("", true),
|
|
1349
1515
|
computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
1350
|
-
createVNode(
|
|
1516
|
+
createVNode(ColumnControl, {
|
|
1351
1517
|
columns: computedColumns.value,
|
|
1352
1518
|
table: props.table,
|
|
1353
1519
|
"column-control": columnControlConfig.value
|
|
1354
1520
|
}, null, 8, ["columns", "table", "column-control"])
|
|
1355
1521
|
])) : createCommentVNode("", true)
|
|
1356
1522
|
]),
|
|
1357
|
-
renderSlot(_ctx.$slots, "table", {
|
|
1523
|
+
renderSlot(_ctx.$slots, "table", normalizeProps(guardReactiveProps({
|
|
1524
|
+
columns: visibleComputedColumns.value,
|
|
1525
|
+
dataSource: computedDataSource.value,
|
|
1526
|
+
pagination: computedPagination.value,
|
|
1527
|
+
loading: loading.value,
|
|
1528
|
+
size: effectiveSize.value,
|
|
1529
|
+
onChange: onTableChange
|
|
1530
|
+
})), () => [
|
|
1358
1531
|
createVNode(unref(Table), mergeProps({ class: "pro-table_content" }, computedTableProps.value, {
|
|
1359
|
-
size: size.value,
|
|
1360
1532
|
loading: loading.value,
|
|
1361
1533
|
columns: visibleComputedColumns.value,
|
|
1362
1534
|
"data-source": computedDataSource.value,
|
|
@@ -1371,7 +1543,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1371
1543
|
])
|
|
1372
1544
|
};
|
|
1373
1545
|
})
|
|
1374
|
-
]), 1040, ["
|
|
1546
|
+
]), 1040, ["loading", "columns", "data-source", "pagination"])
|
|
1375
1547
|
], true)
|
|
1376
1548
|
]),
|
|
1377
1549
|
_: 3
|
|
@@ -1380,7 +1552,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1380
1552
|
};
|
|
1381
1553
|
}
|
|
1382
1554
|
});
|
|
1383
|
-
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1555
|
+
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-e7753db3"]]);
|
|
1384
1556
|
function useTable(params) {
|
|
1385
1557
|
return useTable$1(params);
|
|
1386
1558
|
}
|
|
@@ -1400,15 +1572,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1400
1572
|
Object.keys(INJECT_CONFIG).forEach(
|
|
1401
1573
|
(key) => {
|
|
1402
1574
|
const config = INJECT_CONFIG[key];
|
|
1575
|
+
const ignored = config.ignoreProps;
|
|
1403
1576
|
provide(
|
|
1404
1577
|
config.injectionKey,
|
|
1405
|
-
computed(
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1578
|
+
computed(
|
|
1579
|
+
() => {
|
|
1580
|
+
var _a;
|
|
1581
|
+
return omit(
|
|
1582
|
+
{
|
|
1583
|
+
...config.default,
|
|
1584
|
+
...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
|
|
1585
|
+
},
|
|
1586
|
+
ignored ?? []
|
|
1587
|
+
);
|
|
1588
|
+
}
|
|
1589
|
+
)
|
|
1412
1590
|
);
|
|
1413
1591
|
}
|
|
1414
1592
|
);
|
|
@@ -1429,6 +1607,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1429
1607
|
}
|
|
1430
1608
|
});
|
|
1431
1609
|
}
|
|
1610
|
+
provide(
|
|
1611
|
+
INJECT_COMPONENT_VARS,
|
|
1612
|
+
computed(() => props.componentVars ?? {})
|
|
1613
|
+
);
|
|
1432
1614
|
provide(
|
|
1433
1615
|
INJECT_COMPONENTS,
|
|
1434
1616
|
computed(() => props.componentMap)
|
|
@@ -1444,7 +1626,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1444
1626
|
});
|
|
1445
1627
|
const index = {
|
|
1446
1628
|
/**
|
|
1447
|
-
*
|
|
1629
|
+
* 安装方法
|
|
1448
1630
|
* @description 全局注册所有组件(ProForm、ProTable、ProComponentProvider)
|
|
1449
1631
|
*
|
|
1450
1632
|
* @param {App} app - Vue 应用实例
|
|
@@ -1460,16 +1642,19 @@ const index = {
|
|
|
1460
1642
|
install(app) {
|
|
1461
1643
|
app.component(_sfc_main$a.name, _sfc_main$a);
|
|
1462
1644
|
app.component(ProTable.name, ProTable);
|
|
1463
|
-
app.component(
|
|
1645
|
+
app.component(
|
|
1646
|
+
_sfc_main.name ?? "ProComponentProvider",
|
|
1647
|
+
_sfc_main
|
|
1648
|
+
);
|
|
1464
1649
|
}
|
|
1465
1650
|
};
|
|
1466
1651
|
export {
|
|
1467
|
-
_sfc_main$
|
|
1652
|
+
_sfc_main$e as ContainerFragment,
|
|
1468
1653
|
LOCALE_INJECT_KEY,
|
|
1469
1654
|
_sfc_main as ProComponentProvider,
|
|
1470
1655
|
_sfc_main$a as ProForm,
|
|
1471
1656
|
ProTable,
|
|
1472
|
-
_sfc_main$
|
|
1657
|
+
_sfc_main$d as SlotComponent,
|
|
1473
1658
|
index as default,
|
|
1474
1659
|
enUS2 as enUS,
|
|
1475
1660
|
useFields,
|