/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import { toRefs, computed } from '@vue/composition-api';
import useCommonClassName from '../../../hooks/use-common-classname.js';
import useClassName from './useClassName.js';
import '../../config-provider/useConfig.js';
import '../../config-provider/context.js';
import 'lodash';
import '../../../_chunks/dep-def4c2ce.js';

function formatCSSUnit(unit) {
  if (!unit) return unit;
  return isNaN(Number(unit)) ? unit : `${unit}px`;
}
function useStyle(props) {
  const {
    bordered,
    stripe,
    hover,
    verticalAlign,
    height,
    maxHeight,
    tableContentWidth
  } = toRefs(props);
  const {
    tableBaseClass,
    tableAlignClasses
  } = useClassName();
  const {
    sizeClassNames
  } = useCommonClassName();
  const tableClasses = computed(() => [tableBaseClass.table, {
    [sizeClassNames[props.size]]: props.size !== "medium",
    [tableBaseClass.bordered]: bordered.value,
    [tableBaseClass.striped]: stripe.value,
    [tableBaseClass.hover]: hover.value,
    [tableBaseClass.loading]: props.loading,
    [tableBaseClass.affixedHeader]: props.headerAffixedTop,
    [tableBaseClass.rowspanAndColspan]: props.rowspanAndColspan,
    [tableBaseClass.horizontalBarAffixed]: props.horizontalScrollAffixedBottom,
    [tableBaseClass.footerAffixed]: props.footerAffixedBottom,
    [tableAlignClasses[verticalAlign.value]]: verticalAlign.value !== "middle"
  }]);
  const tableContentStyles = computed(() => ({
    height: formatCSSUnit(height.value),
    maxHeight: formatCSSUnit(maxHeight.value)
  }));
  const tableElementStyles = computed(() => ({
    width: formatCSSUnit(tableContentWidth.value)
  }));
  return {
    sizeClassNames,
    tableClasses,
    tableElementStyles,
    tableContentStyles
  };
}

export { useStyle as default, formatCSSUnit };
//# sourceMappingURL=useStyle.js.map
