@qin-ui/antd-vue-pro 2.3.3 → 2.4.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/README.md +7 -5
- package/api.json +1 -25
- package/es/__tests__/BaseField.spec.d.ts +2 -0
- package/es/__tests__/BaseField.spec.d.ts.map +1 -0
- package/es/__tests__/BaseFormItem.spec.d.ts +2 -0
- package/es/__tests__/BaseFormItem.spec.d.ts.map +1 -0
- package/es/__tests__/ProForm.spec.d.ts +2 -0
- package/es/__tests__/ProForm.spec.d.ts.map +1 -0
- package/es/__tests__/ProTable.spec.d.ts +2 -0
- package/es/__tests__/ProTable.spec.d.ts.map +1 -0
- package/es/__tests__/SearchForm.spec.d.ts +2 -0
- package/es/__tests__/SearchForm.spec.d.ts.map +1 -0
- package/es/__tests__/controls.spec.d.ts +2 -0
- package/es/__tests__/controls.spec.d.ts.map +1 -0
- package/es/__tests__/helpers/fixtures.d.ts +15 -0
- package/es/__tests__/helpers/fixtures.d.ts.map +1 -0
- package/es/__tests__/helpers/mount.d.ts +38 -0
- package/es/__tests__/helpers/mount.d.ts.map +1 -0
- package/es/__tests__/hooks-locale.spec.d.ts +2 -0
- package/es/__tests__/hooks-locale.spec.d.ts.map +1 -0
- package/es/__tests__/index.spec.d.ts +2 -0
- package/es/__tests__/index.spec.d.ts.map +1 -0
- package/es/__tests__/integration.spec.d.ts +2 -0
- package/es/__tests__/integration.spec.d.ts.map +1 -0
- package/es/__tests__/setup.d.ts +14 -0
- package/es/__tests__/setup.d.ts.map +1 -0
- package/es/antd-vue-pro.css +13 -13
- package/es/index.js +435 -319
- package/es/index.js.map +1 -1
- package/es/{components → src/components}/component-provider/components/index.vue.d.ts +5 -1
- package/es/src/components/component-provider/components/index.vue.d.ts.map +1 -0
- package/es/src/components/component-provider/constants/index.d.ts.map +1 -0
- package/es/src/components/component-provider/index.d.ts.map +1 -0
- package/es/src/components/component-provider/types/index.d.ts.map +1 -0
- package/es/{components → src/components}/form/components/BaseField/index.vue.d.ts +4 -1
- package/es/src/components/form/components/BaseField/index.vue.d.ts.map +1 -0
- package/es/src/components/form/components/BaseField/utils/index.d.ts +5 -0
- package/es/src/components/form/components/BaseField/utils/index.d.ts.map +1 -0
- package/es/{components → src/components}/form/components/BaseFormItem/index.vue.d.ts +5 -1
- package/es/src/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
- package/es/{components → src/components}/form/components/ContainerFragment/index.vue.d.ts +3 -1
- package/es/src/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -0
- package/es/src/components/form/components/ProForm/index.vue.d.ts.map +1 -0
- package/es/src/components/form/components/SlotComponent/index.vue.d.ts +11 -0
- package/es/src/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
- package/es/src/components/form/components/index.d.ts.map +1 -0
- package/es/{components → src/components}/form/constants/index.d.ts +1 -1
- package/es/src/components/form/constants/index.d.ts.map +1 -0
- package/es/src/components/form/hooks/index.d.ts.map +1 -0
- package/es/src/components/form/hooks/useFields.d.ts.map +1 -0
- package/es/src/components/form/hooks/useForm.d.ts.map +1 -0
- package/es/src/components/form/hooks/useFormRef.d.ts.map +1 -0
- package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts +22 -0
- package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -0
- package/es/src/components/form/index.d.ts.map +1 -0
- package/es/{components → src/components}/form/types/index.d.ts +26 -2
- package/es/src/components/form/types/index.d.ts.map +1 -0
- package/es/{components → src/components}/table/components/ColumnControl.vue.d.ts +4 -1
- package/es/src/components/table/components/ColumnControl.vue.d.ts.map +1 -0
- package/es/src/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
- package/es/src/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
- package/es/{components → src/components}/table/components/ProTable.vue.d.ts +0 -2
- package/es/src/components/table/components/ProTable.vue.d.ts.map +1 -0
- package/es/{components → src/components}/table/components/SearchForm.vue.d.ts +14 -4
- package/es/src/components/table/components/SearchForm.vue.d.ts.map +1 -0
- package/es/src/components/table/components/SizeControl.vue.d.ts.map +1 -0
- package/es/src/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
- package/es/src/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
- package/es/src/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
- package/es/src/components/table/components/index.d.ts.map +1 -0
- package/es/src/components/table/hooks/index.d.ts.map +1 -0
- package/es/src/components/table/hooks/useTable.d.ts.map +1 -0
- package/es/src/components/table/index.d.ts.map +1 -0
- package/es/src/components/table/types/index.d.ts.map +1 -0
- package/es/{index.d.ts → src/index.d.ts} +1 -1
- package/es/src/index.d.ts.map +1 -0
- package/es/src/locale/index.d.ts.map +1 -0
- package/es/src/shared/core/index.d.ts +6 -0
- package/es/src/shared/core/index.d.ts.map +1 -0
- package/es/src/shared/ui/index.d.ts.map +1 -0
- package/package.json +8 -3
- package/src/components/component-provider/components/index.vue +37 -8
- package/src/components/component-provider/constants/index.ts +2 -1
- package/src/components/form/components/BaseField/index.vue +61 -34
- package/src/components/form/components/BaseField/utils/index.ts +6 -11
- package/src/components/form/components/BaseFormItem/index.vue +91 -94
- package/src/components/form/components/ContainerFragment/index.vue +4 -2
- package/src/components/form/components/ProForm/index.vue +70 -18
- package/src/components/form/components/SlotComponent/index.vue +6 -4
- package/src/components/form/constants/index.ts +1 -5
- package/src/components/form/hooks/useGroupFieldAttrs.ts +126 -0
- package/src/components/form/types/index.ts +26 -2
- package/src/components/table/components/ColumnControl.vue +16 -15
- package/src/components/table/components/ProTable.vue +92 -65
- package/src/components/table/components/SearchForm.vue +80 -59
- package/src/components/table/components/SizeControl.vue +4 -2
- package/src/index.ts +1 -1
- package/src/shared/core/index.ts +4 -2
- package/es/components/component-provider/components/index.vue.d.ts.map +0 -1
- package/es/components/component-provider/constants/index.d.ts.map +0 -1
- package/es/components/component-provider/index.d.ts.map +0 -1
- package/es/components/component-provider/types/index.d.ts.map +0 -1
- package/es/components/form/components/BaseField/index.vue.d.ts.map +0 -1
- package/es/components/form/components/BaseField/utils/index.d.ts +0 -5
- package/es/components/form/components/BaseField/utils/index.d.ts.map +0 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +0 -1
- package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +0 -1
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +0 -29
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts.map +0 -1
- package/es/components/form/components/PathProvider/index.vue.d.ts +0 -24
- package/es/components/form/components/PathProvider/index.vue.d.ts.map +0 -1
- package/es/components/form/components/ProForm/index.vue.d.ts.map +0 -1
- package/es/components/form/components/SlotComponent/index.vue.d.ts +0 -7
- package/es/components/form/components/SlotComponent/index.vue.d.ts.map +0 -1
- package/es/components/form/components/index.d.ts.map +0 -1
- package/es/components/form/constants/index.d.ts.map +0 -1
- package/es/components/form/hooks/index.d.ts.map +0 -1
- package/es/components/form/hooks/useFields.d.ts.map +0 -1
- package/es/components/form/hooks/useForm.d.ts.map +0 -1
- package/es/components/form/hooks/useFormRef.d.ts.map +0 -1
- package/es/components/form/index.d.ts.map +0 -1
- package/es/components/form/types/index.d.ts.map +0 -1
- package/es/components/table/components/ColumnControl.vue.d.ts.map +0 -1
- package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +0 -1
- package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +0 -1
- package/es/components/table/components/ProTable.vue.d.ts.map +0 -1
- package/es/components/table/components/SearchForm.vue.d.ts.map +0 -1
- package/es/components/table/components/SizeControl.vue.d.ts.map +0 -1
- package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +0 -1
- package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +0 -1
- package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +0 -1
- package/es/components/table/components/index.d.ts.map +0 -1
- package/es/components/table/hooks/index.d.ts.map +0 -1
- package/es/components/table/hooks/useTable.d.ts.map +0 -1
- package/es/components/table/index.d.ts.map +0 -1
- package/es/components/table/types/index.d.ts.map +0 -1
- package/es/index.d.ts.map +0 -1
- package/es/locale/index.d.ts.map +0 -1
- package/es/shared/core/index.d.ts +0 -6
- package/es/shared/core/index.d.ts.map +0 -1
- package/es/shared/ui/index.d.ts.map +0 -1
- package/src/components/form/components/GroupedFieldAttrs/index.vue +0 -118
- package/src/components/form/components/PathProvider/index.vue +0 -19
- /package/es/{components → src/components}/component-provider/constants/index.d.ts +0 -0
- /package/es/{components → src/components}/component-provider/index.d.ts +0 -0
- /package/es/{components → src/components}/component-provider/types/index.d.ts +0 -0
- /package/es/{components → src/components}/form/components/ProForm/index.vue.d.ts +0 -0
- /package/es/{components → src/components}/form/components/index.d.ts +0 -0
- /package/es/{components → src/components}/form/hooks/index.d.ts +0 -0
- /package/es/{components → src/components}/form/hooks/useFields.d.ts +0 -0
- /package/es/{components → src/components}/form/hooks/useForm.d.ts +0 -0
- /package/es/{components → src/components}/form/hooks/useFormRef.d.ts +0 -0
- /package/es/{components → src/components}/form/index.d.ts +0 -0
- /package/es/{components → src/components}/table/components/DefaultSearchFormContainer.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/DefaultTableContainer.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/SizeControl.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/icons/ColumnHeightOutlined.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/icons/DownOutlined.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/icons/FilterOutlined.vue.d.ts +0 -0
- /package/es/{components → src/components}/table/components/index.d.ts +0 -0
- /package/es/{components → src/components}/table/hooks/index.d.ts +0 -0
- /package/es/{components → src/components}/table/hooks/useTable.d.ts +0 -0
- /package/es/{components → src/components}/table/index.d.ts +0 -0
- /package/es/{components → src/components}/table/types/index.d.ts +0 -0
- /package/es/{locale → src/locale}/index.d.ts +0 -0
- /package/es/{shared → src/shared}/ui/index.d.ts +0 -0
package/es/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import "./antd-vue-pro.css";
|
|
2
|
-
import {
|
|
3
|
-
import { InjectionPathKey, isPlainObject, getObject, toPath, useForm as useForm$1, resolveLocaleName, zhTW, enUS, zhCN, format, omit, InjectionFormSlotsKey, cloneDeep, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, pick, useTable as useTable$1 } from "@qin-ui/pro-components-core";
|
|
4
|
-
import { enUS as enUS2, useFormData, zhCN as zhCN2, zhTW as zhTW2 } from "@qin-ui/pro-components-core";
|
|
2
|
+
import { inject, computed, toValue, mergeProps, defineComponent, resolveComponent, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList, createVNode, createSlots, toRaw, ref, useAttrs, createCommentVNode, resolveDynamicComponent, renderSlot, normalizeProps, isVNode, createTextVNode, toDisplayString, provide, useSlots, createElementVNode, onBeforeUnmount, watch, watchEffect, normalizeStyle, useModel, onMounted, mergeModels, normalizeClass, guardReactiveProps, nextTick } from "vue";
|
|
5
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";
|
|
6
|
-
import {
|
|
4
|
+
import { isPlainObject, getObject, toPath, useForm as useForm$1, resolveLocaleName, zhTW, enUS, zhCN, format, cloneDeep, InjectionFormSlotsKey, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, pick, isPromise, useTable as useTable$1 } from "@qin-ui/pro-components-core";
|
|
5
|
+
import { enUS as enUS2, useFormData, zhCN as zhCN2, zhTW as zhTW2 } from "@qin-ui/pro-components-core";
|
|
7
6
|
import { colProps } from "ant-design-vue/es/grid/Col";
|
|
7
|
+
import { formItemProps, useInjectFormItemContext } from "ant-design-vue/es/form";
|
|
8
8
|
import { useConfigContextInject } from "ant-design-vue/es/config-provider/context";
|
|
9
9
|
import { useProviderDisabled, useInjectDisabled } from "ant-design-vue/es/config-provider/DisabledContext";
|
|
10
10
|
import { tableProps } from "ant-design-vue/es/table";
|
|
11
|
-
const getPopupContainer = (triggerNode) =>
|
|
11
|
+
const getPopupContainer = (triggerNode) => {
|
|
12
|
+
var _a;
|
|
13
|
+
return ((_a = triggerNode.closest) == null ? void 0 : _a.call(triggerNode, "form[class*='-form']")) || (typeof document !== "undefined" ? document.body : void 0);
|
|
14
|
+
};
|
|
12
15
|
const INJECT_COMPONENTS = Symbol("INJECT_COMPONENTS");
|
|
13
16
|
const INJECT_CONFIG = {
|
|
14
17
|
"pro-table": {
|
|
@@ -169,42 +172,22 @@ const componentMap = {
|
|
|
169
172
|
"tree-select": TreeSelect,
|
|
170
173
|
"transfer": Transfer
|
|
171
174
|
};
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
provide(InjectionPathKey, namePath);
|
|
183
|
-
return (_ctx, _cache) => {
|
|
184
|
-
return renderSlot(_ctx.$slots, "default", { path: namePath.value });
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
189
|
-
__name: "index",
|
|
190
|
-
props: {
|
|
191
|
-
field: {}
|
|
192
|
-
},
|
|
193
|
-
setup(__props) {
|
|
194
|
-
const formItemPropKeys = Object.keys(formItemProps()).concat([
|
|
195
|
-
"formItemContainer"
|
|
196
|
-
]);
|
|
197
|
-
const gridItemPropKeys = Object.keys(colProps());
|
|
198
|
-
const props = __props;
|
|
199
|
-
const config = INJECT_CONFIG["pro-form-item"];
|
|
200
|
-
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
201
|
-
const groupedAttributes = computed(() => {
|
|
175
|
+
const formItemPropKeys = Object.keys(formItemProps()).concat([
|
|
176
|
+
"formItemContainer"
|
|
177
|
+
]);
|
|
178
|
+
const gridItemPropKeys = Object.keys(colProps());
|
|
179
|
+
function useGroupFieldAttrs(validFields) {
|
|
180
|
+
const config = INJECT_CONFIG["pro-form-item"];
|
|
181
|
+
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
182
|
+
return computed(() => {
|
|
183
|
+
const rawInject = toValue(injectFormItemProps) || {};
|
|
184
|
+
return validFields.value.map((field) => {
|
|
202
185
|
let gridItemProps2 = {};
|
|
203
186
|
let formItemProps2 = {};
|
|
204
187
|
const componentProps = { slots: {} };
|
|
205
188
|
const formItemSlots = {};
|
|
206
|
-
if (isPlainObject(
|
|
207
|
-
const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } =
|
|
189
|
+
if (isPlainObject(field)) {
|
|
190
|
+
const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, formItemContainer, ...rest } = field;
|
|
208
191
|
const {
|
|
209
192
|
class: injectClassName,
|
|
210
193
|
style: injectStyle,
|
|
@@ -216,7 +199,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
216
199
|
xl,
|
|
217
200
|
xxl,
|
|
218
201
|
...injectRest
|
|
219
|
-
} =
|
|
202
|
+
} = rawInject;
|
|
220
203
|
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, xxl, span: injectSpan };
|
|
221
204
|
gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
|
|
222
205
|
formItemProps2 = mergeProps(
|
|
@@ -239,137 +222,147 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
239
222
|
if (FORM_ITEM_SLOT_KEYS.includes(k)) {
|
|
240
223
|
formItemSlots[k] = slots[k];
|
|
241
224
|
} else {
|
|
242
|
-
componentProps
|
|
225
|
+
componentProps.slots[k] = slots[k];
|
|
243
226
|
}
|
|
244
227
|
});
|
|
228
|
+
const raw2 = toValue(name) ?? toValue(path);
|
|
229
|
+
return {
|
|
230
|
+
path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
|
|
231
|
+
gridItemProps: gridItemProps2,
|
|
232
|
+
formItemProps: formItemProps2,
|
|
233
|
+
formItemSlots,
|
|
234
|
+
componentProps,
|
|
235
|
+
formItemContainer,
|
|
236
|
+
rawField: field
|
|
237
|
+
};
|
|
245
238
|
}
|
|
246
|
-
|
|
239
|
+
const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
|
|
240
|
+
return {
|
|
241
|
+
path: Array.isArray(raw) ? raw.join(".") : raw || "",
|
|
242
|
+
gridItemProps: gridItemProps2,
|
|
243
|
+
formItemProps: formItemProps2,
|
|
244
|
+
formItemSlots,
|
|
245
|
+
componentProps,
|
|
246
|
+
rawField: field
|
|
247
|
+
};
|
|
247
248
|
});
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
});
|
|
249
|
+
});
|
|
250
|
+
}
|
|
253
251
|
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
254
252
|
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
255
253
|
__name: "index",
|
|
256
254
|
props: {
|
|
257
|
-
grid: { type: [Boolean, Object], default:
|
|
255
|
+
grid: { type: [Boolean, Object], default: void 0 },
|
|
258
256
|
fields: { default: () => [] },
|
|
259
|
-
disabled: { type: Boolean, default:
|
|
257
|
+
disabled: { type: Boolean, default: void 0 }
|
|
260
258
|
},
|
|
261
259
|
setup(__props) {
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
useProviderDisabled(computed(() =>
|
|
260
|
+
const props = __props;
|
|
261
|
+
const validFields = computed(
|
|
262
|
+
() => (props.fields ?? []).filter((field) => !field.hidden)
|
|
263
|
+
);
|
|
264
|
+
useProviderDisabled(computed(() => props.disabled));
|
|
267
265
|
const config = INJECT_CONFIG["pro-form"];
|
|
268
|
-
const
|
|
266
|
+
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
267
|
+
const injectGrid = computed(() => {
|
|
268
|
+
var _a;
|
|
269
|
+
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
270
|
+
});
|
|
269
271
|
const enableGrid = computed(() => {
|
|
270
|
-
if (
|
|
271
|
-
return !!injectGrid;
|
|
272
|
+
if (props.grid !== void 0) return !!props.grid;
|
|
273
|
+
return !!injectGrid.value;
|
|
272
274
|
});
|
|
273
275
|
const computedGridProps = computed(() => {
|
|
274
|
-
return enableGrid.value ? { ...getObject(injectGrid), ...getObject(
|
|
276
|
+
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
275
277
|
});
|
|
276
|
-
const
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
278
|
+
const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
279
|
+
const componentInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
280
|
+
const setFormItemRef = (field, el, formItemProps2) => {
|
|
281
|
+
if (!field || typeof field !== "object") return;
|
|
282
|
+
const raw = toRaw(field);
|
|
283
|
+
if (el) {
|
|
284
|
+
formItemInstanceMap.set(raw, el);
|
|
285
|
+
raw.getFormItemRef = () => formItemInstanceMap.get(raw);
|
|
286
|
+
raw.getFormItemComputedProps = () => formItemProps2;
|
|
287
|
+
} else {
|
|
288
|
+
formItemInstanceMap.delete(raw);
|
|
289
|
+
}
|
|
284
290
|
};
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
291
|
+
const setComponentRef = (field, el) => {
|
|
292
|
+
if (!field || typeof field !== "object") return;
|
|
293
|
+
const raw = toRaw(field);
|
|
294
|
+
if (el) {
|
|
295
|
+
componentInstanceMap.set(raw, el);
|
|
296
|
+
raw.getComponentRef = () => {
|
|
289
297
|
var _a;
|
|
290
|
-
return (_a =
|
|
291
|
-
}
|
|
292
|
-
getComponentComputedProps
|
|
298
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
|
|
299
|
+
};
|
|
300
|
+
raw.getComponentComputedProps = () => {
|
|
293
301
|
var _a;
|
|
294
|
-
return (_a =
|
|
295
|
-
}
|
|
296
|
-
}
|
|
302
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
|
|
303
|
+
};
|
|
304
|
+
} else {
|
|
305
|
+
componentInstanceMap.delete(raw);
|
|
306
|
+
}
|
|
297
307
|
};
|
|
308
|
+
const groupedFields = useGroupFieldAttrs(validFields);
|
|
298
309
|
return (_ctx, _cache) => {
|
|
299
310
|
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
300
311
|
return openBlock(), createBlock(unref(_sfc_main$c), mergeProps({
|
|
301
312
|
component: enableGrid.value ? unref(Row) : void 0
|
|
302
313
|
}, computedGridProps.value), {
|
|
303
314
|
default: withCtx(() => [
|
|
304
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
305
|
-
return openBlock(), createBlock(_sfc_main$
|
|
306
|
-
key:
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
315
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item, index2) => {
|
|
316
|
+
return openBlock(), createBlock(unref(_sfc_main$c), mergeProps({
|
|
317
|
+
key: item.path || index2,
|
|
318
|
+
component: enableGrid.value ? unref(Col) : void 0
|
|
319
|
+
}, { ref_for: true }, item.gridItemProps), {
|
|
320
|
+
default: withCtx(() => [
|
|
321
|
+
createVNode(unref(_sfc_main$c), {
|
|
322
|
+
component: item.formItemContainer,
|
|
323
|
+
path: item.path
|
|
324
|
+
}, {
|
|
325
|
+
default: withCtx(() => [
|
|
326
|
+
createVNode(unref(FormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
327
|
+
ref_for: true,
|
|
328
|
+
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
329
|
+
name: unref(toPath)(item.path),
|
|
330
|
+
path: item.path
|
|
331
|
+
}), createSlots({
|
|
319
332
|
default: withCtx(() => [
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
default: withCtx(() => [
|
|
333
|
-
field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
334
|
-
key: 0,
|
|
335
|
-
grid: field.grid ?? __props.grid,
|
|
336
|
-
fields: field.fields,
|
|
337
|
-
disabled: toValue(field.disabled)
|
|
338
|
-
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
339
|
-
key: 1,
|
|
340
|
-
ref_for: true,
|
|
341
|
-
ref: (el) => componentRefs[index2] = el
|
|
342
|
-
}, { ref_for: true }, componentProps, {
|
|
343
|
-
path,
|
|
344
|
-
onVnodeMounted: ($event) => onComponentMounted(index2)
|
|
345
|
-
}), null, 16, ["path", "onVnodeMounted"]))
|
|
346
|
-
]),
|
|
347
|
-
_: 2
|
|
348
|
-
}, [
|
|
349
|
-
renderList(formItemSlots, (slot, name) => {
|
|
350
|
-
return {
|
|
351
|
-
name,
|
|
352
|
-
fn: withCtx((scoped) => [
|
|
353
|
-
createVNode(unref(_sfc_main$b), mergeProps({
|
|
354
|
-
path,
|
|
355
|
-
component: slot
|
|
356
|
-
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
357
|
-
])
|
|
358
|
-
};
|
|
359
|
-
})
|
|
360
|
-
]), 1040, ["name", "path", "onVnodeMounted"])
|
|
361
|
-
]),
|
|
362
|
-
_: 2
|
|
363
|
-
}, 1032, ["component", "path"])
|
|
333
|
+
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
334
|
+
key: 0,
|
|
335
|
+
grid: item.rawField.grid ?? props.grid,
|
|
336
|
+
fields: item.rawField.fields,
|
|
337
|
+
disabled: toValue(item.rawField.disabled)
|
|
338
|
+
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
339
|
+
key: 1,
|
|
340
|
+
ref_for: true,
|
|
341
|
+
ref: (el) => setComponentRef(item.rawField, el)
|
|
342
|
+
}, { ref_for: true }, item.componentProps, {
|
|
343
|
+
path: item.path
|
|
344
|
+
}), null, 16, ["path"]))
|
|
364
345
|
]),
|
|
365
346
|
_: 2
|
|
366
|
-
},
|
|
347
|
+
}, [
|
|
348
|
+
renderList(item.formItemSlots, (slot, name) => {
|
|
349
|
+
return {
|
|
350
|
+
name,
|
|
351
|
+
fn: withCtx((scoped) => [
|
|
352
|
+
createVNode(unref(_sfc_main$b), mergeProps({
|
|
353
|
+
path: item.path,
|
|
354
|
+
component: slot
|
|
355
|
+
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
356
|
+
])
|
|
357
|
+
};
|
|
358
|
+
})
|
|
359
|
+
]), 1040, ["name", "path"])
|
|
367
360
|
]),
|
|
368
361
|
_: 2
|
|
369
|
-
}, 1032, ["
|
|
362
|
+
}, 1032, ["component", "path"])
|
|
370
363
|
]),
|
|
371
364
|
_: 2
|
|
372
|
-
}, 1040);
|
|
365
|
+
}, 1040, ["component"]);
|
|
373
366
|
}), 128))
|
|
374
367
|
]),
|
|
375
368
|
_: 1
|
|
@@ -393,14 +386,11 @@ const getPlaceholderProps = (key, injectProps, t) => {
|
|
|
393
386
|
if (!placeholderKey || injectProps.placeholder !== void 0) return {};
|
|
394
387
|
return { placeholder: t(placeholderKey) };
|
|
395
388
|
};
|
|
396
|
-
const getInitProps = (field, t) => {
|
|
389
|
+
const getInitProps = (field, injectProps = {}, t) => {
|
|
397
390
|
const { component } = field;
|
|
398
391
|
const picker = component === "date-picker" ? "" : field.picker;
|
|
399
392
|
if (typeof component === "string") {
|
|
400
393
|
const k = [component, picker].filter(Boolean).join(".");
|
|
401
|
-
const config = getInjectConfig(k);
|
|
402
|
-
if (!config) return getPlaceholderProps(k, {}, t);
|
|
403
|
-
const injectProps = inject(config.injectionKey, config.default);
|
|
404
394
|
return { ...injectProps, ...getPlaceholderProps(k, injectProps, t) };
|
|
405
395
|
}
|
|
406
396
|
return {};
|
|
@@ -429,25 +419,27 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
429
419
|
...{ name: "BaseField", inheritAttrs: false },
|
|
430
420
|
__name: "index",
|
|
431
421
|
props: {
|
|
432
|
-
component: { default:
|
|
422
|
+
component: { default: void 0 },
|
|
433
423
|
path: { default: "" }
|
|
434
424
|
},
|
|
435
425
|
setup(__props, { expose: __expose }) {
|
|
426
|
+
const props = __props;
|
|
436
427
|
const { t } = useLocale();
|
|
437
428
|
const form = useForm(false);
|
|
438
|
-
const { getFormData, setFormData } = form;
|
|
439
429
|
const componentRef = ref();
|
|
440
430
|
const formItemContext = useInjectFormItemContext();
|
|
441
431
|
const triggerFormItemChange = () => {
|
|
442
432
|
formItemContext.onFieldChange();
|
|
443
433
|
};
|
|
444
434
|
const attrs = useAttrs();
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
435
|
+
const pickerVal = attrs.picker;
|
|
436
|
+
const injectConfigKey = typeof props.component === "string" ? [props.component, pickerVal].filter(Boolean).join(".") : "";
|
|
437
|
+
const componentInjectConfig = injectConfigKey ? getInjectConfig(injectConfigKey) : void 0;
|
|
438
|
+
const rawInjectComponentProps = componentInjectConfig ? inject(componentInjectConfig.injectionKey, componentInjectConfig.default) : void 0;
|
|
448
439
|
const value = computed({
|
|
449
440
|
get() {
|
|
450
|
-
|
|
441
|
+
var _a;
|
|
442
|
+
let val = (_a = form.getFormData) == null ? void 0 : _a.call(form, props.path);
|
|
451
443
|
const { valueFormatter } = groupedAttrs.value;
|
|
452
444
|
if (typeof valueFormatter === "object" && typeof valueFormatter.get === "function") {
|
|
453
445
|
val = valueFormatter.get(val);
|
|
@@ -455,38 +447,36 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
455
447
|
return val;
|
|
456
448
|
},
|
|
457
449
|
set(val) {
|
|
450
|
+
var _a, _b;
|
|
458
451
|
let newVal = val;
|
|
459
452
|
const { valueFormatter } = groupedAttrs.value;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
newVal = valueFormatter.set(val, getOldValue());
|
|
465
|
-
}
|
|
453
|
+
const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
|
|
454
|
+
if (setFormatter) {
|
|
455
|
+
const oldVal = setFormatter.length > 1 ? cloneDeep((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
|
|
456
|
+
newVal = setFormatter(val, oldVal);
|
|
466
457
|
}
|
|
467
|
-
setFormData == null ? void 0 :
|
|
458
|
+
(_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
|
|
468
459
|
triggerFormItemChange();
|
|
469
460
|
}
|
|
470
461
|
});
|
|
471
462
|
const parentDisabled = useInjectDisabled();
|
|
472
463
|
const groupedAttrs = computed(() => {
|
|
464
|
+
const currentInjectProps = toValue(rawInjectComponentProps) || {};
|
|
473
465
|
const initProps = getInitProps(
|
|
474
|
-
{
|
|
475
|
-
|
|
476
|
-
picker: attrs.picker
|
|
477
|
-
},
|
|
466
|
+
{ component: props.component, picker: attrs.picker },
|
|
467
|
+
currentInjectProps,
|
|
478
468
|
t
|
|
479
469
|
);
|
|
470
|
+
const effectiveModelProp = attrs.modelProp ?? initProps.modelProp ?? "value";
|
|
480
471
|
const mergedProps = mergeProps(
|
|
481
472
|
initProps,
|
|
482
473
|
attrs,
|
|
483
474
|
{ class: attrs.componentClass, style: attrs.componentStyle },
|
|
484
475
|
{ class: initProps.componentClass, style: initProps.componentStyle },
|
|
485
476
|
{ disabled: attrs.disabled ?? parentDisabled.value ?? initProps.disabled },
|
|
486
|
-
{ modelProp:
|
|
477
|
+
{ modelProp: effectiveModelProp }
|
|
487
478
|
);
|
|
488
|
-
const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, ...
|
|
489
|
-
const bindAttrs = omit(rest, [modelProp, `onUpdate:${modelProp}`]);
|
|
479
|
+
const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, [effectiveModelProp]: _modelVal, [`onUpdate:${effectiveModelProp}`]: _onUpdateModelVal, ...bindAttrs } = mergedProps;
|
|
490
480
|
return {
|
|
491
481
|
attrs: bindAttrs,
|
|
492
482
|
slots,
|
|
@@ -498,12 +488,17 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
498
488
|
const formSlots = inject(InjectionFormSlotsKey, void 0);
|
|
499
489
|
const customComponents = inject(INJECT_COMPONENTS, {});
|
|
500
490
|
const is = computed(() => {
|
|
501
|
-
const teleportSlot =
|
|
491
|
+
const teleportSlot = props.path && (formSlots == null ? void 0 : formSlots[props.path]);
|
|
502
492
|
if (teleportSlot) return teleportSlot;
|
|
503
|
-
if (typeof
|
|
504
|
-
|
|
493
|
+
if (typeof props.component === "string") {
|
|
494
|
+
const resolved = customComponents[props.component] || componentMap[props.component];
|
|
495
|
+
if (resolved) return resolved;
|
|
496
|
+
console.warn(
|
|
497
|
+
`[pro-components] 未识别的组件类型 "${props.component}",已降级为原生元素渲染。如为自定义组件请在 componentMap 或 ProComponentProvider 中注册。`
|
|
498
|
+
);
|
|
499
|
+
return props.component;
|
|
505
500
|
}
|
|
506
|
-
return
|
|
501
|
+
return props.component;
|
|
507
502
|
});
|
|
508
503
|
__expose({
|
|
509
504
|
getComponentRef: () => componentRef.value,
|
|
@@ -512,7 +507,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
512
507
|
return (_ctx, _cache) => {
|
|
513
508
|
return openBlock(), createBlock(unref(_sfc_main$c), {
|
|
514
509
|
component: groupedAttrs.value.componentContainer,
|
|
515
|
-
path:
|
|
510
|
+
path: props.path
|
|
516
511
|
}, {
|
|
517
512
|
default: withCtx(() => [
|
|
518
513
|
is.value ? (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: 0 }, groupedAttrs.value.attrs, {
|
|
@@ -520,13 +515,15 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
520
515
|
ref: componentRef,
|
|
521
516
|
[`${groupedAttrs.value.modelProp}`]: value.value,
|
|
522
517
|
[`onUpdate:${groupedAttrs.value.modelProp}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
|
|
523
|
-
path:
|
|
518
|
+
path: props.path
|
|
524
519
|
}), createSlots({ _: 2 }, [
|
|
525
520
|
renderList(groupedAttrs.value.slots, (slot, name) => {
|
|
526
521
|
return {
|
|
527
522
|
name,
|
|
528
523
|
fn: withCtx((scoped) => [
|
|
529
|
-
createVNode(unref(_sfc_main$b), mergeProps({
|
|
524
|
+
createVNode(unref(_sfc_main$b), mergeProps({
|
|
525
|
+
path: props.path
|
|
526
|
+
}, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
530
527
|
])
|
|
531
528
|
};
|
|
532
529
|
})
|
|
@@ -541,11 +538,12 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
541
538
|
...{ name: "ContainerFragment", inheritAttrs: false },
|
|
542
539
|
__name: "index",
|
|
543
540
|
props: {
|
|
544
|
-
component: { type: [Object, Function] }
|
|
541
|
+
component: { type: [Object, Function], default: void 0 }
|
|
545
542
|
},
|
|
546
543
|
setup(__props) {
|
|
544
|
+
const props = __props;
|
|
547
545
|
return (_ctx, _cache) => {
|
|
548
|
-
return
|
|
546
|
+
return props.component ? (openBlock(), createBlock(resolveDynamicComponent(props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
|
|
549
547
|
default: withCtx(() => [
|
|
550
548
|
renderSlot(_ctx.$slots, "default")
|
|
551
549
|
]),
|
|
@@ -558,12 +556,13 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
558
556
|
...{ name: "SlotComponent", inheritAttrs: false },
|
|
559
557
|
__name: "index",
|
|
560
558
|
props: {
|
|
561
|
-
component: { type: [Object, Function, String, Number, Boolean, null] }
|
|
559
|
+
component: { type: [Object, Function, String, Number, Boolean, null], default: void 0 }
|
|
562
560
|
},
|
|
563
561
|
setup(__props) {
|
|
562
|
+
const props = __props;
|
|
564
563
|
return (_ctx, _cache) => {
|
|
565
|
-
return isVNode(
|
|
566
|
-
createTextVNode(toDisplayString(
|
|
564
|
+
return isVNode(props.component) || typeof props.component === "function" ? (openBlock(), createBlock(resolveDynamicComponent(props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
565
|
+
createTextVNode(toDisplayString(props.component), 1)
|
|
567
566
|
], 64));
|
|
568
567
|
};
|
|
569
568
|
}
|
|
@@ -573,30 +572,78 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
573
572
|
__name: "index",
|
|
574
573
|
props: {
|
|
575
574
|
grid: { type: [Boolean, Object], default: false },
|
|
576
|
-
form: { default:
|
|
575
|
+
form: { default: void 0 }
|
|
577
576
|
},
|
|
578
577
|
setup(__props) {
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
config.injectionKey,
|
|
584
|
-
config.default
|
|
578
|
+
const props = __props;
|
|
579
|
+
const fallbackForm = props.form ? void 0 : useForm();
|
|
580
|
+
const currentForm = computed(
|
|
581
|
+
() => props.form ?? fallbackForm
|
|
585
582
|
);
|
|
583
|
+
const formProxy = new Proxy({}, {
|
|
584
|
+
get(_, prop) {
|
|
585
|
+
const target = currentForm.value;
|
|
586
|
+
const val = target == null ? void 0 : target[prop];
|
|
587
|
+
if (typeof val === "function") {
|
|
588
|
+
return (...args) => {
|
|
589
|
+
var _a, _b;
|
|
590
|
+
return (_b = (_a = currentForm.value) == null ? void 0 : _a[prop]) == null ? void 0 : _b.call(_a, ...args);
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
return val;
|
|
594
|
+
},
|
|
595
|
+
set(_, prop, value) {
|
|
596
|
+
if (currentForm.value) {
|
|
597
|
+
currentForm.value[prop] = value;
|
|
598
|
+
}
|
|
599
|
+
return true;
|
|
600
|
+
},
|
|
601
|
+
has(_, prop) {
|
|
602
|
+
return Boolean(currentForm.value && prop in currentForm.value);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
provide(InjectionFormKey, formProxy);
|
|
606
|
+
const fields = computed(() => {
|
|
607
|
+
var _a;
|
|
608
|
+
const f = (_a = currentForm.value) == null ? void 0 : _a.fields;
|
|
609
|
+
return (Array.isArray(f) ? f : f == null ? void 0 : f.value) ?? [];
|
|
610
|
+
});
|
|
611
|
+
const formData = computed(() => {
|
|
612
|
+
var _a;
|
|
613
|
+
return (_a = currentForm.value) == null ? void 0 : _a.formData;
|
|
614
|
+
});
|
|
615
|
+
const setFormRef = (el) => {
|
|
616
|
+
var _a, _b;
|
|
617
|
+
return (_b = (_a = currentForm.value) == null ? void 0 : _a.setFormRef) == null ? void 0 : _b.call(_a, el);
|
|
618
|
+
};
|
|
619
|
+
let formInstanceCounter = 0;
|
|
620
|
+
const formInstanceKeyMap = /* @__PURE__ */ new WeakMap();
|
|
621
|
+
const getFormKey = (f) => {
|
|
622
|
+
if (!formInstanceKeyMap.has(f)) {
|
|
623
|
+
formInstanceKeyMap.set(f, ++formInstanceCounter);
|
|
624
|
+
}
|
|
625
|
+
return formInstanceKeyMap.get(f);
|
|
626
|
+
};
|
|
627
|
+
const formKey = computed(() => getFormKey(currentForm.value));
|
|
628
|
+
const config = INJECT_CONFIG["pro-form"];
|
|
629
|
+
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
630
|
+
const injectAttrs = computed(() => {
|
|
631
|
+
const raw = toValue(injectFormConfig);
|
|
632
|
+
const { grid: _injectGrid, ...rest } = raw || {};
|
|
633
|
+
return rest;
|
|
634
|
+
});
|
|
586
635
|
const slots = useSlots();
|
|
587
|
-
provide(InjectionFormSlotsKey,
|
|
636
|
+
provide(InjectionFormSlotsKey, slots);
|
|
588
637
|
return (_ctx, _cache) => {
|
|
589
638
|
return openBlock(), createBlock(unref(Form), mergeProps({
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
model: unref(formData)
|
|
595
|
-
}, mergeProps(injectAttrs, unref(camelizeProperties)(_ctx.$attrs)), { class: "pro-form" }), {
|
|
639
|
+
key: formKey.value,
|
|
640
|
+
ref: setFormRef,
|
|
641
|
+
model: formData.value
|
|
642
|
+
}, mergeProps(injectAttrs.value, unref(camelizeProperties)(_ctx.$attrs)), { class: "pro-form" }), {
|
|
596
643
|
default: withCtx(() => [
|
|
597
644
|
createVNode(unref(_sfc_main$e), {
|
|
598
|
-
fields:
|
|
599
|
-
grid:
|
|
645
|
+
fields: fields.value,
|
|
646
|
+
grid: props.grid
|
|
600
647
|
}, null, 8, ["fields", "grid"]),
|
|
601
648
|
renderSlot(_ctx.$slots, "default")
|
|
602
649
|
]),
|
|
@@ -638,7 +685,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
638
685
|
...{ name: "SearchForm" },
|
|
639
686
|
__name: "SearchForm",
|
|
640
687
|
props: {
|
|
641
|
-
form: {},
|
|
688
|
+
form: { default: void 0 },
|
|
642
689
|
layout: { default: "grid" },
|
|
643
690
|
expand: { type: [Boolean, Object], default: true },
|
|
644
691
|
searchButton: { type: [Object, Function, Boolean], default: void 0 },
|
|
@@ -652,6 +699,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
652
699
|
emits: ["search", "reset"],
|
|
653
700
|
setup(__props, { emit: __emit }) {
|
|
654
701
|
const { t } = useLocale();
|
|
702
|
+
const props = __props;
|
|
655
703
|
const emit = __emit;
|
|
656
704
|
const proFormHeight = ref("unset");
|
|
657
705
|
const collapseHeight = ref(0);
|
|
@@ -672,43 +720,43 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
672
720
|
cleanupObservers();
|
|
673
721
|
});
|
|
674
722
|
const computedExpand = computed(() => {
|
|
675
|
-
if (!
|
|
676
|
-
if (
|
|
723
|
+
if (!props.expand) return false;
|
|
724
|
+
if (props.expand === true) return { minExpandRows: 2, expandStatus: false };
|
|
677
725
|
return {
|
|
678
|
-
minExpandRows: Math.max(Math.floor(
|
|
679
|
-
expandStatus:
|
|
726
|
+
minExpandRows: Math.max(Math.floor(props.expand.minExpandRows ?? 2), 1),
|
|
727
|
+
expandStatus: props.expand.expandStatus ?? false
|
|
680
728
|
};
|
|
681
729
|
});
|
|
682
730
|
const showExpandToggle = ref(false);
|
|
683
731
|
const expandStatus = ref(true);
|
|
684
|
-
const { formRef, getFormData } = __props.form;
|
|
685
732
|
const updateHeights = () => {
|
|
686
|
-
var _a, _b, _c, _d, _e, _f;
|
|
687
|
-
if (!
|
|
688
|
-
const proFormEl = (
|
|
733
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
734
|
+
if (!props.expand || !((_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value)) return;
|
|
735
|
+
const proFormEl = (_c = props.form.formRef.value) == null ? void 0 : _c.$el;
|
|
689
736
|
if (!proFormEl) return;
|
|
690
|
-
const itemHeight = (
|
|
737
|
+
const itemHeight = (_f = (_e = (_d = proFormEl == null ? void 0 : proFormEl.querySelector("[class*='-form-item']")) == null ? void 0 : _d.getBoundingClientRect) == null ? void 0 : _e.call(_d)) == null ? void 0 : _f.height;
|
|
691
738
|
if (itemHeight && itemHeight > 0) {
|
|
692
739
|
rowHeight.value = itemHeight;
|
|
693
740
|
}
|
|
694
|
-
const naturalHeight = proFormEl.scrollHeight || ((
|
|
741
|
+
const naturalHeight = proFormEl.scrollHeight || ((_h = (_g = proFormEl.getBoundingClientRect) == null ? void 0 : _g.call(proFormEl)) == null ? void 0 : _h.height) || 0;
|
|
695
742
|
if (naturalHeight > 0) {
|
|
696
743
|
proFormHeight.value = naturalHeight;
|
|
697
744
|
}
|
|
698
745
|
};
|
|
746
|
+
const isManualToggle = ref(false);
|
|
699
747
|
const changeExpandStatus = () => {
|
|
748
|
+
isManualToggle.value = true;
|
|
700
749
|
expandStatus.value = !expandStatus.value;
|
|
701
|
-
nextTick(() => {
|
|
702
|
-
updateHeights();
|
|
703
|
-
});
|
|
704
750
|
};
|
|
705
751
|
const hasFieldValue = (val) => val !== null && val !== void 0 && val !== "" && !(Array.isArray(val) && val.length === 0) && !(typeof val === "object" && Object.keys(val).length === 0);
|
|
706
752
|
const setInitExpandStatus = () => {
|
|
707
|
-
var _a;
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
753
|
+
var _a, _b, _c;
|
|
754
|
+
if (isManualToggle.value) return;
|
|
755
|
+
const initStatus = computedExpand.value ? computedExpand.value.expandStatus : false;
|
|
756
|
+
expandStatus.value = initStatus;
|
|
757
|
+
if (((_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value) && computedExpand.value) {
|
|
758
|
+
const formEl = props.form.formRef.value.$el;
|
|
759
|
+
const formItemsEl = (_c = formEl == null ? void 0 : formEl.querySelectorAll) == null ? void 0 : _c.call(
|
|
712
760
|
formEl,
|
|
713
761
|
"[class*='-form-item'] > [path]"
|
|
714
762
|
);
|
|
@@ -718,13 +766,15 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
718
766
|
}
|
|
719
767
|
intersectionObserver = new IntersectionObserver(
|
|
720
768
|
(entries) => {
|
|
769
|
+
if (isManualToggle.value) return;
|
|
721
770
|
expandStatus.value = entries.some((e) => {
|
|
771
|
+
var _a2, _b2;
|
|
722
772
|
if (e.intersectionRatio === 0) {
|
|
723
773
|
const path = e.target.getAttribute("path");
|
|
724
|
-
const searchFieldValue = path ? getFormData == null ? void 0 :
|
|
774
|
+
const searchFieldValue = path ? (_b2 = (_a2 = props.form) == null ? void 0 : _a2.getFormData) == null ? void 0 : _b2.call(_a2, path) : void 0;
|
|
725
775
|
return hasFieldValue(searchFieldValue);
|
|
726
776
|
}
|
|
727
|
-
return
|
|
777
|
+
return computedExpand.value ? computedExpand.value.expandStatus : false;
|
|
728
778
|
});
|
|
729
779
|
intersectionObserver == null ? void 0 : intersectionObserver.disconnect();
|
|
730
780
|
},
|
|
@@ -739,10 +789,13 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
739
789
|
[
|
|
740
790
|
() => {
|
|
741
791
|
var _a, _b, _c;
|
|
742
|
-
return (_c = (_b = (_a =
|
|
792
|
+
return (_c = (_b = (_a = props.form) == null ? void 0 : _a.fields.value) == null ? void 0 : _b.filter((f) => !f.hidden)) == null ? void 0 : _c.length;
|
|
793
|
+
},
|
|
794
|
+
() => {
|
|
795
|
+
var _a, _b;
|
|
796
|
+
return (_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value;
|
|
743
797
|
},
|
|
744
|
-
() =>
|
|
745
|
-
() => __props.expand
|
|
798
|
+
() => props.expand
|
|
746
799
|
],
|
|
747
800
|
() => {
|
|
748
801
|
updateHeights();
|
|
@@ -750,7 +803,10 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
750
803
|
{ flush: "post", immediate: true }
|
|
751
804
|
);
|
|
752
805
|
watch(
|
|
753
|
-
() =>
|
|
806
|
+
() => {
|
|
807
|
+
var _a, _b;
|
|
808
|
+
return (_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value;
|
|
809
|
+
},
|
|
754
810
|
(val) => {
|
|
755
811
|
if (resizeObserver) {
|
|
756
812
|
resizeObserver.disconnect();
|
|
@@ -769,10 +825,10 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
769
825
|
watchEffect(
|
|
770
826
|
() => {
|
|
771
827
|
if (typeof proFormHeight.value !== "number") return;
|
|
772
|
-
if (
|
|
828
|
+
if (props.layout === "grid" && computedExpand.value) {
|
|
773
829
|
const { minExpandRows } = computedExpand.value;
|
|
774
830
|
collapseHeight.value = Math.min(
|
|
775
|
-
minExpandRows * rowHeight.value + (minExpandRows - 1) *
|
|
831
|
+
minExpandRows * rowHeight.value + (minExpandRows - 1) * props.rowGap,
|
|
776
832
|
+proFormHeight.value
|
|
777
833
|
);
|
|
778
834
|
showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
|
|
@@ -785,23 +841,21 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
785
841
|
},
|
|
786
842
|
{ flush: "post" }
|
|
787
843
|
);
|
|
788
|
-
const layoutProps = computed(
|
|
789
|
-
|
|
844
|
+
const layoutProps = computed(() => {
|
|
845
|
+
const currentHeight = expandStatus.value ? proFormHeight.value : collapseHeight.value;
|
|
846
|
+
const heightStyle = currentHeight !== "unset" && currentHeight !== void 0 ? `${currentHeight}px` : void 0;
|
|
847
|
+
return props.layout === "grid" ? {
|
|
790
848
|
grid: {
|
|
791
|
-
gutter: [
|
|
849
|
+
gutter: [props.columnGap, props.rowGap],
|
|
792
850
|
style: { flex: 1, marginRight: "12px" }
|
|
793
851
|
},
|
|
794
|
-
style: {
|
|
795
|
-
display: "flex",
|
|
796
|
-
overflow: "hidden",
|
|
797
|
-
height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
|
|
798
|
-
}
|
|
852
|
+
style: { display: "flex", overflow: "hidden", height: heightStyle }
|
|
799
853
|
} : {
|
|
800
854
|
layout: "inline",
|
|
801
|
-
style: { gap: `${
|
|
855
|
+
style: { gap: `${props.rowGap}px ${props.columnGap}px` },
|
|
802
856
|
grid: false
|
|
803
|
-
}
|
|
804
|
-
);
|
|
857
|
+
};
|
|
858
|
+
});
|
|
805
859
|
const onReset = () => {
|
|
806
860
|
emit("reset");
|
|
807
861
|
};
|
|
@@ -810,7 +864,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
810
864
|
};
|
|
811
865
|
return (_ctx, _cache) => {
|
|
812
866
|
return openBlock(), createBlock(unref(_sfc_main$a), mergeProps(layoutProps.value, {
|
|
813
|
-
form:
|
|
867
|
+
form: props.form,
|
|
814
868
|
class: "pro-table_search-form transition"
|
|
815
869
|
}), {
|
|
816
870
|
default: withCtx(() => [
|
|
@@ -819,9 +873,9 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
819
873
|
class: "pro-table_search-form_button-group"
|
|
820
874
|
}, {
|
|
821
875
|
default: withCtx(() => [
|
|
822
|
-
renderSlot(_ctx.$slots, "reset-button", {
|
|
823
|
-
|
|
824
|
-
|
|
876
|
+
renderSlot(_ctx.$slots, "reset-button", { onReset }, () => [
|
|
877
|
+
props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
878
|
+
props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(props.resetButton), {
|
|
825
879
|
key: 0,
|
|
826
880
|
onClick: onReset
|
|
827
881
|
})) : (openBlock(), createBlock(unref(Button), {
|
|
@@ -836,9 +890,9 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
836
890
|
}))
|
|
837
891
|
], 64)) : createCommentVNode("", true)
|
|
838
892
|
], true),
|
|
839
|
-
renderSlot(_ctx.$slots, "search-button", {
|
|
840
|
-
|
|
841
|
-
|
|
893
|
+
renderSlot(_ctx.$slots, "search-button", { onSearch }, () => [
|
|
894
|
+
props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
895
|
+
props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(props.searchButton), {
|
|
842
896
|
key: 0,
|
|
843
897
|
onClick: onSearch
|
|
844
898
|
})) : (openBlock(), createBlock(unref(Button), {
|
|
@@ -855,9 +909,12 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
855
909
|
}))
|
|
856
910
|
], 64)) : createCommentVNode("", true)
|
|
857
911
|
], true),
|
|
858
|
-
renderSlot(_ctx.$slots, "expand-button", {
|
|
859
|
-
|
|
860
|
-
|
|
912
|
+
renderSlot(_ctx.$slots, "expand-button", {
|
|
913
|
+
expandStatus: expandStatus.value,
|
|
914
|
+
changeExpandStatus
|
|
915
|
+
}, () => [
|
|
916
|
+
props.expandButton !== false && showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
917
|
+
props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(props.expandButton), {
|
|
861
918
|
key: 0,
|
|
862
919
|
"expand-status": expandStatus.value,
|
|
863
920
|
onClick: changeExpandStatus
|
|
@@ -887,7 +944,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
887
944
|
};
|
|
888
945
|
}
|
|
889
946
|
});
|
|
890
|
-
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-
|
|
947
|
+
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-9dca0a5d"]]);
|
|
891
948
|
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
892
949
|
__name: "DefaultSearchFormContainer",
|
|
893
950
|
setup(__props) {
|
|
@@ -942,11 +999,15 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
942
999
|
},
|
|
943
1000
|
emits: ["update:size"],
|
|
944
1001
|
setup(__props) {
|
|
945
|
-
var _a;
|
|
946
1002
|
const { t } = useLocale();
|
|
947
1003
|
const configContext = useConfigContextInject();
|
|
948
1004
|
const size = useModel(__props, "size");
|
|
949
|
-
|
|
1005
|
+
const currentSize = computed(
|
|
1006
|
+
() => {
|
|
1007
|
+
var _a;
|
|
1008
|
+
return size.value ?? ((_a = configContext.componentSize) == null ? void 0 : _a.value) ?? "large";
|
|
1009
|
+
}
|
|
1010
|
+
);
|
|
950
1011
|
const onSizeChange = (val) => {
|
|
951
1012
|
size.value = val.key;
|
|
952
1013
|
};
|
|
@@ -963,7 +1024,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
963
1024
|
overlay: withCtx(() => [
|
|
964
1025
|
createVNode(unref(Menu), {
|
|
965
1026
|
style: { "width": "100px", "text-align": "center" },
|
|
966
|
-
"selected-keys":
|
|
1027
|
+
"selected-keys": [currentSize.value],
|
|
967
1028
|
items: sizeOptions.value,
|
|
968
1029
|
onClick: onSizeChange
|
|
969
1030
|
}, null, 8, ["selected-keys", "items"])
|
|
@@ -984,7 +1045,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
984
1045
|
};
|
|
985
1046
|
}
|
|
986
1047
|
});
|
|
987
|
-
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
1048
|
+
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2ac95d3b"]]);
|
|
988
1049
|
const _sfc_main$3 = {};
|
|
989
1050
|
const _hoisted_1$1 = {
|
|
990
1051
|
focusable: "false",
|
|
@@ -1005,23 +1066,25 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1005
1066
|
__name: "ColumnControl",
|
|
1006
1067
|
props: {
|
|
1007
1068
|
columns: {},
|
|
1008
|
-
table: { default:
|
|
1009
|
-
columnControl: { default:
|
|
1069
|
+
table: { default: void 0 },
|
|
1070
|
+
columnControl: { default: void 0 }
|
|
1010
1071
|
},
|
|
1011
1072
|
setup(__props) {
|
|
1073
|
+
const props = __props;
|
|
1012
1074
|
const { t } = useLocale();
|
|
1013
1075
|
const open = ref(false);
|
|
1014
1076
|
const checkAll = ref(false);
|
|
1015
1077
|
const indeterminate = ref(false);
|
|
1016
1078
|
const checkedColumnsOptions = computed(
|
|
1017
|
-
() =>
|
|
1079
|
+
() => props.columns.flatMap((item) => {
|
|
1018
1080
|
var _a, _b, _c, _d, _e, _f;
|
|
1019
1081
|
const rawKey = item.key ?? (Array.isArray(item.dataIndex) ? item.dataIndex.join(".") : item.dataIndex);
|
|
1020
1082
|
if (!rawKey || !item.title) return [];
|
|
1021
1083
|
const key = String(rawKey);
|
|
1022
|
-
if ((_b = (_a =
|
|
1023
|
-
|
|
1024
|
-
const
|
|
1084
|
+
if ((_b = (_a = props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some((ek) => String(ek) === key))
|
|
1085
|
+
return [];
|
|
1086
|
+
const disabled = ((_d = (_c = props.columnControl) == null ? void 0 : _c.disabledKeys) == null ? void 0 : _d.some((dk) => String(dk) === key)) ?? false;
|
|
1087
|
+
const label = ((_f = (_e = props.columnControl) == null ? void 0 : _e.labels) == null ? void 0 : _f[key]) ?? (typeof item.title === "string" ? item.title : key);
|
|
1025
1088
|
return {
|
|
1026
1089
|
label,
|
|
1027
1090
|
value: key,
|
|
@@ -1043,7 +1106,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1043
1106
|
checkedColumnsOptions.value.forEach((item) => {
|
|
1044
1107
|
var _a, _b;
|
|
1045
1108
|
if (item.disabled) return;
|
|
1046
|
-
(_b = (_a =
|
|
1109
|
+
(_b = (_a = props.table) == null ? void 0 : _a.setColumn) == null ? void 0 : _b.call(_a, item.value, {
|
|
1047
1110
|
hidden: !val.includes(item.value)
|
|
1048
1111
|
});
|
|
1049
1112
|
});
|
|
@@ -1077,20 +1140,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1077
1140
|
);
|
|
1078
1141
|
onMounted(() => {
|
|
1079
1142
|
var _a, _b;
|
|
1080
|
-
(_b = (_a =
|
|
1143
|
+
(_b = (_a = props.columnControl) == null ? void 0 : _a.disabledKeys) == null ? void 0 : _b.forEach((key) => {
|
|
1081
1144
|
var _a2, _b2;
|
|
1082
|
-
(_b2 = (_a2 =
|
|
1145
|
+
(_b2 = (_a2 = props.table) == null ? void 0 : _a2.setColumn) == null ? void 0 : _b2.call(_a2, String(key), { hidden: false });
|
|
1083
1146
|
});
|
|
1084
1147
|
});
|
|
1085
1148
|
watch(
|
|
1086
1149
|
() => {
|
|
1087
1150
|
var _a;
|
|
1088
|
-
return (_a =
|
|
1151
|
+
return (_a = props.columnControl) == null ? void 0 : _a.disabledKeys;
|
|
1089
1152
|
},
|
|
1090
1153
|
(keys) => {
|
|
1091
1154
|
keys == null ? void 0 : keys.forEach((key) => {
|
|
1092
1155
|
var _a, _b;
|
|
1093
|
-
(_b = (_a =
|
|
1156
|
+
(_b = (_a = props.table) == null ? void 0 : _a.setColumn) == null ? void 0 : _b.call(_a, String(key), { hidden: false });
|
|
1094
1157
|
});
|
|
1095
1158
|
},
|
|
1096
1159
|
{ deep: true }
|
|
@@ -1110,7 +1173,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1110
1173
|
default: withCtx(() => {
|
|
1111
1174
|
var _a, _b;
|
|
1112
1175
|
return [
|
|
1113
|
-
!((_a =
|
|
1176
|
+
!((_a = props.columnControl) == null ? void 0 : _a.disableCheckAll) ? (openBlock(), createBlock(unref(MenuItem), {
|
|
1114
1177
|
key: 0,
|
|
1115
1178
|
onClick: onCheckAllChange
|
|
1116
1179
|
}, {
|
|
@@ -1170,7 +1233,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1170
1233
|
};
|
|
1171
1234
|
}
|
|
1172
1235
|
});
|
|
1173
|
-
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
1236
|
+
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-04235d0e"]]);
|
|
1174
1237
|
const _hoisted_1 = { class: "pro-table_header" };
|
|
1175
1238
|
const _hoisted_2 = {
|
|
1176
1239
|
key: 0,
|
|
@@ -1192,32 +1255,36 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1192
1255
|
...{ name: "ProTable", inheritAttrs: false },
|
|
1193
1256
|
__name: "ProTable",
|
|
1194
1257
|
props: /* @__PURE__ */ mergeModels({
|
|
1195
|
-
table: { default:
|
|
1258
|
+
table: { default: void 0 },
|
|
1196
1259
|
search: { type: Function, default: void 0 },
|
|
1197
|
-
addIndexColumn: { type: Boolean, default:
|
|
1198
|
-
immediateSearch: { type: Boolean, default:
|
|
1199
|
-
control: { type: [Boolean, Object], default:
|
|
1200
|
-
searchFormConfig: { default:
|
|
1260
|
+
addIndexColumn: { type: Boolean, default: void 0 },
|
|
1261
|
+
immediateSearch: { type: Boolean, default: void 0 },
|
|
1262
|
+
control: { type: [Boolean, Object], default: void 0 },
|
|
1263
|
+
searchFormConfig: { default: void 0 },
|
|
1201
1264
|
tableContainer: { type: [Object, Function, Boolean], default: void 0 }
|
|
1202
1265
|
}, {
|
|
1203
1266
|
"size": {},
|
|
1204
1267
|
"sizeModifiers": {},
|
|
1205
|
-
"loading": { type: Boolean },
|
|
1268
|
+
"loading": { type: Boolean, ...{ default: false } },
|
|
1206
1269
|
"loadingModifiers": {}
|
|
1207
1270
|
}),
|
|
1208
1271
|
emits: ["update:size", "update:loading"],
|
|
1209
1272
|
setup(__props) {
|
|
1273
|
+
const props = __props;
|
|
1210
1274
|
const { t } = useLocale();
|
|
1211
1275
|
const config = INJECT_CONFIG["pro-table"];
|
|
1212
|
-
const
|
|
1276
|
+
const injectPropsRaw = inject(config.injectionKey, config.default);
|
|
1277
|
+
const injectProps = computed(() => toValue(injectPropsRaw) || {});
|
|
1213
1278
|
const tableProperties = Object.keys(tableProps());
|
|
1214
|
-
const injectAttrs =
|
|
1279
|
+
const injectAttrs = computed(
|
|
1280
|
+
() => pick(injectProps.value, tableProperties)
|
|
1281
|
+
);
|
|
1215
1282
|
const computedSearchFormConfig = computed(() => {
|
|
1216
1283
|
var _a, _b;
|
|
1217
|
-
const container = ((_a =
|
|
1284
|
+
const container = ((_a = props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.value.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
|
|
1218
1285
|
return {
|
|
1219
|
-
...injectProps.searchFormConfig,
|
|
1220
|
-
...getObject(
|
|
1286
|
+
...injectProps.value.searchFormConfig,
|
|
1287
|
+
...getObject(props.searchFormConfig),
|
|
1221
1288
|
container: container ? container : void 0
|
|
1222
1289
|
};
|
|
1223
1290
|
});
|
|
@@ -1225,21 +1292,23 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1225
1292
|
const tableAttrs = computed(() => {
|
|
1226
1293
|
return pick(camelizeProperties(attrs), tableProperties);
|
|
1227
1294
|
});
|
|
1228
|
-
const { columns, dataSource, searchForm, pageParam, setPageParam } = __props.table || {};
|
|
1229
1295
|
const size = useModel(__props, "size");
|
|
1230
1296
|
const loading = useModel(__props, "loading");
|
|
1231
1297
|
const _search = async () => {
|
|
1232
1298
|
var _a;
|
|
1233
|
-
|
|
1299
|
+
const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
|
|
1300
|
+
if (isPromise(searchPromise)) {
|
|
1234
1301
|
loading.value = true;
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1302
|
+
try {
|
|
1303
|
+
await searchPromise;
|
|
1304
|
+
} finally {
|
|
1305
|
+
loading.value = false;
|
|
1306
|
+
}
|
|
1238
1307
|
}
|
|
1239
1308
|
};
|
|
1240
1309
|
const reset = () => {
|
|
1241
|
-
var _a;
|
|
1242
|
-
(_a =
|
|
1310
|
+
var _a, _b;
|
|
1311
|
+
(_b = (_a = props.table) == null ? void 0 : _a.resetQueryParams) == null ? void 0 : _b.call(_a);
|
|
1243
1312
|
nextTick(() => {
|
|
1244
1313
|
_search();
|
|
1245
1314
|
});
|
|
@@ -1254,75 +1323,93 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1254
1323
|
...tableSlots
|
|
1255
1324
|
} = slots;
|
|
1256
1325
|
const searchPage1st = () => {
|
|
1257
|
-
|
|
1326
|
+
var _a, _b;
|
|
1327
|
+
(_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current: 1 });
|
|
1258
1328
|
_search();
|
|
1259
1329
|
};
|
|
1260
1330
|
const computedTableProps = computed(() => {
|
|
1261
1331
|
return {
|
|
1262
|
-
...injectAttrs,
|
|
1332
|
+
...injectAttrs.value,
|
|
1263
1333
|
...tableAttrs.value,
|
|
1264
1334
|
pagination: void 0,
|
|
1265
1335
|
onChange: void 0
|
|
1266
1336
|
};
|
|
1267
1337
|
});
|
|
1268
1338
|
const computedTableContainer = computed(() => {
|
|
1269
|
-
const container =
|
|
1339
|
+
const container = props.tableContainer ?? injectProps.value.tableContainer ?? DefaultTableContainer;
|
|
1270
1340
|
return container ? container : void 0;
|
|
1271
1341
|
});
|
|
1272
|
-
const
|
|
1342
|
+
const renderIndex = ({ index: index2 }) => index2 + 1;
|
|
1343
|
+
const indexColumn = computed(() => ({
|
|
1273
1344
|
title: t("table.index"),
|
|
1274
1345
|
dataIndex: "_index",
|
|
1346
|
+
key: "_index",
|
|
1275
1347
|
width: 80,
|
|
1276
|
-
customRender:
|
|
1348
|
+
customRender: renderIndex
|
|
1349
|
+
}));
|
|
1350
|
+
const computedColumns = computed(() => {
|
|
1351
|
+
var _a;
|
|
1352
|
+
const cols = tableAttrs.value.columns ?? toValue((_a = props.table) == null ? void 0 : _a.columns) ?? [];
|
|
1353
|
+
const needIndex = props.addIndexColumn ?? injectProps.value.addIndexColumn;
|
|
1354
|
+
return needIndex ? [indexColumn.value, ...cols] : cols;
|
|
1277
1355
|
});
|
|
1278
|
-
const computedColumns = computed(
|
|
1279
|
-
() => [
|
|
1280
|
-
...__props.addIndexColumn ?? injectProps.addIndexColumn ? [indexColumn()] : [],
|
|
1281
|
-
...tableAttrs.value.columns ?? (columns == null ? void 0 : columns.value) ?? []
|
|
1282
|
-
]
|
|
1283
|
-
);
|
|
1284
1356
|
const visibleComputedColumns = computed(() => {
|
|
1285
1357
|
return computedColumns.value.filter((item) => !item.hidden);
|
|
1286
1358
|
});
|
|
1287
1359
|
const computedDataSource = computed(() => {
|
|
1288
|
-
|
|
1360
|
+
var _a;
|
|
1361
|
+
return tableAttrs.value.dataSource ?? toValue((_a = props.table) == null ? void 0 : _a.dataSource) ?? [];
|
|
1289
1362
|
});
|
|
1290
1363
|
const computedPagination = computed(() => {
|
|
1291
|
-
var _a, _b;
|
|
1364
|
+
var _a, _b, _c, _d;
|
|
1292
1365
|
if (tableAttrs.value.pagination === false) return false;
|
|
1366
|
+
if (isPlainObject(tableAttrs.value.pagination)) {
|
|
1367
|
+
const globalPagination = injectAttrs.value.pagination === false ? {} : injectAttrs.value.pagination;
|
|
1368
|
+
return {
|
|
1369
|
+
...globalPagination,
|
|
1370
|
+
...(_a = props.table) == null ? void 0 : _a.pageParam,
|
|
1371
|
+
...tableAttrs.value.pagination,
|
|
1372
|
+
showTotal: ((_b = tableAttrs.value.pagination) == null ? void 0 : _b.showTotal) ?? (globalPagination == null ? void 0 : globalPagination.showTotal) ?? ((total) => t("pagination.total", { total }))
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
if (injectAttrs.value.pagination === false) return false;
|
|
1293
1376
|
return {
|
|
1294
|
-
...injectAttrs.pagination,
|
|
1295
|
-
...pageParam,
|
|
1296
|
-
|
|
1297
|
-
showTotal: ((_a = tableAttrs.value.pagination) == null ? void 0 : _a.showTotal) ?? (injectAttrs.pagination === false ? void 0 : (_b = injectAttrs.pagination) == null ? void 0 : _b.showTotal) ?? ((total) => t("pagination.total", { total }))
|
|
1377
|
+
...injectAttrs.value.pagination,
|
|
1378
|
+
...(_c = props.table) == null ? void 0 : _c.pageParam,
|
|
1379
|
+
showTotal: ((_d = injectAttrs.value.pagination) == null ? void 0 : _d.showTotal) ?? ((total) => t("pagination.total", { total }))
|
|
1298
1380
|
};
|
|
1299
1381
|
});
|
|
1300
1382
|
const onTableChange = (...args) => {
|
|
1301
|
-
var _a;
|
|
1302
|
-
setPageParam == null ? void 0 :
|
|
1303
|
-
(
|
|
1383
|
+
var _a, _b, _c;
|
|
1384
|
+
(_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, args[0]);
|
|
1385
|
+
(_c = attrs.onChange) == null ? void 0 : _c.call(attrs, ...args);
|
|
1304
1386
|
_search();
|
|
1305
1387
|
};
|
|
1306
1388
|
const showSearch = computed(() => {
|
|
1307
|
-
var _a, _b;
|
|
1308
|
-
|
|
1389
|
+
var _a, _b, _c, _d;
|
|
1390
|
+
const searchFields = (_b = (_a = props.table) == null ? void 0 : _a.searchForm) == null ? void 0 : _b.fields;
|
|
1391
|
+
const fieldList = (Array.isArray(searchFields) ? searchFields : searchFields == null ? void 0 : searchFields.value) ?? [];
|
|
1392
|
+
return !!(searchFormSlot || ((_c = computedSearchFormConfig.value) == null ? void 0 : _c.hidden) !== true && ((_d = props.table) == null ? void 0 : _d.searchForm) && fieldList.filter((item) => !item.hidden).length > 0);
|
|
1309
1393
|
});
|
|
1310
1394
|
const computedControl = computed(() => {
|
|
1311
|
-
const
|
|
1312
|
-
if (
|
|
1313
|
-
return { sizeControl:
|
|
1395
|
+
const controlConfig = props.control ?? injectProps.value.control;
|
|
1396
|
+
if (controlConfig === true) {
|
|
1397
|
+
return { sizeControl: true, columnControl: true };
|
|
1314
1398
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
return {
|
|
1399
|
+
if (controlConfig === false) {
|
|
1400
|
+
return { sizeControl: false, columnControl: false };
|
|
1401
|
+
}
|
|
1402
|
+
return {
|
|
1403
|
+
sizeControl: !!(controlConfig == null ? void 0 : controlConfig.sizeControl),
|
|
1404
|
+
columnControl: (controlConfig == null ? void 0 : controlConfig.columnControl) ?? false
|
|
1405
|
+
};
|
|
1319
1406
|
});
|
|
1320
1407
|
const columnControlConfig = computed(() => {
|
|
1321
1408
|
const cc = computedControl.value.columnControl;
|
|
1322
1409
|
return typeof cc === "object" ? cc : void 0;
|
|
1323
1410
|
});
|
|
1324
1411
|
onMounted(() => {
|
|
1325
|
-
if (
|
|
1412
|
+
if (props.immediateSearch ?? injectProps.value.immediateSearch) {
|
|
1326
1413
|
_search();
|
|
1327
1414
|
}
|
|
1328
1415
|
});
|
|
@@ -1336,15 +1423,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1336
1423
|
component: computedSearchFormConfig.value.container
|
|
1337
1424
|
}, {
|
|
1338
1425
|
default: withCtx(() => [
|
|
1339
|
-
renderSlot(_ctx.$slots, "search-form", {}, () =>
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1426
|
+
renderSlot(_ctx.$slots, "search-form", {}, () => {
|
|
1427
|
+
var _a;
|
|
1428
|
+
return [
|
|
1429
|
+
((_a = props.table) == null ? void 0 : _a.searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
|
|
1430
|
+
key: 0,
|
|
1431
|
+
form: props.table.searchForm
|
|
1432
|
+
}, computedSearchFormConfig.value, {
|
|
1433
|
+
onSearch: searchPage1st,
|
|
1434
|
+
onReset: reset
|
|
1435
|
+
}), null, 16, ["form"])) : createCommentVNode("", true)
|
|
1436
|
+
];
|
|
1437
|
+
}, true)
|
|
1348
1438
|
]),
|
|
1349
1439
|
_: 3
|
|
1350
1440
|
}, 8, ["component"])) : createCommentVNode("", true),
|
|
@@ -1366,7 +1456,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1366
1456
|
computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
1367
1457
|
createVNode(unref(ColumnControl), {
|
|
1368
1458
|
columns: computedColumns.value,
|
|
1369
|
-
table:
|
|
1459
|
+
table: props.table,
|
|
1370
1460
|
"column-control": columnControlConfig.value
|
|
1371
1461
|
}, null, 8, ["columns", "table", "column-control"])
|
|
1372
1462
|
])) : createCommentVNode("", true)
|
|
@@ -1397,7 +1487,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1397
1487
|
};
|
|
1398
1488
|
}
|
|
1399
1489
|
});
|
|
1400
|
-
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1490
|
+
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-5ce28f7b"]]);
|
|
1401
1491
|
function useTable(params) {
|
|
1402
1492
|
return useTable$1(params);
|
|
1403
1493
|
}
|
|
@@ -1408,16 +1498,42 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1408
1498
|
},
|
|
1409
1499
|
__name: "index",
|
|
1410
1500
|
props: {
|
|
1411
|
-
componentVars: {},
|
|
1412
|
-
componentMap: {},
|
|
1413
|
-
locale: {}
|
|
1501
|
+
componentVars: { default: void 0 },
|
|
1502
|
+
componentMap: { default: void 0 },
|
|
1503
|
+
locale: { default: void 0 }
|
|
1414
1504
|
},
|
|
1415
1505
|
setup(__props) {
|
|
1416
1506
|
const props = __props;
|
|
1507
|
+
Object.keys(INJECT_CONFIG).forEach(
|
|
1508
|
+
(key) => {
|
|
1509
|
+
const config = INJECT_CONFIG[key];
|
|
1510
|
+
provide(
|
|
1511
|
+
config.injectionKey,
|
|
1512
|
+
computed(() => {
|
|
1513
|
+
var _a;
|
|
1514
|
+
return {
|
|
1515
|
+
...config.default,
|
|
1516
|
+
...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
|
|
1517
|
+
};
|
|
1518
|
+
})
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1521
|
+
);
|
|
1417
1522
|
if (props.componentVars) {
|
|
1418
|
-
Object.
|
|
1419
|
-
|
|
1420
|
-
|
|
1523
|
+
Object.keys(props.componentVars).forEach((key) => {
|
|
1524
|
+
if (!(key in INJECT_CONFIG)) {
|
|
1525
|
+
const config = ensureInjectConfig(key);
|
|
1526
|
+
provide(
|
|
1527
|
+
config.injectionKey,
|
|
1528
|
+
computed(() => {
|
|
1529
|
+
var _a;
|
|
1530
|
+
return {
|
|
1531
|
+
...config.default,
|
|
1532
|
+
...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
|
|
1533
|
+
};
|
|
1534
|
+
})
|
|
1535
|
+
);
|
|
1536
|
+
}
|
|
1421
1537
|
});
|
|
1422
1538
|
}
|
|
1423
1539
|
if (props.componentMap) {
|