@hw-component/form 1.9.77 → 1.9.79

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.
@@ -63,7 +63,8 @@ var useTimePickerValue = function useTimePickerValue(_ref4) {
63
63
  var value = _ref4.value,
64
64
  format = _ref4.format;
65
65
  return useMemo(function () {
66
- if (!value || !format) {
66
+ var valStr = value === null || value === void 0 ? void 0 : value.toString();
67
+ if (!valStr || !format) {
67
68
  return value;
68
69
  }
69
70
  if (formatMap[format]) {
@@ -1,3 +1,3 @@
1
1
  import type { IUpLoadProps } from "./modal";
2
- declare const _default: ({ value, maxCount, listType }: IUpLoadProps) => JSX.Element;
2
+ declare const _default: ({ value, maxCount, listType, children }: IUpLoadProps) => JSX.Element;
3
3
  export default _default;
package/es/Upload/Btn.js CHANGED
@@ -1,14 +1,15 @@
1
1
  // welcome to hoo hoo hoo
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { PlusOutlined, UploadOutlined } from '@ant-design/icons';
4
- import { useMemo } from 'react';
4
+ import React, { useMemo } from 'react';
5
5
  import { Button } from 'antd';
6
6
 
7
7
  var Btn = (function (_ref) {
8
8
  var value = _ref.value,
9
9
  _ref$maxCount = _ref.maxCount,
10
10
  maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
11
- listType = _ref.listType;
11
+ listType = _ref.listType,
12
+ children = _ref.children;
12
13
  var len = (value === null || value === void 0 ? void 0 : value.length) || 0;
13
14
  var text = useMemo(function () {
14
15
  if (len === maxCount) {
@@ -26,8 +27,20 @@ var Btn = (function (_ref) {
26
27
  })]
27
28
  });
28
29
  }
30
+ var loading = useMemo(function () {
31
+ return value === null || value === void 0 ? void 0 : value.some(function (_ref2) {
32
+ var status = _ref2.status;
33
+ return status === "uploading";
34
+ });
35
+ }, [value]);
36
+ if (children) {
37
+ return /*#__PURE__*/React.cloneElement(children, {
38
+ loading: loading
39
+ });
40
+ }
29
41
  return jsx(Button, {
30
42
  icon: jsx(UploadOutlined, {}),
43
+ loading: loading,
31
44
  children: text
32
45
  });
33
46
  });
@@ -11,7 +11,7 @@ import { Upload } from 'antd';
11
11
  import Btn from './Btn.js';
12
12
  import HFormConnect from '../Form/HFormConnect.js';
13
13
 
14
- var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat", "thumbUrl", "hideAddBtn"];
14
+ var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat", "thumbUrl", "hideAddBtn", "children"];
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  var Index = function Index(_ref, ref) {
@@ -31,6 +31,7 @@ var Index = function Index(_ref, ref) {
31
31
  addFormat = _ref.addFormat,
32
32
  thumbUrl = _ref.thumbUrl,
33
33
  hideAddBtn = _ref.hideAddBtn,
34
+ children = _ref.children,
34
35
  props = _objectWithoutProperties(_ref, _excluded);
35
36
  var matchProps = useProps({
36
37
  request: request,
@@ -62,6 +63,9 @@ var Index = function Index(_ref, ref) {
62
63
  };
63
64
  }, [maxRowNum, listType]);
64
65
  var preview = function preview(file) {
66
+ if (onPreview === null) {
67
+ return;
68
+ }
65
69
  if (onPreview) {
66
70
  onPreview(file);
67
71
  return;
@@ -110,10 +114,11 @@ var Index = function Index(_ref, ref) {
110
114
  }
111
115
  });
112
116
  var relVal = Array.isArray(value) ? value : [];
117
+ var upListType = listType === null ? undefined : listType;
113
118
  return jsxs("div", {
114
119
  style: contentStyle,
115
120
  children: [jsx(Upload, _objectSpread(_objectSpread({
116
- listType: listType,
121
+ listType: upListType,
117
122
  maxCount: maxNum,
118
123
  fileList: relVal,
119
124
  onPreview: preview,
@@ -125,7 +130,8 @@ var Index = function Index(_ref, ref) {
125
130
  children: hideAddBtn ? null : jsx(Btn, {
126
131
  value: relVal,
127
132
  maxCount: maxCount,
128
- listType: listType
133
+ listType: upListType,
134
+ children: children
129
135
  })
130
136
  })), jsx(Preview, {
131
137
  visible: visible,
@@ -5,7 +5,8 @@ import type { UploadChangeParam } from "antd/lib/upload/interface";
5
5
  import type { MediaTypeEnum } from "@/components/Upload/enums";
6
6
  import type { addFormatItemModal } from "@/components/Form/modal";
7
7
  import type React from "react";
8
- export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
8
+ import { UploadListType } from "antd/lib/upload/interface";
9
+ export interface IUpLoadProps extends Omit<UploadProps, "onChange" | "listType" | "onPreview"> {
9
10
  exFiles?: string[] | null;
10
11
  request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
11
12
  url: string;
@@ -19,6 +20,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
19
20
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
20
21
  thumbUrl?: string;
21
22
  hideAddBtn?: boolean;
23
+ listType?: UploadListType | null;
24
+ onPreview?: UploadProps["onPreview"] | null;
22
25
  }
23
26
  export interface IMediaTypeEleProps {
24
27
  file?: UploadFile;
@@ -64,7 +64,8 @@ var useTimePickerValue = function useTimePickerValue(_ref4) {
64
64
  var value = _ref4.value,
65
65
  format = _ref4.format;
66
66
  return React.useMemo(function () {
67
- if (!value || !format) {
67
+ var valStr = value === null || value === void 0 ? void 0 : value.toString();
68
+ if (!valStr || !format) {
68
69
  return value;
69
70
  }
70
71
  if (formatMap[format]) {
@@ -1,3 +1,3 @@
1
1
  import type { IUpLoadProps } from "./modal";
2
- declare const _default: ({ value, maxCount, listType }: IUpLoadProps) => JSX.Element;
2
+ declare const _default: ({ value, maxCount, listType, children }: IUpLoadProps) => JSX.Element;
3
3
  export default _default;
package/lib/Upload/Btn.js CHANGED
@@ -11,7 +11,8 @@ var Btn = (function (_ref) {
11
11
  var value = _ref.value,
12
12
  _ref$maxCount = _ref.maxCount,
13
13
  maxCount = _ref$maxCount === void 0 ? 1 : _ref$maxCount,
14
- listType = _ref.listType;
14
+ listType = _ref.listType,
15
+ children = _ref.children;
15
16
  var len = (value === null || value === void 0 ? void 0 : value.length) || 0;
16
17
  var text = React.useMemo(function () {
17
18
  if (len === maxCount) {
@@ -29,8 +30,20 @@ var Btn = (function (_ref) {
29
30
  })]
30
31
  });
31
32
  }
33
+ var loading = React.useMemo(function () {
34
+ return value === null || value === void 0 ? void 0 : value.some(function (_ref2) {
35
+ var status = _ref2.status;
36
+ return status === "uploading";
37
+ });
38
+ }, [value]);
39
+ if (children) {
40
+ return /*#__PURE__*/React.cloneElement(children, {
41
+ loading: loading
42
+ });
43
+ }
32
44
  return jsxRuntime.jsx(antd.Button, {
33
45
  icon: jsxRuntime.jsx(icons.UploadOutlined, {}),
46
+ loading: loading,
34
47
  children: text
35
48
  });
36
49
  });
@@ -14,7 +14,7 @@ var antd = require('antd');
14
14
  var Btn = require('./Btn.js');
15
15
  var HFormConnect = require('../Form/HFormConnect.js');
16
16
 
17
- var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat", "thumbUrl", "hideAddBtn"];
17
+ var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat", "thumbUrl", "hideAddBtn", "children"];
18
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
20
  var Index = function Index(_ref, ref) {
@@ -34,6 +34,7 @@ var Index = function Index(_ref, ref) {
34
34
  addFormat = _ref.addFormat,
35
35
  thumbUrl = _ref.thumbUrl,
36
36
  hideAddBtn = _ref.hideAddBtn,
37
+ children = _ref.children,
37
38
  props = _objectWithoutProperties(_ref, _excluded);
38
39
  var matchProps = propsMaker.useProps({
39
40
  request: request,
@@ -65,6 +66,9 @@ var Index = function Index(_ref, ref) {
65
66
  };
66
67
  }, [maxRowNum, listType]);
67
68
  var preview = function preview(file) {
69
+ if (onPreview === null) {
70
+ return;
71
+ }
68
72
  if (onPreview) {
69
73
  onPreview(file);
70
74
  return;
@@ -113,10 +117,11 @@ var Index = function Index(_ref, ref) {
113
117
  }
114
118
  });
115
119
  var relVal = Array.isArray(value) ? value : [];
120
+ var upListType = listType === null ? undefined : listType;
116
121
  return jsxRuntime.jsxs("div", {
117
122
  style: contentStyle,
118
123
  children: [jsxRuntime.jsx(antd.Upload, _objectSpread(_objectSpread({
119
- listType: listType,
124
+ listType: upListType,
120
125
  maxCount: maxNum,
121
126
  fileList: relVal,
122
127
  onPreview: preview,
@@ -128,7 +133,8 @@ var Index = function Index(_ref, ref) {
128
133
  children: hideAddBtn ? null : jsxRuntime.jsx(Btn.default, {
129
134
  value: relVal,
130
135
  maxCount: maxCount,
131
- listType: listType
136
+ listType: upListType,
137
+ children: children
132
138
  })
133
139
  })), jsxRuntime.jsx(index.default, {
134
140
  visible: visible,
@@ -5,7 +5,8 @@ import type { UploadChangeParam } from "antd/lib/upload/interface";
5
5
  import type { MediaTypeEnum } from "@/components/Upload/enums";
6
6
  import type { addFormatItemModal } from "@/components/Form/modal";
7
7
  import type React from "react";
8
- export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
8
+ import { UploadListType } from "antd/lib/upload/interface";
9
+ export interface IUpLoadProps extends Omit<UploadProps, "onChange" | "listType" | "onPreview"> {
9
10
  exFiles?: string[] | null;
10
11
  request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
11
12
  url: string;
@@ -19,6 +20,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
19
20
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
20
21
  thumbUrl?: string;
21
22
  hideAddBtn?: boolean;
23
+ listType?: UploadListType | null;
24
+ onPreview?: UploadProps["onPreview"] | null;
22
25
  }
23
26
  export interface IMediaTypeEleProps {
24
27
  file?: UploadFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.9.77",
3
+ "version": "1.9.79",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -88,7 +88,8 @@ export const useTimePickerValue = ({
88
88
  format,
89
89
  }: UseTimePickerValParams) => {
90
90
  return useMemo(() => {
91
- if (!value || !format) {
91
+ const valStr=value?.toString()
92
+ if (!valStr || !format) {
92
93
  return value;
93
94
  }
94
95
  if (formatMap[format]) {
@@ -1,9 +1,9 @@
1
1
  import { PlusOutlined, UploadOutlined } from "@ant-design/icons";
2
2
  import type { IUpLoadProps } from "./modal";
3
- import { useMemo } from "react";
3
+ import React, { useMemo } from "react";
4
4
  import { Button } from "antd";
5
5
 
6
- export default ({ value, maxCount = 1, listType }: IUpLoadProps) => {
6
+ export default ({ value, maxCount = 1, listType ,children}: IUpLoadProps) => {
7
7
  const len = value?.length || 0;
8
8
  const text = useMemo(() => {
9
9
  if (len === maxCount) {
@@ -11,7 +11,6 @@ export default ({ value, maxCount = 1, listType }: IUpLoadProps) => {
11
11
  }
12
12
  return "上传";
13
13
  }, [len, maxCount]);
14
-
15
14
  if (listType === "picture-card") {
16
15
  return (
17
16
  <div>
@@ -20,5 +19,13 @@ export default ({ value, maxCount = 1, listType }: IUpLoadProps) => {
20
19
  </div>
21
20
  );
22
21
  }
23
- return <Button icon={<UploadOutlined />}>{text}</Button>;
22
+ const loading=useMemo(()=>{
23
+ return value?.some(({status})=>{
24
+ return status==="uploading";
25
+ })
26
+ },[value]);
27
+ if (children){
28
+ return React.cloneElement<any>((children as any),{loading});
29
+ }
30
+ return <Button icon={<UploadOutlined />} loading={loading}>{text}</Button>;
24
31
  };
@@ -4,6 +4,7 @@ import type { RcFile } from "antd/lib/upload";
4
4
  import { useEffect, useMemo } from "react";
5
5
  import type { UploadFileStatus } from "antd/es/upload/interface";
6
6
  import { message } from "antd";
7
+ import {useRequest} from "ahooks";
7
8
 
8
9
  interface SubReqParamsModal {
9
10
  request?: IUpLoadProps["request"];
@@ -73,7 +74,6 @@ export const useCustomRequest = ({
73
74
  useEffect(() => {
74
75
  valObj.value = value;
75
76
  }, [value]); //强制同步避免闭包问题
76
-
77
77
  const sendFile = async (file: RcFile) => {
78
78
  const { uid } = file;
79
79
  const result = await subReq({ request, file });
@@ -22,6 +22,7 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
22
22
  addFormat,
23
23
  thumbUrl,
24
24
  hideAddBtn,
25
+ children,
25
26
  ...props
26
27
  },
27
28
  ref
@@ -48,6 +49,9 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
48
49
  }, [maxRowNum, listType]);
49
50
 
50
51
  const preview = (file) => {
52
+ if (onPreview===null){
53
+ return;
54
+ }
51
55
  if (onPreview) {
52
56
  onPreview(file);
53
57
  return;
@@ -97,10 +101,11 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
97
101
  },
98
102
  });
99
103
  const relVal = Array.isArray(value) ? value : [];
104
+ const upListType=listType===null?undefined:listType;
100
105
  return (
101
106
  <div style={contentStyle}>
102
107
  <Upload
103
- listType={listType}
108
+ listType={upListType}
104
109
  maxCount={maxNum}
105
110
  fileList={relVal}
106
111
  onPreview={preview}
@@ -111,7 +116,9 @@ const Index: React.ForwardRefRenderFunction<IUploadRefModal, IUpLoadProps> = (
111
116
  {...props}
112
117
  >
113
118
  {hideAddBtn ? null : (
114
- <Btn value={relVal} maxCount={maxCount} listType={listType} />
119
+ <Btn value={relVal} maxCount={maxCount} listType={upListType} >
120
+ {children}
121
+ </Btn>
115
122
  )}
116
123
  </Upload>
117
124
  <Preview
@@ -5,8 +5,9 @@ import type { UploadChangeParam } from "antd/lib/upload/interface";
5
5
  import type { MediaTypeEnum } from "@/components/Upload/enums";
6
6
  import type { addFormatItemModal } from "@/components/Form/modal";
7
7
  import type React from "react";
8
+ import {UploadListType} from "antd/lib/upload/interface";
8
9
 
9
- export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
10
+ export interface IUpLoadProps extends Omit<UploadProps, "onChange"|"listType"|"onPreview"> {
10
11
  exFiles?: string[] | null;
11
12
  request?: (
12
13
  file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
@@ -19,6 +20,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
19
20
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
20
21
  thumbUrl?: string;
21
22
  hideAddBtn?: boolean;
23
+ listType?:UploadListType|null;
24
+ onPreview?:UploadProps["onPreview"]|null
22
25
  }
23
26
  export interface IMediaTypeEleProps {
24
27
  file?: UploadFile;
@@ -90,7 +90,7 @@ export default () => {
90
90
  },
91
91
  {
92
92
  label: "富文本",
93
- type: "textArea",
93
+ type: "timePicker",
94
94
  name: "textArea",
95
95
  itemProps:{
96
96
  showCount:true,
@@ -1,4 +1,4 @@
1
- import { Button } from "antd";
1
+ import {Button, Input} from "antd";
2
2
  import {
3
3
  HModalForm,
4
4
  useHDialogForm,
@@ -11,18 +11,20 @@ import { ShowParamsModal } from "@/components/DialogForm/modal";
11
11
  const Test = (props) => {
12
12
  return <HUrlUpload {...props} />;
13
13
  };
14
+ const ITest=()=>{
15
+ return <Input onPressEnter={(e)=>{
16
+ e.preventDefault();
17
+ console.log("ITest")
18
+ }}/>
19
+ }
14
20
  const data = [
15
21
  {
16
22
  label: "输入框",
17
23
  name: "name",
18
24
  hideLabel: true,
19
- rules: [
20
- () => {
21
- return {
22
- required: true,
23
- };
24
- },
25
- ],
25
+ render:()=>{
26
+ return <ITest/>
27
+ },
26
28
  },
27
29
  // {
28
30
  // label: "数字",
@@ -203,6 +205,7 @@ export default () => {
203
205
  marginBottom: 100,
204
206
  }}
205
207
  onOk={() => {
208
+ console.log("fff")
206
209
  return false;
207
210
  }}
208
211
  infoRequest={() => {
@@ -1,4 +1,4 @@
1
- import { Space } from "antd";
1
+ import {Button, Space} from "antd";
2
2
  import { HUpload, HUrlUpload } from "../../components";
3
3
  import React, { useState } from "react";
4
4
  import { MediaTypeEnum } from "../../components/Upload/enums";
@@ -26,11 +26,15 @@ export default () => {
26
26
  value={files1}
27
27
  hideAddBtn={false}
28
28
  mediaType={MediaTypeEnum.file}
29
+ listType={null}
30
+ onPreview={false}
29
31
  showUploadList={{
30
32
  showPreviewIcon: false,
31
33
  }}
32
34
  onChange={setFiles1}
33
- />
35
+ >
36
+ <Button>按钮</Button>
37
+ </HUpload>
34
38
  <HUrlUpload
35
39
  inputHelper="测试"
36
40
  mediaType={MediaTypeEnum.video}