@hw-component/form 0.0.1-bate
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/.babelrc +23 -0
- package/.eslintrc.js +8 -0
- package/.husky/pre-commit +4 -0
- package/.stylelintrc.js +5 -0
- 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 +89 -0
- package/es/CheckboxGroup/modal.d.ts +13 -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 +6 -0
- package/es/Form/HFormConnect.js +54 -0
- package/es/Form/InitSet.d.ts +6 -0
- package/es/Form/InitSet.js +16 -0
- package/es/Form/Label.d.ts +10 -0
- package/es/Form/Label.js +46 -0
- package/es/Form/config.d.ts +28 -0
- package/es/Form/config.js +43 -0
- package/es/Form/hooks/index.d.ts +12 -0
- package/es/Form/hooks/index.js +77 -0
- package/es/Form/hooks/useHForm.d.ts +3 -0
- package/es/Form/hooks/useHForm.js +111 -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 +73 -0
- package/es/Form/modal.d.ts +92 -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 +94 -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 +25 -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 +7 -0
- package/es/Select/components/AllSelect.js +50 -0
- package/es/Select/components/CheckBoxOption.d.ts +7 -0
- package/es/Select/components/CheckBoxOption.js +14 -0
- package/es/Select/components/DropdownComponent.d.ts +9 -0
- package/es/Select/components/DropdownComponent.js +39 -0
- package/es/Select/components/NoFindItem.d.ts +6 -0
- package/es/Select/components/NoFindItem.js +13 -0
- package/es/Select/components/NotFoundContent.d.ts +7 -0
- package/es/Select/components/NotFoundContent.js +38 -0
- package/es/Select/defaultConfig.d.ts +6 -0
- package/es/Select/defaultConfig.js +33 -0
- package/es/Select/hooks/changeHooks.d.ts +5 -0
- package/es/Select/hooks/changeHooks.js +194 -0
- package/es/Select/hooks/norHooks.d.ts +10 -0
- package/es/Select/hooks/norHooks.js +85 -0
- package/es/Select/index.d.ts +4 -0
- package/es/Select/index.js +128 -0
- package/es/Select/modal.d.ts +30 -0
- 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 +116 -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 +3 -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 +69 -0
- package/es/Upload/hooks/propsMaker.d.ts +2 -0
- package/es/Upload/hooks/propsMaker.js +37 -0
- package/es/Upload/index.d.ts +4 -0
- package/es/Upload/index.js +106 -0
- package/es/Upload/modal.d.ts +28 -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 +35 -0
- package/es/index.d.ts +20 -0
- package/es/index.js +25 -0
- 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 +92 -0
- package/lib/CheckboxGroup/modal.d.ts +13 -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 +6 -0
- package/lib/Form/HFormConnect.js +57 -0
- package/lib/Form/InitSet.d.ts +6 -0
- package/lib/Form/InitSet.js +19 -0
- package/lib/Form/Label.d.ts +10 -0
- package/lib/Form/Label.js +49 -0
- package/lib/Form/config.d.ts +28 -0
- package/lib/Form/config.js +47 -0
- package/lib/Form/hooks/index.d.ts +12 -0
- package/lib/Form/hooks/index.js +80 -0
- package/lib/Form/hooks/useHForm.d.ts +3 -0
- package/lib/Form/hooks/useHForm.js +114 -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 +76 -0
- package/lib/Form/modal.d.ts +92 -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 +98 -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 +25 -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 +7 -0
- package/lib/Select/components/AllSelect.js +53 -0
- package/lib/Select/components/CheckBoxOption.d.ts +7 -0
- package/lib/Select/components/CheckBoxOption.js +17 -0
- package/lib/Select/components/DropdownComponent.d.ts +9 -0
- package/lib/Select/components/DropdownComponent.js +42 -0
- package/lib/Select/components/NoFindItem.d.ts +6 -0
- package/lib/Select/components/NoFindItem.js +16 -0
- package/lib/Select/components/NotFoundContent.d.ts +7 -0
- package/lib/Select/components/NotFoundContent.js +41 -0
- package/lib/Select/defaultConfig.d.ts +6 -0
- package/lib/Select/defaultConfig.js +35 -0
- package/lib/Select/hooks/changeHooks.d.ts +5 -0
- package/lib/Select/hooks/changeHooks.js +195 -0
- package/lib/Select/hooks/norHooks.d.ts +10 -0
- package/lib/Select/hooks/norHooks.js +87 -0
- package/lib/Select/index.d.ts +4 -0
- package/lib/Select/index.js +131 -0
- package/lib/Select/modal.d.ts +30 -0
- 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 +119 -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 +3 -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 +70 -0
- package/lib/Upload/hooks/propsMaker.d.ts +2 -0
- package/lib/Upload/hooks/propsMaker.js +38 -0
- package/lib/Upload/index.d.ts +4 -0
- package/lib/Upload/index.js +109 -0
- package/lib/Upload/modal.d.ts +28 -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 +35 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +43 -0
- package/lib/modal.d.ts +15 -0
- package/package.json +81 -0
- package/public/index.html +19 -0
- package/scripts/rollup.config.js +75 -0
- package/scripts/webpack.config.js +76 -0
- package/src/Layout.tsx +61 -0
- package/src/app.tsx +33 -0
- 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/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 +26 -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 +49 -0
- package/src/components/Form/InitSet.tsx +12 -0
- package/src/components/Form/Label.tsx +50 -0
- package/src/components/Form/config.ts +40 -0
- package/src/components/Form/hooks/index.ts +42 -0
- package/src/components/Form/hooks/useHForm.ts +89 -0
- package/src/components/Form/hooks/useInitConfigData.tsx +100 -0
- package/src/components/Form/index.less +22 -0
- package/src/components/Form/index.tsx +61 -0
- package/src/components/Form/modal.ts +142 -0
- package/src/components/Input/ButtonInput.tsx +41 -0
- package/src/components/Input/InputNumber.tsx +5 -0
- package/src/components/Input/SelectInput.tsx +74 -0
- package/src/components/Input/defaultConfig.ts +8 -0
- package/src/components/Input/index.tsx +6 -0
- package/src/components/Input/modal.ts +31 -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 +54 -0
- package/src/components/Select/components/CheckBoxOption.tsx +14 -0
- package/src/components/Select/components/DropdownComponent.tsx +36 -0
- package/src/components/Select/components/NoFindItem.tsx +7 -0
- package/src/components/Select/components/NotFoundContent.tsx +25 -0
- package/src/components/Select/defaultConfig.tsx +23 -0
- package/src/components/Select/hooks/changeHooks.tsx +151 -0
- package/src/components/Select/hooks/norHooks.ts +63 -0
- package/src/components/Select/index.less +22 -0
- package/src/components/Select/index.tsx +120 -0
- package/src/components/Select/modal.ts +30 -0
- 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 +103 -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 +44 -0
- package/src/components/Upload/hooks/propsMaker.ts +20 -0
- package/src/components/Upload/index.tsx +85 -0
- package/src/components/Upload/modal.ts +31 -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 +21 -0
- 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/components/typings.d.ts +11 -0
- package/src/index.less +20 -0
- package/src/index.tsx +12 -0
- package/src/pages/Checkbox/index.tsx +15 -0
- package/src/pages/DatePicker/index.tsx +33 -0
- package/src/pages/Form/index.tsx +146 -0
- package/src/pages/Input/index.tsx +22 -0
- package/src/pages/Radio/index.tsx +18 -0
- package/src/pages/Select/index.tsx +57 -0
- package/src/pages/Switch/index.tsx +18 -0
- package/src/pages/Upload/index.tsx +14 -0
- package/src/routes.tsx +68 -0
- package/tsconfig.json +29 -0
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: true,
|
|
15
|
+
noChecked: false
|
|
16
|
+
},
|
|
17
|
+
valueSwitchMap: {
|
|
18
|
+
open: true,
|
|
19
|
+
close: false
|
|
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
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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 {
|
|
8
|
+
background-color: #f5f5f5;
|
|
9
|
+
}
|
|
10
|
+
.ant-hw-form-item-colon:after {
|
|
11
|
+
position: relative;
|
|
12
|
+
top: -0.5px;
|
|
13
|
+
margin: 0 8px 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
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 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;
|
|
6
|
+
export declare const HInput: ({ ...props }: import("antd").InputProps) => JSX.Element;
|
|
7
|
+
export declare const HSelectInput: ({ selectProps, value, onChange, valueName, ...props }: import("./Input/modal").HSelectInputProps) => JSX.Element;
|
|
8
|
+
export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Upload/modal").IUpLoadProps & import("react").RefAttributes<import("./Upload/modal").IUploadRefModal>>;
|
|
9
|
+
export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
|
|
10
|
+
export declare const HButtonInput: import("react").FC<import("./Input/modal").HButtonInputProps>;
|
|
11
|
+
export declare const HCheckBox: import("react").FC<import("./CheckboxGroup/modal").HCheckboxProps>;
|
|
12
|
+
export declare const HSwitch: import("react").FC<import("./Switch").HSwitchProps>;
|
|
13
|
+
export declare const HCheckboxGroup: (props: import("./Form/modal").HFormItemProps) => import("react").ReactElement<import("./Form/modal").ConnectResultProps, string | import("react").JSXElementConstructor<any>>;
|
|
14
|
+
export declare const HDatePicker: ({ value, onChange, showTime, format, ...props }: import("./TDPicker/modal").HDatePickerProps) => JSX.Element;
|
|
15
|
+
export declare const HRangePicker: ({ value, onChange, showTime, format, valueMap, ranges, name, ...props }: import("./TDPicker/modal").HRangePickerProps) => JSX.Element;
|
|
16
|
+
export declare const HRadioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("./RadioGroup").HRadioGroupProps) => JSX.Element;
|
|
17
|
+
export declare const HTimePicker: ({ value, format, onChange, ...props }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
|
|
18
|
+
export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
|
|
19
|
+
export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
|
|
20
|
+
export declare const HFormConfigProvider: import("react").FC<import("./Form/modal").IFormConfigContextProps>;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
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
|
+
|
|
8
|
+
var HSelect = config.default.select;
|
|
9
|
+
var HInput = config.default.input;
|
|
10
|
+
var HSelectInput = config.default.selectInput;
|
|
11
|
+
var HUpload = config.default.upload;
|
|
12
|
+
var HUrlUpload = config.default.urlUpload;
|
|
13
|
+
var HButtonInput = config.default.buttonInput;
|
|
14
|
+
var HCheckBox = config.default.checkBox;
|
|
15
|
+
var HSwitch = config.default["switch"];
|
|
16
|
+
var HCheckboxGroup = config.default.checkboxGroup;
|
|
17
|
+
var HDatePicker = config.default.datePicker;
|
|
18
|
+
var HRangePicker = config.default.rangePicker.Component;
|
|
19
|
+
var HRadioGroup = config.default.radioGroup;
|
|
20
|
+
var HTimePicker = config.default.timePicker;
|
|
21
|
+
var HInputNumber = config.default.inputNumber;
|
|
22
|
+
var HPageHandler = index$1.default;
|
|
23
|
+
var HFormConfigProvider = config.default.formConfigProvider;
|
|
24
|
+
|
|
25
|
+
exports.HForm = index.default;
|
|
26
|
+
exports.useHForm = useHForm.default;
|
|
27
|
+
exports.HButtonInput = HButtonInput;
|
|
28
|
+
exports.HCheckBox = HCheckBox;
|
|
29
|
+
exports.HCheckboxGroup = HCheckboxGroup;
|
|
30
|
+
exports.HDatePicker = HDatePicker;
|
|
31
|
+
exports.HFormConfigProvider = HFormConfigProvider;
|
|
32
|
+
exports.HInput = HInput;
|
|
33
|
+
exports.HInputNumber = HInputNumber;
|
|
34
|
+
exports.HPageHandler = HPageHandler;
|
|
35
|
+
exports.HRadioGroup = HRadioGroup;
|
|
36
|
+
exports.HRangePicker = HRangePicker;
|
|
37
|
+
exports.HSelect = HSelect;
|
|
38
|
+
exports.HSelectInput = HSelectInput;
|
|
39
|
+
exports.HSwitch = HSwitch;
|
|
40
|
+
exports.HTimePicker = HTimePicker;
|
|
41
|
+
exports.HUpload = HUpload;
|
|
42
|
+
exports.HUrlUpload = HUrlUpload;
|
|
43
|
+
// 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
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hw-component/form",
|
|
3
|
+
"version": "0.0.1-bate",
|
|
4
|
+
"description": "基于antd二次开发",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://gitee.com/hdj_wq/hw-components.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"author": "hdj",
|
|
11
|
+
"main": "lib/index.js",
|
|
12
|
+
"module": "es/index.js",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "rollup --config ./scripts/rollup.config.js",
|
|
15
|
+
"lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
|
|
16
|
+
"lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
|
|
17
|
+
"lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
|
|
18
|
+
"prepare": "husky install",
|
|
19
|
+
"start": "webpack-dev-server --config ./scripts/webpack.config.js",
|
|
20
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
21
|
+
},
|
|
22
|
+
"lint-staged": {
|
|
23
|
+
"**/*.less": "npm run lint:style",
|
|
24
|
+
"**/*.{js,jsx,ts,tsx}": "npm run lint:fix",
|
|
25
|
+
"**/*.{js,jsx,tsx,ts,less,md,json}": [
|
|
26
|
+
"prettier --write"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@ant-design/icons": "4.6.2",
|
|
31
|
+
"ahooks": "2.10.9",
|
|
32
|
+
"antd": "4.20.0",
|
|
33
|
+
"react": "16.14.0",
|
|
34
|
+
"react-dom": "17.0.2",
|
|
35
|
+
"react-router-dom": "^6.11.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@babel/core": "^7.21.8",
|
|
39
|
+
"@babel/plugin-transform-runtime": "^7.21.4",
|
|
40
|
+
"@babel/preset-env": "^7.21.5",
|
|
41
|
+
"@babel/preset-react": "^7.18.6",
|
|
42
|
+
"@babel/preset-typescript": "^7.21.5",
|
|
43
|
+
"@babel/runtime-corejs3": "^7.21.5",
|
|
44
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
45
|
+
"@rollup/plugin-commonjs": "^25.0.0",
|
|
46
|
+
"@rollup/plugin-inject": "^5.0.3",
|
|
47
|
+
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
48
|
+
"@rollup/plugin-url": "^8.0.1",
|
|
49
|
+
"@types/react": "17.0.14",
|
|
50
|
+
"@types/react-dom": "17.0.9",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
|
52
|
+
"@umijs/fabric": "^2.14.1",
|
|
53
|
+
"autoprefixer": "^10.4.14",
|
|
54
|
+
"babel-loader": "^9.1.2",
|
|
55
|
+
"css-loader": "^6.7.4",
|
|
56
|
+
"eslint": "^8.41.0",
|
|
57
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
58
|
+
"eslint-plugin-react": "^7.32.2",
|
|
59
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
60
|
+
"eslint-plugin-unicorn": "^47.0.0",
|
|
61
|
+
"html-webpack-plugin": "^5.5.1",
|
|
62
|
+
"husky": "^8.0.3",
|
|
63
|
+
"less": "^4.1.3",
|
|
64
|
+
"less-loader": "^11.1.0",
|
|
65
|
+
"lint-staged": "10.5.4",
|
|
66
|
+
"postcss": "^8.4.23",
|
|
67
|
+
"postcss-less": "^6.0.0",
|
|
68
|
+
"rollup": "^3.23.0",
|
|
69
|
+
"rollup-plugin-clear": "^2.0.7",
|
|
70
|
+
"rollup-plugin-postcss": "4.0.0",
|
|
71
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
72
|
+
"style-loader": "^3.3.3",
|
|
73
|
+
"stylelint": "13.13.1",
|
|
74
|
+
"typescript": "^5.0.4",
|
|
75
|
+
"webpack": "^5.83.1",
|
|
76
|
+
"webpack-cli": "^5.1.1",
|
|
77
|
+
"webpack-dev-server": "^4.15.0",
|
|
78
|
+
"webpackbar": "^5.0.2"
|
|
79
|
+
},
|
|
80
|
+
"cssPrefix": "hw"
|
|
81
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<meta name="viewport" content="webpack5">
|
|
8
|
+
<title>hw-components</title>
|
|
9
|
+
<style>
|
|
10
|
+
body{
|
|
11
|
+
margin: 0px;
|
|
12
|
+
padding: 0px;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="root"></div>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const clear = require("rollup-plugin-clear");
|
|
3
|
+
const { nodeResolve } = require("@rollup/plugin-node-resolve");
|
|
4
|
+
const { babel } = require("@rollup/plugin-babel");
|
|
5
|
+
const commonjs = require("@rollup/plugin-commonjs");
|
|
6
|
+
const typescript = require("rollup-plugin-typescript2");
|
|
7
|
+
const autoprefixer = require("autoprefixer");
|
|
8
|
+
const inject = require("@rollup/plugin-inject");
|
|
9
|
+
const url = require("@rollup/plugin-url");
|
|
10
|
+
const postcss = require("rollup-plugin-postcss");
|
|
11
|
+
const input = path.resolve(__dirname, "../src/components/index.tsx");
|
|
12
|
+
const outDir = path.resolve(__dirname, "../lib");
|
|
13
|
+
const esOutDir = path.resolve(__dirname, "../es");
|
|
14
|
+
module.exports = {
|
|
15
|
+
input,
|
|
16
|
+
output: [
|
|
17
|
+
{
|
|
18
|
+
dir: outDir,
|
|
19
|
+
format: "cjs",
|
|
20
|
+
footer: "// powered by h",
|
|
21
|
+
entryFileNames: "[name].js",
|
|
22
|
+
exports: "named",
|
|
23
|
+
preserveModules: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
dir: esOutDir,
|
|
27
|
+
format: "es",
|
|
28
|
+
banner: "// welcome to hoo hoo hoo",
|
|
29
|
+
footer: "// powered by hdj",
|
|
30
|
+
entryFileNames: "[name].js",
|
|
31
|
+
exports: "named",
|
|
32
|
+
preserveModules: true,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
plugins: [
|
|
36
|
+
clear({
|
|
37
|
+
targets: [outDir, esOutDir],
|
|
38
|
+
}),
|
|
39
|
+
url({
|
|
40
|
+
fileName: "[dirname][hash][extname]",
|
|
41
|
+
}),
|
|
42
|
+
postcss({
|
|
43
|
+
extract: "index.css",
|
|
44
|
+
plugins: [
|
|
45
|
+
autoprefixer({
|
|
46
|
+
overrideBrowserslist: [
|
|
47
|
+
"last 10 Chrome versions",
|
|
48
|
+
"last 5 Firefox versions",
|
|
49
|
+
"Safari >= 6",
|
|
50
|
+
"ie> 8",
|
|
51
|
+
],
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
54
|
+
}),
|
|
55
|
+
typescript({
|
|
56
|
+
tsconfigOverride: {
|
|
57
|
+
include: [`src/components/**/*`],
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
babel({
|
|
61
|
+
exclude: "node_modules/**",
|
|
62
|
+
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
63
|
+
babelHelpers: "runtime",
|
|
64
|
+
}),
|
|
65
|
+
inject({
|
|
66
|
+
React: "react",
|
|
67
|
+
}),
|
|
68
|
+
nodeResolve({
|
|
69
|
+
resolveOnly: ["node_modules"], //定义为模块
|
|
70
|
+
}),
|
|
71
|
+
commonjs({
|
|
72
|
+
include: ["node_modules"],
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
75
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
3
|
+
const WebpackBar = require("webpackbar");
|
|
4
|
+
const webpack = require("webpack");
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mode: "development",
|
|
8
|
+
devtool: "cheap-module-source-map",
|
|
9
|
+
entry: {
|
|
10
|
+
app: path.resolve(__dirname, "../src/index.tsx"),
|
|
11
|
+
},
|
|
12
|
+
output: {
|
|
13
|
+
path: path.resolve("dist"),
|
|
14
|
+
publicPath: "/",
|
|
15
|
+
clean: true, //每次打包前清空目录
|
|
16
|
+
},
|
|
17
|
+
devServer: {
|
|
18
|
+
port: 3000,
|
|
19
|
+
compress: true,
|
|
20
|
+
open: true,
|
|
21
|
+
hot: true,
|
|
22
|
+
historyApiFallback: {
|
|
23
|
+
disableDotRule: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
module: {
|
|
27
|
+
rules: [
|
|
28
|
+
{
|
|
29
|
+
test: /\.(tsx?|ts)$/,
|
|
30
|
+
loader: "babel-loader",
|
|
31
|
+
options: { cacheDirectory: true },
|
|
32
|
+
exclude: /node_modules/,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
test: /\.css$/,
|
|
36
|
+
use: ["style-loader", "css-loader"],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
test: /\.less$/,
|
|
40
|
+
exclude: /node_modules/,
|
|
41
|
+
use: [
|
|
42
|
+
"style-loader",
|
|
43
|
+
{
|
|
44
|
+
loader: "css-loader",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
loader: "less-loader",
|
|
48
|
+
options: {
|
|
49
|
+
lessOptions: {
|
|
50
|
+
javascriptEnabled: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
resolve: {
|
|
59
|
+
alias: {
|
|
60
|
+
"@": path.resolve(__dirname, "./src/components"),
|
|
61
|
+
},
|
|
62
|
+
extensions: [".tsx", ".ts", ".js", ".json"],
|
|
63
|
+
},
|
|
64
|
+
plugins: [
|
|
65
|
+
new HtmlWebpackPlugin({
|
|
66
|
+
template: path.resolve(__dirname, "../public/index.html"),
|
|
67
|
+
}),
|
|
68
|
+
new WebpackBar({
|
|
69
|
+
name: "hw components",
|
|
70
|
+
color: "#52c41a",
|
|
71
|
+
}),
|
|
72
|
+
new webpack.ProvidePlugin({
|
|
73
|
+
React: "react",
|
|
74
|
+
}),
|
|
75
|
+
],
|
|
76
|
+
};
|
package/src/Layout.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { Menu } from "antd";
|
|
3
|
+
import "./index.less";
|
|
4
|
+
import type { RouteModal } from "./routes";
|
|
5
|
+
import routes from "./routes";
|
|
6
|
+
import { Outlet, useNavigate, useLocation } from "react-router-dom";
|
|
7
|
+
|
|
8
|
+
const menuItem = (item: RouteModal) => {
|
|
9
|
+
const { name, path, children } = item;
|
|
10
|
+
if (!path) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (children) {
|
|
14
|
+
return (
|
|
15
|
+
<Menu.SubMenu title={name} key={path}>
|
|
16
|
+
{children.map((childItem) => {
|
|
17
|
+
return menuItem(childItem);
|
|
18
|
+
})}
|
|
19
|
+
</Menu.SubMenu>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return <Menu.Item key={path}>{name}</Menu.Item>;
|
|
23
|
+
};
|
|
24
|
+
export default () => {
|
|
25
|
+
const navigate = useNavigate();
|
|
26
|
+
const { pathname } = useLocation();
|
|
27
|
+
const [keys, setKeys] = useState(["/form/select"]);
|
|
28
|
+
const [openKey, setOpenKey] = useState(["/form"]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setKeys([pathname]);
|
|
31
|
+
const pathOpenKeys = pathname.split("/");
|
|
32
|
+
const openKeys = pathOpenKeys.map((path) => {
|
|
33
|
+
return "/" + path;
|
|
34
|
+
});
|
|
35
|
+
setOpenKey(openKeys);
|
|
36
|
+
}, [pathname]);
|
|
37
|
+
return (
|
|
38
|
+
<div className="layout">
|
|
39
|
+
<Menu
|
|
40
|
+
className="menu"
|
|
41
|
+
selectedKeys={keys}
|
|
42
|
+
openKeys={openKey}
|
|
43
|
+
onOpenChange={(openKeys) => {
|
|
44
|
+
setOpenKey(openKeys);
|
|
45
|
+
}}
|
|
46
|
+
onSelect={(e) => {
|
|
47
|
+
navigate(e.key);
|
|
48
|
+
}}
|
|
49
|
+
mode={"inline"}
|
|
50
|
+
theme="dark"
|
|
51
|
+
>
|
|
52
|
+
{routes.map((item) => {
|
|
53
|
+
return menuItem(item);
|
|
54
|
+
})}
|
|
55
|
+
</Menu>
|
|
56
|
+
<div className="body">
|
|
57
|
+
<Outlet />
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
package/src/app.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import routes from "./routes";
|
|
3
|
+
import {
|
|
4
|
+
createBrowserRouter,
|
|
5
|
+
Navigate,
|
|
6
|
+
RouterProvider,
|
|
7
|
+
useRouteError,
|
|
8
|
+
} from "react-router-dom";
|
|
9
|
+
import type { RouteObject } from "react-router";
|
|
10
|
+
import Layout from "./Layout";
|
|
11
|
+
const Error = () => {
|
|
12
|
+
const error = useRouteError();
|
|
13
|
+
if (error.status === 404) {
|
|
14
|
+
return <Navigate to="/form/select" replace />;
|
|
15
|
+
}
|
|
16
|
+
return <div>错误</div>;
|
|
17
|
+
};
|
|
18
|
+
const rootRoute = [
|
|
19
|
+
{
|
|
20
|
+
path: "/",
|
|
21
|
+
element: <Layout />,
|
|
22
|
+
errorElement: <Error />,
|
|
23
|
+
children: routes,
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
const router = () => {
|
|
27
|
+
return createBrowserRouter(rootRoute as RouteObject[]);
|
|
28
|
+
};
|
|
29
|
+
export default () => {
|
|
30
|
+
return (
|
|
31
|
+
<RouterProvider router={router()} fallbackElement={<p>Loading...</p>} />
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -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;
|