@lobehub/ui 1.169.1 → 1.169.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/{Draw → Drawer}/index.d.ts +3 -3
- package/es/{Draw → Drawer}/index.js +4 -4
- package/es/Form/components/FormFooter.js +3 -1
- package/es/Form/components/FormGroup.js +1 -1
- package/es/Form/components/FormProvider.d.ts +14 -0
- package/es/Form/components/FormProvider.js +14 -0
- package/es/Form/components/FormSubmitFooter.d.ts +21 -0
- package/es/Form/components/FormSubmitFooter.js +171 -0
- package/es/Form/index.d.ts +3 -7
- package/es/Form/index.js +71 -34
- package/es/FormModal/index.js +20 -20
- package/es/FormModal/style.js +2 -1
- package/es/Swatches/index.js +14 -4
- package/es/components.d.ts +2 -1
- package/es/components.js +1 -1
- package/package.json +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DrawerProps as AntdDrawerProps } from 'antd';
|
|
2
2
|
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
-
export interface
|
|
3
|
+
export interface DrawerProps extends Omit<AntdDrawerProps, 'styles' | 'classNames'> {
|
|
4
4
|
classNames?: AntdDrawerProps['classNames'] & {
|
|
5
5
|
bodyContent?: string;
|
|
6
6
|
extra?: string;
|
|
@@ -16,5 +16,5 @@ export interface DrawProps extends Omit<AntdDrawerProps, 'styles' | 'classNames'
|
|
|
16
16
|
title?: CSSProperties;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
declare const
|
|
20
|
-
export default
|
|
19
|
+
declare const Drawer: import("react").NamedExoticComponent<DrawerProps>;
|
|
20
|
+
export default Drawer;
|
|
@@ -9,7 +9,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
9
9
|
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); }
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
12
|
-
import { Drawer as
|
|
12
|
+
import { Drawer as AntdDrawer } from 'antd';
|
|
13
13
|
import { useTheme } from 'antd-style';
|
|
14
14
|
import { XIcon } from 'lucide-react';
|
|
15
15
|
import { memo, useMemo } from 'react';
|
|
@@ -18,7 +18,7 @@ import ActionIcon from "../ActionIcon";
|
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
20
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
-
var
|
|
21
|
+
var Drawer = /*#__PURE__*/memo(function (_ref) {
|
|
22
22
|
var onClose = _ref.onClose,
|
|
23
23
|
_ref$containerMaxWidt = _ref.containerMaxWidth,
|
|
24
24
|
containerMaxWidth = _ref$containerMaxWidt === void 0 ? 1024 : _ref$containerMaxWidt,
|
|
@@ -86,7 +86,7 @@ var Draw = /*#__PURE__*/memo(function (_ref) {
|
|
|
86
86
|
size: 'site'
|
|
87
87
|
})]
|
|
88
88
|
});
|
|
89
|
-
return /*#__PURE__*/_jsx(
|
|
89
|
+
return /*#__PURE__*/_jsx(AntdDrawer, _objectSpread(_objectSpread({
|
|
90
90
|
classNames: classNames,
|
|
91
91
|
closable: false,
|
|
92
92
|
extra: noHeader ? undefined : extraNode,
|
|
@@ -163,4 +163,4 @@ var Draw = /*#__PURE__*/memo(function (_ref) {
|
|
|
163
163
|
})
|
|
164
164
|
}));
|
|
165
165
|
});
|
|
166
|
-
export default
|
|
166
|
+
export default Drawer;
|
|
@@ -17,9 +17,10 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
var useStyles = createStyles(function (_ref) {
|
|
19
19
|
var css = _ref.css,
|
|
20
|
+
token = _ref.token,
|
|
20
21
|
responsive = _ref.responsive;
|
|
21
22
|
return {
|
|
22
|
-
container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", " {\n padding: 16px;\n }\n "])), responsive.mobile)
|
|
23
|
+
container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", " {\n padding: 16px;\n background: ", ";\n border-block-start: 1px solid ", ";\n }\n "])), responsive.mobile, token.colorBgContainer, token.colorBorderSecondary)
|
|
23
24
|
};
|
|
24
25
|
});
|
|
25
26
|
var FormFooter = /*#__PURE__*/memo(function (_ref2) {
|
|
@@ -30,6 +31,7 @@ var FormFooter = /*#__PURE__*/memo(function (_ref2) {
|
|
|
30
31
|
cx = _useStyles.cx,
|
|
31
32
|
styles = _useStyles.styles;
|
|
32
33
|
return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
34
|
+
align: 'center',
|
|
33
35
|
className: cx(styles.container, className),
|
|
34
36
|
gap: 8,
|
|
35
37
|
horizontal: true,
|
|
@@ -30,7 +30,7 @@ export var useStyles = createStyles(function (_ref) {
|
|
|
30
30
|
flatGroup: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow: hidden;\n padding-inline: 16px;\n "]))),
|
|
31
31
|
ghostStyle: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background: transparent;\n border: 1px solid ", ";\n "])), token.colorBorderSecondary),
|
|
32
32
|
icon: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n transition: all 100ms ", ";\n "])), token.motionEaseOut),
|
|
33
|
-
mobileFlatGroup: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n border-radius:
|
|
33
|
+
mobileFlatGroup: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n border-radius: 0;\n "]))),
|
|
34
34
|
mobileGroupBody: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding-block: 0;\n padding-inline: 16px;\n background: ", ";\n "])), token.colorBgContainer),
|
|
35
35
|
mobileGroupHeader: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n padding: 16px;\n background: ", ";\n "])), token.colorBgLayout),
|
|
36
36
|
pure: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n .", "-collapse-content-box {\n .", "-form-item:first-child {\n border-block-start: 1px solid ", ";\n }\n }\n "])), prefixCls, prefixCls, token.colorFillSecondary),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FormProps } from 'antd';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
interface FormContentConfig {
|
|
4
|
+
form?: FormProps['form'];
|
|
5
|
+
initialValues?: FormProps['initialValues'];
|
|
6
|
+
submitLoading?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const FormContext: import("react").Context<FormContentConfig>;
|
|
9
|
+
export declare const FormProvider: import("react").NamedExoticComponent<{
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
config: FormContentConfig;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const useFormContext: () => FormContentConfig;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext, memo, useContext } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export var FormContext = /*#__PURE__*/createContext({});
|
|
4
|
+
export var FormProvider = /*#__PURE__*/memo(function (_ref) {
|
|
5
|
+
var children = _ref.children,
|
|
6
|
+
config = _ref.config;
|
|
7
|
+
return /*#__PURE__*/_jsx(FormContext.Provider, {
|
|
8
|
+
value: config,
|
|
9
|
+
children: children
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
export var useFormContext = function useFormContext() {
|
|
13
|
+
return useContext(FormContext);
|
|
14
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ButtonProps } from 'antd';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { FlexboxProps } from 'react-layout-kit';
|
|
4
|
+
export interface FormSubmitFooterProps extends FlexboxProps {
|
|
5
|
+
buttonProps?: Omit<ButtonProps, 'children'>;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
enableReset?: boolean;
|
|
8
|
+
enableUnsavedWarning?: boolean;
|
|
9
|
+
float?: boolean;
|
|
10
|
+
onReset?: () => void;
|
|
11
|
+
resetButtonProps?: Omit<ButtonProps, 'children'>;
|
|
12
|
+
resetText?: ReactNode;
|
|
13
|
+
saveButtonProps?: Omit<ButtonProps, 'children'>;
|
|
14
|
+
saveText?: ReactNode;
|
|
15
|
+
texts?: {
|
|
16
|
+
unSaved?: string;
|
|
17
|
+
unSavedWarning?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
declare const FormSubmitFooter: import("react").NamedExoticComponent<FormSubmitFooterProps>;
|
|
21
|
+
export default FormSubmitFooter;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
var _excluded = ["enableReset", "buttonProps", "float", "saveText", "resetText", "onReset", "saveButtonProps", "resetButtonProps", "enableUnsavedWarning", "children", "texts", "className"];
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
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); }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
18
|
+
import { Button, Form } from 'antd';
|
|
19
|
+
import { createStyles } from 'antd-style';
|
|
20
|
+
import isEqual from 'fast-deep-equal';
|
|
21
|
+
import { motion } from 'framer-motion';
|
|
22
|
+
import { merge } from 'lodash-es';
|
|
23
|
+
import { InfoIcon } from 'lucide-react';
|
|
24
|
+
import { memo, useEffect, useState } from 'react';
|
|
25
|
+
import { Flexbox } from 'react-layout-kit';
|
|
26
|
+
import Icon from "../../Icon";
|
|
27
|
+
import { useFormContext } from "./FormProvider";
|
|
28
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
29
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
30
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
|
+
var useStyles = createStyles(function (_ref) {
|
|
32
|
+
var responsive = _ref.responsive,
|
|
33
|
+
css = _ref.css,
|
|
34
|
+
token = _ref.token;
|
|
35
|
+
return {
|
|
36
|
+
floatFooter: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: fixed;\n z-index: 1000;\n inset-block-end: 24px;\n inset-inline-start: 50%;\n transform: translateX(-50%);\n\n width: max-content;\n padding: 8px;\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: 48px;\n box-shadow: ", ";\n "])), token.colorBgContainer, token.colorBorderSecondary, token.boxShadowSecondary),
|
|
37
|
+
footer: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", " {\n margin-block-start: -", "px;\n padding: 16px;\n background: ", ";\n border-block-start: 1px solid ", ";\n }\n "])), responsive.mobile, token.borderRadius, token.colorBgContainer, token.colorBorderSecondary)
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
var FormSubmitFooter = /*#__PURE__*/memo(function (_ref2) {
|
|
41
|
+
var _ref2$enableReset = _ref2.enableReset,
|
|
42
|
+
enableReset = _ref2$enableReset === void 0 ? true : _ref2$enableReset,
|
|
43
|
+
buttonProps = _ref2.buttonProps,
|
|
44
|
+
float = _ref2.float,
|
|
45
|
+
_ref2$saveText = _ref2.saveText,
|
|
46
|
+
saveText = _ref2$saveText === void 0 ? 'Submit' : _ref2$saveText,
|
|
47
|
+
_ref2$resetText = _ref2.resetText,
|
|
48
|
+
resetText = _ref2$resetText === void 0 ? 'Reset' : _ref2$resetText,
|
|
49
|
+
onReset = _ref2.onReset,
|
|
50
|
+
saveButtonProps = _ref2.saveButtonProps,
|
|
51
|
+
resetButtonProps = _ref2.resetButtonProps,
|
|
52
|
+
_ref2$enableUnsavedWa = _ref2.enableUnsavedWarning,
|
|
53
|
+
enableUnsavedWarning = _ref2$enableUnsavedWa === void 0 ? true : _ref2$enableUnsavedWa,
|
|
54
|
+
children = _ref2.children,
|
|
55
|
+
texts = _ref2.texts,
|
|
56
|
+
className = _ref2.className,
|
|
57
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
58
|
+
var _useFormContext = useFormContext(),
|
|
59
|
+
form = _useFormContext.form,
|
|
60
|
+
initialValues = _useFormContext.initialValues,
|
|
61
|
+
submitLoading = _useFormContext.submitLoading;
|
|
62
|
+
var _useState = useState(false),
|
|
63
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
64
|
+
hasUnsavedChanges = _useState2[0],
|
|
65
|
+
setHasUnsavedChanges = _useState2[1];
|
|
66
|
+
var values = Form.useWatch([], form);
|
|
67
|
+
var _useStyles = useStyles(),
|
|
68
|
+
cx = _useStyles.cx,
|
|
69
|
+
styles = _useStyles.styles,
|
|
70
|
+
theme = _useStyles.theme;
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
if (!values) return;
|
|
73
|
+
var v = merge({}, initialValues, values);
|
|
74
|
+
setHasUnsavedChanges(!isEqual(v, initialValues));
|
|
75
|
+
}, [values, initialValues, submitLoading]);
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
if (!enableUnsavedWarning) return;
|
|
78
|
+
if (typeof window === 'undefined' || !hasUnsavedChanges) return;
|
|
79
|
+
// 添加离开页面的提示
|
|
80
|
+
window.addEventListener('beforeunload', function (e) {
|
|
81
|
+
if (hasUnsavedChanges) {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
e.returnValue = (texts === null || texts === void 0 ? void 0 : texts.unSavedWarning) || 'You have unsaved changes. Are you sure you want to leave?';
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return function () {
|
|
87
|
+
// eslint-disable-next-line unicorn/no-invalid-remove-event-listener
|
|
88
|
+
window.removeEventListener('beforeunload', function () {});
|
|
89
|
+
};
|
|
90
|
+
}, [enableUnsavedWarning, hasUnsavedChanges]);
|
|
91
|
+
var content = /*#__PURE__*/_jsxs(_Fragment, {
|
|
92
|
+
children: [(float || hasUnsavedChanges) && /*#__PURE__*/_jsxs(_Fragment, {
|
|
93
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
94
|
+
color: theme.colorTextDescription,
|
|
95
|
+
icon: InfoIcon,
|
|
96
|
+
size: {
|
|
97
|
+
fontSize: 12
|
|
98
|
+
},
|
|
99
|
+
style: {
|
|
100
|
+
marginLeft: 8
|
|
101
|
+
}
|
|
102
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
103
|
+
style: {
|
|
104
|
+
color: theme.colorTextDescription,
|
|
105
|
+
flex: 'none',
|
|
106
|
+
fontSize: 12,
|
|
107
|
+
marginRight: float ? 16 : 4
|
|
108
|
+
},
|
|
109
|
+
children: (texts === null || texts === void 0 ? void 0 : texts.unSaved) || 'Unsaved changes'
|
|
110
|
+
})]
|
|
111
|
+
}), children, enableReset && (float || hasUnsavedChanges) && /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread(_objectSpread({
|
|
112
|
+
color: "default",
|
|
113
|
+
htmlType: "button",
|
|
114
|
+
onClick: function onClick() {
|
|
115
|
+
form === null || form === void 0 || form.resetFields();
|
|
116
|
+
onReset === null || onReset === void 0 || onReset();
|
|
117
|
+
},
|
|
118
|
+
shape: float ? 'round' : undefined,
|
|
119
|
+
variant: 'filled'
|
|
120
|
+
}, buttonProps), resetButtonProps), {}, {
|
|
121
|
+
children: resetText
|
|
122
|
+
})), /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread(_objectSpread({
|
|
123
|
+
htmlType: "submit",
|
|
124
|
+
loading: submitLoading,
|
|
125
|
+
shape: float ? 'round' : undefined,
|
|
126
|
+
type: "primary"
|
|
127
|
+
}, buttonProps), saveButtonProps), {}, {
|
|
128
|
+
children: saveText
|
|
129
|
+
}))]
|
|
130
|
+
});
|
|
131
|
+
if (!float) return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
132
|
+
align: 'center',
|
|
133
|
+
className: cx(styles.footer, className),
|
|
134
|
+
gap: 8,
|
|
135
|
+
horizontal: true,
|
|
136
|
+
justify: 'flex-end'
|
|
137
|
+
}, rest), {}, {
|
|
138
|
+
children: content
|
|
139
|
+
}));
|
|
140
|
+
return /*#__PURE__*/_jsx(motion.div, {
|
|
141
|
+
animate: hasUnsavedChanges ? 'visible' : 'hidden',
|
|
142
|
+
className: styles.floatFooter,
|
|
143
|
+
initial: 'hidden',
|
|
144
|
+
transition: {
|
|
145
|
+
duration: 0.1,
|
|
146
|
+
ease: 'easeOut'
|
|
147
|
+
},
|
|
148
|
+
variants: {
|
|
149
|
+
hidden: {
|
|
150
|
+
opacity: 0,
|
|
151
|
+
x: '-50%',
|
|
152
|
+
y: 20
|
|
153
|
+
},
|
|
154
|
+
visible: {
|
|
155
|
+
opacity: 1,
|
|
156
|
+
x: '-50%',
|
|
157
|
+
y: 0
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
children: /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
161
|
+
align: 'center',
|
|
162
|
+
className: className,
|
|
163
|
+
gap: 8,
|
|
164
|
+
horizontal: true,
|
|
165
|
+
justify: 'center'
|
|
166
|
+
}, rest), {}, {
|
|
167
|
+
children: content
|
|
168
|
+
}))
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
export default FormSubmitFooter;
|
package/es/Form/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Form as AntForm, FormProps as AntFormProps, type FormInstance } from 'antd';
|
|
2
|
-
import {
|
|
2
|
+
import { type ReactNode, RefAttributes } from 'react';
|
|
3
3
|
import FormGroup, { type FormVariant, type ItemGroup, type ItemsType } from './components/FormGroup';
|
|
4
4
|
import FormItem, { type FormItemProps } from './components/FormItem';
|
|
5
|
+
import FormSubmitFooter from './components/FormSubmitFooter';
|
|
5
6
|
export interface FormProps extends Omit<AntFormProps, 'variant'> {
|
|
6
7
|
activeKey?: (string | number)[];
|
|
7
8
|
children?: ReactNode;
|
|
8
|
-
classNames?: {
|
|
9
|
-
footer?: string;
|
|
10
|
-
};
|
|
11
9
|
collapsible?: boolean;
|
|
12
10
|
defaultActiveKey?: (string | number)[];
|
|
13
11
|
footer?: ReactNode;
|
|
@@ -16,9 +14,6 @@ export interface FormProps extends Omit<AntFormProps, 'variant'> {
|
|
|
16
14
|
items?: ItemGroup[] | FormItemProps[];
|
|
17
15
|
itemsType?: ItemsType;
|
|
18
16
|
onCollapse?: (key: (string | number)[]) => void;
|
|
19
|
-
styles?: {
|
|
20
|
-
footer?: CSSProperties;
|
|
21
|
-
};
|
|
22
17
|
variant?: FormVariant;
|
|
23
18
|
}
|
|
24
19
|
export type { FormInstance } from 'antd';
|
|
@@ -27,6 +22,7 @@ export interface IForm {
|
|
|
27
22
|
Group: typeof FormGroup;
|
|
28
23
|
Item: typeof FormItem;
|
|
29
24
|
Provider: typeof AntForm.Provider;
|
|
25
|
+
SubmitFooter: typeof FormSubmitFooter;
|
|
30
26
|
useForm: typeof AntForm.useForm;
|
|
31
27
|
}
|
|
32
28
|
declare const Form: IForm;
|
package/es/Form/index.js
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
|
-
var _excluded = ["className", "itemMinWidth", "footer", "form", "items", "children", "itemsType", "variant", "gap", "style", "collapsible", "
|
|
4
|
+
var _excluded = ["className", "itemMinWidth", "footer", "form", "items", "children", "itemsType", "variant", "gap", "style", "collapsible", "defaultActiveKey", "initialValues", "activeKey", "onCollapse", "onFinish"];
|
|
5
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
6
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
7
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
8
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
9
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
10
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
11
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
12
|
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; }
|
|
12
13
|
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; }
|
|
13
14
|
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; }
|
|
14
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
16
|
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); }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
23
|
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; }
|
|
17
24
|
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; }
|
|
18
25
|
import { Form as AntForm } from 'antd';
|
|
19
26
|
import { isUndefined } from 'lodash-es';
|
|
20
|
-
import { forwardRef } from 'react';
|
|
27
|
+
import { forwardRef, useState } from 'react';
|
|
21
28
|
import FormFlatGroup from "./components/FormFlatGroup";
|
|
22
|
-
import FormFooter from "./components/FormFooter";
|
|
23
29
|
import FormGroup from "./components/FormGroup";
|
|
24
30
|
import FormItem from "./components/FormItem";
|
|
31
|
+
import { FormProvider } from "./components/FormProvider";
|
|
32
|
+
import FormSubmitFooter from "./components/FormSubmitFooter";
|
|
25
33
|
import { useStyles } from "./style";
|
|
26
34
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
35
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -40,17 +48,19 @@ var FormParent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
40
48
|
gap = _ref.gap,
|
|
41
49
|
style = _ref.style,
|
|
42
50
|
collapsible = _ref.collapsible,
|
|
43
|
-
_ref$classNames = _ref.classNames,
|
|
44
|
-
classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
|
|
45
|
-
_ref$styles = _ref.styles,
|
|
46
|
-
styles = _ref$styles === void 0 ? {} : _ref$styles,
|
|
47
51
|
defaultActiveKey = _ref.defaultActiveKey,
|
|
52
|
+
initialValues = _ref.initialValues,
|
|
48
53
|
activeKey = _ref.activeKey,
|
|
49
54
|
_onCollapse = _ref.onCollapse,
|
|
55
|
+
onFinish = _ref.onFinish,
|
|
50
56
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
51
57
|
var _useStyles = useStyles(),
|
|
52
58
|
cx = _useStyles.cx,
|
|
53
59
|
s = _useStyles.styles;
|
|
60
|
+
var _useState = useState(false),
|
|
61
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
+
submitLoading = _useState2[0],
|
|
63
|
+
setSubmitLoading = _useState2[1];
|
|
54
64
|
var mapFlat = function mapFlat(item, itemIndex) {
|
|
55
65
|
return /*#__PURE__*/_jsx(FormItem, _objectSpread({
|
|
56
66
|
divider: itemIndex !== 0,
|
|
@@ -82,35 +92,62 @@ var FormParent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
82
92
|
}) : group.children
|
|
83
93
|
}, key);
|
|
84
94
|
};
|
|
85
|
-
return /*#__PURE__*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
95
|
+
return /*#__PURE__*/_jsx(FormProvider, {
|
|
96
|
+
config: {
|
|
97
|
+
form: form,
|
|
98
|
+
initialValues: initialValues,
|
|
99
|
+
submitLoading: submitLoading
|
|
100
|
+
},
|
|
101
|
+
children: /*#__PURE__*/_jsxs(AntForm, _objectSpread(_objectSpread({
|
|
102
|
+
className: cx(s.form, variant === 'pure' && s.pure, s.mobile, className),
|
|
103
|
+
colon: false,
|
|
104
|
+
form: form,
|
|
105
|
+
initialValues: initialValues,
|
|
106
|
+
layout: 'horizontal',
|
|
107
|
+
onFinish: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
108
|
+
var _args = arguments;
|
|
109
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
110
|
+
while (1) switch (_context.prev = _context.next) {
|
|
111
|
+
case 0:
|
|
112
|
+
if (onFinish) {
|
|
113
|
+
_context.next = 2;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
return _context.abrupt("return");
|
|
117
|
+
case 2:
|
|
118
|
+
setSubmitLoading(true);
|
|
119
|
+
_context.next = 5;
|
|
120
|
+
return onFinish.apply(void 0, _args);
|
|
121
|
+
case 5:
|
|
122
|
+
setSubmitLoading(false);
|
|
123
|
+
case 6:
|
|
124
|
+
case "end":
|
|
125
|
+
return _context.stop();
|
|
126
|
+
}
|
|
127
|
+
}, _callee);
|
|
128
|
+
})),
|
|
129
|
+
ref: ref,
|
|
130
|
+
style: _objectSpread({
|
|
131
|
+
gap: gap
|
|
132
|
+
}, style)
|
|
133
|
+
}, rest), {}, {
|
|
134
|
+
children: [items && (items === null || items === void 0 ? void 0 : items.length) > 0 ? itemsType === 'group' ? items === null || items === void 0 ? void 0 : items.map(function (item, i) {
|
|
135
|
+
return mapTree(item, i);
|
|
136
|
+
}) : /*#__PURE__*/_jsx(FormFlatGroup, {
|
|
137
|
+
variant: variant,
|
|
138
|
+
children: items === null || items === void 0 ? void 0 : items.filter(function (item) {
|
|
139
|
+
return !item.hidden;
|
|
140
|
+
}).map(function (item, i) {
|
|
141
|
+
return mapFlat(item, i);
|
|
142
|
+
})
|
|
143
|
+
}) : undefined, children, footer]
|
|
144
|
+
}))
|
|
145
|
+
});
|
|
110
146
|
});
|
|
111
147
|
var Form = FormParent;
|
|
112
148
|
Form.Item = FormItem;
|
|
113
149
|
Form.Group = FormGroup;
|
|
114
150
|
Form.useForm = AntForm.useForm;
|
|
115
151
|
Form.Provider = AntForm.Provider;
|
|
152
|
+
Form.SubmitFooter = FormSubmitFooter;
|
|
116
153
|
export default Form;
|
package/es/FormModal/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
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); }
|
|
4
4
|
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"],
|
|
5
5
|
_excluded2 = ["form", "footer"],
|
|
6
|
-
_excluded3 = ["form"
|
|
6
|
+
_excluded3 = ["form"];
|
|
7
7
|
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; }
|
|
8
8
|
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; }
|
|
9
9
|
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; }
|
|
@@ -14,6 +14,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
14
14
|
import { Button } from 'antd';
|
|
15
15
|
import { useResponsive } from 'antd-style';
|
|
16
16
|
import { forwardRef } from 'react';
|
|
17
|
+
import { Flexbox } from 'react-layout-kit';
|
|
17
18
|
import Form from "../Form";
|
|
18
19
|
import Modal from "../Modal";
|
|
19
20
|
import { useStyles } from "./style";
|
|
@@ -67,7 +68,6 @@ var FormModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
67
68
|
footerClassName = classNames.footer,
|
|
68
69
|
modalClassNames = _objectWithoutProperties(classNames, _excluded2);
|
|
69
70
|
var formStyle = styles.form,
|
|
70
|
-
footerStyle = styles.footer,
|
|
71
71
|
modalStyles = _objectWithoutProperties(styles, _excluded3);
|
|
72
72
|
return /*#__PURE__*/_jsx(Modal, {
|
|
73
73
|
afterClose: afterClose,
|
|
@@ -104,31 +104,31 @@ var FormModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
104
104
|
zIndex: zIndex,
|
|
105
105
|
children: /*#__PURE__*/_jsx(Form, _objectSpread(_objectSpread({
|
|
106
106
|
className: cx(s.form, formClassName),
|
|
107
|
-
classNames: {
|
|
108
|
-
footer: cx(s.footer, footerClassName)
|
|
109
|
-
},
|
|
110
107
|
clearOnDestroy: destroyOnClose,
|
|
111
|
-
footer: footer || /*#__PURE__*/_jsx(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
footer: footer || /*#__PURE__*/_jsx(Flexbox, {
|
|
109
|
+
align: 'center',
|
|
110
|
+
className: cx(s.footer, footerClassName),
|
|
111
|
+
gap: 8,
|
|
112
|
+
horizontal: true,
|
|
113
|
+
children: /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
|
114
|
+
block: true,
|
|
115
|
+
htmlType: "submit",
|
|
116
|
+
loading: submitLoading,
|
|
117
|
+
onClick: onSubmit,
|
|
118
|
+
type: 'primary'
|
|
119
|
+
}, submitButtonProps), {}, {
|
|
120
|
+
style: _objectSpread({
|
|
121
|
+
flex: 1
|
|
122
|
+
}, submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.style),
|
|
123
|
+
children: submitText || 'Submit'
|
|
124
|
+
}))
|
|
125
|
+
}),
|
|
123
126
|
gap: gap || (variant === 'pure' ? 24 : gap),
|
|
124
127
|
onFinish: onFinish,
|
|
125
128
|
ref: ref,
|
|
126
129
|
style: _objectSpread({
|
|
127
130
|
paddingBottom: 56
|
|
128
131
|
}, formStyle),
|
|
129
|
-
styles: {
|
|
130
|
-
footer: footerStyle
|
|
131
|
-
},
|
|
132
132
|
variant: variant
|
|
133
133
|
}, rest), {}, {
|
|
134
134
|
children: children
|
package/es/FormModal/style.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
var _templateObject, _templateObject2;
|
|
2
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
|
+
import { rgba } from 'polished';
|
|
4
5
|
export var useStyles = createStyles(function (_ref) {
|
|
5
6
|
var css = _ref.css,
|
|
6
7
|
token = _ref.token,
|
|
7
8
|
prefixCls = _ref.prefixCls,
|
|
8
9
|
responsive = _ref.responsive;
|
|
9
10
|
return {
|
|
10
|
-
footer: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n inset-block-end: 0;\n inset-inline: 0;\n\n width: 100%;\n margin: 0;\n padding: 16px;\n\n background: ", ";\n "])), token.colorBgContainer),
|
|
11
|
+
footer: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 10;\n inset-block-end: 0;\n inset-inline: 0;\n\n width: 100%;\n margin: 0;\n padding: 16px;\n\n background: linear-gradient(\n to bottom,\n ", " 0%,\n ", " 10%\n );\n "])), rgba(token.colorBgContainer, 0), token.colorBgContainer),
|
|
11
12
|
form: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: static;\n .", "-form-group-title {\n font-size: 15px;\n font-weight: 500;\n }\n\n ", " {\n .", "-form-group-title {\n font-size: 14px;\n font-weight: normal;\n }\n\n .", "-form-group {\n width: calc(100% + 32px);\n margin-inline: -16px;\n background: transparent;\n }\n }\n "])), prefixCls, responsive.mobile, prefixCls, prefixCls)
|
|
12
13
|
};
|
|
13
14
|
});
|
package/es/Swatches/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { Center, Flexbox } from 'react-layout-kit';
|
|
|
16
16
|
import Icon from "../Icon";
|
|
17
17
|
import { useStyles } from "./style";
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
20
|
var Swatches = /*#__PURE__*/memo(function (_ref) {
|
|
20
21
|
var style = _ref.style,
|
|
21
22
|
colors = _ref.colors,
|
|
@@ -26,15 +27,24 @@ var Swatches = /*#__PURE__*/memo(function (_ref) {
|
|
|
26
27
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
27
28
|
var _useStyles = useStyles(size),
|
|
28
29
|
cx = _useStyles.cx,
|
|
29
|
-
styles = _useStyles.styles
|
|
30
|
-
|
|
30
|
+
styles = _useStyles.styles,
|
|
31
|
+
theme = _useStyles.theme;
|
|
32
|
+
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
31
33
|
gap: 8,
|
|
32
34
|
horizontal: true,
|
|
33
35
|
style: _objectSpread({
|
|
34
36
|
flexWrap: 'wrap'
|
|
35
37
|
}, style)
|
|
36
38
|
}, rest), {}, {
|
|
37
|
-
children:
|
|
39
|
+
children: [/*#__PURE__*/_jsx(Flexbox, {
|
|
40
|
+
className: cx(styles.container, !activeColor && styles.active),
|
|
41
|
+
onClick: function onClick() {
|
|
42
|
+
onSelect === null || onSelect === void 0 || onSelect();
|
|
43
|
+
},
|
|
44
|
+
style: {
|
|
45
|
+
background: theme.colorBgContainer
|
|
46
|
+
}
|
|
47
|
+
}), colors.map(function (c, index) {
|
|
38
48
|
var isActive = c === activeColor;
|
|
39
49
|
return /*#__PURE__*/_jsx(Center, {
|
|
40
50
|
className: cx(styles.container, isActive && styles.active),
|
|
@@ -53,7 +63,7 @@ var Swatches = /*#__PURE__*/memo(function (_ref) {
|
|
|
53
63
|
}
|
|
54
64
|
})
|
|
55
65
|
}, "".concat(c, "_").concat(index));
|
|
56
|
-
})
|
|
66
|
+
})]
|
|
57
67
|
}));
|
|
58
68
|
});
|
|
59
69
|
export default Swatches;
|
package/es/components.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { default as DraggablePanelBody, type DraggablePanelBodyProps, } from './
|
|
|
13
13
|
export { default as DraggablePanelContainer, type DraggablePanelContainerProps, } from './DraggablePanel/components/DraggablePanelContainer';
|
|
14
14
|
export { default as DraggablePanelFooter, type DraggablePanelFooterProps, } from './DraggablePanel/components/DraggablePanelFooter';
|
|
15
15
|
export { default as DraggablePanelHeader, type DraggablePanelHeaderProps, } from './DraggablePanel/components/DraggablePanelHeader';
|
|
16
|
-
export { default as
|
|
16
|
+
export { default as Drawer, type DrawerProps } from './Drawer';
|
|
17
17
|
export { default as EditableText, type EditableTextProps } from './EditableText';
|
|
18
18
|
export { default as EmojiPicker, type EmojiPickerProps } from './EmojiPicker';
|
|
19
19
|
export { default as EmptyCard, type EmptyCardProps } from './EmptyCard';
|
|
@@ -26,6 +26,7 @@ export { default as FormDivider, type FormDividerProps } from './Form/components
|
|
|
26
26
|
export { default as FormFooter, type FormFooterProps } from './Form/components/FormFooter';
|
|
27
27
|
export { default as FormGroup, type FormGroupProps, type ItemGroup, } from './Form/components/FormGroup';
|
|
28
28
|
export { default as FormItem, type FormItemProps } from './Form/components/FormItem';
|
|
29
|
+
export { type FormSubmitFooterProps } from './Form/components/FormSubmitFooter';
|
|
29
30
|
export { default as FormTitle, type FormTitleProps } from './Form/components/FormTitle';
|
|
30
31
|
export { default as FormModal, type FormModalProps } from './FormModal';
|
|
31
32
|
export { default as Grid, type GridProps } from './Grid';
|
package/es/components.js
CHANGED
|
@@ -13,7 +13,7 @@ export { default as DraggablePanelBody } from "./DraggablePanel/components/Dragg
|
|
|
13
13
|
export { default as DraggablePanelContainer } from "./DraggablePanel/components/DraggablePanelContainer";
|
|
14
14
|
export { default as DraggablePanelFooter } from "./DraggablePanel/components/DraggablePanelFooter";
|
|
15
15
|
export { default as DraggablePanelHeader } from "./DraggablePanel/components/DraggablePanelHeader";
|
|
16
|
-
export { default as
|
|
16
|
+
export { default as Drawer } from "./Drawer";
|
|
17
17
|
export { default as EditableText } from "./EditableText";
|
|
18
18
|
export { default as EmojiPicker } from "./EmojiPicker";
|
|
19
19
|
export { default as EmptyCard } from "./EmptyCard";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "1.169.
|
|
3
|
+
"version": "1.169.3",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building AIGC web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"dayjs": "^1.11.13",
|
|
69
69
|
"emoji-mart": "^5.6.0",
|
|
70
70
|
"fast-deep-equal": "^3.1.3",
|
|
71
|
+
"framer-motion": "^11.18.2",
|
|
71
72
|
"immer": "^10.1.1",
|
|
72
73
|
"leva": "^0.10.0",
|
|
73
74
|
"lodash-es": "^4.17.21",
|