UNPKG

aling

Version:

奇怪的组件库

43 lines (42 loc) 2.87 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { Box, styled } from "@mui/system"; import { Form, Button } from "antd-mobile"; import React, { useImperativeHandle } from "react"; const StyledForm = styled(Form)(({ theme: any }) => ({})); import AFormItem from "./AFormItem"; export default React.forwardRef((_a, ref) => { var _b, _c, _d, _e; var { onSubmit, footer, children, footerOptions, onCancel } = _a, otr = __rest(_a, ["onSubmit", "footer", "children", "footerOptions", "onCancel"]); const onFinish = (values) => { }; const [form] = Form.useForm(); const _onSubmit = () => { form.validateFields().then((res) => { onSubmit && onSubmit(form.getFieldsValue(), form); }); }; const _onCancel = () => { form.validateFields().then((res) => { onCancel && onCancel(form.getFieldsValue(), form); }); }; useImperativeHandle(ref, () => ({ instance: form, }), [form]); return (React.createElement(Box, { ref: ref }, React.createElement(StyledForm, Object.assign({ form: form, layout: 'horizontal', onFinish: onFinish }, otr), children, footer === null ? ("") : (React.createElement(AFormItem, null, React.createElement(Box, { sx: { width: "100%", display: "flex", flexDirection: "column" } }, React.createElement(Button, Object.assign({ color: 'primary', style: { marginBottom: 16 } }, footerOptions === null || footerOptions === void 0 ? void 0 : footerOptions.okButton, { onClick: _onSubmit }), ((_b = footerOptions === null || footerOptions === void 0 ? void 0 : footerOptions.okButton) === null || _b === void 0 ? void 0 : _b.children) === null ? null : ((_c = footerOptions === null || footerOptions === void 0 ? void 0 : footerOptions.okButton) === null || _c === void 0 ? void 0 : _c.children) || "确认"), React.createElement(Button, Object.assign({ color: 'default' }, footerOptions === null || footerOptions === void 0 ? void 0 : footerOptions.cancelButton, { onClick: _onCancel }), ((_d = footerOptions === null || footerOptions === void 0 ? void 0 : footerOptions.cancelButton) === null || _d === void 0 ? void 0 : _d.children) === null ? null : ((_e = footerOptions === null || footerOptions === void 0 ? void 0 : footerOptions.cancelButton) === null || _e === void 0 ? void 0 : _e.children) || "取消"))))))); });