yanzhen-design-vue
Version:
90 lines (89 loc) • 2.84 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const lodashEs = require("lodash-es");
const handleTableProps = require("./utils/handleTableProps.cjs");
const useVxeTableConfig = require("./hooks/use-vxe-table-config.cjs");
function useVxeTableColumn(props, emit) {
const $slots = vue.useSlots();
const $table = useVxeTableConfig.useVxeTableConfig("table");
const config = useVxeTableConfig.useVxeTableConfig("config");
const { visible } = vue.toRefs(props);
const { isATableTag, isElTableTag } = useVxeTableConfig.useVxeTableTagConfig(props);
const className = vue.computed(() => {
return [`is-align-${props.align ?? "left"}`].join(" ");
});
const labelClassName = vue.computed(() => {
return [`is-align-${props.headerAlign ?? props.align ?? "left"}`, "table-cell-label"].join(" ");
});
function isEditByRow({ row }) {
var _a, _b;
const isEditByRow2 = (_b = (_a = vue.unref($table)) == null ? void 0 : _a.getTableRef()) == null ? void 0 : _b.isEditByRow;
if (lodashEs.isFunction(isEditByRow2)) {
return isEditByRow2(row);
}
return false;
}
const type = vue.computed(() => {
const type2 = props.type;
if (vue.unref(isElTableTag)) {
switch (type2) {
case "checkbox":
case "radio":
return "selection";
case "expand":
return type2;
case "seq":
return "index";
}
}
return type2;
});
const reserveSelection = vue.computed(() => {
var _a, _b, _c, _d;
switch (vue.unref(type)) {
case "checkbox":
return (_b = (_a = vue.unref(config)) == null ? void 0 : _a.checkboxConfig) == null ? void 0 : _b.reserve;
case "radio":
return (_d = (_c = vue.unref(config)) == null ? void 0 : _c.radioConfig) == null ? void 0 : _d.reserve;
}
return false;
});
const elColumnProps = vue.computed(() => {
return handleTableProps.handleElColumnProps(props);
});
const aColumnProps = vue.computed(() => {
return handleTableProps.handleAColumnProps(props);
});
const vxeColumnProps = vue.computed(() => {
return handleTableProps.handleVxeColumnProps(props, vue.unref($table));
});
function isHiddenByRow(record, name) {
var _a, _b;
return (_b = (_a = vue.unref($table)) == null ? void 0 : _a.isHiddenByRow) == null ? void 0 : _b.call(_a, record, name);
}
const columnSlotStubRef = vue.ref();
const ctx = {
columnSlotStubRef,
type,
$slots,
elColumnProps,
aColumnProps,
vxeColumnProps,
reserveSelection,
className,
labelClassName,
visible,
isElTableTag,
isATableTag
};
const methods = {
isEditByRow,
isHiddenByRow
};
return {
ctx,
methods
};
}
exports.useVxeTableColumn = useVxeTableColumn;