tav-ui
Version:
42 lines (37 loc) • 1.29 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var is = require('../../../../utils/is2.js');
function useItemLabelWidth(schemaItemRef, propsRef) {
return vue.computed(() => {
const schemaItem = vue.unref(schemaItemRef);
const { labelCol = {}, wrapperCol = {} } = schemaItem.itemProps || {};
const { labelWidth, disabledLabelWidth } = schemaItem;
const {
labelWidth: globalLabelWidth,
labelCol: globalLabelCol,
wrapperCol: globWrapperCol,
layout
} = vue.unref(propsRef);
if (!globalLabelWidth && !labelWidth && !globalLabelCol || disabledLabelWidth) {
labelCol.style = {
textAlign: "left"
};
return { labelCol, wrapperCol };
}
let width = labelWidth || globalLabelWidth;
const col = { ...globalLabelCol, ...labelCol };
const wrapCol = { ...globWrapperCol, ...wrapperCol };
if (width)
width = is.isNumber(width) ? `${width}px` : width;
return {
labelCol: { style: { width }, ...col },
wrapperCol: {
style: { width: layout === "vertical" ? "100%" : `calc(100% - ${width})` },
...wrapCol
}
};
});
}
exports.useItemLabelWidth = useItemLabelWidth;
//# sourceMappingURL=useLabelWidth2.js.map