UNPKG

tdesign-vue-next

Version:
69 lines (65 loc) 2.76 kB
/** * tdesign v1.11.5 * (c) 2025 tdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { toRefs, computed } from 'vue'; import useClassName from './useClassName.js'; import useCommonClassName from '../../hooks/useCommonClassName.js'; import { useConfig } from '../../config-provider/hooks/useConfig.js'; import '../../hooks/useConfig.js'; import 'lodash-es'; import '../../config-provider/utils/context.js'; import '../../_chunks/dep-c75b9b8e.js'; import '@babel/runtime/helpers/typeof'; import '../../_chunks/dep-caecb55d.js'; import 'dayjs'; 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 _useConfig = useConfig("table", props.locale), globalConfig = _useConfig.globalConfig; var tableSize = computed(function () { var _size$value; return (_size$value = size.value) !== null && _size$value !== void 0 ? _size$value : globalConfig.value.size; }); var tableClasses = computed(function () { return [tableBaseClass.table, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, sizeClassNames[tableSize.value], tableSize.value !== "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), tableAlignClasses[verticalAlign.value], verticalAlign.value !== "middle")]; }); 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