@hw-component/form 0.0.8-beta-v8 → 0.0.8-beta-v9
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/CheckboxGroup/modal.d.ts +1 -0
- package/es/Form/config.d.ts +1 -1
- package/es/Input/modal.d.ts +1 -0
- package/es/Submit/components.d.ts +6 -0
- package/es/Submit/components.js +70 -0
- package/es/Submit/hooks.d.ts +5 -0
- package/es/Submit/hooks.js +28 -0
- package/es/Submit/index.d.ts +4 -1
- package/es/Submit/index.js +24 -28
- package/lib/CheckboxGroup/modal.d.ts +1 -0
- package/lib/Form/config.d.ts +1 -1
- package/lib/Input/modal.d.ts +1 -0
- package/lib/Submit/components.d.ts +6 -0
- package/lib/Submit/components.js +71 -0
- package/lib/Submit/hooks.d.ts +5 -0
- package/lib/Submit/hooks.js +29 -0
- package/lib/Submit/index.d.ts +4 -1
- package/lib/Submit/index.js +22 -26
- package/package.json +1 -1
- package/src/components/CheckboxGroup/modal.ts +1 -0
- package/src/components/Input/modal.ts +1 -0
- package/src/components/Submit/components.tsx +57 -0
- package/src/components/Submit/hooks.ts +31 -0
- package/src/components/Submit/index.tsx +12 -25
- package/src/pages/Form/index.tsx +50 -0
|
@@ -10,4 +10,5 @@ export interface HCheckboxProps extends Omit<CheckboxProps, "value" | "onChange"
|
|
|
10
10
|
value?: Record<string, any> | any[];
|
|
11
11
|
onChange?: (value: Record<string, any> | any[]) => void;
|
|
12
12
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
13
|
+
subParams?: (formatValue: Record<string, any>, sourceValue: any[]) => any;
|
|
13
14
|
}
|
package/es/Form/config.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare const componentConfig: {
|
|
|
22
22
|
input: ({ copy, value, addonAfter, ...props }: import("../Input/modal").HInputProps<any>) => JSX.Element;
|
|
23
23
|
upload: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
24
24
|
urlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("../Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
25
|
-
submit: ({
|
|
25
|
+
submit: ({ position, reset, extraList, ...props }: import("../Submit").ISubmitProps) => JSX.Element;
|
|
26
26
|
textArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
27
27
|
colorInput: ({ value, onChange, defaultColor, ...props }: import("../Input/modal").HInputProps<any>) => JSX.Element;
|
|
28
28
|
cascader: ({ request, options, fieldNames: propsFieldNames, ...props }: import("../Cascader").HCascaderProps) => JSX.Element;
|
package/es/Input/modal.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface HSelectInputProps extends Omit<HInputProps, "value" | "onChange
|
|
|
22
22
|
valueName?: ValueNameModal;
|
|
23
23
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
24
24
|
addDispatchListener?: AddDispatchListenerFn;
|
|
25
|
+
subParams?: (formatValue: Record<string, any>) => any;
|
|
25
26
|
}
|
|
26
27
|
export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
|
|
27
28
|
onClick: (value: string | readonly string[] | number | undefined, onChange?: (val: any) => void) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ISubmitProps, SubmitBarExtraType } from "@/components/Submit/index";
|
|
2
|
+
interface ControlFooterProps extends ISubmitProps {
|
|
3
|
+
action: SubmitBarExtraType;
|
|
4
|
+
}
|
|
5
|
+
export declare const ControlFooter: ({ action, ...props }: ControlFooterProps) => JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.object.keys.js';
|
|
3
|
+
import 'core-js/modules/es.symbol.js';
|
|
4
|
+
import 'core-js/modules/es.array.filter.js';
|
|
5
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
6
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
8
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
11
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
12
|
+
import { Button } from 'antd';
|
|
13
|
+
import { useFormContext } from '../Form/Context/index.js';
|
|
14
|
+
import React from 'react';
|
|
15
|
+
|
|
16
|
+
var _excluded = ["form"],
|
|
17
|
+
_excluded2 = ["type", "form", "text", "loading"],
|
|
18
|
+
_excluded3 = ["action"];
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
function ResetBtn(_ref) {
|
|
22
|
+
var form = _ref.form,
|
|
23
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
return jsx(Button, _objectSpread(_objectSpread({}, props), {}, {
|
|
25
|
+
onClick: function onClick() {
|
|
26
|
+
form.resetFields();
|
|
27
|
+
},
|
|
28
|
+
children: "\u91CD\u7F6E"
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
function SubBtn(_ref2) {
|
|
32
|
+
var _ref2$type = _ref2.type,
|
|
33
|
+
type = _ref2$type === void 0 ? "primary" : _ref2$type,
|
|
34
|
+
form = _ref2.form,
|
|
35
|
+
_ref2$text = _ref2.text,
|
|
36
|
+
text = _ref2$text === void 0 ? "提交" : _ref2$text,
|
|
37
|
+
loading = _ref2.loading,
|
|
38
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
39
|
+
var _useFormContext = useFormContext(),
|
|
40
|
+
_useFormContext$loadi = _useFormContext.loading,
|
|
41
|
+
formSubLoading = _useFormContext$loadi === void 0 ? loading : _useFormContext$loadi;
|
|
42
|
+
return jsx(Button, _objectSpread(_objectSpread({}, props), {}, {
|
|
43
|
+
type: type,
|
|
44
|
+
onClick: form.submit,
|
|
45
|
+
loading: formSubLoading,
|
|
46
|
+
children: text
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
var ControlFooter = function ControlFooter(_ref3) {
|
|
50
|
+
var action = _ref3.action,
|
|
51
|
+
props = _objectWithoutProperties(_ref3, _excluded3);
|
|
52
|
+
var form = props.form;
|
|
53
|
+
if (action === "reset") {
|
|
54
|
+
return jsx(ResetBtn, _objectSpread({}, props));
|
|
55
|
+
}
|
|
56
|
+
if (action === "submit") {
|
|
57
|
+
return jsx(SubBtn, _objectSpread({}, props));
|
|
58
|
+
}
|
|
59
|
+
if (typeof action === "string") {
|
|
60
|
+
return jsx(Fragment, {
|
|
61
|
+
children: action
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return /*#__PURE__*/React.cloneElement(action, {
|
|
65
|
+
form: form
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { ControlFooter };
|
|
70
|
+
// powered by hdj
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.array.map.js';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
|
|
5
|
+
var getBarComKeyList = function getBarComKeyList(extraList) {
|
|
6
|
+
return extraList.map(function (item, index) {
|
|
7
|
+
return {
|
|
8
|
+
action: item,
|
|
9
|
+
key: "".concat(index)
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var useBarSortList = function useBarSortList(props) {
|
|
14
|
+
var extraList = props.extraList,
|
|
15
|
+
_props$reset = props.reset,
|
|
16
|
+
reset = _props$reset === void 0 ? false : _props$reset;
|
|
17
|
+
var list = useMemo(function () {
|
|
18
|
+
if (!extraList) {
|
|
19
|
+
var defaultList = reset ? ["reset", "submit"] : ["submit"];
|
|
20
|
+
return getBarComKeyList(defaultList);
|
|
21
|
+
}
|
|
22
|
+
return getBarComKeyList(extraList);
|
|
23
|
+
}, [extraList, reset]);
|
|
24
|
+
return list;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { useBarSortList };
|
|
28
|
+
// powered by hdj
|
package/es/Submit/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { ButtonProps, FormInstance } from "antd/es";
|
|
3
|
+
export type SubmitBarExtraType = "submit" | "reset" | React.ReactDOM;
|
|
2
4
|
export interface ISubmitProps extends Omit<ButtonProps, "form"> {
|
|
3
5
|
text?: string;
|
|
4
6
|
form: FormInstance;
|
|
5
7
|
reset?: boolean;
|
|
6
8
|
position?: "start" | "end";
|
|
9
|
+
extraList?: SubmitBarExtraType[];
|
|
7
10
|
}
|
|
8
|
-
declare const _default: ({
|
|
11
|
+
declare const _default: ({ position, reset, extraList, ...props }: ISubmitProps) => JSX.Element;
|
|
9
12
|
export default _default;
|
package/es/Submit/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
4
|
+
import 'core-js/modules/es.array.map.js';
|
|
2
5
|
import 'core-js/modules/es.object.keys.js';
|
|
3
6
|
import 'core-js/modules/es.symbol.js';
|
|
4
7
|
import 'core-js/modules/es.array.filter.js';
|
|
@@ -6,46 +9,39 @@ import 'core-js/modules/es.object.to-string.js';
|
|
|
6
9
|
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
10
|
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
8
11
|
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
import { createElement } from 'react';
|
|
14
|
+
import { Row, Space } from 'antd';
|
|
15
|
+
import { useBarSortList } from './hooks.js';
|
|
16
|
+
import { ControlFooter } from './components.js';
|
|
14
17
|
|
|
15
|
-
var _excluded = ["
|
|
18
|
+
var _excluded = ["position", "reset", "extraList"];
|
|
16
19
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
20
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
21
|
var HSubmit = (function (_ref) {
|
|
19
|
-
var _ref$
|
|
20
|
-
text = _ref$text === void 0 ? "提交" : _ref$text,
|
|
21
|
-
_ref$type = _ref.type,
|
|
22
|
-
type = _ref$type === void 0 ? "primary" : _ref$type,
|
|
23
|
-
form = _ref.form,
|
|
24
|
-
loading = _ref.loading,
|
|
25
|
-
_ref$position = _ref.position,
|
|
22
|
+
var _ref$position = _ref.position,
|
|
26
23
|
position = _ref$position === void 0 ? "start" : _ref$position,
|
|
27
24
|
reset = _ref.reset,
|
|
25
|
+
extraList = _ref.extraList,
|
|
28
26
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
var barList = useBarSortList({
|
|
28
|
+
reset: reset,
|
|
29
|
+
extraList: extraList
|
|
30
|
+
});
|
|
32
31
|
return jsx(Row, {
|
|
33
32
|
justify: position,
|
|
34
33
|
style: {
|
|
35
34
|
width: "100%"
|
|
36
35
|
},
|
|
37
|
-
children:
|
|
38
|
-
children:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
loading: formSubLoading,
|
|
47
|
-
children: text
|
|
48
|
-
}))]
|
|
36
|
+
children: jsx(Space, {
|
|
37
|
+
children: barList === null || barList === void 0 ? void 0 : barList.map(function (_ref2) {
|
|
38
|
+
var action = _ref2.action,
|
|
39
|
+
key = _ref2.key;
|
|
40
|
+
return /*#__PURE__*/createElement(ControlFooter, _objectSpread(_objectSpread({}, props), {}, {
|
|
41
|
+
key: key,
|
|
42
|
+
action: action
|
|
43
|
+
}));
|
|
44
|
+
})
|
|
49
45
|
})
|
|
50
46
|
});
|
|
51
47
|
});
|
|
@@ -10,4 +10,5 @@ export interface HCheckboxProps extends Omit<CheckboxProps, "value" | "onChange"
|
|
|
10
10
|
value?: Record<string, any> | any[];
|
|
11
11
|
onChange?: (value: Record<string, any> | any[]) => void;
|
|
12
12
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
13
|
+
subParams?: (formatValue: Record<string, any>, sourceValue: any[]) => any;
|
|
13
14
|
}
|
package/lib/Form/config.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare const componentConfig: {
|
|
|
22
22
|
input: ({ copy, value, addonAfter, ...props }: import("../Input/modal").HInputProps<any>) => JSX.Element;
|
|
23
23
|
upload: import("react").ForwardRefExoticComponent<import("./modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
24
24
|
urlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("../Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
25
|
-
submit: ({
|
|
25
|
+
submit: ({ position, reset, extraList, ...props }: import("../Submit").ISubmitProps) => JSX.Element;
|
|
26
26
|
textArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
27
27
|
colorInput: ({ value, onChange, defaultColor, ...props }: import("../Input/modal").HInputProps<any>) => JSX.Element;
|
|
28
28
|
cascader: ({ request, options, fieldNames: propsFieldNames, ...props }: import("../Cascader").HCascaderProps) => JSX.Element;
|
package/lib/Input/modal.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface HSelectInputProps extends Omit<HInputProps, "value" | "onChange
|
|
|
22
22
|
valueName?: ValueNameModal;
|
|
23
23
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
24
24
|
addDispatchListener?: AddDispatchListenerFn;
|
|
25
|
+
subParams?: (formatValue: Record<string, any>) => any;
|
|
25
26
|
}
|
|
26
27
|
export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
|
|
27
28
|
onClick: (value: string | readonly string[] | number | undefined, onChange?: (val: any) => void) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ISubmitProps, SubmitBarExtraType } from "@/components/Submit/index";
|
|
2
|
+
interface ControlFooterProps extends ISubmitProps {
|
|
3
|
+
action: SubmitBarExtraType;
|
|
4
|
+
}
|
|
5
|
+
export declare const ControlFooter: ({ action, ...props }: ControlFooterProps) => JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/es.object.keys.js');
|
|
4
|
+
require('core-js/modules/es.symbol.js');
|
|
5
|
+
require('core-js/modules/es.array.filter.js');
|
|
6
|
+
require('core-js/modules/es.object.to-string.js');
|
|
7
|
+
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
8
|
+
require('core-js/modules/web.dom-collections.for-each.js');
|
|
9
|
+
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
11
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
12
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
+
var antd = require('antd');
|
|
14
|
+
var index = require('../Form/Context/index.js');
|
|
15
|
+
var React = require('react');
|
|
16
|
+
|
|
17
|
+
var _excluded = ["form"],
|
|
18
|
+
_excluded2 = ["type", "form", "text", "loading"],
|
|
19
|
+
_excluded3 = ["action"];
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
function ResetBtn(_ref) {
|
|
23
|
+
var form = _ref.form,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
return jsxRuntime.jsx(antd.Button, _objectSpread(_objectSpread({}, props), {}, {
|
|
26
|
+
onClick: function onClick() {
|
|
27
|
+
form.resetFields();
|
|
28
|
+
},
|
|
29
|
+
children: "\u91CD\u7F6E"
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
function SubBtn(_ref2) {
|
|
33
|
+
var _ref2$type = _ref2.type,
|
|
34
|
+
type = _ref2$type === void 0 ? "primary" : _ref2$type,
|
|
35
|
+
form = _ref2.form,
|
|
36
|
+
_ref2$text = _ref2.text,
|
|
37
|
+
text = _ref2$text === void 0 ? "提交" : _ref2$text,
|
|
38
|
+
loading = _ref2.loading,
|
|
39
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
40
|
+
var _useFormContext = index.useFormContext(),
|
|
41
|
+
_useFormContext$loadi = _useFormContext.loading,
|
|
42
|
+
formSubLoading = _useFormContext$loadi === void 0 ? loading : _useFormContext$loadi;
|
|
43
|
+
return jsxRuntime.jsx(antd.Button, _objectSpread(_objectSpread({}, props), {}, {
|
|
44
|
+
type: type,
|
|
45
|
+
onClick: form.submit,
|
|
46
|
+
loading: formSubLoading,
|
|
47
|
+
children: text
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
var ControlFooter = function ControlFooter(_ref3) {
|
|
51
|
+
var action = _ref3.action,
|
|
52
|
+
props = _objectWithoutProperties(_ref3, _excluded3);
|
|
53
|
+
var form = props.form;
|
|
54
|
+
if (action === "reset") {
|
|
55
|
+
return jsxRuntime.jsx(ResetBtn, _objectSpread({}, props));
|
|
56
|
+
}
|
|
57
|
+
if (action === "submit") {
|
|
58
|
+
return jsxRuntime.jsx(SubBtn, _objectSpread({}, props));
|
|
59
|
+
}
|
|
60
|
+
if (typeof action === "string") {
|
|
61
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
62
|
+
children: action
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return /*#__PURE__*/React.cloneElement(action, {
|
|
66
|
+
form: form
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.ControlFooter = ControlFooter;
|
|
71
|
+
// powered by h
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/es.array.map.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
var getBarComKeyList = function getBarComKeyList(extraList) {
|
|
7
|
+
return extraList.map(function (item, index) {
|
|
8
|
+
return {
|
|
9
|
+
action: item,
|
|
10
|
+
key: "".concat(index)
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var useBarSortList = function useBarSortList(props) {
|
|
15
|
+
var extraList = props.extraList,
|
|
16
|
+
_props$reset = props.reset,
|
|
17
|
+
reset = _props$reset === void 0 ? false : _props$reset;
|
|
18
|
+
var list = React.useMemo(function () {
|
|
19
|
+
if (!extraList) {
|
|
20
|
+
var defaultList = reset ? ["reset", "submit"] : ["submit"];
|
|
21
|
+
return getBarComKeyList(defaultList);
|
|
22
|
+
}
|
|
23
|
+
return getBarComKeyList(extraList);
|
|
24
|
+
}, [extraList, reset]);
|
|
25
|
+
return list;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.useBarSortList = useBarSortList;
|
|
29
|
+
// powered by h
|
package/lib/Submit/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import type { ButtonProps, FormInstance } from "antd/es";
|
|
3
|
+
export type SubmitBarExtraType = "submit" | "reset" | React.ReactDOM;
|
|
2
4
|
export interface ISubmitProps extends Omit<ButtonProps, "form"> {
|
|
3
5
|
text?: string;
|
|
4
6
|
form: FormInstance;
|
|
5
7
|
reset?: boolean;
|
|
6
8
|
position?: "start" | "end";
|
|
9
|
+
extraList?: SubmitBarExtraType[];
|
|
7
10
|
}
|
|
8
|
-
declare const _default: ({
|
|
11
|
+
declare const _default: ({ position, reset, extraList, ...props }: ISubmitProps) => JSX.Element;
|
|
9
12
|
export default _default;
|
package/lib/Submit/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
7
|
+
require('core-js/modules/es.array.map.js');
|
|
5
8
|
require('core-js/modules/es.object.keys.js');
|
|
6
9
|
require('core-js/modules/es.symbol.js');
|
|
7
10
|
require('core-js/modules/es.array.filter.js');
|
|
@@ -9,46 +12,39 @@ require('core-js/modules/es.object.to-string.js');
|
|
|
9
12
|
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
10
13
|
require('core-js/modules/web.dom-collections.for-each.js');
|
|
11
14
|
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
12
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
13
|
-
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
14
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
var React = require('react');
|
|
15
17
|
var antd = require('antd');
|
|
16
|
-
var
|
|
18
|
+
var hooks = require('./hooks.js');
|
|
19
|
+
var components = require('./components.js');
|
|
17
20
|
|
|
18
|
-
var _excluded = ["
|
|
21
|
+
var _excluded = ["position", "reset", "extraList"];
|
|
19
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
24
|
var HSubmit = (function (_ref) {
|
|
22
|
-
var _ref$
|
|
23
|
-
text = _ref$text === void 0 ? "提交" : _ref$text,
|
|
24
|
-
_ref$type = _ref.type,
|
|
25
|
-
type = _ref$type === void 0 ? "primary" : _ref$type,
|
|
26
|
-
form = _ref.form,
|
|
27
|
-
loading = _ref.loading,
|
|
28
|
-
_ref$position = _ref.position,
|
|
25
|
+
var _ref$position = _ref.position,
|
|
29
26
|
position = _ref$position === void 0 ? "start" : _ref$position,
|
|
30
27
|
reset = _ref.reset,
|
|
28
|
+
extraList = _ref.extraList,
|
|
31
29
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
var barList = hooks.useBarSortList({
|
|
31
|
+
reset: reset,
|
|
32
|
+
extraList: extraList
|
|
33
|
+
});
|
|
35
34
|
return jsxRuntime.jsx(antd.Row, {
|
|
36
35
|
justify: position,
|
|
37
36
|
style: {
|
|
38
37
|
width: "100%"
|
|
39
38
|
},
|
|
40
|
-
children: jsxRuntime.
|
|
41
|
-
children:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
loading: formSubLoading,
|
|
50
|
-
children: text
|
|
51
|
-
}))]
|
|
39
|
+
children: jsxRuntime.jsx(antd.Space, {
|
|
40
|
+
children: barList === null || barList === void 0 ? void 0 : barList.map(function (_ref2) {
|
|
41
|
+
var action = _ref2.action,
|
|
42
|
+
key = _ref2.key;
|
|
43
|
+
return /*#__PURE__*/React.createElement(components.ControlFooter, _objectSpread(_objectSpread({}, props), {}, {
|
|
44
|
+
key: key,
|
|
45
|
+
action: action
|
|
46
|
+
}));
|
|
47
|
+
})
|
|
52
48
|
})
|
|
53
49
|
});
|
|
54
50
|
});
|
package/package.json
CHANGED
|
@@ -12,4 +12,5 @@ export interface HCheckboxProps
|
|
|
12
12
|
value?: Record<string, any> | any[];
|
|
13
13
|
onChange?: (value: Record<string, any> | any[]) => void;
|
|
14
14
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
15
|
+
subParams?: (formatValue: Record<string, any>, sourceValue: any[]) => any;
|
|
15
16
|
}
|
|
@@ -26,6 +26,7 @@ export interface HSelectInputProps
|
|
|
26
26
|
valueName?: ValueNameModal;
|
|
27
27
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
28
28
|
addDispatchListener?: AddDispatchListenerFn;
|
|
29
|
+
subParams?: (formatValue: Record<string, any>) => any;
|
|
29
30
|
}
|
|
30
31
|
export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
|
|
31
32
|
onClick: (
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Button } from "antd";
|
|
2
|
+
import { useFormContext } from "../Form/Context";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import type {
|
|
5
|
+
ISubmitProps,
|
|
6
|
+
SubmitBarExtraType,
|
|
7
|
+
} from "@/components/Submit/index";
|
|
8
|
+
interface ControlFooterProps extends ISubmitProps {
|
|
9
|
+
action: SubmitBarExtraType;
|
|
10
|
+
}
|
|
11
|
+
function ResetBtn({ form, ...props }) {
|
|
12
|
+
return (
|
|
13
|
+
<Button
|
|
14
|
+
{...props}
|
|
15
|
+
onClick={() => {
|
|
16
|
+
form.resetFields();
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
重置
|
|
20
|
+
</Button>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function SubBtn({
|
|
25
|
+
type = "primary",
|
|
26
|
+
form,
|
|
27
|
+
text = "提交",
|
|
28
|
+
loading,
|
|
29
|
+
...props
|
|
30
|
+
}: ISubmitProps) {
|
|
31
|
+
const { loading: formSubLoading = loading } = useFormContext();
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Button
|
|
35
|
+
{...props}
|
|
36
|
+
type={type as any}
|
|
37
|
+
onClick={form.submit}
|
|
38
|
+
loading={formSubLoading}
|
|
39
|
+
>
|
|
40
|
+
{text}
|
|
41
|
+
</Button>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const ControlFooter = ({ action, ...props }: ControlFooterProps) => {
|
|
46
|
+
const { form } = props;
|
|
47
|
+
if (action === "reset") {
|
|
48
|
+
return <ResetBtn {...props} />;
|
|
49
|
+
}
|
|
50
|
+
if (action === "submit") {
|
|
51
|
+
return <SubBtn {...props} />;
|
|
52
|
+
}
|
|
53
|
+
if (typeof action === "string") {
|
|
54
|
+
return <>{action}</>;
|
|
55
|
+
}
|
|
56
|
+
return React.cloneElement(action as any, { form });
|
|
57
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ISubmitProps,
|
|
3
|
+
SubmitBarExtraType,
|
|
4
|
+
} from "@/components/Submit/index";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
|
|
7
|
+
const getBarComKeyList = (extraList: SubmitBarExtraType[]) => {
|
|
8
|
+
return extraList.map((item, index) => {
|
|
9
|
+
return {
|
|
10
|
+
action: item,
|
|
11
|
+
key: `${index}`,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const useBarSortList = (
|
|
17
|
+
props: Pick<ISubmitProps, "reset" | "extraList">
|
|
18
|
+
) => {
|
|
19
|
+
const { extraList, reset = false } = props;
|
|
20
|
+
const list = useMemo(() => {
|
|
21
|
+
if (!extraList) {
|
|
22
|
+
const defaultList: SubmitBarExtraType[] = reset
|
|
23
|
+
? ["reset", "submit"]
|
|
24
|
+
: ["submit"];
|
|
25
|
+
return getBarComKeyList(defaultList);
|
|
26
|
+
}
|
|
27
|
+
return getBarComKeyList(extraList);
|
|
28
|
+
}, [extraList, reset]);
|
|
29
|
+
|
|
30
|
+
return list;
|
|
31
|
+
};
|
|
@@ -1,45 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Row, Space } from "antd";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { useFormContext } from "../Form/Context";
|
|
4
3
|
import type { ButtonProps, FormInstance } from "antd/es";
|
|
4
|
+
import { useBarSortList } from "./hooks";
|
|
5
|
+
import { ControlFooter } from "./components";
|
|
6
|
+
|
|
7
|
+
export type SubmitBarExtraType = "submit" | "reset" | React.ReactDOM;
|
|
5
8
|
|
|
6
9
|
export interface ISubmitProps extends Omit<ButtonProps, "form"> {
|
|
7
10
|
text?: string;
|
|
8
11
|
form: FormInstance;
|
|
9
12
|
reset?: boolean;
|
|
10
13
|
position?: "start" | "end";
|
|
14
|
+
extraList?: SubmitBarExtraType[];
|
|
11
15
|
}
|
|
12
16
|
export default ({
|
|
13
|
-
text = "提交",
|
|
14
|
-
type = "primary",
|
|
15
|
-
form,
|
|
16
|
-
loading,
|
|
17
17
|
position = "start",
|
|
18
18
|
reset,
|
|
19
|
+
extraList,
|
|
19
20
|
...props
|
|
20
21
|
}: ISubmitProps) => {
|
|
21
|
-
const
|
|
22
|
+
const barList = useBarSortList({ reset, extraList });
|
|
23
|
+
|
|
22
24
|
return (
|
|
23
25
|
<Row justify={position} style={{ width: "100%" }}>
|
|
24
26
|
<Space>
|
|
25
|
-
{
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
onClick={() => {
|
|
29
|
-
form.resetFields();
|
|
30
|
-
}}
|
|
31
|
-
>
|
|
32
|
-
重置
|
|
33
|
-
</Button>
|
|
34
|
-
)}
|
|
35
|
-
<Button
|
|
36
|
-
{...props}
|
|
37
|
-
type={type}
|
|
38
|
-
onClick={form.submit}
|
|
39
|
-
loading={formSubLoading}
|
|
40
|
-
>
|
|
41
|
-
{text}
|
|
42
|
-
</Button>
|
|
27
|
+
{barList?.map(({ action, key }) => {
|
|
28
|
+
return <ControlFooter {...props} key={key} action={action} />;
|
|
29
|
+
})}
|
|
43
30
|
</Space>
|
|
44
31
|
</Row>
|
|
45
32
|
);
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HForm, HFormConfigProvider, useHForm } from "../../components";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
+
import { Button } from "antd";
|
|
3
4
|
|
|
4
5
|
const formData = (options) => {
|
|
5
6
|
const op = [
|
|
@@ -189,8 +190,57 @@ const formData = (options) => {
|
|
|
189
190
|
{
|
|
190
191
|
type: "submit",
|
|
191
192
|
},
|
|
193
|
+
{
|
|
194
|
+
type: "submit",
|
|
195
|
+
itemProps: {
|
|
196
|
+
extraList: [
|
|
197
|
+
<Button
|
|
198
|
+
key="wh"
|
|
199
|
+
onClick={() => {
|
|
200
|
+
console.log("起飞");
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
203
|
+
芜湖
|
|
204
|
+
</Button>,
|
|
205
|
+
"666",
|
|
206
|
+
"reset",
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
type: "submit",
|
|
212
|
+
itemProps: {
|
|
213
|
+
extraList: [
|
|
214
|
+
<Button
|
|
215
|
+
key="wh"
|
|
216
|
+
onClick={() => {
|
|
217
|
+
console.log("起飞");
|
|
218
|
+
}}
|
|
219
|
+
>
|
|
220
|
+
芜湖
|
|
221
|
+
</Button>,
|
|
222
|
+
<Ttta key="aa" />,
|
|
223
|
+
"666",
|
|
224
|
+
"submit",
|
|
225
|
+
"reset",
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
},
|
|
192
229
|
];
|
|
193
230
|
};
|
|
231
|
+
function Ttta({ form }) {
|
|
232
|
+
return (
|
|
233
|
+
<div
|
|
234
|
+
onClick={() => {
|
|
235
|
+
console.log("form", form);
|
|
236
|
+
form.setFieldsValue({ switch: 1 });
|
|
237
|
+
}}
|
|
238
|
+
>
|
|
239
|
+
ttta
|
|
240
|
+
</div>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
194
244
|
const Test = (props) => {
|
|
195
245
|
return <div>ffff</div>;
|
|
196
246
|
};
|