/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { toRefs, computed } from 'vue';
import useCommonClassName from '../../hooks/useCommonClassName.js';
import useClassName from './useClassName.js';
import '../../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import 'lodash/isString';
import '../../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../../_chunks/dep-c9c789a8.js';
import 'dayjs';
import '../../hooks/useConfig.js';

function formatCSSUnit(unit) {
  if (!unit) return unit;
  return isNaN(Number(unit)) ? unit : "".concat(unit, "px");
}
function useStyle(props) {
  var _toRefs = toRefs(props),
    size = _toRefs.size,
    bordered = _toRefs.bordered,
    stripe = _toRefs.stripe,
    hover = _toRefs.hover,
    verticalAlign = _toRefs.verticalAlign,
    height = _toRefs.height,
    maxHeight = _toRefs.maxHeight,
    tableContentWidth = _toRefs.tableContentWidth;
  var _useClassName = useClassName(),
    tableBaseClass = _useClassName.tableBaseClass,
    tableAlignClasses = _useClassName.tableAlignClasses;
  var _useCommonClassName = useCommonClassName(),
    sizeClassNames = _useCommonClassName.sizeClassNames;
  var tableClasses = computed(function () {
    var _ref;
    return [tableBaseClass.table, (_ref = {}, _defineProperty(_ref, sizeClassNames[size.value], size.value !== "medium"), _defineProperty(_ref, tableBaseClass.bordered, bordered.value), _defineProperty(_ref, tableBaseClass.striped, stripe.value), _defineProperty(_ref, tableBaseClass.hover, hover.value), _defineProperty(_ref, tableBaseClass.loading, props.loading), _defineProperty(_ref, tableBaseClass.affixedHeader, props.headerAffixedTop), _defineProperty(_ref, tableBaseClass.rowspanAndColspan, props.rowspanAndColspan), _defineProperty(_ref, tableAlignClasses[verticalAlign.value], verticalAlign.value !== "middle"), _ref)];
  });
  var tableContentStyles = computed(function () {
    return {
      height: formatCSSUnit(height.value),
      maxHeight: formatCSSUnit(maxHeight.value)
    };
  });
  var tableElementStyles = computed(function () {
    return {
      width: formatCSSUnit(tableContentWidth.value)
    };
  });
  return {
    tableClasses: tableClasses,
    sizeClassNames: sizeClassNames,
    tableElementStyles: tableElementStyles,
    tableContentStyles: tableContentStyles
  };
}

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