@qin-ui/element-plus-pro 1.2.2 → 1.2.4
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/api.json +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/constants/index.d.ts +1 -6
- package/es/components/form/constants/index.d.ts.map +1 -1
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts +18 -0
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -0
- package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -1
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
- package/es/components/table/components/SearchForm.vue.d.ts.map +1 -1
- package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -1
- package/es/components/table/types/index.d.ts +2 -0
- package/es/components/table/types/index.d.ts.map +1 -1
- package/es/components/table/useTable.d.ts.map +1 -1
- package/es/element-plus-pro.css +12 -12
- package/es/index.js +201 -177
- package/es/index.js.map +1 -1
- package/es/shared/core/index.d.ts +1 -1
- package/es/shared/core/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/form/components/BaseField/index.vue +8 -8
- package/src/components/form/components/BaseFormItem/index.vue +47 -66
- package/src/components/form/components/ProForm/index.vue +4 -11
- package/src/components/form/constants/index.ts +1 -7
- package/src/components/form/hooks/useGroupFieldAttrs.ts +119 -0
- package/src/components/table/components/ColumnControl.vue +2 -1
- package/src/components/table/components/ProTable.vue +3 -23
- package/src/components/table/components/SearchForm.vue +81 -15
- package/src/components/table/components/TableColumnRenderer.vue +28 -14
- package/src/components/table/types/index.ts +2 -0
- package/src/components/table/useTable.ts +1 -10
- package/src/shared/core/index.ts +1 -1
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +0 -31
- 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/src/components/form/components/GroupedFieldAttrs/index.vue +0 -115
- package/src/components/form/components/PathProvider/index.vue +0 -19
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./element-plus-pro.css";
|
|
2
|
-
import { inject, computed, provide, toValue,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { inject, computed, provide, toValue, mergeProps, defineComponent, resolveComponent, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList, createVNode, createSlots, ref, useAttrs, createCommentVNode, resolveDynamicComponent, renderSlot, normalizeProps, isVNode, createTextVNode, toDisplayString, useSlots, reactive, withModifiers, createElementVNode, onBeforeUnmount, watch, watchEffect, withKeys, normalizeStyle, nextTick, useModel, onMounted, mergeModels, resolveDirective, normalizeClass, withDirectives, guardReactiveProps } from "vue";
|
|
3
|
+
import { ElTable, ElPagination, useFormDisabled, ElCol, ElFormItem, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput, ElRow, useLocale as useLocale$1, ElForm, ElSpace, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElCheckbox, ElTableColumn } from "element-plus";
|
|
4
|
+
import { isPlainObject, getObject, toPath, useForm as useForm$1, zhCN as zhCN$1, zhTW as zhTW$1, enUS as enUS$1, resolveLocaleName, format, omit, InjectionFormSlotsKey, cloneDeep, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, get, pick, 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 || {};
|
|
@@ -205,41 +205,19 @@ const componentMap = {
|
|
|
205
205
|
"tree-select": ElTreeSelect,
|
|
206
206
|
"transfer": ElTransfer
|
|
207
207
|
};
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const props = __props;
|
|
216
|
-
const namePath = computed(() => {
|
|
217
|
-
return Array.isArray(props.path) ? props.path.join(".") : props.path;
|
|
218
|
-
});
|
|
219
|
-
provide(InjectionPathKey, namePath);
|
|
220
|
-
return (_ctx, _cache) => {
|
|
221
|
-
return renderSlot(_ctx.$slots, "default", { path: namePath.value });
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
226
|
-
__name: "index",
|
|
227
|
-
props: {
|
|
228
|
-
field: {}
|
|
229
|
-
},
|
|
230
|
-
setup(__props) {
|
|
231
|
-
const formItemPropKeys = Object.keys(formItemProps());
|
|
232
|
-
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
233
|
-
const props = __props;
|
|
234
|
-
const config = INJECT_CONFIG["pro-form-item"];
|
|
235
|
-
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
236
|
-
const groupedAttributes = computed(() => {
|
|
208
|
+
const formItemPropKeys = Object.keys(formItemProps());
|
|
209
|
+
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
210
|
+
function useGroupFieldAttrs(validFields) {
|
|
211
|
+
const config = INJECT_CONFIG["pro-form-item"];
|
|
212
|
+
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
213
|
+
return computed(() => {
|
|
214
|
+
return validFields.value.map((field) => {
|
|
237
215
|
let gridItemProps2 = {};
|
|
238
216
|
let formItemProps2 = {};
|
|
239
217
|
const componentProps = { slots: {} };
|
|
240
218
|
const formItemSlots = {};
|
|
241
|
-
if (isPlainObject(
|
|
242
|
-
const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } =
|
|
219
|
+
if (isPlainObject(field)) {
|
|
220
|
+
const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
|
|
243
221
|
const {
|
|
244
222
|
class: injectClassName,
|
|
245
223
|
style: injectStyle,
|
|
@@ -260,7 +238,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
260
238
|
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
261
239
|
formItemDataAttrs
|
|
262
240
|
);
|
|
263
|
-
|
|
241
|
+
const container = formItemContainer ?? injectFormItemContainer;
|
|
264
242
|
Object.keys(rest).forEach((k) => {
|
|
265
243
|
if (gridItemPropKeys.includes(k)) {
|
|
266
244
|
gridItemProps2[k] = rest[k];
|
|
@@ -275,17 +253,32 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
275
253
|
if (FORM_ITEM_SLOT_KEYS.includes(k)) {
|
|
276
254
|
formItemSlots[k] = slots[k];
|
|
277
255
|
} else {
|
|
278
|
-
componentProps
|
|
256
|
+
componentProps.slots[k] = slots[k];
|
|
279
257
|
}
|
|
280
258
|
});
|
|
259
|
+
const raw2 = toValue(path) ?? toValue(name);
|
|
260
|
+
return {
|
|
261
|
+
path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
|
|
262
|
+
gridItemProps: gridItemProps2,
|
|
263
|
+
formItemProps: formItemProps2,
|
|
264
|
+
formItemSlots,
|
|
265
|
+
componentProps,
|
|
266
|
+
container,
|
|
267
|
+
rawField: field
|
|
268
|
+
};
|
|
281
269
|
}
|
|
282
|
-
|
|
270
|
+
const raw = toValue(field == null ? void 0 : field.path) ?? toValue(field == null ? void 0 : field.name);
|
|
271
|
+
return {
|
|
272
|
+
path: Array.isArray(raw) ? raw.join(".") : raw || "",
|
|
273
|
+
gridItemProps: gridItemProps2,
|
|
274
|
+
formItemProps: formItemProps2,
|
|
275
|
+
formItemSlots,
|
|
276
|
+
componentProps,
|
|
277
|
+
rawField: field
|
|
278
|
+
};
|
|
283
279
|
});
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
});
|
|
280
|
+
});
|
|
281
|
+
}
|
|
289
282
|
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
290
283
|
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
291
284
|
__name: "index",
|
|
@@ -331,81 +324,66 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
331
324
|
}
|
|
332
325
|
});
|
|
333
326
|
};
|
|
327
|
+
const groupedFields = useGroupFieldAttrs(validFields);
|
|
334
328
|
return (_ctx, _cache) => {
|
|
335
329
|
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
336
330
|
return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
337
331
|
component: enableGrid.value ? unref(ElRow) : void 0
|
|
338
332
|
}, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
339
333
|
default: withCtx(() => [
|
|
340
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
341
|
-
return openBlock(), createBlock(_sfc_main$
|
|
342
|
-
key:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
334
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item, index2) => {
|
|
335
|
+
return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
336
|
+
key: item.path || index2,
|
|
337
|
+
component: enableGrid.value ? unref(ElCol) : void 0
|
|
338
|
+
}, { ref_for: true }, item.gridItemProps), {
|
|
339
|
+
default: withCtx(() => [
|
|
340
|
+
createVNode(unref(_sfc_main$d), {
|
|
341
|
+
component: item.container,
|
|
342
|
+
path: item.path
|
|
343
|
+
}, {
|
|
344
|
+
default: withCtx(() => [
|
|
345
|
+
createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
346
|
+
ref_for: true,
|
|
347
|
+
ref: (el) => formItemRefs[index2] = el,
|
|
348
|
+
prop: unref(toPath)(item.path).join("."),
|
|
349
|
+
path: item.path,
|
|
350
|
+
onVnodeMounted: ($event) => onFormItemMounted(index2, item.formItemProps)
|
|
351
|
+
}), createSlots({
|
|
355
352
|
default: withCtx(() => [
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
370
|
-
key: 0,
|
|
371
|
-
grid: field.grid ?? __props.grid,
|
|
372
|
-
fields: field.fields,
|
|
373
|
-
disabled: toValue(field.disabled)
|
|
374
|
-
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
|
|
375
|
-
key: 1,
|
|
376
|
-
ref_for: true,
|
|
377
|
-
ref: (el) => componentRefs[index2] = el
|
|
378
|
-
}, { ref_for: true }, componentProps, {
|
|
379
|
-
path,
|
|
380
|
-
onVnodeMounted: ($event) => onComponentMounted(index2)
|
|
381
|
-
}), null, 16, ["path", "onVnodeMounted"]))
|
|
382
|
-
]),
|
|
383
|
-
_: 2
|
|
384
|
-
}, [
|
|
385
|
-
renderList(formItemSlots, (slot, name) => {
|
|
386
|
-
return {
|
|
387
|
-
name,
|
|
388
|
-
fn: withCtx((scoped) => [
|
|
389
|
-
createVNode(unref(_sfc_main$c), mergeProps({
|
|
390
|
-
path,
|
|
391
|
-
component: slot
|
|
392
|
-
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
393
|
-
])
|
|
394
|
-
};
|
|
395
|
-
})
|
|
396
|
-
]), 1040, ["prop", "path", "onVnodeMounted"])
|
|
397
|
-
]),
|
|
398
|
-
_: 2
|
|
399
|
-
}, 1032, ["component", "path"])
|
|
353
|
+
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
354
|
+
key: 0,
|
|
355
|
+
grid: item.rawField.grid ?? __props.grid,
|
|
356
|
+
fields: item.rawField.fields,
|
|
357
|
+
disabled: toValue(item.rawField.disabled)
|
|
358
|
+
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
|
|
359
|
+
key: 1,
|
|
360
|
+
ref_for: true,
|
|
361
|
+
ref: (el) => componentRefs[index2] = el
|
|
362
|
+
}, { ref_for: true }, item.componentProps, {
|
|
363
|
+
path: item.path,
|
|
364
|
+
onVnodeMounted: ($event) => onComponentMounted(index2)
|
|
365
|
+
}), null, 16, ["path", "onVnodeMounted"]))
|
|
400
366
|
]),
|
|
401
367
|
_: 2
|
|
402
|
-
},
|
|
368
|
+
}, [
|
|
369
|
+
renderList(item.formItemSlots, (slot, name) => {
|
|
370
|
+
return {
|
|
371
|
+
name,
|
|
372
|
+
fn: withCtx((scoped) => [
|
|
373
|
+
createVNode(unref(_sfc_main$c), mergeProps({
|
|
374
|
+
path: item.path,
|
|
375
|
+
component: slot
|
|
376
|
+
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
377
|
+
])
|
|
378
|
+
};
|
|
379
|
+
})
|
|
380
|
+
]), 1040, ["prop", "path", "onVnodeMounted"])
|
|
403
381
|
]),
|
|
404
382
|
_: 2
|
|
405
|
-
}, 1032, ["
|
|
383
|
+
}, 1032, ["component", "path"])
|
|
406
384
|
]),
|
|
407
385
|
_: 2
|
|
408
|
-
}, 1040);
|
|
386
|
+
}, 1040, ["component"]);
|
|
409
387
|
}), 128))
|
|
410
388
|
]),
|
|
411
389
|
_: 1
|
|
@@ -420,7 +398,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
420
398
|
}
|
|
421
399
|
return target;
|
|
422
400
|
};
|
|
423
|
-
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-
|
|
401
|
+
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-295cd434"]]);
|
|
424
402
|
function useForm(...args) {
|
|
425
403
|
return useForm$1(...args);
|
|
426
404
|
}
|
|
@@ -600,13 +578,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
600
578
|
valueFormatter
|
|
601
579
|
};
|
|
602
580
|
});
|
|
603
|
-
const
|
|
604
|
-
`${TeleportComponentNamePrefix}${__props.path}`,
|
|
605
|
-
void 0
|
|
606
|
-
);
|
|
581
|
+
const formSlots = inject(InjectionFormSlotsKey, void 0);
|
|
607
582
|
const customComponents = inject(INJECT_COMPONENTS, {});
|
|
608
583
|
const is = computed(() => {
|
|
609
|
-
|
|
584
|
+
const teleportSlot = __props.path && (formSlots == null ? void 0 : formSlots[__props.path]);
|
|
585
|
+
if (teleportSlot) return teleportSlot;
|
|
610
586
|
if (typeof __props.component === "string") {
|
|
611
587
|
return customComponents[__props.component] || componentMap[__props.component] || __props.component;
|
|
612
588
|
}
|
|
@@ -693,12 +669,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
693
669
|
config.default
|
|
694
670
|
);
|
|
695
671
|
const slots = useSlots();
|
|
696
|
-
|
|
697
|
-
Object.keys(slots).forEach((name) => {
|
|
698
|
-
if (name === "default") return;
|
|
699
|
-
provide(`${TeleportComponentNamePrefix}${name}`, slots[name]);
|
|
700
|
-
});
|
|
701
|
-
});
|
|
672
|
+
provide(InjectionFormSlotsKey, reactive(slots));
|
|
702
673
|
return (_ctx, _cache) => {
|
|
703
674
|
return openBlock(), createBlock(unref(ElForm), mergeProps({
|
|
704
675
|
ref: (el) => {
|
|
@@ -766,7 +737,22 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
766
737
|
const emit = __emit;
|
|
767
738
|
const proFormHeight = ref("unset");
|
|
768
739
|
const collapseHeight = ref(0);
|
|
769
|
-
|
|
740
|
+
const rowHeight = ref(32);
|
|
741
|
+
let resizeObserver = null;
|
|
742
|
+
let intersectionObserver = null;
|
|
743
|
+
const cleanupObservers = () => {
|
|
744
|
+
if (resizeObserver) {
|
|
745
|
+
resizeObserver.disconnect();
|
|
746
|
+
resizeObserver = null;
|
|
747
|
+
}
|
|
748
|
+
if (intersectionObserver) {
|
|
749
|
+
intersectionObserver.disconnect();
|
|
750
|
+
intersectionObserver = null;
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
onBeforeUnmount(() => {
|
|
754
|
+
cleanupObservers();
|
|
755
|
+
});
|
|
770
756
|
const computedExpand = computed(() => {
|
|
771
757
|
if (!__props.expand) return false;
|
|
772
758
|
if (__props.expand === true) return { minExpandRows: 2, expandStatus: false };
|
|
@@ -777,33 +763,57 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
777
763
|
});
|
|
778
764
|
const showExpandToggle = ref(false);
|
|
779
765
|
const expandStatus = ref(true);
|
|
766
|
+
const { formRef, getFormData } = __props.form;
|
|
767
|
+
const updateHeights = () => {
|
|
768
|
+
var _a, _b, _c, _d, _e, _f;
|
|
769
|
+
if (!__props.expand || !formRef.value) return;
|
|
770
|
+
const proFormEl = (_a = formRef.value) == null ? void 0 : _a.$el;
|
|
771
|
+
if (!proFormEl) return;
|
|
772
|
+
const itemHeight = (_d = (_c = (_b = proFormEl == null ? void 0 : proFormEl.querySelector("[class*='-form-item']")) == null ? void 0 : _b.getBoundingClientRect) == null ? void 0 : _c.call(_b)) == null ? void 0 : _d.height;
|
|
773
|
+
if (itemHeight && itemHeight > 0) {
|
|
774
|
+
rowHeight.value = itemHeight;
|
|
775
|
+
}
|
|
776
|
+
const naturalHeight = proFormEl.scrollHeight || ((_f = (_e = proFormEl.getBoundingClientRect) == null ? void 0 : _e.call(proFormEl)) == null ? void 0 : _f.height) || 0;
|
|
777
|
+
if (naturalHeight > 0) {
|
|
778
|
+
proFormHeight.value = naturalHeight;
|
|
779
|
+
}
|
|
780
|
+
};
|
|
780
781
|
const changeExpandStatus = () => {
|
|
781
782
|
expandStatus.value = !expandStatus.value;
|
|
783
|
+
nextTick(() => {
|
|
784
|
+
updateHeights();
|
|
785
|
+
});
|
|
782
786
|
};
|
|
783
|
-
const
|
|
787
|
+
const hasFieldValue = (val) => val !== null && val !== void 0 && val !== "" && !(Array.isArray(val) && val.length === 0) && !(typeof val === "object" && Object.keys(val).length === 0);
|
|
784
788
|
const setInitExpandStatus = () => {
|
|
789
|
+
var _a;
|
|
785
790
|
expandStatus.value = false;
|
|
786
791
|
if (formRef.value && __props.expand) {
|
|
787
792
|
const formEl = formRef.value.$el;
|
|
788
|
-
const formItemsEl = formEl.querySelectorAll(
|
|
793
|
+
const formItemsEl = (_a = formEl == null ? void 0 : formEl.querySelectorAll) == null ? void 0 : _a.call(
|
|
794
|
+
formEl,
|
|
789
795
|
"[class*='-form-item'] > [path]"
|
|
790
796
|
);
|
|
791
|
-
|
|
797
|
+
if (!formItemsEl || formItemsEl.length === 0) return;
|
|
798
|
+
if (intersectionObserver) {
|
|
799
|
+
intersectionObserver.disconnect();
|
|
800
|
+
}
|
|
801
|
+
intersectionObserver = new IntersectionObserver(
|
|
792
802
|
(entries) => {
|
|
793
803
|
expandStatus.value = entries.some((e) => {
|
|
794
804
|
if (e.intersectionRatio === 0) {
|
|
795
805
|
const path = e.target.getAttribute("path");
|
|
796
806
|
const searchFieldValue = path ? getFormData == null ? void 0 : getFormData(path) : void 0;
|
|
797
|
-
return
|
|
807
|
+
return hasFieldValue(searchFieldValue);
|
|
798
808
|
}
|
|
799
809
|
return __props.expand.expandStatus;
|
|
800
810
|
});
|
|
801
|
-
|
|
811
|
+
intersectionObserver == null ? void 0 : intersectionObserver.disconnect();
|
|
802
812
|
},
|
|
803
813
|
{ root: formEl }
|
|
804
814
|
);
|
|
805
815
|
formItemsEl.forEach((element) => {
|
|
806
|
-
|
|
816
|
+
intersectionObserver == null ? void 0 : intersectionObserver.observe(element);
|
|
807
817
|
});
|
|
808
818
|
}
|
|
809
819
|
};
|
|
@@ -817,22 +827,34 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
817
827
|
() => __props.expand
|
|
818
828
|
],
|
|
819
829
|
() => {
|
|
820
|
-
|
|
821
|
-
if (!__props.expand || !expandStatus.value || !formRef.value) return;
|
|
822
|
-
const proFormEl = (_a = formRef.value) == null ? void 0 : _a.$el;
|
|
823
|
-
const { height = 0 } = ((_b = proFormEl == null ? void 0 : proFormEl.getBoundingClientRect) == null ? void 0 : _b.call(proFormEl)) || {};
|
|
824
|
-
proFormHeight.value = height;
|
|
825
|
-
rowHeight = (_e = (_d = (_c = proFormEl == null ? void 0 : proFormEl.querySelector("[class*='-form-item']")) == null ? void 0 : _c.getBoundingClientRect) == null ? void 0 : _d.call(_c)) == null ? void 0 : _e.height;
|
|
830
|
+
updateHeights();
|
|
826
831
|
},
|
|
827
832
|
{ flush: "post", immediate: true }
|
|
828
833
|
);
|
|
834
|
+
watch(
|
|
835
|
+
() => formRef.value,
|
|
836
|
+
(val) => {
|
|
837
|
+
if (resizeObserver) {
|
|
838
|
+
resizeObserver.disconnect();
|
|
839
|
+
resizeObserver = null;
|
|
840
|
+
}
|
|
841
|
+
const formEl = val == null ? void 0 : val.$el;
|
|
842
|
+
if (formEl && typeof ResizeObserver !== "undefined") {
|
|
843
|
+
resizeObserver = new ResizeObserver(() => {
|
|
844
|
+
updateHeights();
|
|
845
|
+
});
|
|
846
|
+
resizeObserver.observe(formEl);
|
|
847
|
+
}
|
|
848
|
+
},
|
|
849
|
+
{ immediate: true }
|
|
850
|
+
);
|
|
829
851
|
watchEffect(
|
|
830
852
|
() => {
|
|
831
853
|
if (typeof proFormHeight.value !== "number") return;
|
|
832
854
|
if (__props.layout === "grid" && computedExpand.value) {
|
|
833
855
|
const { minExpandRows } = computedExpand.value;
|
|
834
856
|
collapseHeight.value = Math.min(
|
|
835
|
-
minExpandRows * rowHeight + (minExpandRows - 1) * __props.rowGap,
|
|
857
|
+
minExpandRows * rowHeight.value + (minExpandRows - 1) * __props.rowGap,
|
|
836
858
|
+proFormHeight.value
|
|
837
859
|
);
|
|
838
860
|
showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
|
|
@@ -953,7 +975,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
953
975
|
};
|
|
954
976
|
}
|
|
955
977
|
});
|
|
956
|
-
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-
|
|
978
|
+
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-20c91e48"]]);
|
|
957
979
|
const _sfc_main$8 = {};
|
|
958
980
|
const _hoisted_1$4 = { class: "pro-table_search-form-container" };
|
|
959
981
|
function _sfc_render$3(_ctx, _cache) {
|
|
@@ -1073,7 +1095,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1073
1095
|
const indeterminate = ref(false);
|
|
1074
1096
|
const getColumnKey = (column, index2) => {
|
|
1075
1097
|
const key = column.key ?? column.prop;
|
|
1076
|
-
if (key === void 0 || key === null) return `
|
|
1098
|
+
if (key === void 0 || key === null) return `__col_${index2}`;
|
|
1077
1099
|
return Array.isArray(key) ? key.join(".") : String(key);
|
|
1078
1100
|
};
|
|
1079
1101
|
const checkedColumnsOptions = computed(
|
|
@@ -1087,7 +1109,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1087
1109
|
(dk) => String(dk) === key
|
|
1088
1110
|
);
|
|
1089
1111
|
const label = String(
|
|
1090
|
-
item.label ?? item.prop ?? t("table.columnFallback", { index: index2 + 1 })
|
|
1112
|
+
item.label ?? item.title ?? item.prop ?? t("table.columnFallback", { index: index2 + 1 })
|
|
1091
1113
|
);
|
|
1092
1114
|
return {
|
|
1093
1115
|
label,
|
|
@@ -1238,7 +1260,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1238
1260
|
};
|
|
1239
1261
|
}
|
|
1240
1262
|
});
|
|
1241
|
-
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
1263
|
+
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-97c582f9"]]);
|
|
1242
1264
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
1243
1265
|
...{ name: "TableColumnRenderer" },
|
|
1244
1266
|
__name: "TableColumnRenderer",
|
|
@@ -1248,7 +1270,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1248
1270
|
setup(__props) {
|
|
1249
1271
|
const getColumnKey = (column, index2) => {
|
|
1250
1272
|
const key = column.key ?? column.prop;
|
|
1251
|
-
if (key === void 0 || key === null) return `
|
|
1273
|
+
if (key === void 0 || key === null) return `__col_${index2}`;
|
|
1252
1274
|
return Array.isArray(key) ? key.join(".") : String(key);
|
|
1253
1275
|
};
|
|
1254
1276
|
const getCellValue = (row, column) => {
|
|
@@ -1260,34 +1282,53 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1260
1282
|
return __props.columns.filter((column) => !column.hidden);
|
|
1261
1283
|
});
|
|
1262
1284
|
const getColumnProps = (column) => {
|
|
1263
|
-
const { hidden, render, key, ...rest } = column;
|
|
1285
|
+
const { hidden, render, key, children, ...rest } = column;
|
|
1264
1286
|
const prop = column.prop ? String(column.prop) : void 0;
|
|
1265
1287
|
return {
|
|
1266
1288
|
...rest,
|
|
1289
|
+
label: column.label ?? column.title,
|
|
1267
1290
|
prop,
|
|
1268
1291
|
columnKey: key ? String(key) : prop
|
|
1269
1292
|
};
|
|
1270
1293
|
};
|
|
1271
1294
|
return (_ctx, _cache) => {
|
|
1295
|
+
const _component_TableColumnRenderer = resolveComponent("TableColumnRenderer", true);
|
|
1272
1296
|
return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column, index2) => {
|
|
1273
|
-
return openBlock(),
|
|
1274
|
-
key: getColumnKey(column, index2)
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1297
|
+
return openBlock(), createElementBlock(Fragment, {
|
|
1298
|
+
key: getColumnKey(column, index2)
|
|
1299
|
+
}, [
|
|
1300
|
+
column.children && column.children.length > 0 ? (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1301
|
+
key: 0,
|
|
1302
|
+
ref_for: true
|
|
1303
|
+
}, getColumnProps(column)), {
|
|
1304
|
+
default: withCtx(() => [
|
|
1305
|
+
createVNode(_component_TableColumnRenderer, {
|
|
1306
|
+
columns: column.children
|
|
1307
|
+
}, null, 8, ["columns"])
|
|
1308
|
+
]),
|
|
1309
|
+
_: 2
|
|
1310
|
+
}, 1040)) : typeof column.render === "function" ? (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1311
|
+
key: 1,
|
|
1312
|
+
ref_for: true
|
|
1313
|
+
}, getColumnProps(column)), {
|
|
1314
|
+
default: withCtx((scope) => {
|
|
1315
|
+
var _a;
|
|
1316
|
+
return [
|
|
1317
|
+
(openBlock(), createBlock(resolveDynamicComponent(
|
|
1318
|
+
(_a = column.render) == null ? void 0 : _a.call(column, {
|
|
1319
|
+
...scope,
|
|
1320
|
+
column,
|
|
1321
|
+
cellValue: getCellValue(scope.row, column)
|
|
1322
|
+
})
|
|
1323
|
+
)))
|
|
1324
|
+
];
|
|
1325
|
+
}),
|
|
1326
|
+
_: 2
|
|
1327
|
+
}, 1040)) : (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1328
|
+
key: 2,
|
|
1329
|
+
ref_for: true
|
|
1330
|
+
}, getColumnProps(column)), null, 16))
|
|
1331
|
+
], 64);
|
|
1291
1332
|
}), 128);
|
|
1292
1333
|
};
|
|
1293
1334
|
}
|
|
@@ -1452,16 +1493,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1452
1493
|
});
|
|
1453
1494
|
const normalizedRawColumns = computed(() => {
|
|
1454
1495
|
const source = __props.columns ?? (tableColumns == null ? void 0 : tableColumns.value) ?? [];
|
|
1455
|
-
const normalized = source.map((item, index2) => {
|
|
1456
|
-
const current = { ...item };
|
|
1457
|
-
if (current.label === void 0 && current.title !== void 0) {
|
|
1458
|
-
current.label = current.title;
|
|
1459
|
-
}
|
|
1460
|
-
if (current.key === void 0) {
|
|
1461
|
-
current.key = current.prop ?? (typeof current.columnKey === "string" ? current.columnKey : void 0) ?? `col-${index2}`;
|
|
1462
|
-
}
|
|
1463
|
-
return current;
|
|
1464
|
-
});
|
|
1465
1496
|
if (__props.addIndexColumn ?? injectProps.addIndexColumn) {
|
|
1466
1497
|
return [
|
|
1467
1498
|
{
|
|
@@ -1470,10 +1501,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1470
1501
|
label: t("table.index"),
|
|
1471
1502
|
width: 80
|
|
1472
1503
|
},
|
|
1473
|
-
...
|
|
1504
|
+
...source
|
|
1474
1505
|
];
|
|
1475
1506
|
}
|
|
1476
|
-
return
|
|
1507
|
+
return source;
|
|
1477
1508
|
});
|
|
1478
1509
|
const computedDataSource = computed(() => {
|
|
1479
1510
|
const attrsData = attrsTableProps.value.data;
|
|
@@ -1540,8 +1571,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1540
1571
|
return (_ctx, _cache) => {
|
|
1541
1572
|
const _directive_loading = resolveDirective("loading");
|
|
1542
1573
|
return openBlock(), createElementBlock("div", {
|
|
1543
|
-
class: normalizeClass(["pro-table",
|
|
1544
|
-
style: normalizeStyle(
|
|
1574
|
+
class: normalizeClass(["pro-table", unref(attrs).class]),
|
|
1575
|
+
style: normalizeStyle(unref(attrs).style)
|
|
1545
1576
|
}, [
|
|
1546
1577
|
showSearch.value ? (openBlock(), createBlock(unref(_sfc_main$d), {
|
|
1547
1578
|
key: 0,
|
|
@@ -1620,20 +1651,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1620
1651
|
};
|
|
1621
1652
|
}
|
|
1622
1653
|
});
|
|
1623
|
-
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1654
|
+
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-127db81d"]]);
|
|
1624
1655
|
function useTable(params = {}) {
|
|
1625
1656
|
const { data, columns, ...rest } = params;
|
|
1626
1657
|
const coreTable = useTable$1({
|
|
1627
1658
|
...rest,
|
|
1628
1659
|
dataSource: data,
|
|
1629
|
-
|
|
1630
|
-
// 使 setColumn 等按 key 匹配的 API 对 Element Plus 的 prop 列生效
|
|
1631
|
-
columns: columns == null ? void 0 : columns.map((column) => {
|
|
1632
|
-
if (column.key !== void 0 && column.key !== null) return column;
|
|
1633
|
-
const prop = column.prop;
|
|
1634
|
-
const fallback = prop ?? (typeof column.columnKey === "string" ? column.columnKey : void 0);
|
|
1635
|
-
return { ...column, key: fallback };
|
|
1636
|
-
})
|
|
1660
|
+
columns
|
|
1637
1661
|
});
|
|
1638
1662
|
const { dataSource, ...tableWithoutDataSource } = coreTable;
|
|
1639
1663
|
const table = {
|