@hw-component/form 0.0.1 → 0.0.2-beta-v1
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/LICENSE +201 -0
- package/es/CheckboxGroup/CheckBox/index.d.ts +4 -0
- package/es/CheckboxGroup/CheckBox/index.js +40 -0
- package/es/CheckboxGroup/hooks.d.ts +5 -0
- package/es/CheckboxGroup/hooks.js +123 -0
- package/es/CheckboxGroup/index.d.ts +3 -0
- package/es/CheckboxGroup/index.js +91 -0
- package/es/CheckboxGroup/modal.d.ts +13 -0
- package/es/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Footer.js +23 -0
- package/es/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/es/DialogForm/DrawerForm/Title.js +18 -0
- package/es/DialogForm/DrawerForm/index.d.ts +4 -0
- package/es/DialogForm/DrawerForm/index.js +111 -0
- package/es/DialogForm/ModalForm.d.ts +4 -0
- package/es/DialogForm/ModalForm.js +89 -0
- package/es/DialogForm/hooks.d.ts +14 -0
- package/es/DialogForm/hooks.js +124 -0
- package/es/DialogForm/modal.d.ts +25 -0
- package/es/Form/Context/FormConfigProvider.d.ts +5 -0
- package/es/Form/Context/FormConfigProvider.js +47 -0
- package/es/Form/Context/index.d.ts +5 -0
- package/es/Form/Context/index.js +11 -0
- package/es/Form/FormItem/BasicItem.d.ts +4 -0
- package/es/Form/FormItem/BasicItem.js +73 -0
- package/es/Form/FormItem/Helper.d.ts +7 -0
- package/es/Form/FormItem/Helper.js +24 -0
- package/es/Form/FormItem/RegularFormItem.d.ts +4 -0
- package/es/Form/FormItem/RegularFormItem.js +15 -0
- package/es/Form/FormItem/UpFormItem.d.ts +4 -0
- package/es/Form/FormItem/UpFormItem.js +31 -0
- package/es/Form/FormItem/hooks.d.ts +10 -0
- package/es/Form/FormItem/hooks.js +38 -0
- package/es/Form/FormItem/index.d.ts +4 -0
- package/es/Form/FormItem/index.js +11 -0
- package/es/Form/HFormConnect.d.ts +5 -0
- package/es/Form/HFormConnect.js +55 -0
- package/es/Form/InitSet.d.ts +3 -0
- package/es/Form/InitSet.js +15 -0
- package/es/Form/Label.d.ts +10 -0
- package/es/Form/Label.js +46 -0
- package/es/Form/config.d.ts +29 -0
- package/es/Form/config.js +45 -0
- package/es/Form/hooks/index.d.ts +6 -0
- package/es/Form/hooks/index.js +45 -0
- package/es/Form/hooks/useHForm.d.ts +3 -0
- package/es/Form/hooks/useHForm.js +168 -0
- package/es/Form/hooks/useInitConfigData.d.ts +4 -0
- package/es/Form/hooks/useInitConfigData.js +124 -0
- package/es/Form/index.d.ts +4 -0
- package/es/Form/index.js +104 -0
- package/es/Form/modal.d.ts +104 -0
- package/es/Input/ButtonInput.d.ts +4 -0
- package/es/Input/ButtonInput.js +80 -0
- package/es/Input/InputNumber.d.ts +4 -0
- package/es/Input/InputNumber.js +20 -0
- package/es/Input/SelectInput.d.ts +9 -0
- package/es/Input/SelectInput.js +97 -0
- package/es/Input/defaultConfig.d.ts +7 -0
- package/es/Input/defaultConfig.js +11 -0
- package/es/Input/index.d.ts +4 -0
- package/es/Input/index.js +13 -0
- package/es/Input/modal.d.ts +27 -0
- package/es/PageHandler/ErrorComponent.d.ts +4 -0
- package/es/PageHandler/ErrorComponent.js +33 -0
- package/es/PageHandler/LoadingComponent.d.ts +3 -0
- package/es/PageHandler/LoadingComponent.js +18 -0
- package/es/PageHandler/index.d.ts +4 -0
- package/es/PageHandler/index.js +24 -0
- package/es/PageHandler/modal.d.ts +6 -0
- package/es/RadioGroup/index.d.ts +9 -0
- package/es/RadioGroup/index.js +48 -0
- package/es/Select/components/AllSelect.d.ts +3 -3
- package/es/Select/components/AllSelect.js +31 -15
- package/es/Select/components/CheckBoxOption.js +2 -2
- package/es/Select/components/DropdownComponent.js +2 -2
- package/es/Select/components/NoFindItem.js +2 -2
- package/es/Select/components/NotFoundContent.js +3 -5
- package/es/Select/defaultConfig.d.ts +0 -1
- package/es/Select/defaultConfig.js +3 -7
- package/es/Select/hooks/changeHooks.d.ts +1 -1
- package/es/Select/hooks/changeHooks.js +9 -5
- package/es/Select/hooks/norHooks.d.ts +4 -6
- package/es/Select/hooks/norHooks.js +20 -37
- package/es/Select/index.d.ts +1 -1
- package/es/Select/index.js +31 -19
- package/es/Select/modal.d.ts +2 -2
- package/es/Select/utils.d.ts +2 -0
- package/es/Select/utils.js +39 -0
- package/es/Submit/index.d.ts +8 -0
- package/es/Submit/index.js +28 -0
- package/es/Switch/index.d.ts +11 -0
- package/es/Switch/index.js +45 -0
- package/es/TDPicker/RangePicker.d.ts +8 -0
- package/es/TDPicker/RangePicker.js +121 -0
- package/es/TDPicker/TimePicker.d.ts +4 -0
- package/es/TDPicker/TimePicker.js +31 -0
- package/es/TDPicker/hooks.d.ts +33 -0
- package/es/TDPicker/hooks.js +132 -0
- package/es/TDPicker/index.d.ts +4 -0
- package/es/TDPicker/index.js +33 -0
- package/es/TDPicker/modal.d.ts +28 -0
- package/es/TextArea/index.d.ts +4 -0
- package/es/TextArea/index.js +21 -0
- package/es/Upload/Btn.d.ts +4 -0
- package/es/Upload/Btn.js +31 -0
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +10 -0
- package/es/Upload/MediaTypeEle/TypeEle.js +40 -0
- package/es/Upload/MediaTypeEle/index.d.ts +4 -0
- package/es/Upload/MediaTypeEle/index.js +36 -0
- package/es/Upload/Preview/index.d.ts +6 -0
- package/es/Upload/Preview/index.js +21 -0
- package/es/Upload/UrlUpload/index.d.ts +4 -0
- package/es/Upload/UrlUpload/index.js +119 -0
- package/es/Upload/enums.d.ts +5 -0
- package/es/Upload/enums.js +10 -0
- package/es/Upload/hooks/change.d.ts +3 -0
- package/es/Upload/hooks/change.js +109 -0
- package/es/Upload/hooks/customRequest.d.ts +3 -0
- package/es/Upload/hooks/customRequest.js +132 -0
- package/es/Upload/hooks/propsMaker.d.ts +2 -0
- package/es/Upload/hooks/propsMaker.js +37 -0
- package/es/Upload/index.d.ts +3 -0
- package/es/Upload/index.js +140 -0
- package/es/Upload/modal.d.ts +30 -0
- package/es/Upload/util.d.ts +5 -0
- package/es/Upload/util.js +34 -0
- package/es/config.d.ts +2 -0
- package/es/config.js +64 -0
- package/es/hooks/index.d.ts +13 -0
- package/es/hooks/index.js +75 -0
- package/es/index.css +33 -1
- package/es/index.d.ts +24 -1
- package/es/index.js +31 -3
- package/es/modal.d.ts +15 -0
- package/lib/CheckboxGroup/CheckBox/index.d.ts +4 -0
- package/lib/CheckboxGroup/CheckBox/index.js +43 -0
- package/lib/CheckboxGroup/hooks.d.ts +5 -0
- package/lib/CheckboxGroup/hooks.js +124 -0
- package/lib/CheckboxGroup/index.d.ts +3 -0
- package/lib/CheckboxGroup/index.js +94 -0
- package/lib/CheckboxGroup/modal.d.ts +13 -0
- package/lib/DialogForm/DrawerForm/Footer.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Footer.js +26 -0
- package/lib/DialogForm/DrawerForm/Title.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/Title.js +21 -0
- package/lib/DialogForm/DrawerForm/index.d.ts +4 -0
- package/lib/DialogForm/DrawerForm/index.js +114 -0
- package/lib/DialogForm/ModalForm.d.ts +4 -0
- package/lib/DialogForm/ModalForm.js +92 -0
- package/lib/DialogForm/hooks.d.ts +14 -0
- package/lib/DialogForm/hooks.js +128 -0
- package/lib/DialogForm/modal.d.ts +25 -0
- package/lib/Form/Context/FormConfigProvider.d.ts +5 -0
- package/lib/Form/Context/FormConfigProvider.js +51 -0
- package/lib/Form/Context/index.d.ts +5 -0
- package/lib/Form/Context/index.js +14 -0
- package/lib/Form/FormItem/BasicItem.d.ts +4 -0
- package/lib/Form/FormItem/BasicItem.js +76 -0
- package/lib/Form/FormItem/Helper.d.ts +7 -0
- package/lib/Form/FormItem/Helper.js +27 -0
- package/lib/Form/FormItem/RegularFormItem.d.ts +4 -0
- package/lib/Form/FormItem/RegularFormItem.js +18 -0
- package/lib/Form/FormItem/UpFormItem.d.ts +4 -0
- package/lib/Form/FormItem/UpFormItem.js +34 -0
- package/lib/Form/FormItem/hooks.d.ts +10 -0
- package/lib/Form/FormItem/hooks.js +41 -0
- package/lib/Form/FormItem/index.d.ts +4 -0
- package/lib/Form/FormItem/index.js +14 -0
- package/lib/Form/HFormConnect.d.ts +5 -0
- package/lib/Form/HFormConnect.js +58 -0
- package/lib/Form/InitSet.d.ts +3 -0
- package/lib/Form/InitSet.js +18 -0
- package/lib/Form/Label.d.ts +10 -0
- package/lib/Form/Label.js +49 -0
- package/lib/Form/config.d.ts +29 -0
- package/lib/Form/config.js +49 -0
- package/lib/Form/hooks/index.d.ts +6 -0
- package/lib/Form/hooks/index.js +47 -0
- package/lib/Form/hooks/useHForm.d.ts +3 -0
- package/lib/Form/hooks/useHForm.js +171 -0
- package/lib/Form/hooks/useInitConfigData.d.ts +4 -0
- package/lib/Form/hooks/useInitConfigData.js +127 -0
- package/lib/Form/index.d.ts +4 -0
- package/lib/Form/index.js +107 -0
- package/lib/Form/modal.d.ts +104 -0
- package/lib/Input/ButtonInput.d.ts +4 -0
- package/lib/Input/ButtonInput.js +83 -0
- package/lib/Input/InputNumber.d.ts +4 -0
- package/lib/Input/InputNumber.js +23 -0
- package/lib/Input/SelectInput.d.ts +9 -0
- package/lib/Input/SelectInput.js +101 -0
- package/lib/Input/defaultConfig.d.ts +7 -0
- package/lib/Input/defaultConfig.js +13 -0
- package/lib/Input/index.d.ts +4 -0
- package/lib/Input/index.js +16 -0
- package/lib/Input/modal.d.ts +27 -0
- package/lib/PageHandler/ErrorComponent.d.ts +4 -0
- package/lib/PageHandler/ErrorComponent.js +36 -0
- package/lib/PageHandler/LoadingComponent.d.ts +3 -0
- package/lib/PageHandler/LoadingComponent.js +21 -0
- package/lib/PageHandler/index.d.ts +4 -0
- package/lib/PageHandler/index.js +27 -0
- package/lib/PageHandler/modal.d.ts +6 -0
- package/lib/RadioGroup/index.d.ts +9 -0
- package/lib/RadioGroup/index.js +51 -0
- package/lib/Select/components/AllSelect.d.ts +3 -3
- package/lib/Select/components/AllSelect.js +29 -13
- package/lib/Select/components/NotFoundContent.js +1 -3
- package/lib/Select/defaultConfig.d.ts +0 -1
- package/lib/Select/defaultConfig.js +0 -5
- package/lib/Select/hooks/changeHooks.d.ts +1 -1
- package/lib/Select/hooks/changeHooks.js +7 -3
- package/lib/Select/hooks/norHooks.d.ts +4 -6
- package/lib/Select/hooks/norHooks.js +18 -35
- package/lib/Select/index.d.ts +1 -1
- package/lib/Select/index.js +26 -14
- package/lib/Select/modal.d.ts +2 -2
- package/lib/Select/utils.d.ts +2 -0
- package/lib/Select/utils.js +41 -0
- package/lib/Submit/index.d.ts +8 -0
- package/lib/Submit/index.js +31 -0
- package/lib/Switch/index.d.ts +11 -0
- package/lib/Switch/index.js +48 -0
- package/lib/TDPicker/RangePicker.d.ts +8 -0
- package/lib/TDPicker/RangePicker.js +124 -0
- package/lib/TDPicker/TimePicker.d.ts +4 -0
- package/lib/TDPicker/TimePicker.js +34 -0
- package/lib/TDPicker/hooks.d.ts +33 -0
- package/lib/TDPicker/hooks.js +139 -0
- package/lib/TDPicker/index.d.ts +4 -0
- package/lib/TDPicker/index.js +36 -0
- package/lib/TDPicker/modal.d.ts +28 -0
- package/lib/TextArea/index.d.ts +4 -0
- package/lib/TextArea/index.js +24 -0
- package/lib/Upload/Btn.d.ts +4 -0
- package/lib/Upload/Btn.js +34 -0
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +10 -0
- package/lib/Upload/MediaTypeEle/TypeEle.js +43 -0
- package/lib/Upload/MediaTypeEle/index.d.ts +4 -0
- package/lib/Upload/MediaTypeEle/index.js +39 -0
- package/lib/Upload/Preview/index.d.ts +6 -0
- package/lib/Upload/Preview/index.js +24 -0
- package/lib/Upload/UrlUpload/index.d.ts +4 -0
- package/lib/Upload/UrlUpload/index.js +122 -0
- package/lib/Upload/enums.d.ts +5 -0
- package/lib/Upload/enums.js +9 -0
- package/lib/Upload/hooks/change.d.ts +3 -0
- package/lib/Upload/hooks/change.js +110 -0
- package/lib/Upload/hooks/customRequest.d.ts +3 -0
- package/lib/Upload/hooks/customRequest.js +133 -0
- package/lib/Upload/hooks/propsMaker.d.ts +2 -0
- package/lib/Upload/hooks/propsMaker.js +38 -0
- package/lib/Upload/index.d.ts +3 -0
- package/lib/Upload/index.js +143 -0
- package/lib/Upload/modal.d.ts +30 -0
- package/lib/Upload/util.d.ts +5 -0
- package/lib/Upload/util.js +38 -0
- package/lib/config.d.ts +2 -0
- package/lib/config.js +65 -0
- package/lib/hooks/index.d.ts +13 -0
- package/lib/hooks/index.js +78 -0
- package/lib/index.css +33 -1
- package/lib/index.d.ts +24 -1
- package/lib/index.js +48 -3
- package/lib/modal.d.ts +15 -0
- package/package.json +4 -3
- package/scripts/rollup.config.js +3 -8
- package/scripts/webpack.config.js +6 -2
- package/src/Layout.tsx +4 -4
- package/src/components/CheckboxGroup/CheckBox/index.tsx +38 -0
- package/src/components/CheckboxGroup/hooks.ts +102 -0
- package/src/components/CheckboxGroup/index.tsx +79 -0
- package/src/components/CheckboxGroup/modal.ts +15 -0
- package/src/components/DialogForm/DrawerForm/Footer.tsx +19 -0
- package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
- package/src/components/DialogForm/DrawerForm/index.tsx +85 -0
- package/src/components/DialogForm/ModalForm.tsx +60 -0
- package/src/components/DialogForm/hooks.ts +87 -0
- package/src/components/DialogForm/modal.ts +27 -0
- package/src/components/Form/Context/FormConfigProvider.tsx +38 -0
- package/src/components/Form/Context/index.tsx +14 -0
- package/src/components/Form/FormItem/BasicItem.tsx +70 -0
- package/src/components/Form/FormItem/Helper.tsx +25 -0
- package/src/components/Form/FormItem/RegularFormItem.tsx +7 -0
- package/src/components/Form/FormItem/UpFormItem.tsx +20 -0
- package/src/components/Form/FormItem/hooks.tsx +44 -0
- package/src/components/Form/FormItem/index.tsx +8 -0
- package/src/components/Form/HFormConnect.tsx +67 -0
- package/src/components/Form/InitSet.tsx +10 -0
- package/src/components/Form/Label.tsx +50 -0
- package/src/components/Form/config.ts +41 -0
- package/src/components/Form/hooks/index.ts +22 -0
- package/src/components/Form/hooks/useHForm.ts +142 -0
- package/src/components/Form/hooks/useInitConfigData.tsx +100 -0
- package/src/components/Form/index.less +22 -0
- package/src/components/Form/index.tsx +79 -0
- package/src/components/Form/modal.ts +154 -0
- package/src/components/Input/ButtonInput.tsx +41 -0
- package/src/components/Input/InputNumber.tsx +5 -0
- package/src/components/Input/SelectInput.tsx +76 -0
- package/src/components/Input/defaultConfig.ts +8 -0
- package/src/components/Input/index.tsx +6 -0
- package/src/components/Input/modal.ts +33 -0
- package/src/components/PageHandler/ErrorComponent.tsx +20 -0
- package/src/components/PageHandler/LoadingComponent.tsx +9 -0
- package/src/components/PageHandler/index.tsx +14 -0
- package/src/components/PageHandler/modal.ts +6 -0
- package/src/components/RadioGroup/index.tsx +45 -0
- package/src/components/Select/components/AllSelect.tsx +32 -16
- package/src/components/Select/components/DropdownComponent.tsx +1 -0
- package/src/components/Select/components/NotFoundContent.tsx +1 -1
- package/src/components/Select/defaultConfig.tsx +0 -5
- package/src/components/Select/hooks/changeHooks.tsx +14 -4
- package/src/components/Select/hooks/norHooks.ts +8 -19
- package/src/components/Select/index.less +20 -3
- package/src/components/Select/index.tsx +29 -17
- package/src/components/Select/modal.ts +9 -9
- package/src/components/Select/utils.ts +18 -0
- package/src/components/Submit/index.tsx +28 -0
- package/src/components/Switch/index.tsx +52 -0
- package/src/components/TDPicker/RangePicker.tsx +105 -0
- package/src/components/TDPicker/TimePicker.tsx +15 -0
- package/src/components/TDPicker/hooks.ts +150 -0
- package/src/components/TDPicker/index.tsx +22 -0
- package/src/components/TDPicker/modal.ts +30 -0
- package/src/components/TextArea/index.tsx +8 -0
- package/src/components/Upload/Btn.tsx +24 -0
- package/src/components/Upload/MediaTypeEle/TypeEle.tsx +26 -0
- package/src/components/Upload/MediaTypeEle/index.tsx +34 -0
- package/src/components/Upload/Preview/index.tsx +14 -0
- package/src/components/Upload/UrlUpload/index.tsx +91 -0
- package/src/components/Upload/enums.ts +5 -0
- package/src/components/Upload/hooks/change.ts +79 -0
- package/src/components/Upload/hooks/customRequest.ts +87 -0
- package/src/components/Upload/hooks/propsMaker.ts +20 -0
- package/src/components/Upload/index.tsx +117 -0
- package/src/components/Upload/modal.ts +33 -0
- package/src/components/Upload/util.ts +27 -0
- package/src/components/config.ts +40 -0
- package/src/components/hooks/index.ts +53 -0
- package/src/components/index.tsx +27 -1
- package/src/components/modal.ts +15 -0
- package/src/components/styles/index.less +2 -0
- package/src/components/styles/local.less +1 -0
- package/src/pages/Checkbox/index.tsx +15 -0
- package/src/pages/DatePicker/index.tsx +33 -0
- package/src/pages/DrawerForm/index.tsx +127 -0
- package/src/pages/Form/index.tsx +149 -0
- package/src/pages/Input/index.tsx +22 -0
- package/src/pages/ModalForm/index.tsx +127 -0
- package/src/pages/Radio/index.tsx +18 -0
- package/src/pages/Select/index.tsx +7 -4
- package/src/pages/Switch/index.tsx +18 -0
- package/src/pages/Upload/index.tsx +14 -0
- package/src/routes.tsx +55 -10
- package/es/Select/index.less.js +0 -5
- package/lib/Select/index.less.js +0 -8
package/lib/config.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
4
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
5
|
+
var moment = require('moment');
|
|
6
|
+
var util = require('./Upload/util.js');
|
|
7
|
+
|
|
8
|
+
var baseConfig = {
|
|
9
|
+
fieldNames: {
|
|
10
|
+
label: "label",
|
|
11
|
+
value: "value"
|
|
12
|
+
},
|
|
13
|
+
valueCheckMap: {
|
|
14
|
+
checked: 1,
|
|
15
|
+
noChecked: 0
|
|
16
|
+
},
|
|
17
|
+
valueSwitchMap: {
|
|
18
|
+
open: 1,
|
|
19
|
+
close: 0
|
|
20
|
+
},
|
|
21
|
+
valueRangePickerValueMap: {
|
|
22
|
+
start: function start(name) {
|
|
23
|
+
return "".concat(name, "StartTime");
|
|
24
|
+
},
|
|
25
|
+
end: function end(name) {
|
|
26
|
+
return "".concat(name, "EndTime");
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
dateRanges: {
|
|
30
|
+
最近三天: [moment().subtract(2, "days").startOf("days"), moment()],
|
|
31
|
+
最近七天: [moment().subtract(6, "days").startOf("days"), moment()],
|
|
32
|
+
最近三十天: [moment().subtract(29, "days").startOf("days"), moment()]
|
|
33
|
+
},
|
|
34
|
+
uploadProps: {
|
|
35
|
+
exFiles: ["JPG", "PNG", "JPEG", "GIF"],
|
|
36
|
+
request: function () {
|
|
37
|
+
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file) {
|
|
38
|
+
var url;
|
|
39
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
40
|
+
while (1) switch (_context.prev = _context.next) {
|
|
41
|
+
case 0:
|
|
42
|
+
_context.next = 2;
|
|
43
|
+
return util.fileToBase64(file);
|
|
44
|
+
case 2:
|
|
45
|
+
url = _context.sent;
|
|
46
|
+
return _context.abrupt("return", {
|
|
47
|
+
url: url
|
|
48
|
+
});
|
|
49
|
+
case 4:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context.stop();
|
|
52
|
+
}
|
|
53
|
+
}, _callee);
|
|
54
|
+
}));
|
|
55
|
+
function request(_x) {
|
|
56
|
+
return _request.apply(this, arguments);
|
|
57
|
+
}
|
|
58
|
+
return request;
|
|
59
|
+
}(),
|
|
60
|
+
maxSize: 1024 * 1024 * 1.8
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.baseConfig = baseConfig;
|
|
65
|
+
// powered by h
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SelectProps } from "antd";
|
|
2
|
+
import type { IFormConfigContextProps } from "../Form/modal";
|
|
3
|
+
interface UseChangeOptionsParams {
|
|
4
|
+
options?: Record<string, any>[];
|
|
5
|
+
fieldNames?: SelectProps["fieldNames"];
|
|
6
|
+
}
|
|
7
|
+
export declare const useChangeOptions: ({ options, fieldNames, }: UseChangeOptionsParams) => {
|
|
8
|
+
label: any;
|
|
9
|
+
value: any;
|
|
10
|
+
}[] | undefined;
|
|
11
|
+
export declare const useClassName: (className: string | string[]) => string;
|
|
12
|
+
export declare const useMatchConfigProps: (matchProps: IFormConfigContextProps) => IFormConfigContextProps;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _typeof = require('@babel/runtime-corejs3/helpers/typeof');
|
|
4
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
5
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
6
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
|
|
7
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js/array/is-array');
|
|
8
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/concat');
|
|
9
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
|
|
10
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
11
|
+
var _Symbol$toPrimitive = require('@babel/runtime-corejs3/core-js/symbol/to-primitive');
|
|
12
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js/object/get-own-property-symbols');
|
|
13
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
|
|
14
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptor');
|
|
15
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
|
|
16
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
|
|
17
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
|
|
18
|
+
var React = require('react');
|
|
19
|
+
var configProvider = require('antd/es/config-provider');
|
|
20
|
+
var FormConfigProvider = require('../Form/Context/FormConfigProvider.js');
|
|
21
|
+
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context4, _context5; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(source), !0)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context5 = ownKeys(Object(source))).call(_context5, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
25
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[_Symbol$toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
26
|
+
var useChangeOptions = function useChangeOptions(_ref) {
|
|
27
|
+
var options = _ref.options,
|
|
28
|
+
_ref$fieldNames = _ref.fieldNames,
|
|
29
|
+
fieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames;
|
|
30
|
+
return React.useMemo(function () {
|
|
31
|
+
return options === null || options === void 0 ? void 0 : _mapInstanceProperty(options).call(options, function (item) {
|
|
32
|
+
var _context;
|
|
33
|
+
var _fieldNames$label = fieldNames.label,
|
|
34
|
+
label = _fieldNames$label === void 0 ? "" : _fieldNames$label,
|
|
35
|
+
_fieldNames$value = fieldNames.value,
|
|
36
|
+
value = _fieldNames$value === void 0 ? "" : _fieldNames$value;
|
|
37
|
+
var relLabel = item[label],
|
|
38
|
+
relVal = item[value],
|
|
39
|
+
oItem = _objectWithoutProperties(item, _mapInstanceProperty(_context = [label, value]).call(_context, _toPropertyKey));
|
|
40
|
+
return _objectSpread(_objectSpread({}, oItem), {}, {
|
|
41
|
+
label: relLabel,
|
|
42
|
+
value: relVal
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}, [options]);
|
|
46
|
+
};
|
|
47
|
+
var useClassName = function useClassName(className) {
|
|
48
|
+
var config = React.useContext(configProvider.ConfigContext);
|
|
49
|
+
return React.useMemo(function () {
|
|
50
|
+
var _context3;
|
|
51
|
+
if (_Array$isArray(className)) {
|
|
52
|
+
var classNames = _mapInstanceProperty(className).call(className, function (item) {
|
|
53
|
+
var _context2;
|
|
54
|
+
return _concatInstanceProperty(_context2 = "".concat(config.getPrefixCls(), "-")).call(_context2, item);
|
|
55
|
+
});
|
|
56
|
+
return classNames.join(" ");
|
|
57
|
+
}
|
|
58
|
+
return _concatInstanceProperty(_context3 = "".concat(config.getPrefixCls(), "-")).call(_context3, className);
|
|
59
|
+
}, [className]);
|
|
60
|
+
};
|
|
61
|
+
var useMatchConfigProps = function useMatchConfigProps(matchProps) {
|
|
62
|
+
var globalConfig = FormConfigProvider.useFormConfigContext();
|
|
63
|
+
var keys = _Object$keys(matchProps);
|
|
64
|
+
var resultMatchProps = {};
|
|
65
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
66
|
+
if (!matchProps[key]) {
|
|
67
|
+
resultMatchProps[key] = globalConfig[key];
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
resultMatchProps[key] = matchProps[key];
|
|
71
|
+
});
|
|
72
|
+
return resultMatchProps;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.useChangeOptions = useChangeOptions;
|
|
76
|
+
exports.useClassName = useClassName;
|
|
77
|
+
exports.useMatchConfigProps = useMatchConfigProps;
|
|
78
|
+
// powered by h
|
package/lib/index.css
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
.option:
|
|
1
|
+
.ant-hw-all-check-box .ant-select-item-option-active:not( .ant-select-item-option-disabled) {
|
|
2
|
+
background-color: transparent;
|
|
3
|
+
}
|
|
4
|
+
.ant-hw-all-check-box .ant-select-item-option-selected:not( .ant-select-item-option-disabled) {
|
|
5
|
+
background-color: #e6f7ff;
|
|
6
|
+
}
|
|
7
|
+
.ant-hw-all-check-box .ant-select-item-option:not( .ant-select-item-option-selected):hover {
|
|
2
8
|
background-color: #f5f5f5;
|
|
3
9
|
}
|
|
10
|
+
.ant-hw-form-item-colon:after {
|
|
11
|
+
position: relative;
|
|
12
|
+
top: -0.5px;
|
|
13
|
+
margin: 0 0 0 2px;
|
|
14
|
+
content: ":";
|
|
15
|
+
}
|
|
16
|
+
.ant-hw-form-item-required:before {
|
|
17
|
+
display: inline-block;
|
|
18
|
+
margin-right: 4px;
|
|
19
|
+
color: #ff4d4f;
|
|
20
|
+
font-size: 14px;
|
|
21
|
+
font-family: SimSun, sans-serif;
|
|
22
|
+
line-height: 1;
|
|
23
|
+
content: "*";
|
|
24
|
+
}
|
|
25
|
+
.ant-hw-form-base-item {
|
|
26
|
+
display: -webkit-box;
|
|
27
|
+
display: -webkit-flex;
|
|
28
|
+
display: -ms-flexbox;
|
|
29
|
+
display: flex;
|
|
30
|
+
-webkit-box-align: center;
|
|
31
|
+
-webkit-align-items: center;
|
|
32
|
+
-ms-flex-align: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
min-height: 32px;
|
|
35
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import "./styles/index.less";
|
|
3
|
+
export { default as HForm } from "./Form";
|
|
4
|
+
export { default as useHForm } from "./Form/hooks/useHForm";
|
|
5
|
+
export { useHDialogForm } from "./DialogForm/hooks";
|
|
6
|
+
export declare const HSelect: ({ style, mode, options, modeConfig, value, onChange, fieldNames: propsFieldNames, request, manual, optionLabelProp, filterProvider, optionFilterProp, serviceSearch, onSearch: propsOnSearch, filterOption, showSearch, labelInValue, noMatchItemRender, allSelect, ...props }: import("./Select/modal").HSelectProps) => JSX.Element;
|
|
7
|
+
export declare const HInput: ({ ...props }: import("antd").InputProps) => JSX.Element;
|
|
8
|
+
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
9
|
+
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
|
+
export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
11
|
+
export declare const HButtonInput: import("react").FC<import("./Input/modal").HButtonInputProps>;
|
|
12
|
+
export declare const HCheckBox: import("react").FC<import("./CheckboxGroup/modal").HCheckboxProps>;
|
|
13
|
+
export declare const HSwitch: import("react").FC<import("./Switch").HSwitchProps>;
|
|
14
|
+
export declare const HCheckboxGroup: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
15
|
+
export declare const HDatePicker: ({ value, onChange, showTime, format, ...props }: import("./TDPicker/modal").HDatePickerProps) => JSX.Element;
|
|
16
|
+
export declare const HRangePicker: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
17
|
+
export declare const HRadioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("./RadioGroup").HRadioGroupProps) => JSX.Element;
|
|
18
|
+
export declare const HTimePicker: ({ value, format, onChange, ...props }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
|
|
19
|
+
export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
|
|
20
|
+
export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
|
|
21
|
+
export declare const HFormConfigProvider: import("react").FC<import("./Form/modal").IFormConfigContextProps>;
|
|
22
|
+
export declare const HTextArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
|
|
23
|
+
export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
|
|
24
|
+
export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,53 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var config = require('./Form/config.js');
|
|
4
|
+
var index$1 = require('./PageHandler/index.js');
|
|
5
|
+
var index = require('./Form/index.js');
|
|
6
|
+
var useHForm = require('./Form/hooks/useHForm.js');
|
|
7
|
+
var hooks = require('./DialogForm/hooks.js');
|
|
8
|
+
var ModalForm = require('./DialogForm/ModalForm.js');
|
|
9
|
+
var index$2 = require('./DialogForm/DrawerForm/index.js');
|
|
4
10
|
|
|
11
|
+
var HSelect = config.default.select;
|
|
12
|
+
var HInput = config.default.input;
|
|
13
|
+
var HSelectInput = config.default.selectInput;
|
|
14
|
+
var HUpload = config.default.upload;
|
|
15
|
+
var HUrlUpload = config.default.urlUpload;
|
|
16
|
+
var HButtonInput = config.default.buttonInput;
|
|
17
|
+
var HCheckBox = config.default.checkBox;
|
|
18
|
+
var HSwitch = config.default["switch"];
|
|
19
|
+
var HCheckboxGroup = config.default.checkboxGroup;
|
|
20
|
+
var HDatePicker = config.default.datePicker;
|
|
21
|
+
var HRangePicker = config.default.rangePicker.Component;
|
|
22
|
+
var HRadioGroup = config.default.radioGroup;
|
|
23
|
+
var HTimePicker = config.default.timePicker;
|
|
24
|
+
var HInputNumber = config.default.inputNumber;
|
|
25
|
+
var HPageHandler = index$1.default;
|
|
26
|
+
var HFormConfigProvider = config.default.formConfigProvider;
|
|
27
|
+
var HTextArea = config.default.textArea;
|
|
28
|
+
var HModalForm = ModalForm.default;
|
|
29
|
+
var HDrawerForm = index$2.default;
|
|
5
30
|
|
|
6
|
-
|
|
7
|
-
exports.
|
|
31
|
+
exports.HForm = index.default;
|
|
32
|
+
exports.useHForm = useHForm.default;
|
|
33
|
+
exports.useHDialogForm = hooks.useHDialogForm;
|
|
34
|
+
exports.HButtonInput = HButtonInput;
|
|
35
|
+
exports.HCheckBox = HCheckBox;
|
|
36
|
+
exports.HCheckboxGroup = HCheckboxGroup;
|
|
37
|
+
exports.HDatePicker = HDatePicker;
|
|
38
|
+
exports.HDrawerForm = HDrawerForm;
|
|
39
|
+
exports.HFormConfigProvider = HFormConfigProvider;
|
|
40
|
+
exports.HInput = HInput;
|
|
41
|
+
exports.HInputNumber = HInputNumber;
|
|
42
|
+
exports.HModalForm = HModalForm;
|
|
43
|
+
exports.HPageHandler = HPageHandler;
|
|
44
|
+
exports.HRadioGroup = HRadioGroup;
|
|
45
|
+
exports.HRangePicker = HRangePicker;
|
|
46
|
+
exports.HSelect = HSelect;
|
|
47
|
+
exports.HSelectInput = HSelectInput;
|
|
48
|
+
exports.HSwitch = HSwitch;
|
|
49
|
+
exports.HTextArea = HTextArea;
|
|
50
|
+
exports.HTimePicker = HTimePicker;
|
|
51
|
+
exports.HUpload = HUpload;
|
|
52
|
+
exports.HUrlUpload = HUrlUpload;
|
|
8
53
|
// powered by h
|
package/lib/modal.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ValueCheckMapModal {
|
|
2
|
+
checked?: any;
|
|
3
|
+
noChecked?: any;
|
|
4
|
+
}
|
|
5
|
+
export type PromiseFnResult<T = any, R = any> = (params: T) => Promise<R>;
|
|
6
|
+
export interface ValueSwitchMapModal {
|
|
7
|
+
open?: any;
|
|
8
|
+
close?: any;
|
|
9
|
+
}
|
|
10
|
+
type NameProvider = (name: string) => string;
|
|
11
|
+
export interface DateRangePickerValueMapModal {
|
|
12
|
+
start?: string | NameProvider;
|
|
13
|
+
end?: string | NameProvider;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/form",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-beta-v1",
|
|
4
4
|
"description": "基于antd二次开发",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
]
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"@ant-design/icons": "4.6.2",
|
|
30
31
|
"ahooks": "2.10.9",
|
|
31
|
-
"antd": "4.
|
|
32
|
+
"antd": "4.20.7",
|
|
32
33
|
"react": "16.14.0",
|
|
33
34
|
"react-dom": "17.0.2",
|
|
34
35
|
"react-router-dom": "^6.11.2"
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
"postcss-less": "^6.0.0",
|
|
67
68
|
"rollup": "^3.23.0",
|
|
68
69
|
"rollup-plugin-clear": "^2.0.7",
|
|
69
|
-
"rollup-plugin-postcss": "
|
|
70
|
+
"rollup-plugin-postcss": "4.0.0",
|
|
70
71
|
"rollup-plugin-typescript2": "^0.34.1",
|
|
71
72
|
"style-loader": "^3.3.3",
|
|
72
73
|
"stylelint": "13.13.1",
|
package/scripts/rollup.config.js
CHANGED
|
@@ -4,12 +4,10 @@ const { nodeResolve } = require("@rollup/plugin-node-resolve");
|
|
|
4
4
|
const { babel } = require("@rollup/plugin-babel");
|
|
5
5
|
const commonjs = require("@rollup/plugin-commonjs");
|
|
6
6
|
const typescript = require("rollup-plugin-typescript2");
|
|
7
|
-
const postcss = require("rollup-plugin-postcss");
|
|
8
7
|
const autoprefixer = require("autoprefixer");
|
|
9
8
|
const inject = require("@rollup/plugin-inject");
|
|
10
9
|
const url = require("@rollup/plugin-url");
|
|
11
|
-
const
|
|
12
|
-
const prefix = pkg.cssPrefix;
|
|
10
|
+
const postcss = require("rollup-plugin-postcss");
|
|
13
11
|
const input = path.resolve(__dirname, "../src/components/index.tsx");
|
|
14
12
|
const outDir = path.resolve(__dirname, "../lib");
|
|
15
13
|
const esOutDir = path.resolve(__dirname, "../es");
|
|
@@ -27,8 +25,8 @@ module.exports = {
|
|
|
27
25
|
{
|
|
28
26
|
dir: esOutDir,
|
|
29
27
|
format: "es",
|
|
30
|
-
banner: "// welcome to
|
|
31
|
-
footer: "// powered by
|
|
28
|
+
banner: "// welcome to hoo hoo hoo",
|
|
29
|
+
footer: "// powered by hdj",
|
|
32
30
|
entryFileNames: "[name].js",
|
|
33
31
|
exports: "named",
|
|
34
32
|
preserveModules: true,
|
|
@@ -43,9 +41,6 @@ module.exports = {
|
|
|
43
41
|
}),
|
|
44
42
|
postcss({
|
|
45
43
|
extract: "index.css",
|
|
46
|
-
modules: {
|
|
47
|
-
generateScopedName: `${prefix}_[local]`,
|
|
48
|
-
},
|
|
49
44
|
plugins: [
|
|
50
45
|
autoprefixer({
|
|
51
46
|
overrideBrowserslist: [
|
package/src/Layout.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { Menu } from "antd";
|
|
3
|
-
import
|
|
3
|
+
import "./index.less";
|
|
4
4
|
import type { RouteModal } from "./routes";
|
|
5
5
|
import routes from "./routes";
|
|
6
6
|
import { Outlet, useNavigate, useLocation } from "react-router-dom";
|
|
@@ -35,9 +35,9 @@ export default () => {
|
|
|
35
35
|
setOpenKey(openKeys);
|
|
36
36
|
}, [pathname]);
|
|
37
37
|
return (
|
|
38
|
-
<div className=
|
|
38
|
+
<div className="layout">
|
|
39
39
|
<Menu
|
|
40
|
-
className=
|
|
40
|
+
className="menu"
|
|
41
41
|
selectedKeys={keys}
|
|
42
42
|
openKeys={openKey}
|
|
43
43
|
onOpenChange={(openKeys) => {
|
|
@@ -53,7 +53,7 @@ export default () => {
|
|
|
53
53
|
return menuItem(item);
|
|
54
54
|
})}
|
|
55
55
|
</Menu>
|
|
56
|
-
<div className=
|
|
56
|
+
<div className="body">
|
|
57
57
|
<Outlet />
|
|
58
58
|
</div>
|
|
59
59
|
</div>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Checkbox } from "antd";
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import type { CheckboxChangeEvent } from "antd/es/checkbox";
|
|
4
|
+
import type { HCheckboxProps } from "@/components/CheckboxGroup/modal";
|
|
5
|
+
import { useMatchConfigProps } from "../../hooks";
|
|
6
|
+
|
|
7
|
+
const Index: React.FC<HCheckboxProps> = ({
|
|
8
|
+
value,
|
|
9
|
+
onChange,
|
|
10
|
+
children,
|
|
11
|
+
valueMap: propsValueCheckMap,
|
|
12
|
+
}) => {
|
|
13
|
+
const { valueCheckMap = {} } = useMatchConfigProps({
|
|
14
|
+
valueCheckMap: propsValueCheckMap,
|
|
15
|
+
}); //匹配全局
|
|
16
|
+
const checkedVal = useMemo(() => {
|
|
17
|
+
const { checked } = valueCheckMap;
|
|
18
|
+
if (value === checked) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}, [value]);
|
|
23
|
+
const change = (e: CheckboxChangeEvent) => {
|
|
24
|
+
const { checked, noChecked } = valueCheckMap;
|
|
25
|
+
const val = e.target.checked;
|
|
26
|
+
let subVal = checked;
|
|
27
|
+
if (!val) {
|
|
28
|
+
subVal = noChecked;
|
|
29
|
+
}
|
|
30
|
+
onChange?.(subVal);
|
|
31
|
+
};
|
|
32
|
+
return (
|
|
33
|
+
<Checkbox checked={checkedVal} onChange={change}>
|
|
34
|
+
{children}
|
|
35
|
+
</Checkbox>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
export default Index;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import type { HCheckboxProps } from "@/components/CheckboxGroup/modal";
|
|
3
|
+
|
|
4
|
+
const changValProvider = ({
|
|
5
|
+
value,
|
|
6
|
+
options,
|
|
7
|
+
valueMap = {},
|
|
8
|
+
}: HCheckboxProps) => {
|
|
9
|
+
const newVal = { ...value };
|
|
10
|
+
const { checked, noChecked } = valueMap;
|
|
11
|
+
options?.forEach((item) => {
|
|
12
|
+
const { value: itemVal } = item;
|
|
13
|
+
if (newVal[itemVal] !== checked) {
|
|
14
|
+
newVal[itemVal] = noChecked;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return newVal;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const useValueProvider = ({
|
|
21
|
+
value,
|
|
22
|
+
valueMap = {},
|
|
23
|
+
keyInValue = true,
|
|
24
|
+
onChange,
|
|
25
|
+
options,
|
|
26
|
+
}: HCheckboxProps) => {
|
|
27
|
+
const [val, setVal] = useState<Record<any, any>>({});
|
|
28
|
+
const oldValueCheckMap = useMemo(() => {
|
|
29
|
+
return {
|
|
30
|
+
valueMap,
|
|
31
|
+
};
|
|
32
|
+
}, []); //存储老的map
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setVal((oldVal) => {
|
|
35
|
+
return changValProvider({
|
|
36
|
+
value: oldVal,
|
|
37
|
+
options,
|
|
38
|
+
valueMap: oldValueCheckMap.valueMap,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}, [options]); //初始化数据
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const { checked: oldChecked } = oldValueCheckMap.valueMap;
|
|
44
|
+
const { checked, noChecked } = valueMap;
|
|
45
|
+
setVal((oldVal) => {
|
|
46
|
+
const newVal = { ...oldVal };
|
|
47
|
+
const keys = Object.keys(newVal);
|
|
48
|
+
keys.forEach((key) => {
|
|
49
|
+
if (newVal[key] === oldChecked) {
|
|
50
|
+
newVal[key] = checked;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
newVal[key] = noChecked;
|
|
54
|
+
});
|
|
55
|
+
oldValueCheckMap.valueMap = valueMap;
|
|
56
|
+
return newVal;
|
|
57
|
+
});
|
|
58
|
+
}, [valueMap]);
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const { checked } = oldValueCheckMap.valueMap;
|
|
62
|
+
if (!value) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!Array.isArray(value)) {
|
|
66
|
+
setVal(value);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setVal((oldVal) => {
|
|
70
|
+
const newVal = { ...oldVal };
|
|
71
|
+
value.forEach((itemVal) => {
|
|
72
|
+
newVal[itemVal] = checked;
|
|
73
|
+
});
|
|
74
|
+
return newVal;
|
|
75
|
+
});
|
|
76
|
+
}, [value]);
|
|
77
|
+
|
|
78
|
+
const change = (key: any, changeVal: any) => {
|
|
79
|
+
const { checked, noChecked } = valueMap;
|
|
80
|
+
const newVal = { ...val };
|
|
81
|
+
newVal[key] = noChecked;
|
|
82
|
+
if (changeVal === checked) {
|
|
83
|
+
newVal[key] = checked;
|
|
84
|
+
}
|
|
85
|
+
if (!onChange) {
|
|
86
|
+
setVal(newVal);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (keyInValue) {
|
|
90
|
+
onChange(newVal);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const subVal = Object.keys(newVal).filter((valKey) => {
|
|
94
|
+
return newVal[valKey] === checked;
|
|
95
|
+
});
|
|
96
|
+
onChange(subVal);
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
val,
|
|
100
|
+
change,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Space } from "antd";
|
|
2
|
+
import type { HCheckboxProps } from "@/components/CheckboxGroup/modal";
|
|
3
|
+
import { useValueProvider } from "./hooks";
|
|
4
|
+
import Checkbox from "./CheckBox";
|
|
5
|
+
import { useMatchConfigProps, useChangeOptions } from "../hooks";
|
|
6
|
+
import HFormConnect from "../Form/HFormConnect";
|
|
7
|
+
import React from "react";
|
|
8
|
+
|
|
9
|
+
const Index = ({
|
|
10
|
+
options,
|
|
11
|
+
fieldNames,
|
|
12
|
+
onChange,
|
|
13
|
+
valueMap,
|
|
14
|
+
value,
|
|
15
|
+
disabled,
|
|
16
|
+
keyInValue = true,
|
|
17
|
+
addFormat,
|
|
18
|
+
}: HCheckboxProps) => {
|
|
19
|
+
const { valueCheckMap: resultValueCheckMap, fieldNames: resultFieldNames } =
|
|
20
|
+
useMatchConfigProps({ fieldNames, valueCheckMap: valueMap }); //匹配全局
|
|
21
|
+
const checkOptions = useChangeOptions({
|
|
22
|
+
options,
|
|
23
|
+
fieldNames: resultFieldNames,
|
|
24
|
+
});
|
|
25
|
+
const { val, change } = useValueProvider({
|
|
26
|
+
options: checkOptions,
|
|
27
|
+
onChange,
|
|
28
|
+
valueMap: resultValueCheckMap,
|
|
29
|
+
keyInValue,
|
|
30
|
+
value,
|
|
31
|
+
});
|
|
32
|
+
addFormat?.({
|
|
33
|
+
float: {
|
|
34
|
+
inputValue: (item, initValue) => {
|
|
35
|
+
const { name = "" } = item;
|
|
36
|
+
const keys = checkOptions?.map((optItem) => {
|
|
37
|
+
return optItem.value;
|
|
38
|
+
});
|
|
39
|
+
const resultObj = {};
|
|
40
|
+
keys?.forEach((key) => {
|
|
41
|
+
resultObj[key] = initValue[key];
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
[name]: resultObj,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
outputValue: (item, outputValue) => {
|
|
48
|
+
const { name = "" } = item;
|
|
49
|
+
const { [name]: itemVal = {} } = outputValue;
|
|
50
|
+
return {
|
|
51
|
+
...itemVal,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return (
|
|
57
|
+
<Space>
|
|
58
|
+
{checkOptions?.map((item) => {
|
|
59
|
+
const { label, value: itemVal } = item;
|
|
60
|
+
const checked = val[itemVal];
|
|
61
|
+
return (
|
|
62
|
+
<Checkbox
|
|
63
|
+
value={checked}
|
|
64
|
+
key={itemVal}
|
|
65
|
+
onChange={(changeVal) => {
|
|
66
|
+
change(itemVal, changeVal);
|
|
67
|
+
}}
|
|
68
|
+
valueMap={valueMap}
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
>
|
|
71
|
+
{label}
|
|
72
|
+
</Checkbox>
|
|
73
|
+
);
|
|
74
|
+
})}
|
|
75
|
+
</Space>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default HFormConnect(Index);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CheckboxProps } from "antd/lib/checkbox/Checkbox";
|
|
2
|
+
import type { SelectProps } from "antd";
|
|
3
|
+
import type { addFormatItemModal } from "../Form/modal";
|
|
4
|
+
import type { ValueCheckMapModal } from "../modal";
|
|
5
|
+
|
|
6
|
+
export interface HCheckboxProps
|
|
7
|
+
extends Omit<CheckboxProps, "value" | "onChange"> {
|
|
8
|
+
options?: Record<string, any>[];
|
|
9
|
+
fieldNames?: SelectProps["fieldNames"];
|
|
10
|
+
valueMap?: ValueCheckMapModal;
|
|
11
|
+
keyInValue?: boolean;
|
|
12
|
+
value?: Record<string, any> | any[];
|
|
13
|
+
onChange?: (value: Record<string, any> | any[]) => void;
|
|
14
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Row, Space, Button } from "antd";
|
|
2
|
+
import type { DialogFormProps } from "../modal";
|
|
3
|
+
|
|
4
|
+
export default ({
|
|
5
|
+
onCancel,
|
|
6
|
+
onOk,
|
|
7
|
+
confirmLoading,
|
|
8
|
+
}: Omit<DialogFormProps, "configData">) => {
|
|
9
|
+
return (
|
|
10
|
+
<Row justify={"end"}>
|
|
11
|
+
<Space size={"middle"}>
|
|
12
|
+
<Button onClick={onCancel}>关闭</Button>
|
|
13
|
+
<Button type={"primary"} onClick={onOk} loading={confirmLoading}>
|
|
14
|
+
确定
|
|
15
|
+
</Button>
|
|
16
|
+
</Space>
|
|
17
|
+
</Row>
|
|
18
|
+
);
|
|
19
|
+
};
|