UNPKG

yanzhen-design-vue

Version:

42 lines (41 loc) 1.05 kB
import { ref, useSlots, useAttrs, computed, h, mergeProps, unref } from "vue"; import { isNumeral, getNumeric } from "@yanzhen-libs/utils"; import { useProxyProps } from "@yanzhen-libs/utils-vue"; import { Col } from "ant-design-vue"; import { pick } from "lodash-es"; import { AntCol, colEmits } from "./col.mjs"; function useCol(props, emit) { const _ref = ref(); const slots = useSlots(); const attrs = useAttrs(); const config = computed(() => { const _span = props.span; let span = isNumeral(_span) ? Number.parseInt(String(getNumeric(_span))) : 24; if (span <= 1) { span = 24 * span; } return { ...pick(props, ...Object.keys(AntCol.props)), span }; }); const proxyProps = useProxyProps(config, Object.keys(colEmits), { emit, exclude: [] }); return [ { _ref, proxyProps, config }, (props2) => { return h( Col, mergeProps(attrs, unref(proxyProps), props2, { ref: _ref }), unref(slots) ); } ]; } export { useCol };