@hw-component/form 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintcache +1 -1
- package/es/Form/modal.d.ts +1 -1
- package/es/Select/index.js +8 -6
- package/es/Upload/UrlUpload/hooks.js +1 -3
- package/es/Upload/hooks/propsMaker.js +5 -2
- package/es/Upload/modal.d.ts +1 -1
- package/es/Upload/util.d.ts +1 -1
- package/es/Upload/util.js +3 -0
- package/es/index.css +1 -1
- package/lib/Form/modal.d.ts +1 -1
- package/lib/Select/index.js +8 -6
- package/lib/Upload/UrlUpload/hooks.js +1 -3
- package/lib/Upload/hooks/propsMaker.js +5 -2
- package/lib/Upload/modal.d.ts +1 -1
- package/lib/Upload/util.d.ts +1 -1
- package/lib/Upload/util.js +3 -0
- package/lib/index.css +1 -1
- package/package.json +1 -1
- package/src/components/Form/index.less +8 -8
- package/src/components/Form/modal.ts +1 -1
- package/src/components/Select/index.tsx +2 -1
- package/src/components/Upload/UrlUpload/hooks.ts +1 -4
- package/src/components/Upload/UrlUpload/index.tsx +1 -2
- package/src/components/Upload/hooks/change.ts +1 -1
- package/src/components/Upload/hooks/propsMaker.ts +6 -2
- package/src/components/Upload/index.tsx +1 -1
- package/src/components/Upload/modal.ts +1 -1
- package/src/components/Upload/util.ts +4 -1
- package/src/pages/Form/index.tsx +174 -189
- package/src/pages/Select/index.tsx +1 -0
package/lib/Select/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
13
13
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
14
14
|
require('core-js/modules/es.array.map.js');
|
|
15
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
var React = require('react');
|
|
16
17
|
var antd = require('antd');
|
|
17
18
|
var norHooks = require('./hooks/norHooks.js');
|
|
18
19
|
var changeHooks = require('./hooks/changeHooks.js');
|
|
@@ -22,7 +23,8 @@ var AllSelect = require('./components/AllSelect.js');
|
|
|
22
23
|
var index = require('../hooks/index.js');
|
|
23
24
|
var HFormConnect = require('../Form/HFormConnect.js');
|
|
24
25
|
|
|
25
|
-
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch"]
|
|
26
|
+
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch"],
|
|
27
|
+
_excluded2 = ["value", "label"];
|
|
26
28
|
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; }
|
|
27
29
|
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; }
|
|
28
30
|
var Option = antd.Select.Option;
|
|
@@ -133,16 +135,16 @@ var Index = function Index(_ref) {
|
|
|
133
135
|
}, props), {}, {
|
|
134
136
|
children: data === null || data === void 0 ? void 0 : data.map(function (item) {
|
|
135
137
|
var optionValue = item.value,
|
|
136
|
-
label = item.label
|
|
138
|
+
label = item.label,
|
|
139
|
+
oItem = _objectWithoutProperties(item, _excluded2);
|
|
137
140
|
var result = (filterProvider === null || filterProvider === void 0 ? void 0 : filterProvider(item)) || label;
|
|
138
141
|
var filter = _defineProperty({}, optionFilterProp, result);
|
|
139
|
-
return
|
|
142
|
+
return /*#__PURE__*/React.createElement(Option, _objectSpread(_objectSpread({}, oItem), {}, {
|
|
140
143
|
value: optionValue,
|
|
144
|
+
key: optionValue,
|
|
141
145
|
label: label,
|
|
142
146
|
mode: mode
|
|
143
|
-
}, filter),
|
|
144
|
-
children: render ? render(item, val) : label
|
|
145
|
-
}), optionValue);
|
|
147
|
+
}, filter), render ? render(item, val) : label);
|
|
146
148
|
})
|
|
147
149
|
}));
|
|
148
150
|
};
|
|
@@ -9,11 +9,9 @@ var useDefaultExFiles = function useDefaultExFiles(_ref) {
|
|
|
9
9
|
var _ref$mediaType = _ref.mediaType,
|
|
10
10
|
mediaType = _ref$mediaType === void 0 ? enums.MediaTypeEnum.img : _ref$mediaType,
|
|
11
11
|
exFiles = _ref.exFiles;
|
|
12
|
-
|
|
13
|
-
if (exFiles) {
|
|
12
|
+
if (exFiles || exFiles === null) {
|
|
14
13
|
return exFiles;
|
|
15
14
|
}
|
|
16
|
-
console.log(defaultExFiles, mediaType === enums.MediaTypeEnum.video, "mediaType");
|
|
17
15
|
return defaultExFiles[mediaType];
|
|
18
16
|
};
|
|
19
17
|
|
|
@@ -19,7 +19,6 @@ var useProps = function useProps(_ref) {
|
|
|
19
19
|
var configUploadProps = FormConfigProvider.useFormConfigContext("uploadProps");
|
|
20
20
|
var inputProps = {
|
|
21
21
|
request: request,
|
|
22
|
-
exFiles: exFiles,
|
|
23
22
|
maxSize: maxSize
|
|
24
23
|
};
|
|
25
24
|
var keys = Object.keys(inputProps);
|
|
@@ -30,7 +29,11 @@ var useProps = function useProps(_ref) {
|
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
31
|
});
|
|
33
|
-
|
|
32
|
+
var defaultExFiles = exFiles === undefined ? resultProps.exFiles : exFiles;
|
|
33
|
+
console.log(defaultExFiles);
|
|
34
|
+
return _objectSpread(_objectSpread({}, resultProps), {}, {
|
|
35
|
+
exFiles: defaultExFiles
|
|
36
|
+
});
|
|
34
37
|
};
|
|
35
38
|
|
|
36
39
|
exports.useProps = useProps;
|
package/lib/Upload/modal.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { MediaTypeEnum } from "@/components/Upload/enums";
|
|
|
6
6
|
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
7
7
|
import type React from "react";
|
|
8
8
|
export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
9
|
-
exFiles?: string[];
|
|
9
|
+
exFiles?: string[] | null;
|
|
10
10
|
request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
|
|
11
11
|
url: string;
|
|
12
12
|
}>;
|
package/lib/Upload/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UploadFile } from "antd/es/upload/interface";
|
|
2
2
|
export declare const getFileExt: (file: UploadFile) => string;
|
|
3
|
-
export declare const checkFileType: (file: UploadFile, exFiles?: string[]) => boolean;
|
|
3
|
+
export declare const checkFileType: (file: UploadFile, exFiles?: string[] | null) => boolean;
|
|
4
4
|
export declare const checkFileSize: (file: UploadFile, maxSize?: number) => boolean;
|
|
5
5
|
export declare const fileToBase64: (file: any) => Promise<unknown>;
|
package/lib/Upload/util.js
CHANGED
|
@@ -11,6 +11,9 @@ var getFileExt = function getFileExt(file) {
|
|
|
11
11
|
};
|
|
12
12
|
var checkFileType = function checkFileType(file) {
|
|
13
13
|
var exFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
14
|
+
if (!exFiles) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
14
17
|
var exName = getFileExt(file);
|
|
15
18
|
return exFiles.indexOf(exName) !== -1;
|
|
16
19
|
};
|
package/lib/index.css
CHANGED
package/package.json
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
.@{ant-prefix}-hw-form-item-colon {
|
|
18
18
|
text-align: left;
|
|
19
19
|
}
|
|
20
|
-
.@{ant-prefix}-hw-form-item-required{
|
|
20
|
+
.@{ant-prefix}-hw-form-item-required {
|
|
21
21
|
position: absolute;
|
|
22
22
|
left: -10px;
|
|
23
23
|
top: 0;
|
|
24
24
|
}
|
|
25
|
-
.@{ant-prefix}-hw-form-label-item{
|
|
25
|
+
.@{ant-prefix}-hw-form-label-item {
|
|
26
26
|
position: relative;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
.@{ant-prefix}-hw-form-item-colon {
|
|
53
53
|
text-align: left;
|
|
54
54
|
}
|
|
55
|
-
.@{ant-prefix}-hw-form-item-required{
|
|
55
|
+
.@{ant-prefix}-hw-form-item-required {
|
|
56
56
|
position: absolute;
|
|
57
57
|
left: -10px;
|
|
58
|
-
top:
|
|
58
|
+
top: 0;
|
|
59
59
|
}
|
|
60
|
-
.@{ant-prefix}-hw-form-label-item{
|
|
60
|
+
.@{ant-prefix}-hw-form-label-item {
|
|
61
61
|
position: relative;
|
|
62
62
|
}
|
|
63
63
|
.@{ant-prefix}-form-item-label > label {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
.@{ant-prefix}-hw-form-item-no-required{
|
|
68
|
+
.@{ant-prefix}-hw-form-item-no-required {
|
|
69
69
|
display: none;
|
|
70
70
|
}
|
|
71
71
|
.@{ant-prefix}-hw-form-item-required:before {
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
content: "*";
|
|
79
79
|
margin-right: 4px;
|
|
80
80
|
}
|
|
81
|
-
.@{ant-prefix}-hw-form-form-item{
|
|
82
|
-
.@{ant-prefix}-form-item-label{
|
|
81
|
+
.@{ant-prefix}-hw-form-form-item {
|
|
82
|
+
.@{ant-prefix}-form-item-label {
|
|
83
83
|
overflow:visible
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -34,7 +34,7 @@ import type { ForwardedRef } from "react";
|
|
|
34
34
|
import type { DataFnProvider } from "../modal";
|
|
35
35
|
import type { ColProps } from "antd/lib/grid/col";
|
|
36
36
|
import type { Gutter } from "antd/lib/grid/row";
|
|
37
|
-
import {IUrlUploadProps} from "../Upload/modal";
|
|
37
|
+
import type {IUrlUploadProps} from "../Upload/modal";
|
|
38
38
|
|
|
39
39
|
type RenderFun = (
|
|
40
40
|
props: HItemProps,
|
|
@@ -105,11 +105,12 @@ const Index: React.FC<HSelectProps> = ({
|
|
|
105
105
|
{...props}
|
|
106
106
|
>
|
|
107
107
|
{data?.map((item) => {
|
|
108
|
-
const { value: optionValue, label } = item;
|
|
108
|
+
const { value: optionValue, label ,...oItem} = item;
|
|
109
109
|
const result = filterProvider?.(item) || label;
|
|
110
110
|
const filter = { [optionFilterProp]: result };
|
|
111
111
|
return (
|
|
112
112
|
<Option
|
|
113
|
+
{...oItem}
|
|
113
114
|
value={optionValue}
|
|
114
115
|
key={optionValue}
|
|
115
116
|
label={label}
|
|
@@ -6,11 +6,8 @@ const defaultExFiles={
|
|
|
6
6
|
[MediaTypeEnum.audio]:["MP3"],
|
|
7
7
|
}
|
|
8
8
|
export const useDefaultExFiles=({mediaType=MediaTypeEnum.img,exFiles}: IUrlUploadProps)=>{
|
|
9
|
-
|
|
10
|
-
if (exFiles){
|
|
9
|
+
if (exFiles||exFiles===null){
|
|
11
10
|
return exFiles;
|
|
12
11
|
};
|
|
13
|
-
console.log(defaultExFiles,mediaType===MediaTypeEnum.video,"mediaType")
|
|
14
|
-
|
|
15
12
|
return defaultExFiles[mediaType]
|
|
16
13
|
}
|
|
@@ -26,11 +26,10 @@ const Index = ({
|
|
|
26
26
|
...props
|
|
27
27
|
}: IUrlUploadProps) => {
|
|
28
28
|
const { maxCount} = props;
|
|
29
|
-
const defaultExFiles: string[]=useDefaultExFiles({mediaType,exFiles});
|
|
29
|
+
const defaultExFiles: string[]|null=useDefaultExFiles({mediaType,exFiles});
|
|
30
30
|
const [url, setUrl] = useState("");
|
|
31
31
|
const [load, setLoad] = useState<boolean>(false);
|
|
32
32
|
const ref = useRef<IUploadRefModal | null>(null);
|
|
33
|
-
|
|
34
33
|
const onReady = () => {
|
|
35
34
|
const newFileList = [...value];
|
|
36
35
|
newFileList.push({
|
|
@@ -14,7 +14,7 @@ const checkFile = (item: UploadFile, oldFile: UploadFile[] = []) => {
|
|
|
14
14
|
const matchFile = (
|
|
15
15
|
newFile: UploadFile[],
|
|
16
16
|
oldFile: UploadFile[] = [],
|
|
17
|
-
exFiles?: string[],
|
|
17
|
+
exFiles?: string[]|null,
|
|
18
18
|
maxSize?: number
|
|
19
19
|
) => {
|
|
20
20
|
const newResultFileList: UploadFile[] = [];
|
|
@@ -5,7 +5,6 @@ export const useProps = ({ request, exFiles, maxSize }: IUpLoadProps) => {
|
|
|
5
5
|
const configUploadProps = useFormConfigContext("uploadProps");
|
|
6
6
|
const inputProps = {
|
|
7
7
|
request,
|
|
8
|
-
exFiles,
|
|
9
8
|
maxSize,
|
|
10
9
|
};
|
|
11
10
|
const keys = Object.keys(inputProps);
|
|
@@ -16,5 +15,10 @@ export const useProps = ({ request, exFiles, maxSize }: IUpLoadProps) => {
|
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
18
17
|
});
|
|
19
|
-
|
|
18
|
+
const defaultExFiles=exFiles===undefined?resultProps.exFiles:exFiles;
|
|
19
|
+
console.log(defaultExFiles)
|
|
20
|
+
return {
|
|
21
|
+
...resultProps,
|
|
22
|
+
exFiles:defaultExFiles
|
|
23
|
+
};
|
|
20
24
|
};
|
|
@@ -7,7 +7,7 @@ import type { addFormatItemModal } from "@/components/Form/modal";
|
|
|
7
7
|
import type React from "react";
|
|
8
8
|
|
|
9
9
|
export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
10
|
-
exFiles?: string[];
|
|
10
|
+
exFiles?: string[]|null;
|
|
11
11
|
request?: (
|
|
12
12
|
file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
|
|
13
13
|
) => Promise<{ url: string }>;
|
|
@@ -6,7 +6,10 @@ export const getFileExt = (file: UploadFile): string => {
|
|
|
6
6
|
return name.substring(index + 1).toUpperCase();
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export const checkFileType = (file: UploadFile, exFiles: string[] = []) => {
|
|
9
|
+
export const checkFileType = (file: UploadFile, exFiles: string[]|null = []) => {
|
|
10
|
+
if (!exFiles){
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
10
13
|
const exName: string = getFileExt(file);
|
|
11
14
|
return exFiles.indexOf(exName) !== -1;
|
|
12
15
|
};
|