@hw-component/form 1.3.3 → 1.3.5

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.
Files changed (45) hide show
  1. package/.eslintcache +1 -1
  2. package/es/DialogForm/hooks.d.ts +5 -5
  3. package/es/Form/config.js +1 -1
  4. package/es/Form/hooks/useHForm.js +3 -0
  5. package/es/Form/modal.d.ts +1 -0
  6. package/es/Upload/UrlUpload/hooks.d.ts +1 -1
  7. package/es/Upload/UrlUpload/index.js +0 -1
  8. package/es/Upload/hooks/change.d.ts +1 -1
  9. package/es/Upload/index.js +13 -11
  10. package/es/index.css +3 -3
  11. package/lib/DialogForm/hooks.d.ts +5 -5
  12. package/lib/Form/config.js +1 -1
  13. package/lib/Form/hooks/useHForm.js +3 -0
  14. package/lib/Form/modal.d.ts +1 -0
  15. package/lib/Upload/UrlUpload/hooks.d.ts +1 -1
  16. package/lib/Upload/UrlUpload/index.js +0 -1
  17. package/lib/Upload/hooks/change.d.ts +1 -1
  18. package/lib/Upload/index.js +13 -11
  19. package/lib/index.css +3 -3
  20. package/package.json +1 -1
  21. package/src/components/DialogForm/DrawerForm/index.tsx +1 -1
  22. package/src/components/DialogForm/hooks.ts +1 -1
  23. package/src/components/Form/FormItem/BasicItem.tsx +3 -3
  24. package/src/components/Form/FormItem/hooks.tsx +7 -4
  25. package/src/components/Form/HFormConnect.tsx +0 -1
  26. package/src/components/Form/Label.tsx +6 -10
  27. package/src/components/Form/config.ts +1 -1
  28. package/src/components/Form/hooks/useHForm.ts +4 -1
  29. package/src/components/Form/index.less +7 -7
  30. package/src/components/Form/modal.ts +6 -4
  31. package/src/components/Input/ButtonInput.tsx +7 -2
  32. package/src/components/Input/VerificationCodeInput/hooks.ts +32 -33
  33. package/src/components/Input/VerificationCodeInput/index.tsx +83 -81
  34. package/src/components/Select/index.tsx +2 -2
  35. package/src/components/Upload/UrlUpload/hooks.ts +15 -12
  36. package/src/components/Upload/UrlUpload/index.tsx +18 -12
  37. package/src/components/Upload/hooks/change.ts +7 -7
  38. package/src/components/Upload/hooks/propsMaker.ts +2 -2
  39. package/src/components/Upload/index.tsx +21 -15
  40. package/src/components/Upload/modal.ts +2 -2
  41. package/src/components/Upload/util.ts +6 -3
  42. package/src/pages/DrawerForm/index.tsx +27 -94
  43. package/src/pages/Form/index.tsx +185 -185
  44. package/src/pages/ModalForm/index.tsx +1 -1
  45. package/src/pages/Select/index.tsx +1 -1
package/es/index.css CHANGED
@@ -32,8 +32,8 @@
32
32
  }
33
33
  .ant-hw-form-base-item-top-left .ant-hw-form-item-required {
34
34
  position: absolute;
35
- left: -10px;
36
35
  top: 0;
36
+ left: -10px;
37
37
  }
38
38
  .ant-hw-form-base-item-top-left .ant-hw-form-label-item {
39
39
  position: relative;
@@ -58,8 +58,8 @@
58
58
  }
59
59
  .ant-hw-form-base-item-left .ant-hw-form-item-required {
60
60
  position: absolute;
61
- left: -10px;
62
61
  top: 0;
62
+ left: -10px;
63
63
  }
64
64
  .ant-hw-form-base-item-left .ant-hw-form-label-item {
65
65
  position: relative;
@@ -73,12 +73,12 @@
73
73
  .ant-hw-form-item-required:before {
74
74
  display: inline-block;
75
75
  width: 10px;
76
+ margin-right: 4px;
76
77
  color: #ff4d4f;
77
78
  font-size: 14px;
78
79
  font-family: SimSun, sans-serif;
79
80
  line-height: 1;
80
81
  content: "*";
81
- margin-right: 4px;
82
82
  }
83
83
  .ant-hw-form-form-item .ant-form-item-label {
84
84
  overflow: visible;
@@ -1,15 +1,15 @@
1
- import React from "react";
1
+ /// <reference types="react" />
2
2
  import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
3
3
  export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, onCancel, autoClear, }: ModifyPropsModal) => {
4
4
  modalFormData: import("../Form/modal").HItemProps[];
5
5
  modalVisible: boolean | undefined;
6
- setModalVisible: React.Dispatch<React.SetStateAction<boolean | undefined>>;
7
- setModalFormData: React.Dispatch<React.SetStateAction<import("../Form/modal").HItemProps[]>>;
6
+ setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
7
+ setModalFormData: import("react").Dispatch<import("react").SetStateAction<import("../Form/modal").HItemProps[]>>;
8
8
  initValue: Record<string, any> | undefined;
9
- setInitValue: React.Dispatch<React.SetStateAction<Record<string, any> | undefined>>;
9
+ setInitValue: import("react").Dispatch<import("react").SetStateAction<Record<string, any> | undefined>>;
10
10
  onAfterClose: () => void;
11
11
  formParams: any;
12
- title: string | number | boolean | {} | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactNodeArray | React.ReactPortal | null | undefined;
12
+ title: string | number | boolean | {} | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNodeArray | import("react").ReactPortal | null | undefined;
13
13
  };
14
14
  export declare const useHDialogForm: () => HDialogFormInstance<any, any>;
15
15
  export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance<any, any>;
@@ -25,7 +25,7 @@ var TrimInput = require('../Input/TrimInput.js');
25
25
  var TrimTextArea = require('../TextArea/TrimTextArea.js');
26
26
 
27
27
  var placeholderConfig = {
28
- inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", 'urlUpload'],
28
+ inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload"],
29
29
  selectType: ["select", "datePicker", "timePicker", "colorInput"]
30
30
  };
31
31
  var componentConfig = {
@@ -79,6 +79,9 @@ var useHForm = (function () {
79
79
  outputValue: outputValue
80
80
  };
81
81
  },
82
+ clearFormat: function clearFormat(name) {
83
+ Reflect.deleteProperty(formatSourceData, name);
84
+ },
82
85
  formatValues: function formatValues() {
83
86
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
84
87
  var formatKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "inputValue";
@@ -122,6 +122,7 @@ export interface HFormInstance extends FormInstance {
122
122
  reload: PromiseFnResult;
123
123
  clear: VoidFunction;
124
124
  resetFieldsInitValue: VoidFunction;
125
+ clearFormat: (name: string) => void;
125
126
  }
126
127
  export interface ConnectConfigModal {
127
128
  format?: Record<string, addFormatItemModal>;
@@ -1,2 +1,2 @@
1
1
  import type { IUrlUploadProps } from "../modal";
2
- export declare const useDefaultExFiles: ({ mediaType, exFiles }: IUrlUploadProps) => any;
2
+ export declare const useDefaultExFiles: ({ mediaType, exFiles, }: IUrlUploadProps) => any;
@@ -124,7 +124,6 @@ var Index = function Index(_ref) {
124
124
  var upProps = _objectSpread({
125
125
  exFiles: defaultExFiles
126
126
  }, props);
127
- console.log(value, "urlUpload");
128
127
  return jsxRuntime.jsxs(antd.Space, {
129
128
  direction: "vertical",
130
129
  style: _objectSpread({
@@ -1,3 +1,3 @@
1
1
  import type { IUpLoadProps } from "../modal";
2
2
  import type { UploadChangeParam, UploadFile } from "antd/lib/upload/interface";
3
- export declare const useChange: ({ value, onChange, maxCount, request, exFiles, maxSize, thumbUrl }: IUpLoadProps) => (info: UploadChangeParam<UploadFile>) => void;
3
+ export declare const useChange: ({ value, onChange, maxCount, request, exFiles, maxSize, thumbUrl, }: IUpLoadProps) => (info: UploadChangeParam<UploadFile>) => void;
@@ -89,21 +89,23 @@ var Index = function Index(_ref, ref) {
89
89
  addFormat === null || addFormat === void 0 || addFormat({
90
90
  float: {
91
91
  inputValue: function inputValue(item, initValue) {
92
- console.log("inputValue");
93
92
  var _item$name = item.name,
94
93
  name = _item$name === void 0 ? "" : _item$name;
95
94
  var initFileList = initValue[name] || [];
96
95
  var relInitFileList = typeof initFileList === "string" ? [initFileList] : initFileList;
97
- var fileList = relInitFileList.map(function (url, index) {
98
- return {
99
- name: url,
100
- response: {
101
- url: url
102
- },
103
- status: "done",
104
- uid: "init-".concat(index),
105
- thumbUrl: thumbUrl || url
106
- };
96
+ var fileList = relInitFileList.map(function (itemData, index) {
97
+ if (typeof itemData === "string") {
98
+ return {
99
+ name: itemData,
100
+ response: {
101
+ itemData: itemData
102
+ },
103
+ status: "done",
104
+ uid: "init-".concat(index),
105
+ thumbUrl: thumbUrl || itemData
106
+ };
107
+ }
108
+ return _objectSpread({}, itemData);
107
109
  });
108
110
  return _defineProperty({}, name, fileList);
109
111
  },
package/lib/index.css CHANGED
@@ -32,8 +32,8 @@
32
32
  }
33
33
  .ant-hw-form-base-item-top-left .ant-hw-form-item-required {
34
34
  position: absolute;
35
- left: -10px;
36
35
  top: 0;
36
+ left: -10px;
37
37
  }
38
38
  .ant-hw-form-base-item-top-left .ant-hw-form-label-item {
39
39
  position: relative;
@@ -58,8 +58,8 @@
58
58
  }
59
59
  .ant-hw-form-base-item-left .ant-hw-form-item-required {
60
60
  position: absolute;
61
- left: -10px;
62
61
  top: 0;
62
+ left: -10px;
63
63
  }
64
64
  .ant-hw-form-base-item-left .ant-hw-form-label-item {
65
65
  position: relative;
@@ -73,12 +73,12 @@
73
73
  .ant-hw-form-item-required:before {
74
74
  display: inline-block;
75
75
  width: 10px;
76
+ margin-right: 4px;
76
77
  color: #ff4d4f;
77
78
  font-size: 14px;
78
79
  font-family: SimSun, sans-serif;
79
80
  line-height: 1;
80
81
  content: "*";
81
- margin-right: 4px;
82
82
  }
83
83
  .ant-hw-form-form-item .ant-form-item-label {
84
84
  overflow: visible;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,7 +49,7 @@ export default ({
49
49
  title,
50
50
  onCancel,
51
51
  autoClear,
52
- afterClose
52
+ afterClose,
53
53
  });
54
54
  const cancel = () => {
55
55
  onAfterClose();
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useMemo, useState } from "react";
1
+ import { useEffect, useMemo, useState } from "react";
2
2
  import useHForm from "../Form/hooks/useHForm";
3
3
  import type {
4
4
  DialogFormProps,
@@ -3,7 +3,7 @@ import { Form, Space, Col } from "antd";
3
3
  import React from "react";
4
4
  import Helper from "./Helper";
5
5
  import { useClassName } from "../../hooks";
6
- import {useFormItemLabel, useHide, usePositionClassName} from "./hooks";
6
+ import { useFormItemLabel, useHide, usePositionClassName } from "./hooks";
7
7
  import { useFormContext } from "../Context";
8
8
  import type { HItemProps } from "../modal";
9
9
  import { useDefaultRender } from "../hooks/useDefaultRender";
@@ -56,7 +56,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
56
56
  const defaultComponent = useDefaultComponents();
57
57
  const formItemStyle = useFormConfigContext("formItemStyle");
58
58
  const ctxItemProps = useFormConfigContext("itemProps");
59
- const itemClassName=useClassName("hw-form-form-item")
59
+ const itemClassName = useClassName("hw-form-form-item");
60
60
  const defaultItemProps = {
61
61
  ...ctxItemProps,
62
62
  ...itemProps,
@@ -67,7 +67,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
67
67
  );
68
68
  const className = usePositionClassName(align);
69
69
  const hideItem = useHide({ hide, form });
70
- const formItemLabel=useFormItemLabel(form,label);
70
+ const formItemLabel = useFormItemLabel(form, label);
71
71
  if (hideItem) {
72
72
  return null;
73
73
  }
@@ -5,7 +5,7 @@ import { useMemo } from "react";
5
5
  import type { HFormInstance, HItemProps } from "../modal";
6
6
  import type { LabelAlignModal } from "../modal";
7
7
  import { useClassName } from "../../hooks";
8
- import type {HelperModal} from "../modal";
8
+ import type { HelperModal } from "../modal";
9
9
 
10
10
  export const useFormItemDomControl = ({
11
11
  shouldUpdate,
@@ -55,6 +55,9 @@ export const usePositionClassName = (position: LabelAlignModal) => {
55
55
  return useClassName(className);
56
56
  };
57
57
 
58
- export const useFormItemLabel=(form: HFormInstance,label?: React.ReactNode|HelperModal,)=>{
59
- return typeof label==="function"?label(form):label;
60
- }
58
+ export const useFormItemLabel = (
59
+ form: HFormInstance,
60
+ label?: React.ReactNode | HelperModal
61
+ ) => {
62
+ return typeof label === "function" ? label(form) : label;
63
+ };
@@ -50,7 +50,6 @@ export default (
50
50
  useEffect(() => {
51
51
  form?.addFormat(name, formatMaker(props, format[valueType]));
52
52
  }, [valueType, props]);
53
-
54
53
  const addFormat = (aFormat: Record<string, addFormatItemModal>) => {
55
54
  form?.addFormat(name, formatMaker(props, aFormat[valueType]));
56
55
  };
@@ -27,18 +27,14 @@ const Index: React.FC<IProps> = ({
27
27
  hover,
28
28
  }) => {
29
29
  const { text, icon } = useHover({ hover });
30
- const array = [
31
- colon ? "hw-form-item-colon" : "",
32
- ];
30
+ const array = [colon ? "hw-form-item-colon" : ""];
33
31
 
34
- const className = useClassName([...array,"hw-form-label-item"]);
35
- const requiredClass=useClassName("hw-form-item-required");
36
- const noRequiredClass=useClassName("hw-form-item-no-required")
32
+ const className = useClassName([...array, "hw-form-label-item"]);
33
+ const requiredClass = useClassName("hw-form-item-required");
34
+ const noRequiredClass = useClassName("hw-form-item-no-required");
37
35
  return (
38
- <div style={{ width: labelWidth }}
39
- className={className}
40
- >
41
- <span className={required?requiredClass:noRequiredClass}/>
36
+ <div style={{ width: labelWidth }} className={className}>
37
+ <span className={required ? requiredClass : noRequiredClass} />
42
38
  {children}
43
39
  {text && (
44
40
  <span style={{ marginLeft: 4 }}>
@@ -27,7 +27,7 @@ export const placeholderConfig = {
27
27
  "buttonInput",
28
28
  "verificationCodeInput",
29
29
  "trimInput",
30
- 'urlUpload'
30
+ "urlUpload",
31
31
  ],
32
32
  selectType: ["select", "datePicker", "timePicker", "colorInput"],
33
33
  };
@@ -1,4 +1,4 @@
1
- import { useMemo } from "react";
1
+ import { useCallback, useEffect, useMemo, useState } from "react";
2
2
  import { Form } from "antd";
3
3
  import type { FormatItemModal, HFormInstance } from "../modal";
4
4
  import type { argsFn } from "../modal";
@@ -61,6 +61,9 @@ export default () => {
61
61
  outputValue,
62
62
  };
63
63
  }, //注册转化方法
64
+ clearFormat(name: string) {
65
+ Reflect.deleteProperty(formatSourceData, name);
66
+ },
64
67
  formatValues(value = {}, formatKey = "inputValue") {
65
68
  const valKeys = Object.keys(value).length;
66
69
  if (!valKeys) {
@@ -19,8 +19,8 @@
19
19
  }
20
20
  .@{ant-prefix}-hw-form-item-required {
21
21
  position: absolute;
22
- left: -10px;
23
22
  top: 0;
23
+ left: -10px;
24
24
  }
25
25
  .@{ant-prefix}-hw-form-label-item {
26
26
  position: relative;
@@ -54,8 +54,8 @@
54
54
  }
55
55
  .@{ant-prefix}-hw-form-item-required {
56
56
  position: absolute;
57
- left: -10px;
58
57
  top: 0;
58
+ left: -10px;
59
59
  }
60
60
  .@{ant-prefix}-hw-form-label-item {
61
61
  position: relative;
@@ -71,15 +71,15 @@
71
71
  .@{ant-prefix}-hw-form-item-required:before {
72
72
  display: inline-block;
73
73
  width: 10px;
74
+ margin-right: 4px;
74
75
  color: #ff4d4f;
75
76
  font-size: 14px;
76
77
  font-family: SimSun, sans-serif;
77
78
  line-height: 1;
78
79
  content: "*";
79
- margin-right: 4px;
80
80
  }
81
81
  .@{ant-prefix}-hw-form-form-item {
82
- .@{ant-prefix}-form-item-label {
83
- overflow:visible
84
- }
85
- }
82
+ .@{ant-prefix}-form-item-label {
83
+ overflow: visible;
84
+ }
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 type {IUrlUploadProps} from "../Upload/modal";
37
+ import type { IUrlUploadProps } from "../Upload/modal";
38
38
 
39
39
  type RenderFun = (
40
40
  props: HItemProps,
@@ -56,7 +56,7 @@ export type ItemPropsType =
56
56
  | TextAreaProps
57
57
  | IUpLoadProps
58
58
  | CascaderProps<any>
59
- | IUrlUploadProps
59
+ | IUrlUploadProps;
60
60
 
61
61
  export interface HoverModal {
62
62
  text?: string;
@@ -79,7 +79,8 @@ export interface DispatchModal<T = string | string[]> {
79
79
  }
80
80
  export type LabelAlignModal = "left" | "right" | "topLeft" | "topRight" | "top";
81
81
 
82
- export interface HItemProps extends Omit<FormItemProps, "name" | "labelAlign"|"label"> {
82
+ export interface HItemProps
83
+ extends Omit<FormItemProps, "name" | "labelAlign" | "label"> {
83
84
  type?: string;
84
85
  itemProps?: ItemPropsType;
85
86
  render?: RenderFun;
@@ -95,7 +96,7 @@ export interface HItemProps extends Omit<FormItemProps, "name" | "labelAlign"|"l
95
96
  itemSpan?: ColProps;
96
97
  hideLabel?: boolean;
97
98
  labelAlign?: LabelAlignModal;
98
- label?: React.ReactNode|HelperModal;
99
+ label?: React.ReactNode | HelperModal;
99
100
  }
100
101
  export interface HFormProps<T = any, R = any>
101
102
  extends Omit<FormProps, "form" | "onFinish" | "labelAlign"> {
@@ -177,6 +178,7 @@ export interface HFormInstance extends FormInstance {
177
178
  reload: PromiseFnResult;
178
179
  clear: VoidFunction;
179
180
  resetFieldsInitValue: VoidFunction;
181
+ clearFormat: (name: string) => void;
180
182
  }
181
183
 
182
184
  export interface ConnectConfigModal {
@@ -11,7 +11,12 @@ const Index: React.FC<HButtonInputProps> = ({
11
11
  request,
12
12
  ...props
13
13
  }) => {
14
- const { onClick, type = "primary", loading:btnLoading,...oProps } = buttonProps;
14
+ const {
15
+ onClick,
16
+ type = "primary",
17
+ loading: btnLoading,
18
+ ...oProps
19
+ } = buttonProps;
15
20
  const { run, loading } = useRequest(
16
21
  (val) => {
17
22
  return request?.(val);
@@ -36,7 +41,7 @@ const Index: React.FC<HButtonInputProps> = ({
36
41
  {...oProps}
37
42
  type={type}
38
43
  onClick={click}
39
- loading={loading||btnLoading}
44
+ loading={loading || btnLoading}
40
45
  style={{ marginLeft: 4 }}
41
46
  >
42
47
  {children}
@@ -1,36 +1,35 @@
1
- import type {ButtonProps} from "./index";
2
- import {useEffect, useState} from "react";
1
+ import type { ButtonProps } from "./index";
2
+ import { useEffect, useState } from "react";
3
3
 
4
- export const useDis=(buttonProps: ButtonProps)=>{
5
- const {disabled}=buttonProps;
6
- const [btnDis,setBtnDis]=useState<boolean|undefined>(!!disabled);
7
- const [countdown, setCountdown] = useState<number>(0);
8
- const setBtnDisabled=({changedValues})=>{
9
- if (!!countdown){
10
- return setBtnDis(true);
11
- }
12
- if (typeof disabled==="function"){
13
- const resultDisabled=disabled(changedValues);
14
- return setBtnDis(resultDisabled);
15
- }
16
- return setBtnDis(disabled);
4
+ export const useDis = (buttonProps: ButtonProps) => {
5
+ const { disabled } = buttonProps;
6
+ const [btnDis, setBtnDis] = useState<boolean | undefined>(!!disabled);
7
+ const [countdown, setCountdown] = useState<number>(0);
8
+ const setBtnDisabled = ({ changedValues }) => {
9
+ if (!!countdown) {
10
+ return setBtnDis(true);
17
11
  }
18
- useEffect(() => {
19
- setBtnDis(!!countdown);
20
- }, [countdown]);
21
- useEffect(() => {
22
- if (!!countdown){
23
- return;
24
- }
25
- if (typeof disabled==="boolean"){
26
- setBtnDis(disabled);
27
- }
28
-
29
- }, [disabled]);
30
- return {
31
- disabled:btnDis,
32
- setBtnDisabled,
33
- countdown,
34
- setCountdown
12
+ if (typeof disabled === "function") {
13
+ const resultDisabled = disabled(changedValues);
14
+ return setBtnDis(resultDisabled);
15
+ }
16
+ return setBtnDis(disabled);
17
+ };
18
+ useEffect(() => {
19
+ setBtnDis(!!countdown);
20
+ }, [countdown]);
21
+ useEffect(() => {
22
+ if (!!countdown) {
23
+ return;
24
+ }
25
+ if (typeof disabled === "boolean") {
26
+ setBtnDis(disabled);
35
27
  }
36
- }
28
+ }, [disabled]);
29
+ return {
30
+ disabled: btnDis,
31
+ setBtnDisabled,
32
+ countdown,
33
+ setCountdown,
34
+ };
35
+ };