vben
2020-12-25 4ff1c408dc1acfc49e0adc61dc2e539c0c198158
src/components/Form/src/hooks/useLabelWidth.ts
@@ -4,23 +4,8 @@
import { computed, unref } from 'vue';
import { isNumber } from '/@/utils/is';
// export function useGlobalLabelWidth(propsRef: ComputedRef<FormProps>) {
//   return computed(() => {
//     const { labelWidth, labelCol, wrapperCol } = unref(propsRef);
//     if (!labelWidth) {
//       return { labelCol, wrapperCol };
//     }
//     const width = isNumber(labelWidth) ? `${labelWidth}px` : labelWidth;
//     return {
//       labelCol: { style: { width }, span: 1, ...labelCol },
//       wrapperCol: { style: { width: `calc(100% - ${width})` }, span: 23, ...wrapperCol },
//     };
//   });
// }
export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<FormProps>) {
  return computed((): any => {
  return computed(() => {
    const schemaItem = unref(schemaItemRef);
    const { labelCol = {}, wrapperCol = {} } = schemaItem.itemProps || {};
    const { labelWidth, disabledLabelWidth } = schemaItem;
@@ -29,7 +14,7 @@
      labelWidth: globalLabelWidth,
      labelCol: globalLabelCol,
      wrapperCol: globWrapperCol,
    } = unref(propsRef) as any;
    } = unref(propsRef);
    // If labelWidth is set globally, all items setting
    if ((!globalLabelWidth && !labelWidth && !globalLabelCol) || disabledLabelWidth) {