@hw-component/form 0.0.5 → 0.0.6-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/es/CheckboxGroup/CheckBox/index.d.ts +2 -5
- package/es/CheckboxGroup/CheckBox/index.js +16 -10
- package/es/CheckboxGroup/hooks.d.ts +1 -1
- package/es/CheckboxGroup/hooks.js +33 -37
- package/es/CheckboxGroup/index.d.ts +2 -3
- package/es/CheckboxGroup/index.js +71 -27
- package/es/CheckboxGroup/modal.d.ts +13 -0
- package/es/DialogForm/DrawerForm/Footer.d.ts +7 -0
- package/es/DialogForm/DrawerForm/Footer.js +27 -0
- package/es/DialogForm/DrawerForm/Title.d.ts +3 -0
- package/es/DialogForm/DrawerForm/Title.js +21 -0
- package/es/DialogForm/DrawerForm/index.d.ts +3 -0
- package/es/DialogForm/DrawerForm/index.js +137 -0
- package/es/DialogForm/ModalForm.d.ts +3 -0
- package/es/DialogForm/ModalForm.js +118 -0
- package/es/DialogForm/hooks.d.ts +16 -0
- package/es/DialogForm/hooks.js +148 -0
- package/es/DialogForm/modal.d.ts +33 -0
- package/es/Form/Context/FormConfigProvider.d.ts +5 -0
- package/es/Form/Context/FormConfigProvider.js +48 -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 +92 -0
- package/es/Form/FormItem/Helper.d.ts +7 -0
- package/es/Form/FormItem/Helper.js +26 -0
- package/es/Form/FormItem/RegularFormItem.d.ts +3 -0
- package/es/Form/FormItem/RegularFormItem.js +24 -0
- package/es/Form/FormItem/UpFormItem.d.ts +3 -0
- package/es/Form/FormItem/UpFormItem.js +42 -0
- package/es/Form/FormItem/hooks.d.ts +8 -0
- package/es/Form/FormItem/hooks.js +38 -0
- package/es/Form/FormItem/index.d.ts +3 -0
- package/es/Form/FormItem/index.js +21 -0
- package/es/Form/HFormConnect.d.ts +5 -0
- package/es/Form/HFormConnect.js +68 -0
- package/es/Form/InitSet.d.ts +2 -0
- package/es/Form/InitSet.js +16 -0
- package/es/Form/Label.d.ts +10 -0
- package/es/Form/Label.js +49 -0
- package/es/Form/config.d.ts +29 -0
- package/es/Form/config.js +45 -0
- package/es/Form/hooks/index.d.ts +16 -0
- package/es/Form/hooks/index.js +157 -0
- package/es/Form/hooks/useDefaultRender.d.ts +3 -0
- package/es/Form/hooks/useDefaultRender.js +48 -0
- package/es/Form/hooks/useHForm.d.ts +3 -0
- package/es/Form/hooks/useHForm.js +193 -0
- package/es/Form/hooks/useInitConfigData.d.ts +8 -0
- package/es/Form/hooks/useInitConfigData.js +169 -0
- package/es/Form/index.d.ts +3 -0
- package/es/Form/index.js +102 -0
- package/es/Form/modal.d.ts +123 -0
- package/es/Input/ButtonInput.d.ts +2 -2
- package/es/Input/ButtonInput.js +34 -20
- package/es/Input/ColorInput/Picker.d.ts +3 -0
- package/es/Input/ColorInput/Picker.js +22 -0
- package/es/Input/ColorInput/data.d.ts +1 -0
- package/es/Input/ColorInput/data.js +5 -0
- package/es/Input/ColorInput/index.d.ts +3 -0
- package/es/Input/ColorInput/index.js +94 -0
- package/es/Input/InputNumber.d.ts +0 -1
- package/es/Input/InputNumber.js +17 -8
- package/es/Input/SelectInput.d.ts +2 -1
- package/es/Input/SelectInput.js +51 -23
- package/es/Input/defaultConfig.js +2 -2
- package/es/Input/index.d.ts +0 -1
- package/es/Input/index.js +18 -8
- package/es/Input/modal.d.ts +30 -0
- package/es/PageHandler/ErrorComponent.d.ts +3 -0
- package/es/PageHandler/ErrorComponent.js +38 -0
- package/es/PageHandler/LoadingComponent.d.ts +2 -0
- package/es/PageHandler/LoadingComponent.js +19 -0
- package/es/PageHandler/index.d.ts +4 -0
- package/es/PageHandler/index.js +26 -0
- package/es/PageHandler/modal.d.ts +6 -0
- package/es/RadioGroup/index.d.ts +2 -3
- package/es/RadioGroup/index.js +27 -13
- package/es/Select/components/AllSelect.d.ts +3 -4
- package/es/Select/components/AllSelect.js +37 -20
- package/es/Select/components/CheckBoxOption.js +8 -6
- package/es/Select/components/DropdownComponent.js +18 -13
- package/es/Select/components/NoFindItem.d.ts +0 -1
- package/es/Select/components/NoFindItem.js +7 -6
- package/es/Select/components/NotFoundContent.d.ts +0 -1
- package/es/Select/components/NotFoundContent.js +25 -22
- package/es/Select/defaultConfig.d.ts +0 -1
- package/es/Select/defaultConfig.js +8 -9
- package/es/Select/hooks/changeHooks.js +26 -25
- package/es/Select/hooks/norHooks.d.ts +10 -3
- package/es/Select/hooks/norHooks.js +56 -18
- package/es/Select/index.d.ts +2 -3
- package/es/Select/index.js +65 -37
- package/es/Select/modal.d.ts +9 -1
- package/es/Select/utils.js +14 -16
- package/es/Submit/index.d.ts +9 -0
- package/es/Submit/index.js +54 -0
- package/es/Switch/index.d.ts +4 -3
- package/es/Switch/index.js +37 -19
- package/es/TDPicker/RangePicker.d.ts +8 -0
- package/es/TDPicker/RangePicker.js +125 -0
- package/es/TDPicker/TimePicker.d.ts +3 -0
- package/es/TDPicker/TimePicker.js +44 -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 +47 -0
- package/es/TDPicker/modal.d.ts +35 -0
- package/es/TextArea/index.d.ts +3 -0
- package/es/TextArea/index.js +30 -0
- package/es/Upload/Btn.d.ts +3 -0
- package/es/Upload/Btn.js +36 -0
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +9 -0
- package/es/Upload/MediaTypeEle/TypeEle.js +42 -0
- package/es/Upload/MediaTypeEle/index.d.ts +3 -0
- package/es/Upload/MediaTypeEle/index.js +36 -0
- package/es/Upload/Preview/index.d.ts +5 -0
- package/es/Upload/Preview/index.js +22 -0
- package/es/Upload/UrlUpload/index.d.ts +3 -0
- package/es/Upload/UrlUpload/index.js +133 -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 +107 -0
- package/es/Upload/hooks/customRequest.d.ts +3 -0
- package/es/Upload/hooks/customRequest.js +131 -0
- package/es/Upload/hooks/propsMaker.d.ts +2 -0
- package/es/Upload/hooks/propsMaker.js +36 -0
- package/es/Upload/index.d.ts +3 -0
- package/es/Upload/index.js +145 -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 +5 -13
- package/es/config.js +57 -10
- package/{lib/hooks/useChangeOptions.d.ts → es/hooks/index.d.ts} +3 -0
- package/es/hooks/index.js +74 -0
- package/es/index.css +42 -1
- package/es/index.d.ts +26 -11
- package/es/index.js +33 -13
- package/es/modal.d.ts +16 -0
- package/lib/CheckboxGroup/CheckBox/index.d.ts +2 -5
- package/lib/CheckboxGroup/CheckBox/index.js +13 -7
- package/lib/CheckboxGroup/hooks.d.ts +1 -1
- package/lib/CheckboxGroup/hooks.js +31 -35
- package/lib/CheckboxGroup/index.d.ts +2 -3
- package/lib/CheckboxGroup/index.js +69 -25
- package/lib/CheckboxGroup/modal.d.ts +13 -0
- package/lib/DialogForm/DrawerForm/Footer.d.ts +7 -0
- package/lib/DialogForm/DrawerForm/Footer.js +30 -0
- package/lib/DialogForm/DrawerForm/Title.d.ts +3 -0
- package/lib/DialogForm/DrawerForm/Title.js +24 -0
- package/lib/DialogForm/DrawerForm/index.d.ts +3 -0
- package/lib/DialogForm/DrawerForm/index.js +140 -0
- package/lib/DialogForm/ModalForm.d.ts +3 -0
- package/lib/DialogForm/ModalForm.js +121 -0
- package/lib/DialogForm/hooks.d.ts +16 -0
- package/lib/DialogForm/hooks.js +152 -0
- package/lib/DialogForm/modal.d.ts +33 -0
- package/lib/Form/Context/FormConfigProvider.d.ts +5 -0
- package/lib/Form/Context/FormConfigProvider.js +52 -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 +95 -0
- package/lib/Form/FormItem/Helper.d.ts +7 -0
- package/lib/Form/FormItem/Helper.js +29 -0
- package/lib/Form/FormItem/RegularFormItem.d.ts +3 -0
- package/lib/Form/FormItem/RegularFormItem.js +27 -0
- package/lib/Form/FormItem/UpFormItem.d.ts +3 -0
- package/lib/Form/FormItem/UpFormItem.js +45 -0
- package/lib/Form/FormItem/hooks.d.ts +8 -0
- package/lib/Form/FormItem/hooks.js +41 -0
- package/lib/Form/FormItem/index.d.ts +3 -0
- package/lib/Form/FormItem/index.js +24 -0
- package/lib/Form/HFormConnect.d.ts +5 -0
- package/lib/Form/HFormConnect.js +71 -0
- package/lib/Form/InitSet.d.ts +2 -0
- package/lib/Form/InitSet.js +19 -0
- package/lib/Form/Label.d.ts +10 -0
- package/lib/Form/Label.js +52 -0
- package/lib/Form/config.d.ts +29 -0
- package/lib/Form/config.js +49 -0
- package/lib/Form/hooks/index.d.ts +16 -0
- package/lib/Form/hooks/index.js +161 -0
- package/lib/Form/hooks/useDefaultRender.d.ts +3 -0
- package/lib/Form/hooks/useDefaultRender.js +49 -0
- package/lib/Form/hooks/useHForm.d.ts +3 -0
- package/lib/Form/hooks/useHForm.js +196 -0
- package/lib/Form/hooks/useInitConfigData.d.ts +8 -0
- package/lib/Form/hooks/useInitConfigData.js +172 -0
- package/lib/Form/index.d.ts +3 -0
- package/lib/Form/index.js +105 -0
- package/lib/Form/modal.d.ts +123 -0
- package/lib/Input/ButtonInput.d.ts +2 -2
- package/lib/Input/ButtonInput.js +32 -18
- package/lib/Input/ColorInput/Picker.d.ts +3 -0
- package/lib/Input/ColorInput/Picker.js +25 -0
- package/lib/Input/ColorInput/data.d.ts +1 -0
- package/lib/Input/ColorInput/data.js +6 -0
- package/lib/Input/ColorInput/index.d.ts +3 -0
- package/lib/Input/ColorInput/index.js +97 -0
- package/lib/Input/InputNumber.d.ts +0 -1
- package/lib/Input/InputNumber.js +14 -5
- package/lib/Input/SelectInput.d.ts +2 -1
- package/lib/Input/SelectInput.js +50 -21
- package/lib/Input/index.d.ts +0 -1
- package/lib/Input/index.js +16 -6
- package/lib/Input/modal.d.ts +30 -0
- package/lib/PageHandler/ErrorComponent.d.ts +3 -0
- package/lib/PageHandler/ErrorComponent.js +41 -0
- package/lib/PageHandler/LoadingComponent.d.ts +2 -0
- package/lib/PageHandler/LoadingComponent.js +22 -0
- package/lib/PageHandler/index.d.ts +4 -0
- package/lib/PageHandler/index.js +29 -0
- package/lib/PageHandler/modal.d.ts +6 -0
- package/lib/RadioGroup/index.d.ts +2 -3
- package/lib/RadioGroup/index.js +25 -11
- package/lib/Select/components/AllSelect.d.ts +3 -4
- package/lib/Select/components/AllSelect.js +35 -18
- package/lib/Select/components/CheckBoxOption.js +6 -4
- package/lib/Select/components/DropdownComponent.js +16 -11
- package/lib/Select/components/NoFindItem.d.ts +0 -1
- package/lib/Select/components/NoFindItem.js +5 -4
- package/lib/Select/components/NotFoundContent.d.ts +0 -1
- package/lib/Select/components/NotFoundContent.js +23 -20
- package/lib/Select/defaultConfig.d.ts +0 -1
- package/lib/Select/defaultConfig.js +6 -7
- package/lib/Select/hooks/changeHooks.js +24 -23
- package/lib/Select/hooks/norHooks.d.ts +10 -3
- package/lib/Select/hooks/norHooks.js +53 -15
- package/lib/Select/index.d.ts +2 -3
- package/lib/Select/index.js +62 -34
- package/lib/Select/modal.d.ts +9 -1
- package/lib/Select/utils.js +12 -14
- package/lib/Submit/index.d.ts +9 -0
- package/lib/Submit/index.js +57 -0
- package/lib/Switch/index.d.ts +4 -3
- package/lib/Switch/index.js +34 -16
- package/lib/TDPicker/RangePicker.d.ts +8 -0
- package/lib/TDPicker/RangePicker.js +128 -0
- package/lib/TDPicker/TimePicker.d.ts +3 -0
- package/lib/TDPicker/TimePicker.js +47 -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 +50 -0
- package/lib/TDPicker/modal.d.ts +35 -0
- package/lib/TextArea/index.d.ts +3 -0
- package/lib/TextArea/index.js +33 -0
- package/lib/Upload/Btn.d.ts +3 -0
- package/lib/Upload/Btn.js +39 -0
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +9 -0
- package/lib/Upload/MediaTypeEle/TypeEle.js +45 -0
- package/lib/Upload/MediaTypeEle/index.d.ts +3 -0
- package/lib/Upload/MediaTypeEle/index.js +39 -0
- package/lib/Upload/Preview/index.d.ts +5 -0
- package/lib/Upload/Preview/index.js +25 -0
- package/lib/Upload/UrlUpload/index.d.ts +3 -0
- package/lib/Upload/UrlUpload/index.js +136 -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 +108 -0
- package/lib/Upload/hooks/customRequest.d.ts +3 -0
- package/lib/Upload/hooks/customRequest.js +132 -0
- package/lib/Upload/hooks/propsMaker.d.ts +2 -0
- package/lib/Upload/hooks/propsMaker.js +37 -0
- package/lib/Upload/index.d.ts +3 -0
- package/lib/Upload/index.js +148 -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 +5 -13
- package/lib/config.js +55 -8
- package/{es/hooks/useChangeOptions.d.ts → lib/hooks/index.d.ts} +3 -0
- package/lib/hooks/index.js +77 -0
- package/lib/index.css +42 -1
- package/lib/index.d.ts +26 -11
- package/lib/index.js +52 -23
- package/lib/modal.d.ts +16 -0
- package/package.json +17 -7
- package/scripts/rollup.config.js +14 -4
- package/scripts/webpack.config.js +5 -8
- package/src/Layout.tsx +4 -4
- package/src/components/CheckboxGroup/CheckBox/index.tsx +7 -7
- package/src/components/CheckboxGroup/hooks.ts +12 -13
- package/src/components/CheckboxGroup/index.tsx +40 -7
- package/src/components/CheckboxGroup/{modal.d.ts → modal.ts} +4 -1
- package/src/components/DialogForm/DrawerForm/Footer.tsx +20 -0
- package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
- package/src/components/DialogForm/DrawerForm/index.tsx +95 -0
- package/src/components/DialogForm/ModalForm.tsx +77 -0
- package/src/components/DialogForm/hooks.ts +109 -0
- package/src/components/DialogForm/modal.ts +36 -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 +76 -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 +40 -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 +43 -0
- package/src/components/Form/hooks/index.ts +115 -0
- package/src/components/Form/hooks/useDefaultRender.tsx +42 -0
- package/src/components/Form/hooks/useHForm.ts +164 -0
- package/src/components/Form/hooks/useInitConfigData.tsx +194 -0
- package/src/components/Form/index.less +22 -0
- package/src/components/Form/index.tsx +85 -0
- package/src/components/Form/modal.ts +179 -0
- package/src/components/Input/ButtonInput.tsx +11 -5
- package/src/components/Input/ColorInput/Picker.tsx +18 -0
- package/src/components/Input/ColorInput/data.ts +102 -0
- package/src/components/Input/ColorInput/index.less +10 -0
- package/src/components/Input/ColorInput/index.tsx +48 -0
- package/src/components/Input/SelectInput.tsx +33 -3
- package/src/components/Input/modal.ts +36 -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 +8 -4
- package/src/components/Select/components/AllSelect.tsx +28 -17
- package/src/components/Select/components/DropdownComponent.tsx +1 -0
- package/src/components/Select/components/NotFoundContent.tsx +1 -1
- package/src/components/Select/hooks/changeHooks.tsx +6 -2
- package/src/components/Select/hooks/norHooks.ts +33 -6
- package/src/components/Select/index.less +20 -4
- package/src/components/Select/index.tsx +25 -11
- package/src/components/Select/modal.ts +17 -8
- package/src/components/Submit/index.tsx +46 -0
- package/src/components/Switch/index.tsx +14 -9
- package/src/components/TDPicker/RangePicker.tsx +109 -0
- package/src/components/TDPicker/TimePicker.tsx +25 -0
- package/src/components/TDPicker/hooks.ts +150 -0
- package/src/components/TDPicker/index.tsx +28 -0
- package/src/components/TDPicker/modal.ts +46 -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 +119 -0
- package/src/components/Upload/modal.ts +33 -0
- package/src/components/Upload/util.ts +27 -0
- package/src/components/config.ts +39 -8
- package/src/components/hooks/index.ts +53 -0
- package/src/components/index.tsx +30 -11
- package/src/components/modal.ts +20 -0
- package/src/components/styles/index.less +3 -1
- package/src/components/styles/local.less +1 -1
- package/src/components/typings.d.ts +0 -5
- package/src/pages/Checkbox/index.tsx +4 -5
- package/src/pages/DatePicker/index.tsx +20 -2
- package/src/pages/DrawerForm/index.tsx +127 -0
- package/src/pages/Form/index.tsx +203 -0
- package/src/pages/Input/index.tsx +2 -0
- package/src/pages/ModalForm/index.tsx +147 -0
- package/src/pages/Select/index.tsx +6 -3
- package/src/pages/Switch/index.tsx +1 -1
- package/src/pages/Upload/index.tsx +14 -0
- package/src/routes.tsx +24 -0
- package/tsconfig.json +1 -1
- package/es/DatePicker/RangePicker.d.ts +0 -4
- package/es/DatePicker/RangePicker.js +0 -23
- package/es/DatePicker/index.d.ts +0 -4
- package/es/DatePicker/index.js +0 -39
- package/es/TimePicker/index.d.ts +0 -2
- package/es/hooks/useChangeOptions.js +0 -25
- package/es/hooks/useClassName.d.ts +0 -1
- package/es/hooks/useClassName.js +0 -15
- package/lib/DatePicker/RangePicker.d.ts +0 -4
- package/lib/DatePicker/RangePicker.js +0 -26
- package/lib/DatePicker/index.d.ts +0 -4
- package/lib/DatePicker/index.js +0 -42
- package/lib/TimePicker/index.d.ts +0 -2
- package/lib/hooks/useChangeOptions.js +0 -26
- package/lib/hooks/useClassName.d.ts +0 -1
- package/lib/hooks/useClassName.js +0 -16
- package/src/components/DatePicker/RangePicker.tsx +0 -19
- package/src/components/DatePicker/index.tsx +0 -38
- package/src/components/DatePicker/modal.d.ts +0 -17
- package/src/components/Input/modal.d.ts +0 -26
- package/src/components/TimePicker/index.tsx +0 -1
- package/src/components/hooks/useChangeOptions.ts +0 -22
- package/src/components/hooks/useClassName.ts +0 -9
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
|
+
import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
4
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
5
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
6
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
7
|
+
import 'core-js/modules/es.regexp.to-string.js';
|
|
8
|
+
import 'core-js/modules/es.string.trim.js';
|
|
9
|
+
import 'core-js/modules/es.array.map.js';
|
|
10
|
+
import 'core-js/modules/es.array.from.js';
|
|
11
|
+
import 'core-js/modules/es.string.iterator.js';
|
|
12
|
+
import 'core-js/modules/es.function.name.js';
|
|
13
|
+
import 'core-js/modules/es.object.keys.js';
|
|
14
|
+
import 'core-js/modules/es.symbol.js';
|
|
15
|
+
import 'core-js/modules/es.array.filter.js';
|
|
16
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
17
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
18
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
19
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
20
|
+
import { Space, message } from 'antd';
|
|
21
|
+
import Input from 'antd/es/input/Input';
|
|
22
|
+
import HUpload from '../index.js';
|
|
23
|
+
import TypeEle from '../MediaTypeEle/TypeEle.js';
|
|
24
|
+
import { useState, useRef } from 'react';
|
|
25
|
+
|
|
26
|
+
var _excluded = ["placeholder", "value", "onChange", "mediaType"];
|
|
27
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
|
+
var Index = function Index(_ref) {
|
|
30
|
+
var _ref$placeholder = _ref.placeholder,
|
|
31
|
+
placeholder = _ref$placeholder === void 0 ? "请输入文件地址" : _ref$placeholder,
|
|
32
|
+
_ref$value = _ref.value,
|
|
33
|
+
value = _ref$value === void 0 ? [] : _ref$value,
|
|
34
|
+
onChange = _ref.onChange,
|
|
35
|
+
mediaType = _ref.mediaType,
|
|
36
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
37
|
+
var _useState = useState(""),
|
|
38
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
+
url = _useState2[0],
|
|
40
|
+
setUrl = _useState2[1];
|
|
41
|
+
var _useState3 = useState(false),
|
|
42
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
|
+
load = _useState4[0],
|
|
44
|
+
setLoad = _useState4[1];
|
|
45
|
+
var ref = useRef(null);
|
|
46
|
+
var onReady = function onReady() {
|
|
47
|
+
var newFileList = _toConsumableArray(value);
|
|
48
|
+
newFileList.push({
|
|
49
|
+
url: url,
|
|
50
|
+
uid: new Date().valueOf().toString(),
|
|
51
|
+
name: url,
|
|
52
|
+
fileName: url,
|
|
53
|
+
thumbUrl: url,
|
|
54
|
+
response: {
|
|
55
|
+
url: url
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
onChange === null || onChange === void 0 || onChange(newFileList);
|
|
59
|
+
setUrl("");
|
|
60
|
+
setLoad(false);
|
|
61
|
+
};
|
|
62
|
+
var onError = function onError() {
|
|
63
|
+
message.error("文件错误!");
|
|
64
|
+
setUrl("");
|
|
65
|
+
setLoad(false);
|
|
66
|
+
};
|
|
67
|
+
var onBlur = function onBlur(e) {
|
|
68
|
+
if (e.target.value.trim() === "") {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
setLoad(true);
|
|
72
|
+
};
|
|
73
|
+
var onPaste = function onPaste(e) {
|
|
74
|
+
var _ref$current;
|
|
75
|
+
var files = e.clipboardData.files;
|
|
76
|
+
if (!files.length) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
var newFileList = Array.from(files).map(function (item) {
|
|
81
|
+
var name = item.name,
|
|
82
|
+
size = item.size,
|
|
83
|
+
type = item.type;
|
|
84
|
+
return {
|
|
85
|
+
name: name,
|
|
86
|
+
size: size,
|
|
87
|
+
status: "uploading",
|
|
88
|
+
uid: new Date().valueOf().toString(),
|
|
89
|
+
originFileObj: item,
|
|
90
|
+
type: type
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.change({
|
|
94
|
+
fileList: newFileList,
|
|
95
|
+
file: newFileList[0]
|
|
96
|
+
});
|
|
97
|
+
setUrl("");
|
|
98
|
+
setLoad(false);
|
|
99
|
+
};
|
|
100
|
+
return jsxs(Space, {
|
|
101
|
+
direction: "vertical",
|
|
102
|
+
style: {
|
|
103
|
+
width: "100%"
|
|
104
|
+
},
|
|
105
|
+
size: "middle",
|
|
106
|
+
children: [jsx(Input, {
|
|
107
|
+
placeholder: placeholder,
|
|
108
|
+
onBlur: onBlur,
|
|
109
|
+
value: url,
|
|
110
|
+
onPaste: onPaste,
|
|
111
|
+
onChange: function onChange(e) {
|
|
112
|
+
setUrl(e.target.value);
|
|
113
|
+
}
|
|
114
|
+
}), jsx(HUpload, _objectSpread(_objectSpread({}, props), {}, {
|
|
115
|
+
ref: ref,
|
|
116
|
+
value: value,
|
|
117
|
+
onChange: onChange
|
|
118
|
+
})), load && jsx("div", {
|
|
119
|
+
style: {
|
|
120
|
+
display: "none"
|
|
121
|
+
},
|
|
122
|
+
children: jsx(TypeEle, {
|
|
123
|
+
url: url,
|
|
124
|
+
mediaType: mediaType,
|
|
125
|
+
onReady: onReady,
|
|
126
|
+
onError: onError
|
|
127
|
+
})
|
|
128
|
+
})]
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export { Index as default };
|
|
133
|
+
// powered by hdj
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
var MediaTypeEnum;
|
|
3
|
+
(function (MediaTypeEnum) {
|
|
4
|
+
MediaTypeEnum[MediaTypeEnum["video"] = 0] = "video";
|
|
5
|
+
MediaTypeEnum[MediaTypeEnum["audio"] = 1] = "audio";
|
|
6
|
+
MediaTypeEnum[MediaTypeEnum["img"] = 2] = "img";
|
|
7
|
+
})(MediaTypeEnum || (MediaTypeEnum = {}));
|
|
8
|
+
|
|
9
|
+
export { MediaTypeEnum };
|
|
10
|
+
// powered by hdj
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IUpLoadProps } from "../modal";
|
|
2
|
+
import type { UploadChangeParam, UploadFile } from "antd/lib/upload/interface";
|
|
3
|
+
export declare const useChange: ({ value, onChange, maxCount, request, exFiles, maxSize, }: IUpLoadProps) => (info: UploadChangeParam<UploadFile>) => void;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
4
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
5
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
6
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
7
|
+
import 'core-js/modules/es.object.keys.js';
|
|
8
|
+
import 'core-js/modules/es.symbol.js';
|
|
9
|
+
import 'core-js/modules/es.array.filter.js';
|
|
10
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
11
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
12
|
+
import { useRequest } from 'ahooks';
|
|
13
|
+
import { useCustomRequest } from './customRequest.js';
|
|
14
|
+
import { checkFileSize, checkFileType } from '../util.js';
|
|
15
|
+
import { message } from 'antd';
|
|
16
|
+
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
var checkFile = function checkFile(item) {
|
|
20
|
+
var oldFile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
21
|
+
return oldFile.every(function (oldItem) {
|
|
22
|
+
return item.uid !== oldItem.uid;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var matchFile = function matchFile(newFile) {
|
|
26
|
+
var oldFile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
27
|
+
var exFiles = arguments.length > 2 ? arguments[2] : undefined;
|
|
28
|
+
var maxSize = arguments.length > 3 ? arguments[3] : undefined;
|
|
29
|
+
var newResultFileList = [];
|
|
30
|
+
var addFile = [];
|
|
31
|
+
var errList = [];
|
|
32
|
+
newFile.forEach(function (item) {
|
|
33
|
+
if (!checkFileSize(item, maxSize)) {
|
|
34
|
+
return errList.push(new Error("超出限制大小!"));
|
|
35
|
+
}
|
|
36
|
+
if (!checkFileType(item, exFiles)) {
|
|
37
|
+
return errList.push(new Error("文件格式错误!"));
|
|
38
|
+
}
|
|
39
|
+
if (checkFile(item, oldFile)) {
|
|
40
|
+
addFile.push(item);
|
|
41
|
+
newResultFileList.push(_objectSpread(_objectSpread({}, item), {}, {
|
|
42
|
+
status: "uploading"
|
|
43
|
+
}));
|
|
44
|
+
} else {
|
|
45
|
+
newResultFileList.push(item);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
addFile: addFile,
|
|
50
|
+
fileList: newResultFileList,
|
|
51
|
+
errList: errList
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
var useChange = function useChange(_ref) {
|
|
55
|
+
var value = _ref.value,
|
|
56
|
+
onChange = _ref.onChange,
|
|
57
|
+
_ref$maxCount = _ref.maxCount,
|
|
58
|
+
maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
|
|
59
|
+
request = _ref.request,
|
|
60
|
+
exFiles = _ref.exFiles,
|
|
61
|
+
maxSize = _ref.maxSize;
|
|
62
|
+
var customRequest = useCustomRequest({
|
|
63
|
+
request: request,
|
|
64
|
+
onChange: onChange,
|
|
65
|
+
value: value
|
|
66
|
+
});
|
|
67
|
+
var _useRequest = useRequest( /*#__PURE__*/function () {
|
|
68
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
|
|
69
|
+
var fileList, _matchFile, addFile, newFileList, errList;
|
|
70
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
71
|
+
while (1) switch (_context.prev = _context.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
fileList = _ref2.fileList;
|
|
74
|
+
if (!(fileList.length > maxCount)) {
|
|
75
|
+
_context.next = 4;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
message.error("超出最多文件限制!");
|
|
79
|
+
return _context.abrupt("return");
|
|
80
|
+
case 4:
|
|
81
|
+
_matchFile = matchFile(fileList, value, exFiles, maxSize), addFile = _matchFile.addFile, newFileList = _matchFile.fileList, errList = _matchFile.errList;
|
|
82
|
+
if (errList.length) {
|
|
83
|
+
message.error(errList[0].message);
|
|
84
|
+
}
|
|
85
|
+
onChange === null || onChange === void 0 || onChange(newFileList);
|
|
86
|
+
customRequest(addFile);
|
|
87
|
+
case 8:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context.stop();
|
|
90
|
+
}
|
|
91
|
+
}, _callee);
|
|
92
|
+
}));
|
|
93
|
+
return function (_x) {
|
|
94
|
+
return _ref3.apply(this, arguments);
|
|
95
|
+
};
|
|
96
|
+
}(), {
|
|
97
|
+
manual: true,
|
|
98
|
+
debounceInterval: 100
|
|
99
|
+
}),
|
|
100
|
+
run = _useRequest.run;
|
|
101
|
+
return function (info) {
|
|
102
|
+
run(info);
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { useChange };
|
|
107
|
+
// powered by hdj
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.object.keys.js';
|
|
3
|
+
import 'core-js/modules/es.symbol.js';
|
|
4
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
5
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
7
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
8
|
+
import 'core-js/modules/es.array.filter.js';
|
|
9
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
10
|
+
import 'core-js/modules/es.array.map.js';
|
|
11
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
12
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
13
|
+
import { useMemo, useEffect } from 'react';
|
|
14
|
+
import { message } from 'antd';
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
+
var subReq = /*#__PURE__*/function () {
|
|
19
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
20
|
+
var request, file, _yield$request, url;
|
|
21
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
|
+
while (1) switch (_context.prev = _context.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
request = _ref.request, file = _ref.file;
|
|
25
|
+
if (request) {
|
|
26
|
+
_context.next = 3;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
return _context.abrupt("return", {
|
|
30
|
+
url: "",
|
|
31
|
+
status: "done"
|
|
32
|
+
});
|
|
33
|
+
case 3:
|
|
34
|
+
_context.prev = 3;
|
|
35
|
+
_context.next = 6;
|
|
36
|
+
return request(file);
|
|
37
|
+
case 6:
|
|
38
|
+
_yield$request = _context.sent;
|
|
39
|
+
url = _yield$request.url;
|
|
40
|
+
return _context.abrupt("return", {
|
|
41
|
+
url: url,
|
|
42
|
+
status: "done"
|
|
43
|
+
});
|
|
44
|
+
case 11:
|
|
45
|
+
_context.prev = 11;
|
|
46
|
+
_context.t0 = _context["catch"](3);
|
|
47
|
+
message.error(_context.t0.message);
|
|
48
|
+
return _context.abrupt("return", {
|
|
49
|
+
url: "",
|
|
50
|
+
status: "error"
|
|
51
|
+
});
|
|
52
|
+
case 15:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context.stop();
|
|
55
|
+
}
|
|
56
|
+
}, _callee, null, [[3, 11]]);
|
|
57
|
+
}));
|
|
58
|
+
return function subReq(_x) {
|
|
59
|
+
return _ref2.apply(this, arguments);
|
|
60
|
+
};
|
|
61
|
+
}();
|
|
62
|
+
var fileListProvider = function fileListProvider(changeFile, files) {
|
|
63
|
+
var status = changeFile.status,
|
|
64
|
+
url = changeFile.url,
|
|
65
|
+
uid = changeFile.uid;
|
|
66
|
+
if (status === "error") {
|
|
67
|
+
return files === null || files === void 0 ? void 0 : files.filter(function (item) {
|
|
68
|
+
return item.uid !== uid;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return files === null || files === void 0 ? void 0 : files.map(function (item) {
|
|
72
|
+
var resultUrl = url || item.thumbUrl;
|
|
73
|
+
if (item.uid === uid) {
|
|
74
|
+
item.status = status;
|
|
75
|
+
item.response = {
|
|
76
|
+
url: resultUrl
|
|
77
|
+
};
|
|
78
|
+
return item;
|
|
79
|
+
}
|
|
80
|
+
return item;
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
var useCustomRequest = function useCustomRequest(_ref3) {
|
|
84
|
+
var value = _ref3.value,
|
|
85
|
+
request = _ref3.request,
|
|
86
|
+
onChange = _ref3.onChange;
|
|
87
|
+
var valObj = useMemo(function () {
|
|
88
|
+
return {
|
|
89
|
+
value: value
|
|
90
|
+
};
|
|
91
|
+
}, []);
|
|
92
|
+
useEffect(function () {
|
|
93
|
+
valObj.value = value;
|
|
94
|
+
}, [value]);
|
|
95
|
+
var sendFile = /*#__PURE__*/function () {
|
|
96
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(file) {
|
|
97
|
+
var uid, result, fileList;
|
|
98
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
99
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
100
|
+
case 0:
|
|
101
|
+
uid = file.uid;
|
|
102
|
+
_context2.next = 3;
|
|
103
|
+
return subReq({
|
|
104
|
+
request: request,
|
|
105
|
+
file: file
|
|
106
|
+
});
|
|
107
|
+
case 3:
|
|
108
|
+
result = _context2.sent;
|
|
109
|
+
fileList = fileListProvider(_objectSpread(_objectSpread({}, result), {}, {
|
|
110
|
+
uid: uid
|
|
111
|
+
}), valObj.value);
|
|
112
|
+
onChange === null || onChange === void 0 || onChange(fileList || []);
|
|
113
|
+
case 6:
|
|
114
|
+
case "end":
|
|
115
|
+
return _context2.stop();
|
|
116
|
+
}
|
|
117
|
+
}, _callee2);
|
|
118
|
+
}));
|
|
119
|
+
return function sendFile(_x2) {
|
|
120
|
+
return _ref4.apply(this, arguments);
|
|
121
|
+
};
|
|
122
|
+
}();
|
|
123
|
+
return function (fileList) {
|
|
124
|
+
fileList.forEach(function (item) {
|
|
125
|
+
sendFile(item);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export { useCustomRequest };
|
|
131
|
+
// powered by hdj
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.symbol.js';
|
|
3
|
+
import 'core-js/modules/es.array.filter.js';
|
|
4
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
5
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
7
|
+
import 'core-js/modules/es.object.keys.js';
|
|
8
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
9
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
10
|
+
import { useFormConfigContext } from '../../Form/Context/FormConfigProvider.js';
|
|
11
|
+
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
var useProps = function useProps(_ref) {
|
|
15
|
+
var request = _ref.request,
|
|
16
|
+
exFiles = _ref.exFiles,
|
|
17
|
+
maxSize = _ref.maxSize;
|
|
18
|
+
var configUploadProps = useFormConfigContext("uploadProps");
|
|
19
|
+
var inputProps = {
|
|
20
|
+
request: request,
|
|
21
|
+
exFiles: exFiles,
|
|
22
|
+
maxSize: maxSize
|
|
23
|
+
};
|
|
24
|
+
var keys = Object.keys(inputProps);
|
|
25
|
+
var resultProps = _objectSpread({}, configUploadProps);
|
|
26
|
+
keys.forEach(function (key) {
|
|
27
|
+
if (inputProps[key]) {
|
|
28
|
+
resultProps[key] = inputProps[key];
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return resultProps;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { useProps };
|
|
36
|
+
// powered by hdj
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.object.keys.js';
|
|
3
|
+
import 'core-js/modules/es.symbol.js';
|
|
4
|
+
import 'core-js/modules/es.array.filter.js';
|
|
5
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
6
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
8
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
11
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
12
|
+
import 'core-js/modules/es.number.constructor.js';
|
|
13
|
+
import 'core-js/modules/es.function.name.js';
|
|
14
|
+
import 'core-js/modules/es.array.map.js';
|
|
15
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
16
|
+
import React, { useState, useImperativeHandle, useMemo } from 'react';
|
|
17
|
+
import { useProps } from './hooks/propsMaker.js';
|
|
18
|
+
import Preview from './Preview/index.js';
|
|
19
|
+
import { useChange } from './hooks/change.js';
|
|
20
|
+
import { Upload } from 'antd';
|
|
21
|
+
import Btn from './Btn.js';
|
|
22
|
+
import HFormConnect from '../Form/HFormConnect.js';
|
|
23
|
+
|
|
24
|
+
var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat"];
|
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
var Index = function Index(_ref, ref) {
|
|
28
|
+
var _ref$value = _ref.value,
|
|
29
|
+
value = _ref$value === void 0 ? [] : _ref$value,
|
|
30
|
+
onChange = _ref.onChange,
|
|
31
|
+
_ref$listType = _ref.listType,
|
|
32
|
+
listType = _ref$listType === void 0 ? "picture-card" : _ref$listType,
|
|
33
|
+
exFiles = _ref.exFiles,
|
|
34
|
+
_ref$maxCount = _ref.maxCount,
|
|
35
|
+
maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
|
|
36
|
+
_ref$maxRowNum = _ref.maxRowNum,
|
|
37
|
+
maxRowNum = _ref$maxRowNum === void 0 ? 3 : _ref$maxRowNum,
|
|
38
|
+
onPreview = _ref.onPreview,
|
|
39
|
+
request = _ref.request,
|
|
40
|
+
maxSize = _ref.maxSize,
|
|
41
|
+
addFormat = _ref.addFormat,
|
|
42
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
|
+
var matchProps = useProps({
|
|
44
|
+
request: request,
|
|
45
|
+
exFiles: exFiles,
|
|
46
|
+
maxSize: maxSize
|
|
47
|
+
});
|
|
48
|
+
var _useState = useState({}),
|
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
+
previewModal = _useState2[0],
|
|
51
|
+
setPreviewModal = _useState2[1];
|
|
52
|
+
var change = useChange(_objectSpread(_objectSpread({}, matchProps), {}, {
|
|
53
|
+
value: value,
|
|
54
|
+
maxCount: maxCount,
|
|
55
|
+
onChange: onChange
|
|
56
|
+
}));
|
|
57
|
+
useImperativeHandle(ref, function () {
|
|
58
|
+
return {
|
|
59
|
+
change: change
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
var contentStyle = useMemo(function () {
|
|
63
|
+
if (listType !== "picture-card") {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
width: 112 * maxRowNum,
|
|
68
|
+
maxWidth: "100%"
|
|
69
|
+
};
|
|
70
|
+
}, [maxRowNum, listType]);
|
|
71
|
+
var preview = function preview(file) {
|
|
72
|
+
if (onPreview) {
|
|
73
|
+
onPreview(file);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
setPreviewModal({
|
|
77
|
+
visible: true,
|
|
78
|
+
file: file
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
var maxNum = maxCount === 1 ? maxCount : Number.MAX_VALUE;
|
|
82
|
+
var visible = previewModal.visible,
|
|
83
|
+
previewFile = previewModal.file;
|
|
84
|
+
addFormat === null || addFormat === void 0 || addFormat({
|
|
85
|
+
float: {
|
|
86
|
+
inputValue: function inputValue(item, initValue) {
|
|
87
|
+
var _item$name = item.name,
|
|
88
|
+
name = _item$name === void 0 ? "" : _item$name;
|
|
89
|
+
var initFileList = initValue[name] || [];
|
|
90
|
+
var relInitFileList = typeof initFileList === "string" ? [initFileList] : initFileList;
|
|
91
|
+
var fileList = relInitFileList.map(function (url, index) {
|
|
92
|
+
return {
|
|
93
|
+
name: url,
|
|
94
|
+
response: {
|
|
95
|
+
url: url
|
|
96
|
+
},
|
|
97
|
+
status: "done",
|
|
98
|
+
uid: "init-".concat(index),
|
|
99
|
+
thumbUrl: url
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
return _defineProperty({}, name, fileList);
|
|
103
|
+
},
|
|
104
|
+
outputValue: function outputValue(item, _outputValue) {
|
|
105
|
+
var _item$name2 = item.name,
|
|
106
|
+
valueName = _item$name2 === void 0 ? "" : _item$name2;
|
|
107
|
+
var _outputValue$valueNam = _outputValue[valueName],
|
|
108
|
+
itemVal = _outputValue$valueNam === void 0 ? [] : _outputValue$valueNam;
|
|
109
|
+
var urls = itemVal.map(function (fileItem) {
|
|
110
|
+
return fileItem.response.url;
|
|
111
|
+
});
|
|
112
|
+
return _defineProperty({}, valueName, maxCount === 1 ? urls[0] : urls);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return jsxs("div", {
|
|
117
|
+
style: contentStyle,
|
|
118
|
+
children: [jsx(Upload, _objectSpread(_objectSpread({
|
|
119
|
+
listType: listType,
|
|
120
|
+
maxCount: maxNum,
|
|
121
|
+
fileList: value,
|
|
122
|
+
onPreview: preview,
|
|
123
|
+
onChange: change,
|
|
124
|
+
beforeUpload: function beforeUpload() {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}, props), {}, {
|
|
128
|
+
children: jsx(Btn, {
|
|
129
|
+
value: value,
|
|
130
|
+
maxCount: maxCount,
|
|
131
|
+
listType: listType
|
|
132
|
+
})
|
|
133
|
+
})), jsx(Preview, {
|
|
134
|
+
visible: visible,
|
|
135
|
+
file: previewFile,
|
|
136
|
+
onCancel: function onCancel() {
|
|
137
|
+
setPreviewModal({});
|
|
138
|
+
}
|
|
139
|
+
})]
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
var HUpload = HFormConnect( /*#__PURE__*/React.forwardRef(Index));
|
|
143
|
+
|
|
144
|
+
export { HUpload as default };
|
|
145
|
+
// powered by hdj
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { UploadProps } from "antd";
|
|
2
|
+
import type { UploadFile } from "antd/es/upload/interface";
|
|
3
|
+
import type { BeforeUploadFileType, RcFile } from "rc-upload/lib/interface";
|
|
4
|
+
import type { UploadChangeParam } from "antd/lib/upload/interface";
|
|
5
|
+
import type { MediaTypeEnum } from "@/components/Upload/enums";
|
|
6
|
+
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
7
|
+
export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
8
|
+
exFiles?: string[];
|
|
9
|
+
request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
|
|
10
|
+
url: string;
|
|
11
|
+
}>;
|
|
12
|
+
errorType?: "alert" | "show";
|
|
13
|
+
onChange?: (fileList: UploadFile[]) => void;
|
|
14
|
+
value?: UploadFile[];
|
|
15
|
+
maxRowNum?: number;
|
|
16
|
+
maxSize?: number;
|
|
17
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface IMediaTypeEleProps {
|
|
20
|
+
file?: UploadFile;
|
|
21
|
+
onReady?: VoidFunction;
|
|
22
|
+
onError?: VoidFunction;
|
|
23
|
+
}
|
|
24
|
+
export interface IUploadRefModal {
|
|
25
|
+
change: (info: UploadChangeParam<UploadFile>) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface IUrlUploadProps extends IUpLoadProps {
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
mediaType?: MediaTypeEnum;
|
|
30
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UploadFile } from "antd/es/upload/interface";
|
|
2
|
+
export declare const getFileExt: (file: UploadFile) => string;
|
|
3
|
+
export declare const checkFileType: (file: UploadFile, exFiles?: string[]) => boolean;
|
|
4
|
+
export declare const checkFileSize: (file: UploadFile, maxSize?: number) => boolean;
|
|
5
|
+
export declare const fileToBase64: (file: any) => Promise<unknown>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.function.name.js';
|
|
3
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
4
|
+
import 'core-js/modules/es.promise.js';
|
|
5
|
+
|
|
6
|
+
var getFileExt = function getFileExt(file) {
|
|
7
|
+
var name = file.name;
|
|
8
|
+
var index = name.lastIndexOf(".");
|
|
9
|
+
return name.substring(index + 1).toUpperCase();
|
|
10
|
+
};
|
|
11
|
+
var checkFileType = function checkFileType(file) {
|
|
12
|
+
var exFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
13
|
+
var exName = getFileExt(file);
|
|
14
|
+
return exFiles.indexOf(exName) !== -1;
|
|
15
|
+
};
|
|
16
|
+
var checkFileSize = function checkFileSize(file) {
|
|
17
|
+
var maxSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
18
|
+
var _file$size = file.size,
|
|
19
|
+
size = _file$size === void 0 ? 0 : _file$size;
|
|
20
|
+
return size <= maxSize;
|
|
21
|
+
};
|
|
22
|
+
var fileToBase64 = function fileToBase64(file) {
|
|
23
|
+
return new Promise(function (resolve) {
|
|
24
|
+
var reader = new FileReader();
|
|
25
|
+
reader.readAsDataURL(file === null || file === void 0 ? void 0 : file.originFileObj);
|
|
26
|
+
reader.onload = function (e) {
|
|
27
|
+
var _e$target;
|
|
28
|
+
resolve((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.result);
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { checkFileSize, checkFileType, fileToBase64, getFileExt };
|
|
34
|
+
// powered by hdj
|