{"version":3,"file":"useLabelWidth2.mjs","sources":["../../../../../../../../packages/components/form/src/hooks/useLabelWidth.ts"],"sourcesContent":["import { computed, unref } from 'vue'\nimport { isNumber } from '@tav-ui/utils/is'\nimport type { Ref } from 'vue'\n// import type { FormProps, FormSchema } from '../types/form'\n\nexport function useItemLabelWidth(schemaItemRef: Ref<any>, propsRef: Ref<any>) {\n  return computed(() => {\n    const schemaItem = unref(schemaItemRef)\n    const { labelCol = {}, wrapperCol = {} } = schemaItem.itemProps || {}\n    const { labelWidth, disabledLabelWidth } = schemaItem\n\n    const {\n      labelWidth: globalLabelWidth,\n      labelCol: globalLabelCol,\n      wrapperCol: globWrapperCol,\n      layout,\n    } = unref(propsRef)\n\n    // If labelWidth is set globally, all items setting\n    if ((!globalLabelWidth && !labelWidth && !globalLabelCol) || disabledLabelWidth) {\n      labelCol.style = {\n        textAlign: 'left',\n      }\n      return { labelCol, wrapperCol }\n    }\n    let width = labelWidth || globalLabelWidth\n    const col = { ...globalLabelCol, ...labelCol }\n    const wrapCol = { ...globWrapperCol, ...wrapperCol }\n\n    if (width) width = isNumber(width) ? `${width}px` : width\n\n    return {\n      labelCol: { style: { width }, ...col },\n      wrapperCol: {\n        style: { width: layout === 'vertical' ? '100%' : `calc(100% - ${width})` },\n        ...wrapCol,\n      },\n    }\n  })\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,iBAAiB,CAAC,aAAa,EAAE,QAAQ,EAAE;AAC3D,EAAE,OAAO,QAAQ,CAAC,MAAM;AACxB,IAAI,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;AAC5C,IAAI,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,UAAU,CAAC,SAAS,IAAI,EAAE,CAAC;AAC1E,IAAI,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAAG,UAAU,CAAC;AAC1D,IAAI,MAAM;AACV,MAAM,UAAU,EAAE,gBAAgB;AAClC,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