UNPKG

@alicloud/console-components

Version:

Alibaba Cloud React Components

32 lines (31 loc) 1.38 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import React, { forwardRef } from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; import { Form as FusionForm } from '@alifd/next'; import { ETheme } from '../../../enum'; import { useCssTheme } from '../../../hook'; import FormSubmit from './form-submit'; import FormReset from './form-reset'; // 之前很奇怪的杀了一个不存在的 prop labelWidth function Form(props, ref) { var theme = useCssTheme(); if (theme === ETheme.WIND || theme.startsWith(ETheme.XCONSOLE) || theme.startsWith(ETheme.HYBRID) || theme.startsWith(ETheme.YUNXIAO)) { return React.createElement(FusionForm, __assign({}, __assign(__assign({ labelTextAlign: 'left' }, props), { ref: ref }))); } return React.createElement(FusionForm, __assign({}, props, { ref: ref })); } var FormWithRef = forwardRef(Form); hoistNonReactStatics(FormWithRef, FusionForm); // 原有 FormWithRef.Submit = FormSubmit; // 覆盖 FormWithRef.Reset = FormReset; // 覆盖 export default FormWithRef;