UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

138 lines (137 loc) 7.23 kB
'use client'; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var _excluded = ["classNames", "className", "style", "closable", "styles", "allowFullscreen", "title", "wrapClassName", "afterOpenChange", "width", "onCancel", "centered", "open", "afterClose", "destroyOnClose", "closeIcon", "paddings", "maxHeight", "enableResponsive", "zIndex", "mask", "getContainer", "keyboard", "focusTriggerAfterClose", "forceRender", "loading", "footer", "submitButtonProps", "submitLoading", "onFinish", "submitText", "variant", "gap", "onSubmit", "children"], _excluded2 = ["form", "footer"], _excluded3 = ["form", "footer"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import { Button } from 'antd'; import { useResponsive } from 'antd-style'; import { forwardRef } from 'react'; import Form from "../Form"; import Modal from "../Modal"; import { useStyles } from "./style"; import { jsx as _jsx } from "react/jsx-runtime"; var FormModal = /*#__PURE__*/forwardRef(function (_ref, ref) { var _ref$classNames = _ref.classNames, classNames = _ref$classNames === void 0 ? {} : _ref$classNames, className = _ref.className, style = _ref.style, closable = _ref.closable, _ref$styles = _ref.styles, styles = _ref$styles === void 0 ? {} : _ref$styles, allowFullscreen = _ref.allowFullscreen, title = _ref.title, wrapClassName = _ref.wrapClassName, afterOpenChange = _ref.afterOpenChange, width = _ref.width, onCancel = _ref.onCancel, centered = _ref.centered, open = _ref.open, afterClose = _ref.afterClose, destroyOnClose = _ref.destroyOnClose, closeIcon = _ref.closeIcon, paddings = _ref.paddings, maxHeight = _ref.maxHeight, enableResponsive = _ref.enableResponsive, zIndex = _ref.zIndex, mask = _ref.mask, getContainer = _ref.getContainer, keyboard = _ref.keyboard, focusTriggerAfterClose = _ref.focusTriggerAfterClose, forceRender = _ref.forceRender, loading = _ref.loading, footer = _ref.footer, submitButtonProps = _ref.submitButtonProps, submitLoading = _ref.submitLoading, onFinish = _ref.onFinish, submitText = _ref.submitText, _ref$variant = _ref.variant, variant = _ref$variant === void 0 ? 'pure' : _ref$variant, gap = _ref.gap, onSubmit = _ref.onSubmit, children = _ref.children, rest = _objectWithoutProperties(_ref, _excluded); var _useResponsive = useResponsive(), mobile = _useResponsive.mobile; var _useStyles = useStyles(), cx = _useStyles.cx, s = _useStyles.styles; var formClassName = classNames.form, footerClassName = classNames.footer, modalClassNames = _objectWithoutProperties(classNames, _excluded2); var formStyle = styles.form, footerStyle = styles.footer, modalStyles = _objectWithoutProperties(styles, _excluded3); return /*#__PURE__*/_jsx(Modal, { afterClose: afterClose, afterOpenChange: afterOpenChange, allowFullscreen: allowFullscreen, centered: centered, className: className, classNames: modalClassNames, closable: closable, closeIcon: closeIcon, confirmLoading: submitLoading, destroyOnClose: destroyOnClose, enableResponsive: enableResponsive, focusTriggerAfterClose: focusTriggerAfterClose, footer: null, forceRender: forceRender, getContainer: getContainer, keyboard: keyboard, loading: loading, mask: mask, maxHeight: maxHeight, onCancel: onCancel, open: open, paddings: paddings, style: style, styles: _objectSpread(_objectSpread({}, modalStyles), {}, { body: _objectSpread({ paddingTop: mobile ? 0 : undefined }, modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.body) }), title: title, width: width, wrapClassName: wrapClassName, zIndex: zIndex, children: /*#__PURE__*/_jsx(Form, _objectSpread(_objectSpread({ className: cx(s.form, formClassName), classNames: { footer: cx(s.footer, footerClassName) }, clearOnDestroy: destroyOnClose, footer: footer || /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({ block: true, htmlType: "submit", loading: submitLoading, onClick: onSubmit, type: 'primary' }, submitButtonProps), {}, { style: _objectSpread({ flex: 1 }, submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.style), children: submitText || 'Submit' })), gap: gap || (variant === 'pure' ? 24 : gap), onFinish: onFinish, ref: ref, style: _objectSpread({ paddingBottom: 56 }, formStyle), styles: { footer: footerStyle }, variant: variant }, rest), {}, { children: children })) }); }); export default FormModal;