1 line
13 KiB
JSON
1 line
13 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { ConfigContext } from '../config-provider';\nimport RowContext from './RowContext';\nimport { useColStyle } from './style';\nfunction parseFlex(flex) {\n if (typeof flex === 'number') {\n return `${flex} ${flex} auto`;\n }\n if (/^\\d+(\\.\\d+)?(px|em|rem|%)$/.test(flex)) {\n return `0 0 ${flex}`;\n }\n return flex;\n}\nconst sizes = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];\nconst Col = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n getPrefixCls,\n direction\n } = React.useContext(ConfigContext);\n const {\n gutter,\n wrap\n } = React.useContext(RowContext);\n const {\n prefixCls: customizePrefixCls,\n span,\n order,\n offset,\n push,\n pull,\n className,\n children,\n flex,\n style\n } = props,\n others = __rest(props, [\"prefixCls\", \"span\", \"order\", \"offset\", \"push\", \"pull\", \"className\", \"children\", \"flex\", \"style\"]);\n const prefixCls = getPrefixCls('col', customizePrefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useColStyle(prefixCls);\n // ===================== Size ======================\n const sizeStyle = {};\n let sizeClassObj = {};\n sizes.forEach(size => {\n let sizeProps = {};\n const propSize = props[size];\n if (typeof propSize === 'number') {\n sizeProps.span = propSize;\n } else if (typeof propSize === 'object') {\n sizeProps = propSize || {};\n }\n delete others[size];\n sizeClassObj = Object.assign(Object.assign({}, sizeClassObj), {\n [`${prefixCls}-${size}-${sizeProps.span}`]: sizeProps.span !== undefined,\n [`${prefixCls}-${size}-order-${sizeProps.order}`]: sizeProps.order || sizeProps.order === 0,\n [`${prefixCls}-${size}-offset-${sizeProps.offset}`]: sizeProps.offset || sizeProps.offset === 0,\n [`${prefixCls}-${size}-push-${sizeProps.push}`]: sizeProps.push || sizeProps.push === 0,\n [`${prefixCls}-${size}-pull-${sizeProps.pull}`]: sizeProps.pull || sizeProps.pull === 0,\n [`${prefixCls}-rtl`]: direction === 'rtl'\n });\n // Responsive flex layout\n if (sizeProps.flex) {\n sizeClassObj[`${prefixCls}-${size}-flex`] = true;\n sizeStyle[`--${prefixCls}-${size}-flex`] = parseFlex(sizeProps.flex);\n }\n });\n // ==================== Normal =====================\n const classes = classNames(prefixCls, {\n [`${prefixCls}-${span}`]: span !== undefined,\n [`${prefixCls}-order-${order}`]: order,\n [`${prefixCls}-offset-${offset}`]: offset,\n [`${prefixCls}-push-${push}`]: push,\n [`${prefixCls}-pull-${pull}`]: pull\n }, className, sizeClassObj, hashId, cssVarCls);\n const mergedStyle = {};\n // Horizontal gutter use padding\n if (gutter && gutter[0] > 0) {\n const horizontalGutter = gutter[0] / 2;\n mergedStyle.paddingLeft = horizontalGutter;\n mergedStyle.paddingRight = horizontalGutter;\n }\n if (flex) {\n mergedStyle.flex = parseFlex(flex);\n // Hack for Firefox to avoid size issue\n // https://github.com/ant-design/ant-design/pull/20023#issuecomment-564389553\n if (wrap === false && !mergedStyle.minWidth) {\n mergedStyle.minWidth = 0;\n }\n }\n // ==================== Render =====================\n return wrapCSSVar( /*#__PURE__*/React.createElement(\"div\", Object.assign({}, others, {\n style: Object.assign(Object.assign(Object.assign({}, mergedStyle), style), sizeStyle),\n className: classes,\n ref: ref\n }), children));\n});\nif (process.env.NODE_ENV !== 'production') {\n Col.di
|