@hw-component/form 0.0.3-beta-v5 → 0.0.3-beta-v7

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 (145) hide show
  1. package/es/DialogForm/DrawerForm/Footer.d.ts +1 -2
  2. package/es/DialogForm/DrawerForm/Title.d.ts +0 -1
  3. package/es/DialogForm/DrawerForm/index.d.ts +0 -1
  4. package/es/DialogForm/ModalForm.d.ts +0 -1
  5. package/es/DialogForm/ModalForm.js +3 -3
  6. package/es/DialogForm/hooks.d.ts +1 -1
  7. package/es/DialogForm/hooks.js +3 -3
  8. package/es/Form/FormItem/BasicItem.d.ts +2 -2
  9. package/es/Form/FormItem/BasicItem.js +19 -15
  10. package/es/Form/FormItem/RegularFormItem.d.ts +2 -3
  11. package/es/Form/FormItem/UpFormItem.d.ts +2 -3
  12. package/es/Form/FormItem/hooks.d.ts +2 -4
  13. package/es/Form/FormItem/index.d.ts +2 -3
  14. package/es/Form/InitSet.d.ts +0 -1
  15. package/es/Form/config.d.ts +5 -5
  16. package/es/Form/config.js +10 -10
  17. package/es/Form/hooks/index.d.ts +1 -0
  18. package/es/Form/hooks/index.js +20 -3
  19. package/es/Form/hooks/useDefaultRender.d.ts +3 -0
  20. package/es/Form/hooks/useDefaultRender.js +49 -0
  21. package/es/Form/hooks/useInitConfigData.d.ts +2 -2
  22. package/es/Form/hooks/useInitConfigData.js +26 -45
  23. package/es/Form/index.d.ts +0 -1
  24. package/es/Form/modal.d.ts +20 -13
  25. package/es/Input/ColorInput/Picker.d.ts +3 -0
  26. package/es/Input/ColorInput/Picker.js +22 -0
  27. package/es/Input/ColorInput/data.d.ts +1 -0
  28. package/es/Input/ColorInput/data.js +5 -0
  29. package/es/Input/ColorInput/index.d.ts +3 -0
  30. package/es/Input/ColorInput/index.js +76 -0
  31. package/es/Input/InputNumber.d.ts +0 -1
  32. package/es/Input/index.d.ts +0 -1
  33. package/es/Input/modal.d.ts +4 -1
  34. package/es/PageHandler/ErrorComponent.d.ts +0 -1
  35. package/es/PageHandler/LoadingComponent.d.ts +0 -1
  36. package/es/RadioGroup/index.d.ts +0 -1
  37. package/es/Select/components/NoFindItem.d.ts +0 -1
  38. package/es/Select/components/NotFoundContent.d.ts +0 -1
  39. package/es/Select/defaultConfig.d.ts +0 -1
  40. package/es/Select/index.d.ts +0 -1
  41. package/es/Submit/index.d.ts +3 -2
  42. package/es/Submit/index.js +16 -4
  43. package/es/TDPicker/TimePicker.d.ts +0 -1
  44. package/es/TDPicker/index.d.ts +3 -3
  45. package/es/TDPicker/index.js +6 -5
  46. package/es/TextArea/index.d.ts +0 -1
  47. package/es/Upload/Btn.d.ts +0 -1
  48. package/es/Upload/MediaTypeEle/TypeEle.d.ts +0 -1
  49. package/es/Upload/MediaTypeEle/index.d.ts +0 -1
  50. package/es/Upload/Preview/index.d.ts +0 -1
  51. package/es/Upload/UrlUpload/index.d.ts +0 -1
  52. package/es/config.js +2 -1
  53. package/es/index.css +9 -0
  54. package/es/index.d.ts +3 -2
  55. package/es/index.js +19 -18
  56. package/es/modal.d.ts +5 -4
  57. package/lib/DialogForm/DrawerForm/Footer.d.ts +1 -2
  58. package/lib/DialogForm/DrawerForm/Title.d.ts +0 -1
  59. package/lib/DialogForm/DrawerForm/index.d.ts +0 -1
  60. package/lib/DialogForm/ModalForm.d.ts +0 -1
  61. package/lib/DialogForm/ModalForm.js +3 -3
  62. package/lib/DialogForm/hooks.d.ts +1 -1
  63. package/lib/DialogForm/hooks.js +3 -3
  64. package/lib/Form/FormItem/BasicItem.d.ts +2 -2
  65. package/lib/Form/FormItem/BasicItem.js +21 -17
  66. package/lib/Form/FormItem/RegularFormItem.d.ts +2 -3
  67. package/lib/Form/FormItem/UpFormItem.d.ts +2 -3
  68. package/lib/Form/FormItem/hooks.d.ts +2 -4
  69. package/lib/Form/FormItem/index.d.ts +2 -3
  70. package/lib/Form/InitSet.d.ts +0 -1
  71. package/lib/Form/config.d.ts +5 -5
  72. package/lib/Form/config.js +6 -6
  73. package/lib/Form/hooks/index.d.ts +1 -0
  74. package/lib/Form/hooks/index.js +20 -2
  75. package/lib/Form/hooks/useDefaultRender.d.ts +3 -0
  76. package/lib/Form/hooks/useDefaultRender.js +50 -0
  77. package/lib/Form/hooks/useInitConfigData.d.ts +2 -2
  78. package/lib/Form/hooks/useInitConfigData.js +24 -43
  79. package/lib/Form/index.d.ts +0 -1
  80. package/lib/Form/modal.d.ts +20 -13
  81. package/lib/Input/ColorInput/Picker.d.ts +3 -0
  82. package/lib/Input/ColorInput/Picker.js +25 -0
  83. package/lib/Input/ColorInput/data.d.ts +1 -0
  84. package/lib/Input/ColorInput/data.js +6 -0
  85. package/lib/Input/ColorInput/index.d.ts +3 -0
  86. package/lib/Input/ColorInput/index.js +79 -0
  87. package/lib/Input/InputNumber.d.ts +0 -1
  88. package/lib/Input/index.d.ts +0 -1
  89. package/lib/Input/modal.d.ts +4 -1
  90. package/lib/PageHandler/ErrorComponent.d.ts +0 -1
  91. package/lib/PageHandler/LoadingComponent.d.ts +0 -1
  92. package/lib/RadioGroup/index.d.ts +0 -1
  93. package/lib/Select/components/NoFindItem.d.ts +0 -1
  94. package/lib/Select/components/NotFoundContent.d.ts +0 -1
  95. package/lib/Select/defaultConfig.d.ts +0 -1
  96. package/lib/Select/index.d.ts +0 -1
  97. package/lib/Submit/index.d.ts +3 -2
  98. package/lib/Submit/index.js +15 -3
  99. package/lib/TDPicker/TimePicker.d.ts +0 -1
  100. package/lib/TDPicker/index.d.ts +3 -3
  101. package/lib/TDPicker/index.js +6 -5
  102. package/lib/TextArea/index.d.ts +0 -1
  103. package/lib/Upload/Btn.d.ts +0 -1
  104. package/lib/Upload/MediaTypeEle/TypeEle.d.ts +0 -1
  105. package/lib/Upload/MediaTypeEle/index.d.ts +0 -1
  106. package/lib/Upload/Preview/index.d.ts +0 -1
  107. package/lib/Upload/UrlUpload/index.d.ts +0 -1
  108. package/lib/config.js +2 -1
  109. package/lib/index.css +9 -0
  110. package/lib/index.d.ts +3 -2
  111. package/lib/index.js +4 -2
  112. package/lib/modal.d.ts +5 -4
  113. package/package.json +5 -3
  114. package/src/components/DialogForm/DrawerForm/Footer.tsx +5 -9
  115. package/src/components/DialogForm/DrawerForm/index.tsx +5 -5
  116. package/src/components/DialogForm/ModalForm.tsx +16 -11
  117. package/src/components/DialogForm/hooks.ts +12 -12
  118. package/src/components/DialogForm/modal.ts +2 -2
  119. package/src/components/Form/FormItem/BasicItem.tsx +22 -16
  120. package/src/components/Form/FormItem/RegularFormItem.tsx +2 -2
  121. package/src/components/Form/FormItem/UpFormItem.tsx +2 -2
  122. package/src/components/Form/FormItem/hooks.tsx +2 -6
  123. package/src/components/Form/FormItem/index.tsx +2 -2
  124. package/src/components/Form/config.ts +7 -5
  125. package/src/components/Form/hooks/index.ts +16 -9
  126. package/src/components/Form/hooks/useDefaultRender.tsx +42 -0
  127. package/src/components/Form/hooks/useHForm.ts +2 -2
  128. package/src/components/Form/hooks/useInitConfigData.tsx +44 -35
  129. package/src/components/Form/modal.ts +28 -17
  130. package/src/components/Input/ColorInput/Picker.tsx +18 -0
  131. package/src/components/Input/ColorInput/data.ts +102 -0
  132. package/src/components/Input/ColorInput/index.less +10 -0
  133. package/src/components/Input/ColorInput/index.tsx +48 -0
  134. package/src/components/Input/modal.ts +5 -2
  135. package/src/components/Select/hooks/changeHooks.tsx +1 -1
  136. package/src/components/Submit/index.tsx +23 -9
  137. package/src/components/TDPicker/RangePicker.tsx +1 -1
  138. package/src/components/TDPicker/index.tsx +6 -9
  139. package/src/components/config.ts +1 -0
  140. package/src/components/index.tsx +2 -1
  141. package/src/components/modal.ts +5 -3
  142. package/src/components/styles/index.less +1 -0
  143. package/src/pages/Form/index.tsx +16 -1
  144. package/src/pages/Input/index.tsx +2 -0
  145. package/src/pages/ModalForm/index.tsx +9 -9
@@ -0,0 +1,42 @@
1
+ import type {
2
+ DefaultComponentModal,
3
+ HFormItemProps,
4
+ ConfigComponentModal,
5
+ } from "../modal";
6
+ import FormConfig from "../config";
7
+ import type { FormInstance } from "antd";
8
+ import React from "react";
9
+
10
+ export const useDefaultRender = (
11
+ props: HFormItemProps,
12
+ defaultComponents: DefaultComponentModal
13
+ ) => {
14
+ const {
15
+ render,
16
+ labelWidth,
17
+ colon,
18
+ type = "input",
19
+ itemProps = {},
20
+ ...componentProps
21
+ } = props;
22
+ const mergeComponent = { ...FormConfig, ...defaultComponents };
23
+ const dom = mergeComponent[type];
24
+ return (form: FormInstance) => {
25
+ let Component = dom;
26
+ if ((dom as ConfigComponentModal)?.Component) {
27
+ Component = (dom as ConfigComponentModal).Component;
28
+ }
29
+ const node = Component && (
30
+ <Component {...componentProps} {...itemProps} form={form} />
31
+ );
32
+ if (render) {
33
+ const resultNode = render(props, node, form);
34
+ return React.cloneElement<any>(resultNode as any, {
35
+ ...componentProps,
36
+ ...itemProps,
37
+ form,
38
+ });
39
+ }
40
+ return node;
41
+ };
42
+ };
@@ -30,8 +30,8 @@ export default () => {
30
30
  };
31
31
  };
32
32
  return {
33
- reload:(params)=>{
34
- return Promise.resolve(params);
33
+ reload: (params) => {
34
+ return Promise.resolve(params);
35
35
  },
36
36
  initValues() {
37
37
  if (cacheValues) {
@@ -1,18 +1,24 @@
1
1
  import React, { useMemo } from "react";
2
2
  import type {
3
- FormItemWithRender,
4
3
  HFormItemProps,
5
4
  HFormProps,
6
5
  HItemProps,
7
- } from "@/components/Form/modal";
8
- import FormConfig, { placeholderConfig } from "../config";
6
+ DefaultComponentModal,
7
+ } from "../modal";
8
+ import { placeholderConfig } from "../config";
9
9
  import type { Rule } from "rc-field-form/lib/interface";
10
10
  import type { FormInstance } from "antd";
11
+ import { useDefaultComponents } from "../hooks";
12
+ import type { ConfigComponentModal } from "../modal";
11
13
 
12
- const mathRequired = (configItem: HFormItemProps, form: FormInstance) => {
14
+ const mathRequired = (
15
+ configItem: HFormItemProps,
16
+ form: FormInstance,
17
+ defaultComponents: DefaultComponentModal
18
+ ) => {
13
19
  const { required, placeholder, rules, type = "input" } = configItem;
14
20
  let resultRequired = false;
15
- const dom = FormConfig[type];
21
+ const dom = defaultComponents[type];
16
22
  const resultRules = rules?.map((item) => {
17
23
  let eachItem = item;
18
24
  if (typeof item === "function") {
@@ -24,12 +30,15 @@ const mathRequired = (configItem: HFormItemProps, form: FormInstance) => {
24
30
  resultRequired = itemRequired;
25
31
  }
26
32
  if (itemRequired && !message) {
33
+ let msg = placeholder;
34
+ const itemDom = dom as ConfigComponentModal;
35
+ if (itemDom?.requiredErrMsg) {
36
+ msg = itemDom.requiredErrMsg(configItem);
37
+ }
27
38
  return {
28
39
  ...eachItem,
29
40
  required: itemRequired,
30
- message: !!dom?.requiredErrMsg
31
- ? dom.requiredErrMsg(configItem)
32
- : placeholder,
41
+ message: msg,
33
42
  };
34
43
  }
35
44
  return eachItem;
@@ -39,50 +48,49 @@ const mathRequired = (configItem: HFormItemProps, form: FormInstance) => {
39
48
  rules: resultRules as Rule[],
40
49
  };
41
50
  }; //是否必填
42
- const matchDefaultPlaceholder = (props: HFormItemProps) => {
51
+ const matchDefaultPlaceholder = (
52
+ props: HFormItemProps,
53
+ defaultComponents: DefaultComponentModal
54
+ ) => {
43
55
  const { label, placeholder, type = "input" } = props;
44
- const dom = FormConfig[type];
56
+ const dom = defaultComponents[type];
45
57
  if (placeholder) {
46
58
  return placeholder;
47
59
  }
48
- if (dom?.placeholder) {
49
- return dom.placeholder(props);
60
+ const itemDom = dom as ConfigComponentModal;
61
+ if (itemDom?.placeholder) {
62
+ return itemDom.placeholder(props);
50
63
  }
51
64
  if (placeholderConfig.inputType.indexOf(type) !== -1) {
52
65
  return `请输入${label}`;
53
66
  }
54
67
  return `请选择${label}`;
55
68
  }; //自动构建
56
- const defaultRenderMaker = (props: HFormItemProps) => {
57
- const { render, type = "input", itemProps = {}, ...componentProps } = props;
58
- const dom = FormConfig[type];
59
- return (form: FormInstance) => {
60
- const Component = !!dom?.Component ? dom.Component : dom;
61
- const node = Component && (
62
- <Component {...componentProps} {...itemProps} form={form} />
63
- );
64
- if (render) {
65
- const resultNode=render(props, node, form);
66
- return React.cloneElement<any>((resultNode as any),{...componentProps,...itemProps,form})
67
- }
68
- return node;
69
- };
70
- };
71
69
 
72
- const defaultPlaceholderPropsMaker = (props: HFormItemProps) => {
73
- const placeholder = matchDefaultPlaceholder(props);
70
+ const defaultPlaceholderPropsMaker = (
71
+ props: HFormItemProps,
72
+ defaultComponents: DefaultComponentModal
73
+ ) => {
74
+ const placeholder = matchDefaultPlaceholder(props, defaultComponents);
74
75
  return {
75
76
  ...props,
76
77
  placeholder,
77
- render: defaultRenderMaker({ ...props, placeholder }),
78
78
  };
79
79
  }; //组装参数
80
80
  const itemControl = (
81
81
  item: HItemProps,
82
- form: FormInstance
83
- ): FormItemWithRender => {
84
- const { render, ...defaultProps } = defaultPlaceholderPropsMaker(item);
85
- const { rules, required } = mathRequired(defaultProps, form);
82
+ form: FormInstance,
83
+ defaultComponents: DefaultComponentModal
84
+ ): HFormItemProps => {
85
+ const { render, ...defaultProps } = defaultPlaceholderPropsMaker(
86
+ item,
87
+ defaultComponents
88
+ );
89
+ const { rules, required } = mathRequired(
90
+ defaultProps,
91
+ form,
92
+ defaultComponents
93
+ );
86
94
  return {
87
95
  ...defaultProps,
88
96
  required,
@@ -93,9 +101,10 @@ const itemControl = (
93
101
  type InitConfigModal = Required<Pick<HFormProps, "configData" | "form">>;
94
102
 
95
103
  export default ({ configData, form }: InitConfigModal) => {
104
+ const defaultComponents = useDefaultComponents();
96
105
  return useMemo(() => {
97
106
  return configData.map((item) => {
98
- return itemControl(item, form);
107
+ return itemControl(item, form, defaultComponents);
99
108
  });
100
109
  }, [configData]);
101
110
  };
@@ -1,22 +1,22 @@
1
1
  import type { FormInstance, FormItemProps, FormProps } from "antd";
2
- import type { HCheckboxProps } from "@/components/CheckboxGroup/modal";
2
+ import type { HCheckboxProps } from "../CheckboxGroup/modal";
3
3
  import type React from "react";
4
4
  import type {
5
5
  HButtonProps,
6
6
  HInputProps,
7
7
  HSelectInputProps,
8
- } from "@/components/Input/modal";
9
- import type { HRadioGroupProps } from "@/components/RadioGroup";
10
- import type { HSelectProps } from "@/components/Select/modal";
8
+ } from "../Input/modal";
9
+ import type { HRadioGroupProps } from "../RadioGroup";
10
+ import type { HSelectProps } from "../Select/modal";
11
11
  import type { ButtonProps } from "antd/es";
12
- import type { HSwitchProps } from "@/components/Switch";
12
+ import type { HSwitchProps } from "../Switch";
13
13
  import type {
14
14
  HDatePickerProps,
15
15
  HRangePickerProps,
16
16
  HTimePickerProps,
17
- } from "@/components/TDPicker/modal";
17
+ } from "../TDPicker/modal";
18
18
  import type { TextAreaProps } from "antd/es/input";
19
- import type { IUpLoadProps } from "@/components/Upload/modal";
19
+ import type { IUpLoadProps } from "../Upload/modal";
20
20
  import type { SelectProps } from "antd";
21
21
  import type { RangePickerProps } from "antd/es/date-picker";
22
22
  import type {
@@ -26,6 +26,7 @@ import type {
26
26
  DateRangePickerValueMapModal,
27
27
  } from "../modal";
28
28
  import type { ForwardedRef } from "react";
29
+ import type { DataFnProvider } from "../modal";
29
30
  type RenderFun = (
30
31
  props: HItemProps,
31
32
  node: React.ReactNode,
@@ -70,15 +71,16 @@ export interface HItemProps extends Omit<FormItemProps, "name"> {
70
71
  name?: string;
71
72
  }
72
73
 
73
- export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"|"onFinish"> {
74
+ export interface HFormProps<T = any, R = any>
75
+ extends Omit<FormProps, "form" | "onFinish"> {
74
76
  configData: HItemProps[];
75
77
  labelWidth?: number;
76
- request?: (values:T,params?:any)=>Promise<R>;
78
+ request?: (values: T, params?: any) => Promise<R>;
77
79
  infoRequest?: PromiseFnResult;
78
80
  valueType?: string;
79
81
  form?: HFormInstance;
80
82
  params?: any;
81
- onFinish?:(values:T,params?:any)=>void;
83
+ onFinish?: (values: T, params?: any) => void;
82
84
  }
83
85
 
84
86
  export interface HFormItemProps extends HItemProps {
@@ -86,9 +88,6 @@ export interface HFormItemProps extends HItemProps {
86
88
  value?: any;
87
89
  onChange?: (val: any, item: any) => void;
88
90
  }
89
- export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
90
- render: (form: HFormInstance) => React.ReactNode;
91
- }
92
91
  export type argsFn = (...args: any[]) => void;
93
92
  export interface FormContextProps {
94
93
  loading?: boolean;
@@ -100,7 +99,18 @@ interface ConfigUploadProps {
100
99
  maxSize?: number;
101
100
  request?: PromiseFnResult;
102
101
  }
102
+ export type ComponentModal =
103
+ | React.FunctionComponent<any>
104
+ | React.ComponentClass<any>
105
+ | React.ForwardRefExoticComponent<any>;
103
106
 
107
+ export interface ConfigComponentModal {
108
+ Component: ComponentModal;
109
+ placeholder?: DataFnProvider<HItemProps>;
110
+ requiredErrMsg?: DataFnProvider<HItemProps>;
111
+ }
112
+ export type DefaultComponentItemModal = ComponentModal | ConfigComponentModal;
113
+ export type DefaultComponentModal = Record<string, DefaultComponentItemModal>;
104
114
  export interface IFormConfigContextProps {
105
115
  fieldNames?: SelectProps["fieldNames"];
106
116
  valueCheckMap?: ValueCheckMapModal;
@@ -108,6 +118,7 @@ export interface IFormConfigContextProps {
108
118
  valueRangePickerValueMap?: DateRangePickerValueMapModal;
109
119
  dateRanges?: RangePickerProps["ranges"];
110
120
  uploadProps?: ConfigUploadProps;
121
+ defaultComponent?: DefaultComponentModal;
111
122
  }
112
123
  interface ActionModal {
113
124
  key: string;
@@ -124,7 +135,7 @@ export interface HFormInstance extends FormInstance {
124
135
  outputValues: (values?: Record<string, any>) => Record<string, any>;
125
136
  addDispatchListener: AddDispatchListenerFn;
126
137
  removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
127
- reload:PromiseFnResult;
138
+ reload: PromiseFnResult;
128
139
  }
129
140
 
130
141
  export interface ConnectConfigModal {
@@ -138,14 +149,14 @@ export interface FormatItemModal {
138
149
  outputValue: ValueFormat;
139
150
  }
140
151
 
141
- type addValueFormat = (
152
+ type AddValueFormat = (
142
153
  item: HFormItemProps,
143
154
  value: Record<string, any>
144
155
  ) => Record<string, any>;
145
156
 
146
157
  export interface addFormatItemModal {
147
- inputValue: addValueFormat;
148
- outputValue: addValueFormat;
158
+ inputValue: AddValueFormat;
159
+ outputValue: AddValueFormat;
149
160
  }
150
161
 
151
162
  export interface ConnectResultProps extends HFormItemProps {
@@ -0,0 +1,18 @@
1
+ import { SketchPicker } from "react-color";
2
+ import type { HInputProps } from "@/components/Input/modal";
3
+ import { presetColors } from "./data";
4
+ import { useClassName } from "../../hooks";
5
+
6
+ export default ({ value, onChange }: HInputProps) => {
7
+ const classname = useClassName("hw-color-input-picker");
8
+ return (
9
+ <SketchPicker
10
+ width={"250px"}
11
+ styles={{}}
12
+ presetColors={presetColors}
13
+ color={value}
14
+ onChangeComplete={onChange}
15
+ className={classname}
16
+ />
17
+ );
18
+ };
@@ -0,0 +1,102 @@
1
+ export const presetColors = [
2
+ "#fff1f0",
3
+ "#ffccc7",
4
+ "#ffa39e",
5
+ "#ff7875",
6
+ "#ff4d4f",
7
+ "#f5222d",
8
+ "#cf1322",
9
+ "#a8071a",
10
+ "#820014",
11
+ "#5c0011",
12
+ "#fff7e6",
13
+ "#ffe7ba",
14
+ "#ffd591",
15
+ "#ffc069",
16
+ "#ffa940",
17
+ "#fa8c16",
18
+ "#d46b08",
19
+ "#ad4e00",
20
+ "#873800",
21
+ "#612500",
22
+ "#feffe6",
23
+ "#ffffb8",
24
+ "#fffb8f",
25
+ "#fff566",
26
+ "#ffec3d",
27
+ "#fadb14",
28
+ "#d4b106",
29
+ "#ad8b00",
30
+ "#876800",
31
+ "#614700",
32
+ "#f6ffed",
33
+ "#d9f7be",
34
+ "#b7eb8f",
35
+ "#95de64",
36
+ "#73d13d",
37
+ "#52c41a",
38
+ "#389e0d",
39
+ "#237804",
40
+ "#135200",
41
+ "#092b00",
42
+ "#e6fffb",
43
+ "#b5f5ec",
44
+ "#87e8de",
45
+ "#5cdbd3",
46
+ "#36cfc9",
47
+ "#13c2c2",
48
+ "#08979c",
49
+ "#006d75",
50
+ "#00474f",
51
+ "#002329",
52
+ "#e6f7ff",
53
+ "#bae7ff",
54
+ "#91d5ff",
55
+ "#69c0ff",
56
+ "#40a9ff",
57
+ "#1890ff",
58
+ "#096dd9",
59
+ "#0050b3",
60
+ "#003a8c",
61
+ "#002766",
62
+ "#f0f5ff",
63
+ "#d6e4ff",
64
+ "#adc6ff",
65
+ "#85a5ff",
66
+ "#597ef7",
67
+ "#2f54eb",
68
+ "#1d39c4",
69
+ "#10239e",
70
+ "#061178",
71
+ "#030852",
72
+ "#f9f0ff",
73
+ "#efdbff",
74
+ "#d3adf7",
75
+ "#b37feb",
76
+ "#9254de",
77
+ "#722ed1",
78
+ "#531dab",
79
+ "#391085",
80
+ "#22075e",
81
+ "#120338",
82
+ "#fff0f6",
83
+ "#ffd6e7",
84
+ "#ffadd2",
85
+ "#ff85c0",
86
+ "#f759ab",
87
+ "#eb2f96",
88
+ "#c41d7f",
89
+ "#9e1068",
90
+ "#780650",
91
+ "#520339",
92
+ "#ffffff",
93
+ "#fafafa",
94
+ "#f5f5f5",
95
+ "#f0f0f0",
96
+ "#d9d9d9",
97
+ "#bfbfbf",
98
+ "#8c8c8c",
99
+ "#595959",
100
+ "#434343",
101
+ "#262626",
102
+ ];
@@ -0,0 +1,10 @@
1
+ @import "../../styles/local.less";
2
+ .@{ant-prefix}-hw-color-box {
3
+ width: 22px;
4
+ height: 22px;
5
+ border-radius: 4px;
6
+ cursor: pointer;
7
+ }
8
+ .@{ant-prefix}-hw-color-input-picker {
9
+ box-shadow: 0 0 0 0 !important;
10
+ }
@@ -0,0 +1,48 @@
1
+ import type { HInputProps } from "@/components/Input/modal";
2
+ import { Input, Popover } from "antd";
3
+ import Picker from "./Picker";
4
+ import { useMemo } from "react";
5
+ import { useClassName } from "../../hooks";
6
+ export default ({ value, onChange, ...props }: HInputProps) => {
7
+ const classname = useClassName("hw-color-box");
8
+ const pickerValue = useMemo(() => {
9
+ if (typeof value === "string") {
10
+ if (value.startsWith("#")) {
11
+ return value;
12
+ }
13
+ const rgbaRegular = /(?<=(rgba\())(?<rgba>.*?)(?=(\)))/;
14
+ const result = value.match(rgbaRegular);
15
+ if (result?.groups?.rgba) {
16
+ const rgbas = result.groups.rgba.split(",");
17
+ return {
18
+ r: Number(rgbas[0]),
19
+ g: Number(rgbas[1]),
20
+ b: Number(rgbas[2]),
21
+ a: Number(rgbas[3]),
22
+ };
23
+ }
24
+ }
25
+ return "";
26
+ }, [value]);
27
+ const colorChange = (val) => {
28
+ const { rgb } = val;
29
+ const text = `rgba(${rgb.r},${rgb.g},${rgb.b},${rgb.a})`;
30
+ onChange?.(text);
31
+ };
32
+ return (
33
+ <Input
34
+ {...props}
35
+ value={value}
36
+ onChange={onChange}
37
+ suffix={
38
+ <Popover
39
+ trigger="click"
40
+ content={<Picker value={pickerValue} onChange={colorChange} />}
41
+ placement="topLeft"
42
+ >
43
+ <div style={{ backgroundColor: value }} className={classname} />
44
+ </Popover>
45
+ }
46
+ />
47
+ );
48
+ };
@@ -4,8 +4,11 @@ import type { SelectInputType } from "./SelectInput";
4
4
  import type { PromiseFnResult } from "../modal";
5
5
  import type { addFormatItemModal } from "../Form/modal";
6
6
  import type { AddDispatchListenerFn } from "../Form/modal";
7
-
8
- export type HInputProps = InputProps;
7
+ export interface HInputProps<V = any>
8
+ extends Omit<InputProps, "onChange" | "value"> {
9
+ onChange?: (value: V) => void;
10
+ value?: V;
11
+ }
9
12
 
10
13
  interface ValueNameModal {
11
14
  input?: string;
@@ -138,7 +138,7 @@ export const useValueChange = (params: PartialHSelectProps) => {
138
138
  onChange(newChangeVal, subItemOps);
139
139
  };
140
140
  useEffect(() => {
141
- if (mode==="tags"){
141
+ if (mode === "tags") {
142
142
  setVal(value);
143
143
  return;
144
144
  }
@@ -1,4 +1,4 @@
1
- import { Button } from "antd";
1
+ import {Button, Row} from "antd";
2
2
  import React from "react";
3
3
  import { useFormContext } from "../Form/Context";
4
4
  import type { ButtonProps, FormInstance } from "antd/es";
@@ -6,23 +6,37 @@ import type { ButtonProps, FormInstance } from "antd/es";
6
6
  export interface ISubmitProps extends Omit<ButtonProps, "form"> {
7
7
  text?: string;
8
8
  form: FormInstance;
9
+ reset?:boolean;
10
+ position?:"start"|"end"
9
11
  }
10
12
  export default ({
11
13
  text = "提交",
12
14
  type = "primary",
13
15
  form,
14
16
  loading,
17
+ position="start",
18
+ reset,
15
19
  ...props
16
20
  }: ISubmitProps) => {
17
21
  const { loading: formSubLoading = loading } = useFormContext();
18
22
  return (
19
- <Button
20
- {...props}
21
- type={type}
22
- onClick={form.submit}
23
- loading={formSubLoading}
24
- >
25
- {text}
26
- </Button>
23
+ <Row justify={position} style={{width:"100%"}}>
24
+ {reset&&<Button
25
+ {...props}
26
+ onClick={()=>{
27
+ form.resetFields();
28
+ }}
29
+ >
30
+ 重制
31
+ </Button>}
32
+ <Button
33
+ {...props}
34
+ type={type}
35
+ onClick={form.submit}
36
+ loading={formSubLoading}
37
+ >
38
+ {text}
39
+ </Button>
40
+ </Row>
27
41
  );
28
42
  };
@@ -11,7 +11,7 @@ import { useMatchConfigProps } from "../hooks";
11
11
  import type { HItemProps } from "../Form/modal";
12
12
  import HFormConnect from "../Form/HFormConnect";
13
13
 
14
- const { RangePicker } = DatePicker;
14
+ const RangePicker = DatePicker.RangePicker as any;
15
15
 
16
16
  const HRangePicker: React.FC<HRangePickerProps> = ({
17
17
  value,
@@ -1,22 +1,19 @@
1
1
  import { DatePicker } from "antd";
2
2
  import type { HDatePickerProps } from "./modal";
3
3
  import { useTimeChange, useTimeVal } from "./hooks";
4
-
5
- export default ({
4
+ import React from "react";
5
+ const Picker = DatePicker as any;
6
+ const Index: React.FC<HDatePickerProps> = ({
6
7
  value,
7
8
  onChange,
8
9
  showTime = true,
9
10
  format = "X",
10
11
  ...props
11
- }: HDatePickerProps) => {
12
+ }) => {
12
13
  const timeVal = useTimeVal({ value, format });
13
14
  const change = useTimeChange({ format, onChange });
14
15
  return (
15
- <DatePicker
16
- value={timeVal}
17
- onChange={change}
18
- showTime={showTime}
19
- {...props}
20
- />
16
+ <Picker value={timeVal} onChange={change} showTime={showTime} {...props} />
21
17
  );
22
18
  };
19
+ export default Index;
@@ -37,4 +37,5 @@ export const baseConfig: IFormConfigContextProps = {
37
37
  },
38
38
  maxSize: 1024 * 1024 * 1.8,
39
39
  },
40
+ defaultComponent: {},
40
41
  };
@@ -5,6 +5,7 @@ export { default as HForm } from "./Form";
5
5
  export { default as useHForm } from "./Form/hooks/useHForm";
6
6
  export { useHDialogForm } from "./DialogForm/hooks";
7
7
  export { default as HFormConnect } from "./Form/HFormConnect";
8
+ export { default as HFormConfigProvider } from "./Form/Context/FormConfigProvider";
8
9
 
9
10
  import ModalForm from "./DialogForm/ModalForm";
10
11
  import DrawerForm from "./DialogForm/DrawerForm";
@@ -23,7 +24,7 @@ export const HRadioGroup = FormConfig.radioGroup;
23
24
  export const HTimePicker = FormConfig.timePicker;
24
25
  export const HInputNumber = FormConfig.inputNumber;
25
26
  export const HPageHandler = PageHandler;
26
- export const HFormConfigProvider = FormConfig.formConfigProvider;
27
27
  export const HTextArea = FormConfig.textArea;
28
+ export const HColorInput = FormConfig.colorInput;
28
29
  export const HModalForm = ModalForm;
29
30
  export const HDrawerForm = DrawerForm;
@@ -7,9 +7,11 @@ export interface ValueSwitchMapModal {
7
7
  open?: any;
8
8
  close?: any;
9
9
  }
10
- type NameProvider = (name: string) => string;
10
+ export interface DataFnProvider<P = any, R = any> {
11
+ (name: P): R;
12
+ }
11
13
 
12
14
  export interface DateRangePickerValueMapModal {
13
- start?: string | NameProvider;
14
- end?: string | NameProvider;
15
+ start?: string | DataFnProvider<string, string>;
16
+ end?: string | DataFnProvider<string, string>;
15
17
  }
@@ -1,2 +1,3 @@
1
1
  @import "../Select/index.less";
2
2
  @import "../Form/index.less";
3
+ @import "../Input/ColorInput/index.less";