@qin-ui/element-plus-pro 1.3.3 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI-CONTEXT.md +4 -4
- package/README.md +3 -2
- package/api.json +2 -2
- package/es/components/component-provider/constants/index.d.ts.map +1 -1
- package/es/components/component-provider/types/index.d.ts +3 -2
- package/es/components/component-provider/types/index.d.ts.map +1 -1
- package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts +1 -1
- package/es/components/form/components/BaseFormItem/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.map +1 -1
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -1
- package/es/components/form/types/index.d.ts +2 -2
- package/es/components/form/types/index.d.ts.map +1 -1
- package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -1
- package/es/components/table/components/ProTable.vue.d.ts +30 -4
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
- package/es/components/table/components/SearchForm.vue.d.ts +1 -1
- package/es/components/table/components/SearchForm.vue.d.ts.map +1 -1
- package/es/components/table/components/SizeControl.vue.d.ts +2 -2
- package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -1
- package/es/components/table/index.d.ts +4 -28
- package/es/components/table/index.d.ts.map +1 -1
- package/es/components/table/useTable.d.ts +1 -1
- package/es/element-plus-pro.css +12 -12
- package/es/index.js +410 -331
- package/es/index.js.map +1 -1
- package/es/shared/core/index.d.ts +1 -2
- package/es/shared/core/index.d.ts.map +1 -1
- package/es/shared/ui/index.d.ts +2 -2
- package/es/shared/ui/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/components/component-provider/constants/index.ts +12 -0
- package/src/components/component-provider/types/index.ts +8 -2
- package/src/components/form/components/BaseField/index.vue +25 -9
- package/src/components/form/components/BaseField/utils/index.ts +1 -1
- package/src/components/form/components/BaseFormItem/index.vue +62 -8
- package/src/components/form/components/ProForm/index.vue +24 -12
- package/src/components/form/components/SlotComponent/index.vue +4 -3
- package/src/components/form/hooks/useGroupFieldAttrs.ts +8 -15
- package/src/components/form/types/index.ts +2 -8
- package/src/components/table/components/ColumnControl.vue +40 -37
- package/src/components/table/components/ProTable.vue +74 -18
- package/src/components/table/components/SearchForm.vue +5 -4
- package/src/components/table/components/TableColumnRenderer.vue +22 -9
- package/src/components/table/index.ts +10 -30
- package/src/components/table/useTable.ts +1 -1
- package/src/shared/core/index.ts +1 -2
- package/src/shared/ui/index.ts +2 -0
- package/tsconfig.json +23 -0
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./element-plus-pro.css";
|
|
2
|
-
import { inject, computed, toValue,
|
|
3
|
-
import { ElTable, ElPagination, ElCol, ElFormItem, useFormDisabled, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput,
|
|
4
|
-
import {
|
|
2
|
+
import { inject, computed, toValue, defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, ref, useAttrs, createCommentVNode, createSlots, renderList, createVNode, resolveComponent, unref, toRaw, provide, useSlots, shallowRef, onUpdated, triggerRef, withModifiers, createElementVNode, normalizeStyle, useModel, watch, mergeModels, onMounted, resolveDirective, normalizeClass, withDirectives, guardReactiveProps, nextTick } from "vue";
|
|
3
|
+
import { ElTable, ElPagination, ElCol, ElFormItem, useFormDisabled, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput, localeContextKey, useLocale as useLocale$1, ElRow, ElForm, ElSpace, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElCheckbox, ElTableColumn, ElLoading } from "element-plus";
|
|
4
|
+
import { useForm as useForm$1, zhCN as zhCN$1, zhTW as zhTW$1, enUS as enUS$1, resolveLocaleName, format, cloneDeep, InjectionFormSlotsKey, isPlainObject, getObject, normalizePathKey, createFormProxy, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, useSearchFormExpand, get, pick, isPromise, useTable as useTable$1 } from "@qin-ui/pro-components-core";
|
|
5
5
|
import { useFormData } from "@qin-ui/pro-components-core";
|
|
6
6
|
const _tableProps = ElTable.props || {};
|
|
7
7
|
const _paginationProps = ElPagination.props || {};
|
|
@@ -133,6 +133,18 @@ const INJECT_CONFIG = {
|
|
|
133
133
|
injectionKey: Symbol(""),
|
|
134
134
|
default: { style: { width: "100%" } }
|
|
135
135
|
},
|
|
136
|
+
"date-picker.quarter": {
|
|
137
|
+
injectionKey: Symbol(""),
|
|
138
|
+
default: { style: { width: "100%" } }
|
|
139
|
+
},
|
|
140
|
+
"date-picker.quarters": {
|
|
141
|
+
injectionKey: Symbol(""),
|
|
142
|
+
default: { style: { width: "100%" } }
|
|
143
|
+
},
|
|
144
|
+
"date-picker.quarterrange": {
|
|
145
|
+
injectionKey: Symbol(""),
|
|
146
|
+
default: { style: { width: "100%" } }
|
|
147
|
+
},
|
|
136
148
|
"date-picker.datetime": {
|
|
137
149
|
injectionKey: Symbol(""),
|
|
138
150
|
default: { style: { width: "100%" } }
|
|
@@ -189,6 +201,38 @@ const ensureInjectConfig = (key) => {
|
|
|
189
201
|
DYNAMIC_INJECT_CONFIG[key] = created;
|
|
190
202
|
return created;
|
|
191
203
|
};
|
|
204
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
205
|
+
...{ name: "ContainerFragment", inheritAttrs: false },
|
|
206
|
+
__name: "index",
|
|
207
|
+
props: {
|
|
208
|
+
component: { type: [Object, Function] }
|
|
209
|
+
},
|
|
210
|
+
setup(__props) {
|
|
211
|
+
return (_ctx, _cache) => {
|
|
212
|
+
return __props.component ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
|
|
213
|
+
default: withCtx(() => [
|
|
214
|
+
renderSlot(_ctx.$slots, "default")
|
|
215
|
+
]),
|
|
216
|
+
_: 3
|
|
217
|
+
}, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
222
|
+
...{ name: "SlotComponent", inheritAttrs: false },
|
|
223
|
+
__name: "index",
|
|
224
|
+
props: {
|
|
225
|
+
component: { type: [Object, Function, String, Number, Boolean, null] }
|
|
226
|
+
},
|
|
227
|
+
setup(__props) {
|
|
228
|
+
const isRenderable = (c) => c !== null && c !== void 0 && (typeof c === "function" || typeof c === "object");
|
|
229
|
+
return (_ctx, _cache) => {
|
|
230
|
+
return isRenderable(__props.component) ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
231
|
+
createTextVNode(toDisplayString(__props.component), 1)
|
|
232
|
+
], 64));
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
});
|
|
192
236
|
const FORM_ITEM_SLOT_KEYS = ["label", "error"];
|
|
193
237
|
const componentMap = {
|
|
194
238
|
"input": ElInput,
|
|
@@ -206,215 +250,6 @@ const componentMap = {
|
|
|
206
250
|
"tree-select": ElTreeSelect,
|
|
207
251
|
"transfer": ElTransfer
|
|
208
252
|
};
|
|
209
|
-
const formItemPropKeys = Object.keys(formItemProps()).filter(
|
|
210
|
-
(k) => k !== "disabled"
|
|
211
|
-
);
|
|
212
|
-
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
213
|
-
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
214
|
-
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
215
|
-
function useGroupFieldAttrs(validFields) {
|
|
216
|
-
const config = INJECT_CONFIG["pro-form-item"];
|
|
217
|
-
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
218
|
-
return computed(() => {
|
|
219
|
-
const rawInjectProps = toValue(injectFormItemProps) || {};
|
|
220
|
-
return validFields.value.map((field) => {
|
|
221
|
-
let gridItemProps2 = {};
|
|
222
|
-
let formItemProps2 = {};
|
|
223
|
-
const componentProps = { slots: {} };
|
|
224
|
-
const formItemSlots = {};
|
|
225
|
-
if (isPlainObject(field)) {
|
|
226
|
-
const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
|
|
227
|
-
const {
|
|
228
|
-
class: injectClassName,
|
|
229
|
-
style: injectStyle,
|
|
230
|
-
span: injectSpan,
|
|
231
|
-
formItemContainer: injectFormItemContainer,
|
|
232
|
-
xs,
|
|
233
|
-
sm,
|
|
234
|
-
md,
|
|
235
|
-
lg,
|
|
236
|
-
xl,
|
|
237
|
-
...injectRest
|
|
238
|
-
} = rawInjectProps;
|
|
239
|
-
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
240
|
-
gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
|
|
241
|
-
formItemProps2 = mergeProps(
|
|
242
|
-
injectRest,
|
|
243
|
-
{ class: injectClassName, style: injectStyle },
|
|
244
|
-
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
245
|
-
formItemDataAttrs
|
|
246
|
-
);
|
|
247
|
-
const container = formItemContainer ?? injectFormItemContainer;
|
|
248
|
-
Object.keys(rest).forEach((k) => {
|
|
249
|
-
if (gridItemPropKeySet.has(k)) {
|
|
250
|
-
gridItemProps2[k] = rest[k];
|
|
251
|
-
} else if (formItemPropKeySet.has(k)) {
|
|
252
|
-
formItemProps2[k] = rest[k];
|
|
253
|
-
} else {
|
|
254
|
-
componentProps[k] = rest[k];
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
Object.assign(componentProps, componentDataAttrs);
|
|
258
|
-
Object.keys(slots).forEach((k) => {
|
|
259
|
-
if (FORM_ITEM_SLOT_KEYS.includes(k)) {
|
|
260
|
-
formItemSlots[k] = slots[k];
|
|
261
|
-
} else {
|
|
262
|
-
componentProps.slots[k] = slots[k];
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
const raw2 = toValue(name) ?? toValue(path);
|
|
266
|
-
return {
|
|
267
|
-
path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
|
|
268
|
-
gridItemProps: gridItemProps2,
|
|
269
|
-
formItemProps: formItemProps2,
|
|
270
|
-
formItemSlots,
|
|
271
|
-
componentProps,
|
|
272
|
-
container,
|
|
273
|
-
rawField: field
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
|
|
277
|
-
return {
|
|
278
|
-
path: Array.isArray(raw) ? raw.join(".") : raw || "",
|
|
279
|
-
gridItemProps: gridItemProps2,
|
|
280
|
-
formItemProps: formItemProps2,
|
|
281
|
-
formItemSlots,
|
|
282
|
-
componentProps,
|
|
283
|
-
rawField: field
|
|
284
|
-
};
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
289
|
-
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
290
|
-
__name: "index",
|
|
291
|
-
props: {
|
|
292
|
-
grid: { type: [Boolean, Object], default: void 0 },
|
|
293
|
-
fields: { default: () => [] }
|
|
294
|
-
},
|
|
295
|
-
setup(__props) {
|
|
296
|
-
const props = __props;
|
|
297
|
-
const validFields = computed(
|
|
298
|
-
() => (
|
|
299
|
-
// hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
|
|
300
|
-
(props.fields ?? []).filter((field) => !toValue(field.hidden))
|
|
301
|
-
)
|
|
302
|
-
);
|
|
303
|
-
const config = INJECT_CONFIG["pro-form"];
|
|
304
|
-
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
305
|
-
const injectGrid = computed(() => {
|
|
306
|
-
var _a;
|
|
307
|
-
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
308
|
-
});
|
|
309
|
-
const enableGrid = computed(() => {
|
|
310
|
-
if (props.grid !== void 0) return !!props.grid;
|
|
311
|
-
return !!injectGrid.value;
|
|
312
|
-
});
|
|
313
|
-
const computedGridProps = computed(() => {
|
|
314
|
-
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
315
|
-
});
|
|
316
|
-
const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
317
|
-
const componentInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
318
|
-
const setFormItemRef = (field, el, formItemProps2) => {
|
|
319
|
-
if (!field || typeof field !== "object") return;
|
|
320
|
-
const raw = toRaw(field);
|
|
321
|
-
if (el) {
|
|
322
|
-
formItemInstanceMap.set(raw, el);
|
|
323
|
-
raw.getFormItemRef = () => formItemInstanceMap.get(raw);
|
|
324
|
-
raw.getFormItemComputedProps = () => formItemProps2;
|
|
325
|
-
} else {
|
|
326
|
-
formItemInstanceMap.delete(raw);
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
const setComponentRef = (field, el) => {
|
|
330
|
-
if (!field || typeof field !== "object") return;
|
|
331
|
-
const raw = toRaw(field);
|
|
332
|
-
if (el) {
|
|
333
|
-
componentInstanceMap.set(raw, el);
|
|
334
|
-
raw.getComponentRef = () => {
|
|
335
|
-
var _a;
|
|
336
|
-
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
|
|
337
|
-
};
|
|
338
|
-
raw.getComponentComputedProps = () => {
|
|
339
|
-
var _a;
|
|
340
|
-
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
|
|
341
|
-
};
|
|
342
|
-
} else {
|
|
343
|
-
componentInstanceMap.delete(raw);
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
const groupedFields = useGroupFieldAttrs(validFields);
|
|
347
|
-
return (_ctx, _cache) => {
|
|
348
|
-
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
349
|
-
return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
350
|
-
component: enableGrid.value ? unref(ElRow) : void 0
|
|
351
|
-
}, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
352
|
-
default: withCtx(() => [
|
|
353
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item, index2) => {
|
|
354
|
-
return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
355
|
-
key: item.path || index2,
|
|
356
|
-
component: enableGrid.value ? unref(ElCol) : void 0
|
|
357
|
-
}, { ref_for: true }, item.gridItemProps), {
|
|
358
|
-
default: withCtx(() => [
|
|
359
|
-
createVNode(unref(_sfc_main$d), {
|
|
360
|
-
component: item.container,
|
|
361
|
-
path: item.path
|
|
362
|
-
}, {
|
|
363
|
-
default: withCtx(() => [
|
|
364
|
-
createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
365
|
-
ref_for: true,
|
|
366
|
-
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
367
|
-
prop: unref(normalizePathKey)(item.path),
|
|
368
|
-
path: item.path
|
|
369
|
-
}), createSlots({
|
|
370
|
-
default: withCtx(() => [
|
|
371
|
-
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
372
|
-
key: 0,
|
|
373
|
-
grid: item.rawField.grid ?? props.grid,
|
|
374
|
-
fields: item.rawField.fields
|
|
375
|
-
}, null, 8, ["grid", "fields"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
|
|
376
|
-
key: 1,
|
|
377
|
-
ref_for: true,
|
|
378
|
-
ref: (el) => setComponentRef(item.rawField, el)
|
|
379
|
-
}, { ref_for: true }, item.componentProps, {
|
|
380
|
-
path: item.path
|
|
381
|
-
}), null, 16, ["path"]))
|
|
382
|
-
]),
|
|
383
|
-
_: 2
|
|
384
|
-
}, [
|
|
385
|
-
renderList(item.formItemSlots, (slot, name) => {
|
|
386
|
-
return {
|
|
387
|
-
name,
|
|
388
|
-
fn: withCtx((scoped) => [
|
|
389
|
-
createVNode(unref(_sfc_main$c), mergeProps({
|
|
390
|
-
path: item.path,
|
|
391
|
-
component: slot
|
|
392
|
-
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
393
|
-
])
|
|
394
|
-
};
|
|
395
|
-
})
|
|
396
|
-
]), 1040, ["prop", "path"])
|
|
397
|
-
]),
|
|
398
|
-
_: 2
|
|
399
|
-
}, 1032, ["component", "path"])
|
|
400
|
-
]),
|
|
401
|
-
_: 2
|
|
402
|
-
}, 1040, ["component"]);
|
|
403
|
-
}), 128))
|
|
404
|
-
]),
|
|
405
|
-
_: 1
|
|
406
|
-
}, 16, ["component"]);
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
const _export_sfc = (sfc, props) => {
|
|
411
|
-
const target = sfc.__vccOpts || sfc;
|
|
412
|
-
for (const [key, val] of props) {
|
|
413
|
-
target[key] = val;
|
|
414
|
-
}
|
|
415
|
-
return target;
|
|
416
|
-
};
|
|
417
|
-
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-e8f152ee"]]);
|
|
418
253
|
function useForm(...args) {
|
|
419
254
|
return useForm$1(...args);
|
|
420
255
|
}
|
|
@@ -533,7 +368,7 @@ const useLocale = () => {
|
|
|
533
368
|
};
|
|
534
369
|
return { t, lang };
|
|
535
370
|
};
|
|
536
|
-
const _sfc_main$
|
|
371
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
537
372
|
...{ name: "BaseField", inheritAttrs: false },
|
|
538
373
|
__name: "index",
|
|
539
374
|
props: {
|
|
@@ -541,6 +376,10 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
541
376
|
path: { default: "" }
|
|
542
377
|
},
|
|
543
378
|
setup(__props, { expose: __expose }) {
|
|
379
|
+
const cloneDeepIfObject = (val) => (
|
|
380
|
+
// 原始值直接传递,引用值克隆快照
|
|
381
|
+
typeof val === "object" && val !== null ? cloneDeep(val) : val
|
|
382
|
+
);
|
|
544
383
|
const props = __props;
|
|
545
384
|
const { t } = useLocale();
|
|
546
385
|
const form = useForm(false);
|
|
@@ -566,10 +405,16 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
566
405
|
const { valueFormatter } = groupedAttrs.value;
|
|
567
406
|
const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
|
|
568
407
|
if (setFormatter) {
|
|
569
|
-
const oldVal = setFormatter.length > 1 ?
|
|
408
|
+
const oldVal = setFormatter.length > 1 ? cloneDeepIfObject((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
|
|
570
409
|
newVal = setFormatter(val, oldVal);
|
|
571
410
|
}
|
|
572
411
|
(_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
|
|
412
|
+
const { onUpdateValue } = groupedAttrs.value;
|
|
413
|
+
if (typeof onUpdateValue === "function") {
|
|
414
|
+
onUpdateValue(val);
|
|
415
|
+
} else if (Array.isArray(onUpdateValue)) {
|
|
416
|
+
onUpdateValue.forEach((listener) => listener(val));
|
|
417
|
+
}
|
|
573
418
|
}
|
|
574
419
|
});
|
|
575
420
|
const parentDisabled = useDisabledContext();
|
|
@@ -592,23 +437,24 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
592
437
|
{ disabled: effectiveDisabled },
|
|
593
438
|
{ modelProp: modelPropName }
|
|
594
439
|
);
|
|
595
|
-
const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, [modelPropName]: _modelVal, [`onUpdate:${modelPropName}`]:
|
|
440
|
+
const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, [modelPropName]: _modelVal, [`onUpdate:${modelPropName}`]: onUpdateValue, ...bindAttrs } = mergedProps;
|
|
596
441
|
return {
|
|
597
442
|
attrs: bindAttrs,
|
|
598
443
|
slots,
|
|
599
444
|
componentContainer,
|
|
600
445
|
modelProp: modelPropName,
|
|
601
|
-
valueFormatter
|
|
446
|
+
valueFormatter,
|
|
447
|
+
onUpdateValue
|
|
602
448
|
};
|
|
603
449
|
});
|
|
604
|
-
const
|
|
450
|
+
const injectedFormSlots = inject(InjectionFormSlotsKey, void 0);
|
|
605
451
|
const customComponents = inject(INJECT_COMPONENTS, {});
|
|
606
452
|
const is = computed(() => {
|
|
607
|
-
var _a;
|
|
608
|
-
const teleportSlot = props.path && (
|
|
453
|
+
var _a, _b;
|
|
454
|
+
const teleportSlot = props.path && ((_a = injectedFormSlots == null ? void 0 : injectedFormSlots.value) == null ? void 0 : _a[props.path]);
|
|
609
455
|
if (teleportSlot) return teleportSlot;
|
|
610
456
|
if (typeof props.component === "string") {
|
|
611
|
-
const resolved = ((
|
|
457
|
+
const resolved = ((_b = toValue(customComponents)) == null ? void 0 : _b[props.component]) || componentMap[props.component];
|
|
612
458
|
if (resolved) return resolved;
|
|
613
459
|
warnUnknownComponent(props.component);
|
|
614
460
|
return props.component;
|
|
@@ -620,7 +466,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
620
466
|
getComponentComputedProps: () => groupedAttrs.value.attrs
|
|
621
467
|
});
|
|
622
468
|
return (_ctx, _cache) => {
|
|
623
|
-
return openBlock(), createBlock(
|
|
469
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
624
470
|
component: groupedAttrs.value.componentContainer,
|
|
625
471
|
path: props.path
|
|
626
472
|
}, {
|
|
@@ -636,7 +482,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
636
482
|
return {
|
|
637
483
|
name,
|
|
638
484
|
fn: withCtx((scoped) => [
|
|
639
|
-
createVNode(
|
|
485
|
+
createVNode(_sfc_main$e, mergeProps({
|
|
640
486
|
path: props.path
|
|
641
487
|
}, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
642
488
|
])
|
|
@@ -649,38 +495,244 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
649
495
|
};
|
|
650
496
|
}
|
|
651
497
|
});
|
|
652
|
-
const
|
|
653
|
-
|
|
498
|
+
const formItemPropKeys = Object.keys(formItemProps()).filter(
|
|
499
|
+
(k) => k !== "disabled"
|
|
500
|
+
);
|
|
501
|
+
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
502
|
+
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
503
|
+
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
504
|
+
const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
|
|
505
|
+
function useGroupFieldAttrs(validFields) {
|
|
506
|
+
const config = INJECT_CONFIG["pro-form-item"];
|
|
507
|
+
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
508
|
+
return computed(() => {
|
|
509
|
+
const rawInjectProps = toValue(injectFormItemProps) || {};
|
|
510
|
+
return validFields.value.map((field) => {
|
|
511
|
+
let gridItemProps2 = {};
|
|
512
|
+
let formItemProps2 = {};
|
|
513
|
+
const componentProps = { slots: {} };
|
|
514
|
+
const formItemSlots = {};
|
|
515
|
+
if (isPlainObject(field)) {
|
|
516
|
+
const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
|
|
517
|
+
const { class: injectClassName, style: injectStyle, span: injectSpan, formItemContainer: injectFormItemContainer, xs, sm, md, lg, xl, ...injectRest } = rawInjectProps;
|
|
518
|
+
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
519
|
+
gridItemProps2 = fields ? { ...initGridItemProps, span: span ?? 24 } : initGridItemProps;
|
|
520
|
+
formItemProps2 = mergeProps(
|
|
521
|
+
injectRest,
|
|
522
|
+
{ class: injectClassName, style: injectStyle },
|
|
523
|
+
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
524
|
+
formItemDataAttrs
|
|
525
|
+
);
|
|
526
|
+
const container = formItemContainer ?? injectFormItemContainer;
|
|
527
|
+
Object.keys(rest).forEach((k) => {
|
|
528
|
+
if (gridItemPropKeySet.has(k)) {
|
|
529
|
+
gridItemProps2[k] = rest[k];
|
|
530
|
+
} else if (formItemPropKeySet.has(k)) {
|
|
531
|
+
formItemProps2[k] = rest[k];
|
|
532
|
+
} else {
|
|
533
|
+
componentProps[k] = rest[k];
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
Object.assign(componentProps, componentDataAttrs);
|
|
537
|
+
Object.keys(slots).forEach((k) => {
|
|
538
|
+
if (formItemSlotKeySet.has(k)) {
|
|
539
|
+
formItemSlots[k] = slots[k];
|
|
540
|
+
} else {
|
|
541
|
+
componentProps.slots[k] = slots[k];
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
const raw2 = toValue(name) ?? toValue(path);
|
|
545
|
+
return {
|
|
546
|
+
path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
|
|
547
|
+
gridItemProps: gridItemProps2,
|
|
548
|
+
formItemProps: formItemProps2,
|
|
549
|
+
formItemSlots,
|
|
550
|
+
componentProps,
|
|
551
|
+
container,
|
|
552
|
+
rawField: field
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
|
|
556
|
+
return {
|
|
557
|
+
path: Array.isArray(raw) ? raw.join(".") : raw || "",
|
|
558
|
+
gridItemProps: gridItemProps2,
|
|
559
|
+
formItemProps: formItemProps2,
|
|
560
|
+
formItemSlots,
|
|
561
|
+
componentProps,
|
|
562
|
+
rawField: field
|
|
563
|
+
};
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
568
|
+
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
654
569
|
__name: "index",
|
|
655
570
|
props: {
|
|
656
|
-
|
|
571
|
+
grid: { type: [Boolean, Object], default: void 0 },
|
|
572
|
+
fields: { default: () => [] }
|
|
657
573
|
},
|
|
658
574
|
setup(__props) {
|
|
575
|
+
let fieldKeySeed = 0;
|
|
576
|
+
const fieldKeyMap = /* @__PURE__ */ new WeakMap();
|
|
577
|
+
const getFieldKey = (field) => {
|
|
578
|
+
const raw = toRaw(field);
|
|
579
|
+
let key = fieldKeyMap.get(raw);
|
|
580
|
+
if (key === void 0) {
|
|
581
|
+
key = ++fieldKeySeed;
|
|
582
|
+
fieldKeyMap.set(raw, key);
|
|
583
|
+
}
|
|
584
|
+
return key;
|
|
585
|
+
};
|
|
586
|
+
const props = __props;
|
|
587
|
+
const validFields = computed(
|
|
588
|
+
() => (
|
|
589
|
+
// hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
|
|
590
|
+
(props.fields ?? []).filter((field) => !toValue(field.hidden))
|
|
591
|
+
)
|
|
592
|
+
);
|
|
593
|
+
const config = INJECT_CONFIG["pro-form"];
|
|
594
|
+
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
595
|
+
const injectGrid = computed(() => {
|
|
596
|
+
var _a;
|
|
597
|
+
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
598
|
+
});
|
|
599
|
+
const enableGrid = computed(() => {
|
|
600
|
+
if (props.grid !== void 0) return !!props.grid;
|
|
601
|
+
return !!injectGrid.value;
|
|
602
|
+
});
|
|
603
|
+
const computedGridProps = computed(() => {
|
|
604
|
+
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
605
|
+
});
|
|
606
|
+
const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
607
|
+
const componentInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
608
|
+
const warnedFrozenFields = /* @__PURE__ */ new WeakSet();
|
|
609
|
+
const defineFieldAccessors = (raw, accessors) => {
|
|
610
|
+
try {
|
|
611
|
+
for (const [key, getter] of Object.entries(accessors)) {
|
|
612
|
+
Object.defineProperty(raw, key, {
|
|
613
|
+
value: getter,
|
|
614
|
+
enumerable: false,
|
|
615
|
+
configurable: true,
|
|
616
|
+
writable: true
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
} catch {
|
|
620
|
+
if (!warnedFrozenFields.has(raw)) {
|
|
621
|
+
warnedFrozenFields.add(raw);
|
|
622
|
+
console.warn(
|
|
623
|
+
"[pro-components] 字段配置对象不可写(如被 Object.freeze),getFormItemRef / getComponentRef 等实例访问器挂载失败。"
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
const setFormItemRef = (field, el, formItemProps2) => {
|
|
629
|
+
if (!field || typeof field !== "object") return;
|
|
630
|
+
const raw = toRaw(field);
|
|
631
|
+
if (el) {
|
|
632
|
+
formItemInstanceMap.set(raw, el);
|
|
633
|
+
defineFieldAccessors(raw, {
|
|
634
|
+
getFormItemRef: () => formItemInstanceMap.get(raw),
|
|
635
|
+
getFormItemComputedProps: () => formItemProps2
|
|
636
|
+
});
|
|
637
|
+
} else {
|
|
638
|
+
formItemInstanceMap.delete(raw);
|
|
639
|
+
delete raw.getFormItemRef;
|
|
640
|
+
delete raw.getFormItemComputedProps;
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
const setComponentRef = (field, el) => {
|
|
644
|
+
if (!field || typeof field !== "object") return;
|
|
645
|
+
const raw = toRaw(field);
|
|
646
|
+
if (el) {
|
|
647
|
+
componentInstanceMap.set(raw, el);
|
|
648
|
+
defineFieldAccessors(raw, {
|
|
649
|
+
getComponentRef: () => {
|
|
650
|
+
var _a;
|
|
651
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
|
|
652
|
+
},
|
|
653
|
+
getComponentComputedProps: () => {
|
|
654
|
+
var _a;
|
|
655
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
} else {
|
|
659
|
+
componentInstanceMap.delete(raw);
|
|
660
|
+
delete raw.getComponentRef;
|
|
661
|
+
delete raw.getComponentComputedProps;
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
const groupedFields = useGroupFieldAttrs(validFields);
|
|
659
665
|
return (_ctx, _cache) => {
|
|
660
|
-
|
|
666
|
+
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
667
|
+
return openBlock(), createBlock(_sfc_main$f, mergeProps({
|
|
668
|
+
component: enableGrid.value ? unref(ElRow) : void 0
|
|
669
|
+
}, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
661
670
|
default: withCtx(() => [
|
|
662
|
-
|
|
671
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item) => {
|
|
672
|
+
return openBlock(), createBlock(_sfc_main$f, mergeProps({
|
|
673
|
+
key: item.path || getFieldKey(item.rawField),
|
|
674
|
+
component: enableGrid.value ? unref(ElCol) : void 0
|
|
675
|
+
}, { ref_for: true }, item.gridItemProps), {
|
|
676
|
+
default: withCtx(() => [
|
|
677
|
+
createVNode(_sfc_main$f, {
|
|
678
|
+
component: item.container,
|
|
679
|
+
path: item.path
|
|
680
|
+
}, {
|
|
681
|
+
default: withCtx(() => [
|
|
682
|
+
createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
683
|
+
ref_for: true,
|
|
684
|
+
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
685
|
+
prop: unref(normalizePathKey)(item.path),
|
|
686
|
+
path: item.path
|
|
687
|
+
}), createSlots({
|
|
688
|
+
default: withCtx(() => [
|
|
689
|
+
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
690
|
+
key: 0,
|
|
691
|
+
grid: item.rawField.grid ?? props.grid,
|
|
692
|
+
fields: item.rawField.fields
|
|
693
|
+
}, null, 8, ["grid", "fields"])) : (openBlock(), createBlock(_sfc_main$d, mergeProps({
|
|
694
|
+
key: 1,
|
|
695
|
+
ref_for: true,
|
|
696
|
+
ref: (el) => setComponentRef(item.rawField, el)
|
|
697
|
+
}, { ref_for: true }, item.componentProps, {
|
|
698
|
+
path: item.path
|
|
699
|
+
}), null, 16, ["path"]))
|
|
700
|
+
]),
|
|
701
|
+
_: 2
|
|
702
|
+
}, [
|
|
703
|
+
renderList(item.formItemSlots, (slot, name) => {
|
|
704
|
+
return {
|
|
705
|
+
name,
|
|
706
|
+
fn: withCtx((scoped) => [
|
|
707
|
+
createVNode(_sfc_main$e, mergeProps({
|
|
708
|
+
path: item.path,
|
|
709
|
+
component: slot
|
|
710
|
+
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
711
|
+
])
|
|
712
|
+
};
|
|
713
|
+
})
|
|
714
|
+
]), 1040, ["prop", "path"])
|
|
715
|
+
]),
|
|
716
|
+
_: 2
|
|
717
|
+
}, 1032, ["component", "path"])
|
|
718
|
+
]),
|
|
719
|
+
_: 2
|
|
720
|
+
}, 1040, ["component"]);
|
|
721
|
+
}), 128))
|
|
663
722
|
]),
|
|
664
|
-
_:
|
|
665
|
-
}, 16
|
|
723
|
+
_: 1
|
|
724
|
+
}, 16, ["component"]);
|
|
666
725
|
};
|
|
667
726
|
}
|
|
668
727
|
});
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
component: { type: [Object, Function, String, Number, Boolean, null] }
|
|
674
|
-
},
|
|
675
|
-
setup(__props) {
|
|
676
|
-
const isRenderable = (c) => c !== null && c !== void 0 && (typeof c === "function" || typeof c === "object");
|
|
677
|
-
return (_ctx, _cache) => {
|
|
678
|
-
return isRenderable(__props.component) ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
679
|
-
createTextVNode(toDisplayString(__props.component), 1)
|
|
680
|
-
], 64));
|
|
681
|
-
};
|
|
728
|
+
const _export_sfc = (sfc, props) => {
|
|
729
|
+
const target = sfc.__vccOpts || sfc;
|
|
730
|
+
for (const [key, val] of props) {
|
|
731
|
+
target[key] = val;
|
|
682
732
|
}
|
|
683
|
-
|
|
733
|
+
return target;
|
|
734
|
+
};
|
|
735
|
+
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-6f664240"]]);
|
|
684
736
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
685
737
|
...{ name: "ProForm", inheritAttrs: false },
|
|
686
738
|
__name: "index",
|
|
@@ -690,9 +742,9 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
690
742
|
},
|
|
691
743
|
setup(__props) {
|
|
692
744
|
const props = __props;
|
|
693
|
-
|
|
745
|
+
let fallbackForm;
|
|
694
746
|
const currentForm = computed(
|
|
695
|
-
() => props.form ?? fallbackForm
|
|
747
|
+
() => props.form ?? (fallbackForm ?? (fallbackForm = useForm()))
|
|
696
748
|
);
|
|
697
749
|
const formProxy = createFormProxy(() => currentForm.value);
|
|
698
750
|
provide(InjectionFormKey, formProxy);
|
|
@@ -712,6 +764,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
712
764
|
let formInstanceCounter = 0;
|
|
713
765
|
const formInstanceKeyMap = /* @__PURE__ */ new WeakMap();
|
|
714
766
|
const getFormKey = (f) => {
|
|
767
|
+
if (f == null) return 0;
|
|
715
768
|
if (!formInstanceKeyMap.has(f)) {
|
|
716
769
|
formInstanceKeyMap.set(f, ++formInstanceCounter);
|
|
717
770
|
}
|
|
@@ -730,7 +783,11 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
730
783
|
return mergeProps(injectAttrs.value, camelizeProperties(attrs));
|
|
731
784
|
});
|
|
732
785
|
const slots = useSlots();
|
|
733
|
-
|
|
786
|
+
const formSlotsRef = shallowRef(slots);
|
|
787
|
+
onUpdated(() => {
|
|
788
|
+
triggerRef(formSlotsRef);
|
|
789
|
+
});
|
|
790
|
+
provide(InjectionFormSlotsKey, formSlotsRef);
|
|
734
791
|
return (_ctx, _cache) => {
|
|
735
792
|
return openBlock(), createBlock(unref(ElForm), mergeProps({
|
|
736
793
|
key: formKey.value,
|
|
@@ -742,7 +799,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
742
799
|
}, ["prevent"]))
|
|
743
800
|
}), {
|
|
744
801
|
default: withCtx(() => [
|
|
745
|
-
createVNode(
|
|
802
|
+
createVNode(BaseFormItem, {
|
|
746
803
|
fields: fields.value,
|
|
747
804
|
grid: props.grid
|
|
748
805
|
}, null, 8, ["fields", "grid"]),
|
|
@@ -825,9 +882,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
825
882
|
emit("search");
|
|
826
883
|
};
|
|
827
884
|
return (_ctx, _cache) => {
|
|
828
|
-
return openBlock(), createBlock(
|
|
885
|
+
return openBlock(), createBlock(_sfc_main$b, mergeProps(layoutProps.value, {
|
|
829
886
|
form: props.form,
|
|
830
|
-
class: "pro-table_search-form transition"
|
|
887
|
+
class: "pro-table_search-form transition",
|
|
888
|
+
onSubmit: withModifiers(onSearch, ["prevent"])
|
|
831
889
|
}), {
|
|
832
890
|
default: withCtx(() => [
|
|
833
891
|
createVNode(unref(ElSpace), {
|
|
@@ -861,8 +919,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
861
919
|
key: 1,
|
|
862
920
|
class: "pro-table_search-form_search-button",
|
|
863
921
|
type: "primary",
|
|
864
|
-
"native-type": "submit"
|
|
865
|
-
onClick: onSearch
|
|
922
|
+
"native-type": "submit"
|
|
866
923
|
}, {
|
|
867
924
|
default: withCtx(() => [
|
|
868
925
|
createTextVNode(toDisplayString(unref(t)("table.query")), 1)
|
|
@@ -906,7 +963,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
906
963
|
};
|
|
907
964
|
}
|
|
908
965
|
});
|
|
909
|
-
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-
|
|
966
|
+
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-746ff159"]]);
|
|
910
967
|
const _sfc_main$8 = {};
|
|
911
968
|
const _hoisted_1$4 = { class: "pro-table_search-form-container" };
|
|
912
969
|
function _sfc_render$3(_ctx, _cache) {
|
|
@@ -1024,32 +1081,32 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1024
1081
|
const { t } = useLocale();
|
|
1025
1082
|
const checkAll = ref(false);
|
|
1026
1083
|
const indeterminate = ref(false);
|
|
1027
|
-
const getColumnKey = (column
|
|
1084
|
+
const getColumnKey = (column) => {
|
|
1028
1085
|
const rawKey = column.key ?? column.prop;
|
|
1029
|
-
if (rawKey === void 0 || rawKey === null
|
|
1086
|
+
if (rawKey === void 0 || rawKey === null || rawKey === "")
|
|
1087
|
+
return void 0;
|
|
1030
1088
|
return normalizePathKey(rawKey);
|
|
1031
1089
|
};
|
|
1032
1090
|
const checkedColumnsOptions = computed(
|
|
1033
|
-
() => props.columns.
|
|
1091
|
+
() => props.columns.flatMap((item) => {
|
|
1034
1092
|
var _a, _b, _c, _d, _e, _f;
|
|
1035
|
-
const key = getColumnKey(item
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
);
|
|
1093
|
+
const key = getColumnKey(item);
|
|
1094
|
+
if (key === void 0) return [];
|
|
1095
|
+
if (key === "__INDEX__" || item.type === "index" || ((_b = (_a = props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some((ek) => String(ek) === key)))
|
|
1096
|
+
return [];
|
|
1097
|
+
const disabled = ((_d = (_c = props.columnControl) == null ? void 0 : _c.disabledKeys) == null ? void 0 : _d.some((dk) => String(dk) === key)) ?? false;
|
|
1040
1098
|
const rawTitle = item.label ?? item.title;
|
|
1041
1099
|
const titleLabel = typeof rawTitle === "string" ? rawTitle : void 0;
|
|
1042
1100
|
const propLabel = item.prop !== void 0 && item.prop !== null ? String(item.prop) : void 0;
|
|
1043
|
-
const label = ((_f = (_e = props.columnControl) == null ? void 0 : _e.labels) == null ? void 0 : _f[key]) ?? titleLabel ?? propLabel ?? key
|
|
1101
|
+
const label = ((_f = (_e = props.columnControl) == null ? void 0 : _e.labels) == null ? void 0 : _f[key]) ?? titleLabel ?? propLabel ?? key;
|
|
1044
1102
|
return {
|
|
1045
1103
|
label,
|
|
1046
1104
|
value: key,
|
|
1047
1105
|
checked: !item.hidden || !!disabled,
|
|
1048
1106
|
disabled: !!disabled,
|
|
1049
|
-
column: item
|
|
1050
|
-
excluded
|
|
1107
|
+
column: item
|
|
1051
1108
|
};
|
|
1052
|
-
})
|
|
1109
|
+
})
|
|
1053
1110
|
);
|
|
1054
1111
|
const controllableOptions = computed(
|
|
1055
1112
|
() => checkedColumnsOptions.value.filter((item) => !item.disabled)
|
|
@@ -1061,11 +1118,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1061
1118
|
);
|
|
1062
1119
|
},
|
|
1063
1120
|
set(val) {
|
|
1121
|
+
const checkedSet = new Set(val);
|
|
1064
1122
|
checkedColumnsOptions.value.forEach((item) => {
|
|
1065
1123
|
var _a;
|
|
1066
|
-
if (item.disabled) return;
|
|
1124
|
+
if (item.disabled || item.checked === checkedSet.has(item.value)) return;
|
|
1067
1125
|
(_a = props.table) == null ? void 0 : _a.setColumn(item.value, {
|
|
1068
|
-
hidden: !
|
|
1126
|
+
hidden: !checkedSet.has(item.value)
|
|
1069
1127
|
});
|
|
1070
1128
|
});
|
|
1071
1129
|
}
|
|
@@ -1180,7 +1238,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1180
1238
|
};
|
|
1181
1239
|
}
|
|
1182
1240
|
});
|
|
1183
|
-
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
1241
|
+
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-55e837c0"]]);
|
|
1184
1242
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
1185
1243
|
...{ name: "TableColumnRenderer" },
|
|
1186
1244
|
__name: "TableColumnRenderer",
|
|
@@ -1189,9 +1247,21 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1189
1247
|
},
|
|
1190
1248
|
setup(__props) {
|
|
1191
1249
|
const props = __props;
|
|
1192
|
-
|
|
1250
|
+
let columnKeySeed = 0;
|
|
1251
|
+
const columnKeyMap = /* @__PURE__ */ new WeakMap();
|
|
1252
|
+
const getStableColumnKey = (column) => {
|
|
1253
|
+
const raw = toRaw(column);
|
|
1254
|
+
let key = columnKeyMap.get(raw);
|
|
1255
|
+
if (key === void 0) {
|
|
1256
|
+
key = ++columnKeySeed;
|
|
1257
|
+
columnKeyMap.set(raw, key);
|
|
1258
|
+
}
|
|
1259
|
+
return key;
|
|
1260
|
+
};
|
|
1261
|
+
const getColumnKey = (column) => {
|
|
1193
1262
|
const rawKey = column.key ?? column.prop;
|
|
1194
|
-
if (rawKey === void 0 || rawKey === null)
|
|
1263
|
+
if (rawKey === void 0 || rawKey === null)
|
|
1264
|
+
return getStableColumnKey(column);
|
|
1195
1265
|
return normalizePathKey(rawKey);
|
|
1196
1266
|
};
|
|
1197
1267
|
const getCellValue = (row, column) => {
|
|
@@ -1215,9 +1285,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1215
1285
|
};
|
|
1216
1286
|
return (_ctx, _cache) => {
|
|
1217
1287
|
const _component_TableColumnRenderer = resolveComponent("TableColumnRenderer", true);
|
|
1218
|
-
return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column
|
|
1288
|
+
return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column) => {
|
|
1219
1289
|
return openBlock(), createElementBlock(Fragment, {
|
|
1220
|
-
key: getColumnKey(column
|
|
1290
|
+
key: getColumnKey(column)
|
|
1221
1291
|
}, [
|
|
1222
1292
|
column.children && column.children.length > 0 ? (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1223
1293
|
key: 0,
|
|
@@ -1236,7 +1306,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1236
1306
|
default: withCtx((scope) => {
|
|
1237
1307
|
var _a;
|
|
1238
1308
|
return [
|
|
1239
|
-
createVNode(
|
|
1309
|
+
createVNode(_sfc_main$e, {
|
|
1240
1310
|
component: (_a = column.render) == null ? void 0 : _a.call(column, {
|
|
1241
1311
|
...scope,
|
|
1242
1312
|
column,
|
|
@@ -1291,53 +1361,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1291
1361
|
tableContainer: { type: [Object, Function, Boolean], default: void 0 },
|
|
1292
1362
|
columns: { default: void 0 },
|
|
1293
1363
|
data: { default: void 0 },
|
|
1294
|
-
pagination: { type: [Boolean, Object], default: void 0 }
|
|
1295
|
-
size: {},
|
|
1296
|
-
width: {},
|
|
1297
|
-
height: {},
|
|
1298
|
-
maxHeight: {},
|
|
1299
|
-
fit: { type: Boolean },
|
|
1300
|
-
stripe: { type: Boolean },
|
|
1301
|
-
border: { type: Boolean },
|
|
1302
|
-
rowKey: {},
|
|
1303
|
-
context: {},
|
|
1304
|
-
showHeader: { type: Boolean },
|
|
1305
|
-
showSummary: { type: Boolean },
|
|
1306
|
-
sumText: {},
|
|
1307
|
-
summaryMethod: {},
|
|
1308
|
-
rowClassName: {},
|
|
1309
|
-
rowStyle: {},
|
|
1310
|
-
cellClassName: {},
|
|
1311
|
-
cellStyle: {},
|
|
1312
|
-
headerRowClassName: {},
|
|
1313
|
-
headerRowStyle: {},
|
|
1314
|
-
headerCellClassName: {},
|
|
1315
|
-
headerCellStyle: {},
|
|
1316
|
-
highlightCurrentRow: { type: Boolean },
|
|
1317
|
-
currentRowKey: {},
|
|
1318
|
-
emptyText: {},
|
|
1319
|
-
expandRowKeys: {},
|
|
1320
|
-
defaultExpandAll: { type: Boolean },
|
|
1321
|
-
rowExpandable: {},
|
|
1322
|
-
defaultSort: {},
|
|
1323
|
-
tooltipEffect: {},
|
|
1324
|
-
tooltipOptions: {},
|
|
1325
|
-
spanMethod: {},
|
|
1326
|
-
selectOnIndeterminate: { type: Boolean },
|
|
1327
|
-
indent: {},
|
|
1328
|
-
treeProps: {},
|
|
1329
|
-
lazy: { type: Boolean },
|
|
1330
|
-
load: {},
|
|
1331
|
-
className: {},
|
|
1332
|
-
style: { type: [Boolean, null, String, Object, Array] },
|
|
1333
|
-
tableLayout: {},
|
|
1334
|
-
scrollbarAlwaysOn: { type: Boolean },
|
|
1335
|
-
flexible: { type: Boolean },
|
|
1336
|
-
showOverflowTooltip: { type: [Boolean, Object] },
|
|
1337
|
-
tooltipFormatter: {},
|
|
1338
|
-
appendFilterPanelTo: {},
|
|
1339
|
-
scrollbarTabindex: {},
|
|
1340
|
-
nativeScrollbar: { type: Boolean }
|
|
1364
|
+
pagination: { type: [Boolean, Object], default: void 0 }
|
|
1341
1365
|
}, {
|
|
1342
1366
|
"size": {},
|
|
1343
1367
|
"sizeModifiers": {},
|
|
@@ -1354,8 +1378,34 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1354
1378
|
const injectPropsRaw = inject(config.injectionKey, config.default);
|
|
1355
1379
|
const injectProps = computed(() => toValue(injectPropsRaw) || {});
|
|
1356
1380
|
const attrs = useAttrs();
|
|
1381
|
+
const PRO_TABLE_EXCLUDED_ATTR_KEYS = /* @__PURE__ */ new Set([
|
|
1382
|
+
"class",
|
|
1383
|
+
"style",
|
|
1384
|
+
"onSearch",
|
|
1385
|
+
"onChange",
|
|
1386
|
+
"onUpdate:size",
|
|
1387
|
+
"onUpdate:loading",
|
|
1388
|
+
"data",
|
|
1389
|
+
"columns",
|
|
1390
|
+
"size",
|
|
1391
|
+
"pagination"
|
|
1392
|
+
]);
|
|
1393
|
+
const PRO_TABLE_PROVIDER_KEYS = /* @__PURE__ */ new Set([
|
|
1394
|
+
"pagination",
|
|
1395
|
+
"searchFormConfig",
|
|
1396
|
+
"control",
|
|
1397
|
+
"immediateSearch",
|
|
1398
|
+
"addIndexColumn",
|
|
1399
|
+
"tableContainer"
|
|
1400
|
+
]);
|
|
1357
1401
|
const injectTableAttrs = computed(() => {
|
|
1358
|
-
|
|
1402
|
+
const tableConfig = {};
|
|
1403
|
+
for (const [key, value] of Object.entries(injectProps.value)) {
|
|
1404
|
+
if (!PRO_TABLE_PROVIDER_KEYS.has(key)) {
|
|
1405
|
+
tableConfig[key] = value;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
return tableConfig;
|
|
1359
1409
|
});
|
|
1360
1410
|
const attrsTableProps = computed(() => {
|
|
1361
1411
|
return pick(
|
|
@@ -1363,14 +1413,39 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1363
1413
|
tableProperties
|
|
1364
1414
|
);
|
|
1365
1415
|
});
|
|
1416
|
+
const restTableAttrs = computed(() => {
|
|
1417
|
+
const rest = {};
|
|
1418
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
1419
|
+
if (!PRO_TABLE_EXCLUDED_ATTR_KEYS.has(key)) {
|
|
1420
|
+
rest[key] = value;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
return rest;
|
|
1424
|
+
});
|
|
1366
1425
|
const size = useModel(__props, "size");
|
|
1367
1426
|
const loading = useModel(__props, "loading");
|
|
1368
1427
|
let searchSequence = 0;
|
|
1428
|
+
let warnedSearchConfig = false;
|
|
1429
|
+
const warnSearchConfig = (reason) => {
|
|
1430
|
+
if (warnedSearchConfig) return;
|
|
1431
|
+
warnedSearchConfig = true;
|
|
1432
|
+
console.warn(`[ProTable] ${reason}`);
|
|
1433
|
+
};
|
|
1369
1434
|
const _search = async () => {
|
|
1370
1435
|
var _a;
|
|
1371
|
-
|
|
1436
|
+
if (props.search && attrs.onSearch) {
|
|
1437
|
+
warnSearchConfig(
|
|
1438
|
+
"同时配置了 :search prop 与 @search 监听,@search 监听不会被执行,请仅保留其一。"
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1372
1441
|
const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
|
|
1373
|
-
if (!isPromise(searchPromise))
|
|
1442
|
+
if (!isPromise(searchPromise)) {
|
|
1443
|
+
warnSearchConfig(
|
|
1444
|
+
"search 未返回 Promise,本次查询不参与 loading 竞态管理(在途请求的 loading 状态保持不变)。"
|
|
1445
|
+
);
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
const seq = ++searchSequence;
|
|
1374
1449
|
loading.value = true;
|
|
1375
1450
|
try {
|
|
1376
1451
|
await searchPromise;
|
|
@@ -1440,16 +1515,20 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1440
1515
|
return source;
|
|
1441
1516
|
});
|
|
1442
1517
|
const computedDataSource = computed(() => {
|
|
1443
|
-
var _a
|
|
1518
|
+
var _a;
|
|
1444
1519
|
const attrsData = attrsTableProps.value.data;
|
|
1445
|
-
return props.data ?? attrsData ?? toValue((_a = props.table) == null ? void 0 : _a.
|
|
1520
|
+
return props.data ?? attrsData ?? toValue((_a = props.table) == null ? void 0 : _a.data) ?? [];
|
|
1446
1521
|
});
|
|
1447
1522
|
const computedTableProps = computed(() => {
|
|
1448
1523
|
const merged = {
|
|
1449
1524
|
...injectTableAttrs.value,
|
|
1525
|
+
...restTableAttrs.value,
|
|
1450
1526
|
...attrsTableProps.value
|
|
1451
1527
|
};
|
|
1452
1528
|
delete merged.data;
|
|
1529
|
+
delete merged.columns;
|
|
1530
|
+
delete merged.size;
|
|
1531
|
+
delete merged.pagination;
|
|
1453
1532
|
return merged;
|
|
1454
1533
|
});
|
|
1455
1534
|
const computedPagination = computed(() => {
|
|
@@ -1533,7 +1612,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1533
1612
|
class: normalizeClass(["pro-table", unref(attrs).class]),
|
|
1534
1613
|
style: normalizeStyle(unref(attrs).style)
|
|
1535
1614
|
}, [
|
|
1536
|
-
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(
|
|
1615
|
+
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(_sfc_main$f, {
|
|
1537
1616
|
key: 0,
|
|
1538
1617
|
component: computedSearchFormConfig.value.container
|
|
1539
1618
|
}, {
|
|
@@ -1553,7 +1632,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1553
1632
|
]),
|
|
1554
1633
|
_: 3
|
|
1555
1634
|
}, 8, ["component"])) : createCommentVNode("", true),
|
|
1556
|
-
createVNode(
|
|
1635
|
+
createVNode(_sfc_main$f, { component: computedTableContainer.value }, {
|
|
1557
1636
|
default: withCtx(() => [
|
|
1558
1637
|
createElementVNode("div", _hoisted_1, [
|
|
1559
1638
|
_ctx.$slots["button-bar"] ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
@@ -1563,13 +1642,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1563
1642
|
renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
|
|
1564
1643
|
])) : createCommentVNode("", true),
|
|
1565
1644
|
computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
1566
|
-
createVNode(
|
|
1645
|
+
createVNode(SizeControl, {
|
|
1567
1646
|
size: size.value,
|
|
1568
1647
|
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
|
|
1569
1648
|
}, null, 8, ["size"])
|
|
1570
1649
|
])) : createCommentVNode("", true),
|
|
1571
1650
|
computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
1572
|
-
createVNode(
|
|
1651
|
+
createVNode(ColumnControl, {
|
|
1573
1652
|
columns: normalizedRawColumns.value.filter((item) => item.key !== "__INDEX__"),
|
|
1574
1653
|
table: props.table,
|
|
1575
1654
|
"column-control": columnControlConfig.value
|
|
@@ -1613,7 +1692,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1613
1692
|
};
|
|
1614
1693
|
}
|
|
1615
1694
|
});
|
|
1616
|
-
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1695
|
+
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-6ec2beda"]]);
|
|
1617
1696
|
function useTable(params = {}) {
|
|
1618
1697
|
const { data, columns, ...rest } = params;
|
|
1619
1698
|
const coreTable = useTable$1({
|
|
@@ -1708,12 +1787,12 @@ const index = {
|
|
|
1708
1787
|
}
|
|
1709
1788
|
};
|
|
1710
1789
|
export {
|
|
1711
|
-
_sfc_main$
|
|
1790
|
+
_sfc_main$f as ContainerFragment,
|
|
1712
1791
|
LOCALE_INJECT_KEY,
|
|
1713
1792
|
_sfc_main as ProComponentProvider,
|
|
1714
1793
|
_sfc_main$b as ProForm,
|
|
1715
1794
|
ProTable,
|
|
1716
|
-
_sfc_main$
|
|
1795
|
+
_sfc_main$e as SlotComponent,
|
|
1717
1796
|
index as default,
|
|
1718
1797
|
enUS,
|
|
1719
1798
|
useFields,
|