@hw-component/form 1.9.86 → 1.9.87
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/.eslintcache +1 -1
- package/es/Form/config.d.ts +2 -1
- package/es/Form/config.js +3 -1
- package/es/Select/TagSelect/Content.d.ts +7 -0
- package/es/Select/TagSelect/Content.js +90 -0
- package/es/Select/TagSelect/hooks.d.ts +10 -0
- package/es/Select/TagSelect/hooks.js +97 -0
- package/es/Select/TagSelect/index.d.ts +3 -0
- package/es/Select/TagSelect/index.js +100 -0
- package/es/Select/index.js +0 -1
- package/es/Select/modal.d.ts +7 -1
- package/es/index.css +15 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/lib/Form/config.d.ts +2 -1
- package/lib/Form/config.js +3 -1
- package/lib/Select/TagSelect/Content.d.ts +7 -0
- package/lib/Select/TagSelect/Content.js +93 -0
- package/lib/Select/TagSelect/hooks.d.ts +10 -0
- package/lib/Select/TagSelect/hooks.js +99 -0
- package/lib/Select/TagSelect/index.d.ts +3 -0
- package/lib/Select/TagSelect/index.js +103 -0
- package/lib/Select/index.js +0 -1
- package/lib/Select/modal.d.ts +7 -1
- package/lib/index.css +15 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -0
- package/package.json +1 -1
- package/src/components/Form/config.ts +2 -1
- package/src/components/Form/index.less +6 -0
- package/src/components/Select/TagSelect/Content.tsx +50 -0
- package/src/components/Select/TagSelect/hooks.ts +83 -0
- package/src/components/Select/TagSelect/index.tsx +63 -0
- package/src/components/Select/index.less +13 -0
- package/src/components/Select/index.tsx +0 -1
- package/src/components/Select/modal.ts +7 -1
- package/src/components/index.tsx +2 -0
- package/src/pages/Form/index.tsx +149 -132
- package/src/pages/Select/index.tsx +25 -4
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var antd = require('antd');
|
|
9
|
+
var index = require('../../hooks/index.js');
|
|
10
|
+
var norHooks = require('../hooks/norHooks.js');
|
|
11
|
+
var Content = require('./Content.js');
|
|
12
|
+
var hooks = require('./hooks.js');
|
|
13
|
+
var HFormConnect = require('../../Form/HFormConnect.js');
|
|
14
|
+
|
|
15
|
+
var _excluded = ["children"];
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
18
|
+
var Panel = antd.Collapse.Panel;
|
|
19
|
+
var ItemTitle = function ItemTitle(_ref) {
|
|
20
|
+
var children = _ref.children,
|
|
21
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
+
return jsxRuntime.jsx("div", {
|
|
23
|
+
onClick: function onClick(event) {
|
|
24
|
+
event.stopPropagation();
|
|
25
|
+
},
|
|
26
|
+
children: jsxRuntime.jsx(antd.Checkbox, _objectSpread(_objectSpread({}, props), {}, {
|
|
27
|
+
children: children
|
|
28
|
+
}))
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
var Index = function Index(_ref2) {
|
|
32
|
+
var options = _ref2.options,
|
|
33
|
+
_ref2$value = _ref2.value,
|
|
34
|
+
value = _ref2$value === void 0 ? [] : _ref2$value,
|
|
35
|
+
onChange = _ref2.onChange,
|
|
36
|
+
dispatch = _ref2.dispatch,
|
|
37
|
+
propsFieldNames = _ref2.fieldNames,
|
|
38
|
+
request = _ref2.request,
|
|
39
|
+
title = _ref2.title,
|
|
40
|
+
manual = _ref2.manual,
|
|
41
|
+
_ref2$className = _ref2.className,
|
|
42
|
+
className = _ref2$className === void 0 ? "" : _ref2$className,
|
|
43
|
+
collapseProps = _ref2.collapseProps,
|
|
44
|
+
addDispatchListener = _ref2.addDispatchListener;
|
|
45
|
+
var collapseClassName = index.useClassName("hw-tag-select");
|
|
46
|
+
var _useMatchConfigProps = index.useMatchConfigProps({
|
|
47
|
+
fieldNames: propsFieldNames
|
|
48
|
+
}),
|
|
49
|
+
fieldNames = _useMatchConfigProps.fieldNames;
|
|
50
|
+
var _useSelectReq = norHooks.useSelectReq({
|
|
51
|
+
options: options,
|
|
52
|
+
manual: manual,
|
|
53
|
+
request: request,
|
|
54
|
+
dispatch: dispatch
|
|
55
|
+
}),
|
|
56
|
+
loading = _useSelectReq.loading,
|
|
57
|
+
resultData = _useSelectReq.data,
|
|
58
|
+
error = _useSelectReq.error,
|
|
59
|
+
reload = _useSelectReq.reload;
|
|
60
|
+
var _useTagControl = hooks.useTagControl({
|
|
61
|
+
value: value,
|
|
62
|
+
options: resultData,
|
|
63
|
+
title: title
|
|
64
|
+
}),
|
|
65
|
+
labelNode = _useTagControl.labelNode,
|
|
66
|
+
checked = _useTagControl.checked,
|
|
67
|
+
indeterminate = _useTagControl.indeterminate;
|
|
68
|
+
var _useChangeControl = hooks.useChangeControl({
|
|
69
|
+
value: value,
|
|
70
|
+
options: resultData,
|
|
71
|
+
onChange: onChange,
|
|
72
|
+
fieldNames: fieldNames
|
|
73
|
+
}),
|
|
74
|
+
allCheck = _useChangeControl.allCheck;
|
|
75
|
+
addDispatchListener === null || addDispatchListener === void 0 || addDispatchListener("reload", reload);
|
|
76
|
+
return jsxRuntime.jsx(antd.Collapse, _objectSpread(_objectSpread({
|
|
77
|
+
bordered: false,
|
|
78
|
+
ghost: true
|
|
79
|
+
}, collapseProps), {}, {
|
|
80
|
+
className: "".concat(collapseClassName, " ").concat(className),
|
|
81
|
+
children: jsxRuntime.jsx(Panel, {
|
|
82
|
+
header: jsxRuntime.jsx(ItemTitle, {
|
|
83
|
+
indeterminate: indeterminate,
|
|
84
|
+
checked: checked,
|
|
85
|
+
onChange: allCheck,
|
|
86
|
+
children: labelNode
|
|
87
|
+
}),
|
|
88
|
+
children: jsxRuntime.jsx(Content.default, {
|
|
89
|
+
loading: loading,
|
|
90
|
+
options: resultData,
|
|
91
|
+
value: value,
|
|
92
|
+
error: error,
|
|
93
|
+
onChange: onChange,
|
|
94
|
+
reload: reload,
|
|
95
|
+
fieldNames: fieldNames
|
|
96
|
+
})
|
|
97
|
+
}, "1")
|
|
98
|
+
}));
|
|
99
|
+
};
|
|
100
|
+
var HTagSelect = HFormConnect.default(Index);
|
|
101
|
+
|
|
102
|
+
exports.default = HTagSelect;
|
|
103
|
+
// powered by h
|
package/lib/Select/index.js
CHANGED
package/lib/Select/modal.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { SelectProps } from "antd";
|
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
4
|
import type { addFormatItemModal, argsFn, DispatchModal } from "../Form/modal";
|
|
5
|
+
import { CollapseProps } from "antd/lib/collapse/Collapse";
|
|
5
6
|
export type OptionType = Record<string, any>;
|
|
6
7
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
7
8
|
interface ModeConfigItem {
|
|
@@ -21,7 +22,7 @@ export interface OptionsPageResultModal {
|
|
|
21
22
|
total: number;
|
|
22
23
|
}
|
|
23
24
|
export type OptionsDataType = OptionsListType | OptionsPageResultModal;
|
|
24
|
-
export interface HSelectProps extends Omit<SelectProps, "options" | "placeholder"> {
|
|
25
|
+
export interface HSelectProps extends Omit<SelectProps, "options" | "placeholder" | "onChange"> {
|
|
25
26
|
style?: React.CSSProperties;
|
|
26
27
|
request?: PromiseFnResult<any, OptionsDataType>;
|
|
27
28
|
manual?: boolean;
|
|
@@ -38,10 +39,15 @@ export interface HSelectProps extends Omit<SelectProps, "options" | "placeholder
|
|
|
38
39
|
isList?: boolean;
|
|
39
40
|
addonBefore?: React.ReactNode;
|
|
40
41
|
addonAfter?: React.ReactNode;
|
|
42
|
+
onChange?: (value: any, opts?: OptionType[] | OptionType) => void;
|
|
41
43
|
}
|
|
42
44
|
export interface FilterDataModal {
|
|
43
45
|
value: any;
|
|
44
46
|
index: number;
|
|
45
47
|
}
|
|
48
|
+
export interface HTagSelectProps extends HSelectProps {
|
|
49
|
+
title?: React.ReactNode;
|
|
50
|
+
collapseProps?: CollapseProps;
|
|
51
|
+
}
|
|
46
52
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
47
53
|
export {};
|
package/lib/index.css
CHANGED
|
@@ -42,6 +42,18 @@
|
|
|
42
42
|
border-top-right-radius: 0 !important;
|
|
43
43
|
border-bottom-right-radius: 0 !important;
|
|
44
44
|
}
|
|
45
|
+
.ant-hw-tag-select {
|
|
46
|
+
width: 100%;
|
|
47
|
+
}
|
|
48
|
+
.ant-hw-tag-select .ant-collapse-content-box {
|
|
49
|
+
padding: 0px 40px !important;
|
|
50
|
+
}
|
|
51
|
+
.ant-hw-tag-select .ant-hw-tag-select {
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
}
|
|
54
|
+
.ant-hw-tag-select .ant-collapse-header {
|
|
55
|
+
padding: 5px 16px !important;
|
|
56
|
+
}
|
|
45
57
|
.ant-hw-form-item-colon:after {
|
|
46
58
|
position: relative;
|
|
47
59
|
top: -0.5px;
|
|
@@ -167,6 +179,9 @@
|
|
|
167
179
|
display: -ms-flexbox;
|
|
168
180
|
display: flex;
|
|
169
181
|
}
|
|
182
|
+
.ant-hw-tag-select .ant-hw-tag-item {
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
}
|
|
170
185
|
.ant-hw-input-group .ant-hw-input-group-disabled {
|
|
171
186
|
background-color: #f5f5f5;
|
|
172
187
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare const HRadioGroup: ({ value, options, onChange, fieldNames: props
|
|
|
22
22
|
export declare const HTimePicker: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
23
23
|
export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps) => JSX.Element;
|
|
24
24
|
export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
|
|
25
|
-
export declare const HTextArea: ({ autoSize, bordered, className, ...props }: import("./TextArea").HTextAreaProps) => JSX.Element;
|
|
25
|
+
export declare const HTextArea: ({ autoSize, bordered, className, style, ...props }: import("./TextArea").HTextAreaProps) => JSX.Element;
|
|
26
26
|
export declare const HColorInput: ({ value, onChange, defaultColor, ...props }: import("./Input/modal").HInputProps) => JSX.Element;
|
|
27
27
|
export declare const HModalForm: import("react").FC<import("./DialogForm/modal").DialogFormProps<any, any>>;
|
|
28
28
|
export declare const HDrawerForm: import("react").FC<import("./DialogForm/modal").DialogFormProps<any, any>>;
|
|
@@ -31,3 +31,4 @@ export declare const HVerificationCodeInput: import("react").ForwardRefExoticCom
|
|
|
31
31
|
export declare const HTrimInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
32
32
|
export declare const HTrimTextArea: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
33
33
|
export declare const HInputNumberGroup: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
34
|
+
export declare const HTagSelect: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
package/lib/index.js
CHANGED
|
@@ -37,6 +37,7 @@ var HVerificationCodeInput = config.default.verificationCodeInput;
|
|
|
37
37
|
var HTrimInput = config.default.trimInput;
|
|
38
38
|
var HTrimTextArea = config.default.trimTextArea;
|
|
39
39
|
var HInputNumberGroup = config.default.inputNumberGroup.Component;
|
|
40
|
+
var HTagSelect = config.default.tagSelect;
|
|
40
41
|
|
|
41
42
|
exports.HForm = index.default;
|
|
42
43
|
exports.useHForm = useHForm.default;
|
|
@@ -63,6 +64,7 @@ exports.HRichEditor = HRichEditor;
|
|
|
63
64
|
exports.HSelect = HSelect;
|
|
64
65
|
exports.HSelectInput = HSelectInput;
|
|
65
66
|
exports.HSwitch = HSwitch;
|
|
67
|
+
exports.HTagSelect = HTagSelect;
|
|
66
68
|
exports.HTextArea = HTextArea;
|
|
67
69
|
exports.HTimePicker = HTimePicker;
|
|
68
70
|
exports.HTrimInput = HTrimInput;
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ import TrimTextArea from "../TextArea/TrimTextArea";
|
|
|
23
23
|
import HInputNumberGroup from "../Input/InputNumberGroup";
|
|
24
24
|
import HText from "../Text";
|
|
25
25
|
import HRichEditor from "../RichEditor";
|
|
26
|
-
|
|
26
|
+
import HTagSelect from '../Select/TagSelect';
|
|
27
27
|
export const placeholderConfig = {
|
|
28
28
|
inputType: [
|
|
29
29
|
"input",
|
|
@@ -70,6 +70,7 @@ const componentConfig = {
|
|
|
70
70
|
treeSelect: HTreeSelect,
|
|
71
71
|
text: HText,
|
|
72
72
|
richEditor: HRichEditor,
|
|
73
|
+
tagSelect:HTagSelect
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
export default componentConfig;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {HTagSelectProps} from "../modal";
|
|
2
|
+
import {useClassName} from "@/components/hooks";
|
|
3
|
+
import {Row, Skeleton, Space, Tag,Empty} from "antd";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import {useChangeControl} from "./hooks";
|
|
6
|
+
import NotFoundContent from "../components/NotFoundContent";
|
|
7
|
+
|
|
8
|
+
const ItemOption=({options,value,onChange,fieldNames}:HTagSelectProps)=>{
|
|
9
|
+
const tagClassName = useClassName("hw-tag-item");
|
|
10
|
+
const {label:labelKey="label",value:valueKey="value"}=fieldNames||{};
|
|
11
|
+
const {change}=useChangeControl({options,value,onChange,fieldNames});
|
|
12
|
+
return <Row gutter={[0,8]}>
|
|
13
|
+
{options?.map((item)=>{
|
|
14
|
+
const {[labelKey]:label,[valueKey]:itemVal}=item;
|
|
15
|
+
const index=value?.indexOf(itemVal);
|
|
16
|
+
const checkedTag=index!==-1;
|
|
17
|
+
return <Tag color={checkedTag?"processing":undefined}
|
|
18
|
+
className={tagClassName}
|
|
19
|
+
key={itemVal}
|
|
20
|
+
onClick={()=>{
|
|
21
|
+
change(itemVal);
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
{label}
|
|
25
|
+
</Tag>
|
|
26
|
+
})}
|
|
27
|
+
</Row>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface IContentProps extends HTagSelectProps{
|
|
31
|
+
error?:Error;
|
|
32
|
+
reload:VoidFunction;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default ({loading,value,options,onChange,fieldNames,error,reload}:IContentProps)=>{
|
|
36
|
+
const len=options?.length||0;
|
|
37
|
+
if (loading&&len===0){
|
|
38
|
+
return <Space direction={"vertical"} style={{width:"100%"}}>
|
|
39
|
+
<Skeleton.Button active size={"small"} block />
|
|
40
|
+
<Skeleton.Button active size={"small"} block />
|
|
41
|
+
</Space>
|
|
42
|
+
}
|
|
43
|
+
if (error && len === 0) {
|
|
44
|
+
return <NotFoundContent error={error} reload={reload}/>;
|
|
45
|
+
}
|
|
46
|
+
if (len===0){
|
|
47
|
+
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
|
48
|
+
}
|
|
49
|
+
return <ItemOption options={options} value={value} onChange={onChange} fieldNames={fieldNames}/>
|
|
50
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {useMemo} from "react";
|
|
2
|
+
import {HTagSelectProps, OptionType} from "@/components/Select/modal";
|
|
3
|
+
|
|
4
|
+
export const useTagControl=({value,options,title}:HTagSelectProps)=>{
|
|
5
|
+
const {checked,indeterminate}=useMemo(()=>{
|
|
6
|
+
const len=value?.length;
|
|
7
|
+
const opLen=options?.length;
|
|
8
|
+
if (!opLen){
|
|
9
|
+
return {
|
|
10
|
+
checked:false
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (len===opLen){
|
|
14
|
+
return {
|
|
15
|
+
checked:true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
indeterminate:!!len
|
|
20
|
+
}
|
|
21
|
+
},[value,options]);
|
|
22
|
+
const labelNode=useMemo(()=>{
|
|
23
|
+
if (title){
|
|
24
|
+
return title;
|
|
25
|
+
}
|
|
26
|
+
if (checked){
|
|
27
|
+
return "取消"
|
|
28
|
+
}
|
|
29
|
+
return "全选"
|
|
30
|
+
},[title,checked,indeterminate]);
|
|
31
|
+
return {
|
|
32
|
+
labelNode,
|
|
33
|
+
checked,
|
|
34
|
+
indeterminate
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const useChangeControl=({options,value,onChange,fieldNames}:HTagSelectProps)=>{
|
|
39
|
+
const {value:valueKey="value"}=fieldNames||{};
|
|
40
|
+
const optsNk=(newVal)=>{
|
|
41
|
+
const newOpts:OptionType[]=[];
|
|
42
|
+
newVal?.forEach((itemVal)=>{
|
|
43
|
+
const index=options?.findIndex((item)=>{
|
|
44
|
+
return itemVal===item[valueKey];
|
|
45
|
+
});
|
|
46
|
+
if (typeof index!=="undefined"){
|
|
47
|
+
newOpts.push((options?.[index] as OptionType));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return newOpts;
|
|
51
|
+
}
|
|
52
|
+
const checkedVal=(val)=>{
|
|
53
|
+
const newVal=[...value];
|
|
54
|
+
newVal.push(val);
|
|
55
|
+
onChange?.(newVal,optsNk(newVal));
|
|
56
|
+
}
|
|
57
|
+
const removeVal=(index)=>{
|
|
58
|
+
const newVal=[...value];
|
|
59
|
+
newVal.splice(index,1);
|
|
60
|
+
onChange?.(newVal,optsNk(newVal));
|
|
61
|
+
}
|
|
62
|
+
const change=(val)=>{
|
|
63
|
+
const index=value?.indexOf(val);
|
|
64
|
+
const checked=index===-1;
|
|
65
|
+
if (checked){
|
|
66
|
+
return checkedVal(val);
|
|
67
|
+
}
|
|
68
|
+
return removeVal(index);
|
|
69
|
+
}
|
|
70
|
+
const allCheck=(e)=>{
|
|
71
|
+
if (!e.target.checked){
|
|
72
|
+
return onChange?.([],[]);
|
|
73
|
+
}
|
|
74
|
+
const newVal=options?.map((item)=>{
|
|
75
|
+
return item[valueKey];
|
|
76
|
+
});
|
|
77
|
+
return onChange?.(newVal,options);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
change,
|
|
81
|
+
allCheck
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {Collapse, Checkbox} from 'antd';
|
|
2
|
+
import {useClassName, useMatchConfigProps} from "../../hooks";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {useSelectReq} from "../hooks/norHooks";
|
|
5
|
+
import {HTagSelectProps} from "../modal";
|
|
6
|
+
import {CheckboxProps} from "antd/lib/checkbox/Checkbox";
|
|
7
|
+
import Content from './Content';
|
|
8
|
+
import {useChangeControl, useTagControl} from "@/components/Select/TagSelect/hooks";
|
|
9
|
+
import HFormConnect from "@/components/Form/HFormConnect";
|
|
10
|
+
const { Panel } = Collapse;
|
|
11
|
+
|
|
12
|
+
const ItemTitle:React.FC<CheckboxProps>=({children,...props})=>{
|
|
13
|
+
return <div onClick={(event)=>{
|
|
14
|
+
event.stopPropagation();
|
|
15
|
+
}}>
|
|
16
|
+
<Checkbox {...props}>
|
|
17
|
+
{children}
|
|
18
|
+
</Checkbox>
|
|
19
|
+
</div>
|
|
20
|
+
}
|
|
21
|
+
const Index:React.FC<HTagSelectProps>=({options,value=[],onChange,dispatch,fieldNames:propsFieldNames,request,title,manual,className="",collapseProps,addDispatchListener})=>{
|
|
22
|
+
const collapseClassName = useClassName("hw-tag-select");
|
|
23
|
+
const { fieldNames } = useMatchConfigProps({ fieldNames: propsFieldNames });
|
|
24
|
+
const {
|
|
25
|
+
loading,
|
|
26
|
+
data: resultData,
|
|
27
|
+
error,
|
|
28
|
+
reload,
|
|
29
|
+
} = useSelectReq({
|
|
30
|
+
options,
|
|
31
|
+
manual,
|
|
32
|
+
request,
|
|
33
|
+
dispatch,
|
|
34
|
+
}); //options
|
|
35
|
+
const {labelNode,checked,indeterminate}=useTagControl({value,options:resultData,title});
|
|
36
|
+
const {allCheck}=useChangeControl({
|
|
37
|
+
value,
|
|
38
|
+
options:resultData,
|
|
39
|
+
onChange,
|
|
40
|
+
fieldNames
|
|
41
|
+
});
|
|
42
|
+
addDispatchListener?.("reload", reload);
|
|
43
|
+
return <Collapse bordered={false}
|
|
44
|
+
ghost
|
|
45
|
+
{...collapseProps}
|
|
46
|
+
className={`${collapseClassName} ${className}`}
|
|
47
|
+
>
|
|
48
|
+
<Panel key="1" header={<ItemTitle indeterminate={indeterminate}
|
|
49
|
+
checked={checked}
|
|
50
|
+
onChange={allCheck}
|
|
51
|
+
>{labelNode}</ItemTitle>}>
|
|
52
|
+
<Content loading={loading}
|
|
53
|
+
options={resultData}
|
|
54
|
+
value={value}
|
|
55
|
+
error={error}
|
|
56
|
+
onChange={onChange}
|
|
57
|
+
reload={reload}
|
|
58
|
+
fieldNames={fieldNames}
|
|
59
|
+
/>
|
|
60
|
+
</Panel>
|
|
61
|
+
</Collapse>
|
|
62
|
+
}
|
|
63
|
+
export default HFormConnect(Index);
|
|
@@ -55,3 +55,16 @@
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
.@{ant-prefix}-hw-tag-select {
|
|
59
|
+
width: 100%;
|
|
60
|
+
.@{ant-prefix}-collapse-content-box {
|
|
61
|
+
padding: 0px 40px !important;
|
|
62
|
+
}
|
|
63
|
+
.@{ant-prefix}-hw-tag-select{
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
}
|
|
66
|
+
.@{ant-prefix}-collapse-header{
|
|
67
|
+
padding: 5px 16px !important;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
@@ -2,6 +2,7 @@ import type { SelectProps } from "antd";
|
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
4
|
import type { addFormatItemModal, argsFn, DispatchModal } from "../Form/modal";
|
|
5
|
+
import {CollapseProps} from "antd/lib/collapse/Collapse";
|
|
5
6
|
|
|
6
7
|
export type OptionType = Record<string, any>;
|
|
7
8
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
@@ -24,7 +25,7 @@ export interface OptionsPageResultModal {
|
|
|
24
25
|
}
|
|
25
26
|
export type OptionsDataType = OptionsListType | OptionsPageResultModal;
|
|
26
27
|
export interface HSelectProps
|
|
27
|
-
extends Omit<SelectProps, "options" | "placeholder"> {
|
|
28
|
+
extends Omit<SelectProps, "options" | "placeholder"|"onChange"> {
|
|
28
29
|
style?: React.CSSProperties;
|
|
29
30
|
request?: PromiseFnResult<any, OptionsDataType>;
|
|
30
31
|
manual?: boolean;
|
|
@@ -41,9 +42,14 @@ export interface HSelectProps
|
|
|
41
42
|
isList?: boolean;
|
|
42
43
|
addonBefore?: React.ReactNode;
|
|
43
44
|
addonAfter?: React.ReactNode;
|
|
45
|
+
onChange?:(value:any,opts?:OptionType[]|OptionType)=>void;
|
|
44
46
|
}
|
|
45
47
|
export interface FilterDataModal {
|
|
46
48
|
value: any;
|
|
47
49
|
index: number;
|
|
48
50
|
}
|
|
51
|
+
export interface HTagSelectProps extends HSelectProps{
|
|
52
|
+
title?:React.ReactNode;
|
|
53
|
+
collapseProps?:CollapseProps
|
|
54
|
+
}
|
|
49
55
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
package/src/components/index.tsx
CHANGED