@flatbiz/antd
Version:
110 lines (104 loc) • 3.62 kB
JavaScript
/* eslint-disable */
import './../fba-hooks/index.css';
import './../flex-layout/index.css';
import './index.css';
/*! @flatjs/forge MIT @flatbiz/antd */
import { b as _objectSpread2, i as _defineProperty } from '../_rollupPluginBabelHelpers-BYm17lo8.js';
import { classNames } from '@dimjs/utils/class-names/class-names';
import { fbaHooks } from '../fba-hooks/index.js';
import { jsxs, jsx } from 'react/jsx-runtime';
import { useMemo, isValidElement, cloneElement } from 'react';
import { Form } from 'antd';
import { F as FlexLayout } from '../flex-layout-BaDncU_Z.js';
import '@wove/react/hooks';
import '@flatbiz/utils';
import '../use-responsive-point-Bp3D3lZT.js';
var FormItemCard = function FormItemCard(props) {
var classNamePrefix = 'form-item-group-card';
var theme = fbaHooks.useThemeToken();
var style = {
'--form-item-group-colorPrimary': theme.colorPrimary
};
return /*#__PURE__*/jsxs("div", {
className: classNames(classNamePrefix, props.className),
style: _objectSpread2(_objectSpread2({}, style), props.style),
children: [props.title ? /*#__PURE__*/jsx("div", {
className: classNames("".concat(classNamePrefix, "-title"), _defineProperty({}, "".concat(classNamePrefix, "-title-sign"), props.titleSign === true)),
children: props.title
}) : null, props.children]
});
};
FormItemCard.defaultProps = {
titleSign: true
};
/**
* FormItem 水平布局
* ```
* Demo: https://fex.qa.tcshuke.com/docs/admin/main/form/input
* ```
* @param props
* @returns
*/
var FormItemHorizontalUnion = function FormItemHorizontalUnion(props) {
var groupFlexElementData = useMemo(function () {
var fullIndex = [];
var flexElementList = [];
var groupConfigList = props.groupConfigList.filter(function (item) {
return !item.hidden;
});
groupConfigList.forEach(function (item) {
if (item.before) {
flexElementList.push(/*#__PURE__*/isValidElement(item.before) ? item.before : /*#__PURE__*/jsx("div", {
className: "union-before-text",
children: item.before
}));
}
if (item.width) {
flexElementList.push(/*#__PURE__*/cloneElement(item.mainItem, {
style: _objectSpread2({
width: item.width
}, item.mainItem.props.style)
}));
} else {
fullIndex.push(flexElementList.length);
flexElementList.push(item.mainItem);
}
if (item.after) {
flexElementList.push(/*#__PURE__*/isValidElement(item.after) ? item.after : /*#__PURE__*/jsx("div", {
className: "union-after-text",
children: item.after
}));
}
});
return {
flexElementList: flexElementList,
fullIndex: fullIndex
};
}, [props.groupConfigList]);
return /*#__PURE__*/jsx(Form.Item, {
label: props.label,
className: classNames('form-item-group-horizontal-union', props.className),
style: props.style,
hidden: props.hidden,
required: props.required,
colon: props.colon,
children: /*#__PURE__*/jsx(FlexLayout, {
direction: "horizontal",
gap: props.gap === undefined ? 15 : props.gap,
fullIndex: groupFlexElementData.fullIndex,
style: props.flexLayoutStyle,
className: props.flexLayoutClassName,
children: groupFlexElementData.flexElementList.map(function (item, index) {
return /*#__PURE__*/cloneElement(item, {
key: index
});
})
})
});
};
var FormItemGroup = {
HorizontalUnion: FormItemHorizontalUnion,
Card: FormItemCard
};
export { FormItemGroup };
//# sourceMappingURL=index.js.map