@hw-component/form 1.9.87 → 1.9.88
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/Select/TagSelect/hooks.d.ts +4 -0
- package/es/Select/TagSelect/hooks.js +27 -2
- package/es/Select/TagSelect/index.js +16 -6
- package/es/Select/modal.d.ts +3 -2
- package/lib/Select/TagSelect/hooks.d.ts +4 -0
- package/lib/Select/TagSelect/hooks.js +26 -0
- package/lib/Select/TagSelect/index.js +15 -5
- package/lib/Select/modal.d.ts +3 -2
- package/package.json +1 -1
- package/src/components/Select/TagSelect/hooks.ts +20 -1
- package/src/components/Select/TagSelect/index.tsx +19 -3
- package/src/components/Select/modal.ts +3 -1
- package/src/pages/Select/index.tsx +9 -3
|
@@ -8,3 +8,7 @@ export declare const useChangeControl: ({ options, value, onChange, fieldNames }
|
|
|
8
8
|
change: (val: any) => void;
|
|
9
9
|
allCheck: (e: any) => void | undefined;
|
|
10
10
|
};
|
|
11
|
+
export declare const useCollapseControl: ({ visible, defaultVisible, onVisibleChange }: HTagSelectProps) => {
|
|
12
|
+
activeKey: string[];
|
|
13
|
+
onChange: (keys: any) => void;
|
|
14
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
2
3
|
import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
+
import { useMemo, useState, useEffect } from 'react';
|
|
4
5
|
|
|
5
6
|
var useTagControl = function useTagControl(_ref) {
|
|
6
7
|
var value = _ref.value,
|
|
@@ -92,6 +93,30 @@ var useChangeControl = function useChangeControl(_ref2) {
|
|
|
92
93
|
allCheck: allCheck
|
|
93
94
|
};
|
|
94
95
|
};
|
|
96
|
+
var useCollapseControl = function useCollapseControl(_ref4) {
|
|
97
|
+
var visible = _ref4.visible,
|
|
98
|
+
defaultVisible = _ref4.defaultVisible,
|
|
99
|
+
onVisibleChange = _ref4.onVisibleChange;
|
|
100
|
+
var _useState = useState(defaultVisible ? ["1"] : []),
|
|
101
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
102
|
+
activeKey = _useState2[0],
|
|
103
|
+
setActiveKey = _useState2[1];
|
|
104
|
+
useEffect(function () {
|
|
105
|
+
if (typeof visible === "undefined") {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
setActiveKey(visible ? ["1"] : []);
|
|
109
|
+
}, [visible]);
|
|
110
|
+
var onChange = function onChange(keys) {
|
|
111
|
+
var len = keys === null || keys === void 0 ? void 0 : keys.length;
|
|
112
|
+
onVisibleChange === null || onVisibleChange === void 0 || onVisibleChange(!!len);
|
|
113
|
+
setActiveKey(keys);
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
activeKey: activeKey,
|
|
117
|
+
onChange: onChange
|
|
118
|
+
};
|
|
119
|
+
};
|
|
95
120
|
|
|
96
|
-
export { useChangeControl, useTagControl };
|
|
121
|
+
export { useChangeControl, useCollapseControl, useTagControl };
|
|
97
122
|
// powered by hdj
|
|
@@ -6,7 +6,7 @@ import { Collapse, Checkbox } from 'antd';
|
|
|
6
6
|
import { useClassName, useMatchConfigProps } from '../../hooks/index.js';
|
|
7
7
|
import { useSelectReq } from '../hooks/norHooks.js';
|
|
8
8
|
import Content from './Content.js';
|
|
9
|
-
import { useTagControl, useChangeControl } from './hooks.js';
|
|
9
|
+
import { useCollapseControl, useTagControl, useChangeControl } from './hooks.js';
|
|
10
10
|
import HFormConnect from '../../Form/HFormConnect.js';
|
|
11
11
|
|
|
12
12
|
var _excluded = ["children"];
|
|
@@ -37,13 +37,22 @@ var Index = function Index(_ref2) {
|
|
|
37
37
|
manual = _ref2.manual,
|
|
38
38
|
_ref2$className = _ref2.className,
|
|
39
39
|
className = _ref2$className === void 0 ? "" : _ref2$className,
|
|
40
|
-
|
|
40
|
+
visible = _ref2.visible,
|
|
41
|
+
defaultVisible = _ref2.defaultVisible,
|
|
42
|
+
onVisibleChange = _ref2.onVisibleChange,
|
|
41
43
|
addDispatchListener = _ref2.addDispatchListener;
|
|
42
44
|
var collapseClassName = useClassName("hw-tag-select");
|
|
43
45
|
var _useMatchConfigProps = useMatchConfigProps({
|
|
44
46
|
fieldNames: propsFieldNames
|
|
45
47
|
}),
|
|
46
48
|
fieldNames = _useMatchConfigProps.fieldNames;
|
|
49
|
+
var _useCollapseControl = useCollapseControl({
|
|
50
|
+
defaultVisible: defaultVisible,
|
|
51
|
+
visible: visible,
|
|
52
|
+
onVisibleChange: onVisibleChange
|
|
53
|
+
}),
|
|
54
|
+
activeKey = _useCollapseControl.activeKey,
|
|
55
|
+
colChange = _useCollapseControl.onChange;
|
|
47
56
|
var _useSelectReq = useSelectReq({
|
|
48
57
|
options: options,
|
|
49
58
|
manual: manual,
|
|
@@ -70,10 +79,11 @@ var Index = function Index(_ref2) {
|
|
|
70
79
|
}),
|
|
71
80
|
allCheck = _useChangeControl.allCheck;
|
|
72
81
|
addDispatchListener === null || addDispatchListener === void 0 || addDispatchListener("reload", reload);
|
|
73
|
-
return jsx(Collapse,
|
|
82
|
+
return jsx(Collapse, {
|
|
74
83
|
bordered: false,
|
|
75
|
-
ghost: true
|
|
76
|
-
|
|
84
|
+
ghost: true,
|
|
85
|
+
activeKey: activeKey,
|
|
86
|
+
onChange: colChange,
|
|
77
87
|
className: "".concat(collapseClassName, " ").concat(className),
|
|
78
88
|
children: jsx(Panel, {
|
|
79
89
|
header: jsx(ItemTitle, {
|
|
@@ -92,7 +102,7 @@ var Index = function Index(_ref2) {
|
|
|
92
102
|
fieldNames: fieldNames
|
|
93
103
|
})
|
|
94
104
|
}, "1")
|
|
95
|
-
})
|
|
105
|
+
});
|
|
96
106
|
};
|
|
97
107
|
var HTagSelect = HFormConnect(Index);
|
|
98
108
|
|
package/es/Select/modal.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ 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";
|
|
6
5
|
export type OptionType = Record<string, any>;
|
|
7
6
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
8
7
|
interface ModeConfigItem {
|
|
@@ -47,7 +46,9 @@ export interface FilterDataModal {
|
|
|
47
46
|
}
|
|
48
47
|
export interface HTagSelectProps extends HSelectProps {
|
|
49
48
|
title?: React.ReactNode;
|
|
50
|
-
|
|
49
|
+
defaultVisible?: boolean;
|
|
50
|
+
visible?: boolean;
|
|
51
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
51
52
|
}
|
|
52
53
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
53
54
|
export {};
|
|
@@ -8,3 +8,7 @@ export declare const useChangeControl: ({ options, value, onChange, fieldNames }
|
|
|
8
8
|
change: (val: any) => void;
|
|
9
9
|
allCheck: (e: any) => void | undefined;
|
|
10
10
|
};
|
|
11
|
+
export declare const useCollapseControl: ({ visible, defaultVisible, onVisibleChange }: HTagSelectProps) => {
|
|
12
|
+
activeKey: string[];
|
|
13
|
+
onChange: (keys: any) => void;
|
|
14
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
3
4
|
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
4
5
|
var React = require('react');
|
|
5
6
|
|
|
@@ -93,7 +94,32 @@ var useChangeControl = function useChangeControl(_ref2) {
|
|
|
93
94
|
allCheck: allCheck
|
|
94
95
|
};
|
|
95
96
|
};
|
|
97
|
+
var useCollapseControl = function useCollapseControl(_ref4) {
|
|
98
|
+
var visible = _ref4.visible,
|
|
99
|
+
defaultVisible = _ref4.defaultVisible,
|
|
100
|
+
onVisibleChange = _ref4.onVisibleChange;
|
|
101
|
+
var _useState = React.useState(defaultVisible ? ["1"] : []),
|
|
102
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
103
|
+
activeKey = _useState2[0],
|
|
104
|
+
setActiveKey = _useState2[1];
|
|
105
|
+
React.useEffect(function () {
|
|
106
|
+
if (typeof visible === "undefined") {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
setActiveKey(visible ? ["1"] : []);
|
|
110
|
+
}, [visible]);
|
|
111
|
+
var onChange = function onChange(keys) {
|
|
112
|
+
var len = keys === null || keys === void 0 ? void 0 : keys.length;
|
|
113
|
+
onVisibleChange === null || onVisibleChange === void 0 || onVisibleChange(!!len);
|
|
114
|
+
setActiveKey(keys);
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
activeKey: activeKey,
|
|
118
|
+
onChange: onChange
|
|
119
|
+
};
|
|
120
|
+
};
|
|
96
121
|
|
|
97
122
|
exports.useChangeControl = useChangeControl;
|
|
123
|
+
exports.useCollapseControl = useCollapseControl;
|
|
98
124
|
exports.useTagControl = useTagControl;
|
|
99
125
|
// powered by h
|
|
@@ -40,13 +40,22 @@ var Index = function Index(_ref2) {
|
|
|
40
40
|
manual = _ref2.manual,
|
|
41
41
|
_ref2$className = _ref2.className,
|
|
42
42
|
className = _ref2$className === void 0 ? "" : _ref2$className,
|
|
43
|
-
|
|
43
|
+
visible = _ref2.visible,
|
|
44
|
+
defaultVisible = _ref2.defaultVisible,
|
|
45
|
+
onVisibleChange = _ref2.onVisibleChange,
|
|
44
46
|
addDispatchListener = _ref2.addDispatchListener;
|
|
45
47
|
var collapseClassName = index.useClassName("hw-tag-select");
|
|
46
48
|
var _useMatchConfigProps = index.useMatchConfigProps({
|
|
47
49
|
fieldNames: propsFieldNames
|
|
48
50
|
}),
|
|
49
51
|
fieldNames = _useMatchConfigProps.fieldNames;
|
|
52
|
+
var _useCollapseControl = hooks.useCollapseControl({
|
|
53
|
+
defaultVisible: defaultVisible,
|
|
54
|
+
visible: visible,
|
|
55
|
+
onVisibleChange: onVisibleChange
|
|
56
|
+
}),
|
|
57
|
+
activeKey = _useCollapseControl.activeKey,
|
|
58
|
+
colChange = _useCollapseControl.onChange;
|
|
50
59
|
var _useSelectReq = norHooks.useSelectReq({
|
|
51
60
|
options: options,
|
|
52
61
|
manual: manual,
|
|
@@ -73,10 +82,11 @@ var Index = function Index(_ref2) {
|
|
|
73
82
|
}),
|
|
74
83
|
allCheck = _useChangeControl.allCheck;
|
|
75
84
|
addDispatchListener === null || addDispatchListener === void 0 || addDispatchListener("reload", reload);
|
|
76
|
-
return jsxRuntime.jsx(antd.Collapse,
|
|
85
|
+
return jsxRuntime.jsx(antd.Collapse, {
|
|
77
86
|
bordered: false,
|
|
78
|
-
ghost: true
|
|
79
|
-
|
|
87
|
+
ghost: true,
|
|
88
|
+
activeKey: activeKey,
|
|
89
|
+
onChange: colChange,
|
|
80
90
|
className: "".concat(collapseClassName, " ").concat(className),
|
|
81
91
|
children: jsxRuntime.jsx(Panel, {
|
|
82
92
|
header: jsxRuntime.jsx(ItemTitle, {
|
|
@@ -95,7 +105,7 @@ var Index = function Index(_ref2) {
|
|
|
95
105
|
fieldNames: fieldNames
|
|
96
106
|
})
|
|
97
107
|
}, "1")
|
|
98
|
-
})
|
|
108
|
+
});
|
|
99
109
|
};
|
|
100
110
|
var HTagSelect = HFormConnect.default(Index);
|
|
101
111
|
|
package/lib/Select/modal.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ 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";
|
|
6
5
|
export type OptionType = Record<string, any>;
|
|
7
6
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
|
8
7
|
interface ModeConfigItem {
|
|
@@ -47,7 +46,9 @@ export interface FilterDataModal {
|
|
|
47
46
|
}
|
|
48
47
|
export interface HTagSelectProps extends HSelectProps {
|
|
49
48
|
title?: React.ReactNode;
|
|
50
|
-
|
|
49
|
+
defaultVisible?: boolean;
|
|
50
|
+
visible?: boolean;
|
|
51
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
51
52
|
}
|
|
52
53
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
53
54
|
export {};
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useMemo} from "react";
|
|
1
|
+
import {useEffect, useMemo, useState} from "react";
|
|
2
2
|
import {HTagSelectProps, OptionType} from "@/components/Select/modal";
|
|
3
3
|
|
|
4
4
|
export const useTagControl=({value,options,title}:HTagSelectProps)=>{
|
|
@@ -80,4 +80,23 @@ export const useChangeControl=({options,value,onChange,fieldNames}:HTagSelectPro
|
|
|
80
80
|
change,
|
|
81
81
|
allCheck
|
|
82
82
|
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const useCollapseControl=({visible,defaultVisible,onVisibleChange}:HTagSelectProps)=>{
|
|
86
|
+
const [activeKey,setActiveKey]=useState(defaultVisible?["1"]:[]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (typeof visible==="undefined"){
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
setActiveKey(visible?["1"]:[]);
|
|
92
|
+
}, [visible]);
|
|
93
|
+
const onChange=(keys)=>{
|
|
94
|
+
const len=keys?.length;
|
|
95
|
+
onVisibleChange?.(!!len);
|
|
96
|
+
setActiveKey(keys)
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
activeKey,
|
|
100
|
+
onChange
|
|
101
|
+
}
|
|
83
102
|
}
|
|
@@ -5,7 +5,7 @@ import {useSelectReq} from "../hooks/norHooks";
|
|
|
5
5
|
import {HTagSelectProps} from "../modal";
|
|
6
6
|
import {CheckboxProps} from "antd/lib/checkbox/Checkbox";
|
|
7
7
|
import Content from './Content';
|
|
8
|
-
import {useChangeControl, useTagControl} from "@/components/Select/TagSelect/hooks";
|
|
8
|
+
import {useChangeControl, useCollapseControl, useTagControl} from "@/components/Select/TagSelect/hooks";
|
|
9
9
|
import HFormConnect from "@/components/Form/HFormConnect";
|
|
10
10
|
const { Panel } = Collapse;
|
|
11
11
|
|
|
@@ -18,9 +18,24 @@ const ItemTitle:React.FC<CheckboxProps>=({children,...props})=>{
|
|
|
18
18
|
</Checkbox>
|
|
19
19
|
</div>
|
|
20
20
|
}
|
|
21
|
-
const Index:React.FC<HTagSelectProps>=({
|
|
21
|
+
const Index:React.FC<HTagSelectProps>=({
|
|
22
|
+
options,
|
|
23
|
+
value=[],
|
|
24
|
+
onChange,
|
|
25
|
+
dispatch,
|
|
26
|
+
fieldNames:propsFieldNames,
|
|
27
|
+
request,
|
|
28
|
+
title,
|
|
29
|
+
manual,
|
|
30
|
+
className="",
|
|
31
|
+
visible,
|
|
32
|
+
defaultVisible,
|
|
33
|
+
onVisibleChange,
|
|
34
|
+
addDispatchListener
|
|
35
|
+
})=>{
|
|
22
36
|
const collapseClassName = useClassName("hw-tag-select");
|
|
23
37
|
const { fieldNames } = useMatchConfigProps({ fieldNames: propsFieldNames });
|
|
38
|
+
const {activeKey,onChange:colChange}=useCollapseControl({defaultVisible,visible,onVisibleChange})
|
|
24
39
|
const {
|
|
25
40
|
loading,
|
|
26
41
|
data: resultData,
|
|
@@ -42,7 +57,8 @@ const Index:React.FC<HTagSelectProps>=({options,value=[],onChange,dispatch,field
|
|
|
42
57
|
addDispatchListener?.("reload", reload);
|
|
43
58
|
return <Collapse bordered={false}
|
|
44
59
|
ghost
|
|
45
|
-
{
|
|
60
|
+
activeKey={activeKey}
|
|
61
|
+
onChange={colChange}
|
|
46
62
|
className={`${collapseClassName} ${className}`}
|
|
47
63
|
>
|
|
48
64
|
<Panel key="1" header={<ItemTitle indeterminate={indeterminate}
|
|
@@ -50,6 +50,8 @@ export interface FilterDataModal {
|
|
|
50
50
|
}
|
|
51
51
|
export interface HTagSelectProps extends HSelectProps{
|
|
52
52
|
title?:React.ReactNode;
|
|
53
|
-
|
|
53
|
+
defaultVisible?:boolean;
|
|
54
|
+
visible?:boolean;
|
|
55
|
+
onVisibleChange?:(visible:boolean)=>void;
|
|
54
56
|
}
|
|
55
57
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
@@ -6,7 +6,7 @@ export default () => {
|
|
|
6
6
|
const [op, setOp] = useState([{ label: "1", value: 1 }]);
|
|
7
7
|
const [val, setVal] = useState([2, 3]);
|
|
8
8
|
const [tagVal, setTagVal] = useState([]);
|
|
9
|
-
|
|
9
|
+
const [visible,setVisible]=useState(true);
|
|
10
10
|
return (
|
|
11
11
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
12
12
|
<HSelect
|
|
@@ -46,10 +46,16 @@ export default () => {
|
|
|
46
46
|
}}
|
|
47
47
|
mode="multiple"
|
|
48
48
|
/>
|
|
49
|
+
<div onClick={()=>{
|
|
50
|
+
setVisible(false)
|
|
51
|
+
}}>
|
|
52
|
+
关闭
|
|
53
|
+
</div>
|
|
49
54
|
<HTagSelect
|
|
50
55
|
value={tagVal}
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
visible={visible}
|
|
57
|
+
onVisibleChange={(v)=>{
|
|
58
|
+
console.log(v)
|
|
53
59
|
}}
|
|
54
60
|
request={()=>{
|
|
55
61
|
return new Promise((resolve, reject)=>{
|