@hw-component/form 0.0.2-bate → 0.0.2-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.
Files changed (112) hide show
  1. package/es/CheckboxGroup/index.d.ts +1 -1
  2. package/es/CheckboxGroup/index.js +4 -2
  3. package/es/DialogForm/DrawerForm/Footer.d.ts +4 -0
  4. package/es/DialogForm/DrawerForm/Footer.js +23 -0
  5. package/es/DialogForm/DrawerForm/Title.d.ts +4 -0
  6. package/es/DialogForm/DrawerForm/Title.js +18 -0
  7. package/es/DialogForm/DrawerForm/index.d.ts +4 -0
  8. package/es/DialogForm/DrawerForm/index.js +111 -0
  9. package/es/DialogForm/ModalForm.d.ts +4 -0
  10. package/es/DialogForm/ModalForm.js +89 -0
  11. package/es/DialogForm/hooks.d.ts +14 -0
  12. package/es/DialogForm/hooks.js +124 -0
  13. package/es/DialogForm/modal.d.ts +25 -0
  14. package/es/Form/HFormConnect.d.ts +1 -2
  15. package/es/Form/HFormConnect.js +17 -16
  16. package/es/Form/InitSet.d.ts +1 -4
  17. package/es/Form/InitSet.js +2 -3
  18. package/es/Form/config.d.ts +5 -4
  19. package/es/Form/config.js +6 -4
  20. package/es/Form/hooks/index.d.ts +0 -6
  21. package/es/Form/hooks/index.js +1 -33
  22. package/es/Form/hooks/useHForm.js +72 -15
  23. package/es/Form/index.js +46 -15
  24. package/es/Form/modal.d.ts +20 -8
  25. package/es/Input/SelectInput.d.ts +2 -2
  26. package/es/Input/SelectInput.js +8 -5
  27. package/es/Input/modal.d.ts +2 -0
  28. package/es/Select/hooks/norHooks.d.ts +1 -1
  29. package/es/TDPicker/RangePicker.d.ts +1 -1
  30. package/es/TDPicker/RangePicker.js +4 -2
  31. package/es/TextArea/index.js +21 -0
  32. package/es/Upload/UrlUpload/index.d.ts +2 -2
  33. package/es/Upload/UrlUpload/index.js +3 -3
  34. package/es/Upload/hooks/customRequest.js +99 -36
  35. package/es/Upload/index.d.ts +1 -2
  36. package/es/Upload/index.js +39 -5
  37. package/es/Upload/modal.d.ts +2 -0
  38. package/es/config.js +4 -4
  39. package/es/index.css +1 -1
  40. package/es/index.d.ts +8 -4
  41. package/es/index.js +7 -1
  42. package/lib/CheckboxGroup/index.d.ts +1 -1
  43. package/lib/CheckboxGroup/index.js +4 -2
  44. package/lib/DialogForm/DrawerForm/Footer.d.ts +4 -0
  45. package/lib/DialogForm/DrawerForm/Footer.js +26 -0
  46. package/lib/DialogForm/DrawerForm/Title.d.ts +4 -0
  47. package/lib/DialogForm/DrawerForm/Title.js +21 -0
  48. package/lib/DialogForm/DrawerForm/index.d.ts +4 -0
  49. package/lib/DialogForm/DrawerForm/index.js +114 -0
  50. package/lib/DialogForm/ModalForm.d.ts +4 -0
  51. package/lib/DialogForm/ModalForm.js +92 -0
  52. package/lib/DialogForm/hooks.d.ts +14 -0
  53. package/lib/DialogForm/hooks.js +128 -0
  54. package/lib/DialogForm/modal.d.ts +25 -0
  55. package/lib/Form/HFormConnect.d.ts +1 -2
  56. package/lib/Form/HFormConnect.js +17 -16
  57. package/lib/Form/InitSet.d.ts +1 -4
  58. package/lib/Form/InitSet.js +2 -3
  59. package/lib/Form/config.d.ts +5 -4
  60. package/lib/Form/config.js +3 -1
  61. package/lib/Form/hooks/index.d.ts +0 -6
  62. package/lib/Form/hooks/index.js +0 -33
  63. package/lib/Form/hooks/useHForm.js +72 -15
  64. package/lib/Form/index.js +53 -22
  65. package/lib/Form/modal.d.ts +20 -8
  66. package/lib/Input/SelectInput.d.ts +2 -2
  67. package/lib/Input/SelectInput.js +8 -5
  68. package/lib/Input/modal.d.ts +2 -0
  69. package/lib/Select/hooks/norHooks.d.ts +1 -1
  70. package/lib/TDPicker/RangePicker.d.ts +1 -1
  71. package/lib/TDPicker/RangePicker.js +4 -2
  72. package/lib/TextArea/index.js +24 -0
  73. package/lib/Upload/UrlUpload/index.d.ts +2 -2
  74. package/lib/Upload/UrlUpload/index.js +3 -3
  75. package/lib/Upload/hooks/customRequest.js +99 -36
  76. package/lib/Upload/index.d.ts +1 -2
  77. package/lib/Upload/index.js +39 -5
  78. package/lib/Upload/modal.d.ts +2 -0
  79. package/lib/config.js +4 -4
  80. package/lib/index.css +1 -1
  81. package/lib/index.d.ts +8 -4
  82. package/lib/index.js +10 -0
  83. package/package.json +1 -1
  84. package/src/components/CheckboxGroup/index.tsx +2 -2
  85. package/src/components/DialogForm/DrawerForm/Footer.tsx +19 -0
  86. package/src/components/DialogForm/DrawerForm/Title.tsx +12 -0
  87. package/src/components/DialogForm/DrawerForm/index.tsx +85 -0
  88. package/src/components/DialogForm/ModalForm.tsx +60 -0
  89. package/src/components/DialogForm/hooks.ts +87 -0
  90. package/src/components/DialogForm/modal.ts +27 -0
  91. package/src/components/Form/FormItem/Helper.tsx +3 -4
  92. package/src/components/Form/HFormConnect.tsx +26 -8
  93. package/src/components/Form/InitSet.tsx +3 -5
  94. package/src/components/Form/config.ts +2 -1
  95. package/src/components/Form/hooks/index.ts +0 -20
  96. package/src/components/Form/hooks/useHForm.ts +67 -14
  97. package/src/components/Form/index.less +1 -1
  98. package/src/components/Form/index.tsx +25 -7
  99. package/src/components/Form/modal.ts +22 -10
  100. package/src/components/Input/SelectInput.tsx +4 -2
  101. package/src/components/Input/modal.ts +2 -0
  102. package/src/components/TDPicker/RangePicker.tsx +5 -6
  103. package/src/components/Upload/UrlUpload/index.tsx +2 -2
  104. package/src/components/Upload/hooks/customRequest.ts +57 -14
  105. package/src/components/Upload/index.tsx +39 -7
  106. package/src/components/Upload/modal.ts +2 -0
  107. package/src/components/config.ts +4 -4
  108. package/src/components/index.tsx +6 -0
  109. package/src/pages/DrawerForm/index.tsx +127 -0
  110. package/src/pages/Form/index.tsx +3 -0
  111. package/src/pages/ModalForm/index.tsx +127 -0
  112. package/src/routes.tsx +12 -0
@@ -12,6 +12,7 @@ import type { IUpLoadProps } from "@/components/Upload/modal";
12
12
  import type { SelectProps } from "antd";
13
13
  import type { RangePickerProps } from "antd/es/date-picker";
14
14
  import type { PromiseFnResult, ValueCheckMapModal, ValueSwitchMapModal, DateRangePickerValueMapModal } from "../modal";
15
+ import type { ForwardedRef } from "react";
15
16
  type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => void;
16
17
  type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps;
17
18
  export interface HoverModal {
@@ -20,17 +21,17 @@ export interface HoverModal {
20
21
  }
21
22
  type HelperModal = (form: HFormInstance) => React.ReactNode | string;
22
23
  export type HideModal = (form: HFormInstance) => boolean;
24
+ export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
23
25
  export interface HItemProps extends Omit<FormItemProps, "name"> {
24
26
  type?: string;
25
27
  itemProps?: ItemPropsType;
26
28
  render?: RenderFun;
27
- helper?: HelperModal;
29
+ helper?: HelperModal | string;
28
30
  hover?: string | HoverModal;
29
31
  labelWidth?: number;
30
32
  hide?: boolean | HideModal;
31
33
  placeholder?: string | string[];
32
- formatKeys?: string[];
33
- name: string;
34
+ name?: string;
34
35
  }
35
36
  export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
36
37
  configData: HItemProps[];
@@ -42,10 +43,13 @@ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
42
43
  }
43
44
  export interface HFormItemProps extends HItemProps {
44
45
  required?: boolean;
46
+ value?: any;
47
+ onChange?: (val: any, item: any) => void;
45
48
  }
46
49
  export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
47
50
  render: (form: HFormInstance) => React.ReactNode;
48
51
  }
52
+ export type argsFn = (...args: any[]) => void;
49
53
  export interface FormContextProps {
50
54
  loading?: boolean;
51
55
  form: HFormInstance;
@@ -64,14 +68,18 @@ export interface IFormConfigContextProps {
64
68
  dateRanges?: RangePickerProps["ranges"];
65
69
  uploadProps?: ConfigUploadProps;
66
70
  }
71
+ interface ActionModal {
72
+ key: string;
73
+ name?: string;
74
+ }
67
75
  export interface HFormInstance extends FormInstance {
68
76
  addFormat: (name: string, formats?: FormatItemModal) => void;
69
- initValues: (values?: Record<string, any>) => void;
77
+ initValues: VoidFunction;
70
78
  formatValues: (values?: Record<string, any>, formatKey?: string) => Record<string, any>;
71
- dispatch: (key: string) => void;
79
+ dispatch: (action: ActionModal, ...args: any[]) => void;
72
80
  outputValues: (values?: Record<string, any>) => Record<string, any>;
73
- addDispatchListener: (key: string, fn: VoidFunction) => void;
74
- removeDispatchListener: (key?: string) => void;
81
+ addDispatchListener: AddDispatchListenerFn;
82
+ removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
75
83
  }
76
84
  export interface ConnectConfigModal {
77
85
  format?: Record<string, addFormatItemModal>;
@@ -86,7 +94,11 @@ export interface addFormatItemModal {
86
94
  inputValue: addValueFormat;
87
95
  outputValue: addValueFormat;
88
96
  }
89
- export interface ConnectResultProps {
97
+ export interface ConnectResultProps extends HFormItemProps {
90
98
  addFormat?: (format: Record<string, addFormatItemModal>) => void;
99
+ addDispatchListener?: (key: string, fn: argsFn) => void;
100
+ ref?: ForwardedRef<any>;
101
+ value?: any;
102
+ onChange?: (value: any, item?: any) => void;
91
103
  }
92
104
  export {};
@@ -4,6 +4,6 @@ export declare enum SelectInputType {
4
4
  input = 0,
5
5
  select = 1
6
6
  }
7
- export declare const Index: ({ selectProps, value, onChange, valueName, addFormat, ...props }: HSelectInputProps) => JSX.Element;
8
- declare const _default: (props: import("../Form/modal").HFormItemProps) => import("react").ReactElement<import("../Form/modal").ConnectResultProps, string | import("react").JSXElementConstructor<any>>;
7
+ export declare const Index: ({ selectProps, value, onChange, valueName, addFormat, addDispatchListener, ...props }: HSelectInputProps) => JSX.Element;
8
+ declare const _default: import("react").ForwardRefExoticComponent<import("@/components/Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
9
9
  export default _default;
@@ -20,7 +20,7 @@ var index = require('../Select/index.js');
20
20
  var defaultConfig = require('./defaultConfig.js');
21
21
  var HFormConnect = require('../Form/HFormConnect.js');
22
22
 
23
- var _excluded = ["selectProps", "value", "onChange", "valueName", "addFormat"],
23
+ var _excluded = ["selectProps", "value", "onChange", "valueName", "addFormat", "addDispatchListener"],
24
24
  _excluded2 = ["style", "placeholder"];
25
25
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -37,8 +37,9 @@ var Index = function Index(_ref) {
37
37
  onChange = _ref.onChange,
38
38
  _ref$valueName = _ref.valueName,
39
39
  valueName = _ref$valueName === void 0 ? defaultConfig.defaultValueName : _ref$valueName,
40
- addFormat = _ref.addFormat,
41
- props = _objectWithoutProperties(_ref, _excluded);
40
+ addFormat = _ref.addFormat;
41
+ _ref.addDispatchListener;
42
+ var props = _objectWithoutProperties(_ref, _excluded);
42
43
  var _valueName$input = valueName.input,
43
44
  input = _valueName$input === void 0 ? "" : _valueName$input,
44
45
  _valueName$select = valueName.select,
@@ -60,7 +61,8 @@ var Index = function Index(_ref) {
60
61
  "float": {
61
62
  inputValue: function inputValue(item, initValue) {
62
63
  var _context;
63
- var name = item.name;
64
+ var _item$name = item.name,
65
+ name = _item$name === void 0 ? "" : _item$name;
64
66
  var resultObj = {};
65
67
  _forEachInstanceProperty(_context = _Object$values(valueName)).call(_context, function (key) {
66
68
  resultObj[key] = initValue[key];
@@ -68,7 +70,8 @@ var Index = function Index(_ref) {
68
70
  return _defineProperty({}, name, resultObj);
69
71
  },
70
72
  outputValue: function outputValue(item, _outputValue) {
71
- var name = item.name;
73
+ var _item$name2 = item.name,
74
+ name = _item$name2 === void 0 ? "" : _item$name2;
72
75
  var _outputValue$name = _outputValue[name],
73
76
  itemVal = _outputValue$name === void 0 ? {} : _outputValue$name;
74
77
  var newItemVal = _defineProperty({}, itemVal[select], itemVal[input]);
@@ -3,6 +3,7 @@ import type { HSelectProps } from "../Select/modal";
3
3
  import type { SelectInputType } from "./SelectInput";
4
4
  import type { PromiseFnResult } from "../modal";
5
5
  import type { addFormatItemModal } from "../Form/modal";
6
+ import type { AddDispatchListenerFn } from "../Form/modal";
6
7
  export type HInputProps = InputProps;
7
8
  interface ValueNameModal {
8
9
  input?: string;
@@ -14,6 +15,7 @@ export interface HSelectInputProps extends Omit<HInputProps, "value" | "onChange
14
15
  onChange?: (value: Record<string, any>, type: SelectInputType) => void;
15
16
  valueName?: ValueNameModal;
16
17
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
18
+ addDispatchListener?: AddDispatchListenerFn;
17
19
  }
18
20
  export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
19
21
  onClick: (value: string | readonly string[] | number | undefined, e: HTMLElement) => void;
@@ -1,6 +1,6 @@
1
1
  import type { OptionType, PartialHSelectProps } from "@/components/Select/modal";
2
2
  export declare const useOptionReq: ({ manual, request, options, serviceSearch, showSearch, onSearch: propsOnSearch, }: PartialHSelectProps) => {
3
- run: (params?: any, type?: any) => Promise<any>;
3
+ run: (params?: any, type?: any) => Promise<OptionType[] | undefined>;
4
4
  loading: boolean;
5
5
  error: Error | undefined;
6
6
  data: OptionType[] | undefined;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import type { HItemProps } from "../Form/modal";
3
3
  declare const _default: {
4
- Component: (props: import("../Form/modal").HFormItemProps) => React.ReactElement<import("../Form/modal").ConnectResultProps, string | React.JSXElementConstructor<any>>;
4
+ Component: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
5
5
  placeholder: ({ label }: HItemProps) => string[];
6
6
  requiredErrMsg: ({ label }: HItemProps) => string;
7
7
  };
@@ -70,7 +70,8 @@ var HRangePicker = function HRangePicker(_ref) {
70
70
  "float": {
71
71
  inputValue: function inputValue(item, initValue) {
72
72
  var _context;
73
- var valueName = item.name;
73
+ var _item$name = item.name,
74
+ valueName = _item$name === void 0 ? "" : _item$name;
74
75
  var resultObj = {};
75
76
  _forEachInstanceProperty(_context = _Object$values(dateMapKeys)).call(_context, function (key) {
76
77
  if (initValue[key]) {
@@ -81,7 +82,8 @@ var HRangePicker = function HRangePicker(_ref) {
81
82
  return _defineProperty({}, valueName, hasKeys ? resultObj : null);
82
83
  },
83
84
  outputValue: function outputValue(item, _outputValue) {
84
- var valueName = item.name;
85
+ var _item$name2 = item.name,
86
+ valueName = _item$name2 === void 0 ? "" : _item$name2;
85
87
  var _outputValue$valueNam = _outputValue[valueName],
86
88
  itemVal = _outputValue$valueNam === void 0 ? {} : _outputValue$valueNam;
87
89
  return _objectSpread({}, itemVal);
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var _extends = require('@babel/runtime-corejs3/helpers/extends');
7
+ var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
8
+ var antd = require('antd');
9
+
10
+ var _excluded = ["autoSize"];
11
+ var TextArea = (function (_ref) {
12
+ var _ref$autoSize = _ref.autoSize,
13
+ autoSize = _ref$autoSize === void 0 ? {
14
+ minRows: 4,
15
+ maxRows: 4
16
+ } : _ref$autoSize,
17
+ props = _objectWithoutProperties(_ref, _excluded);
18
+ return /*#__PURE__*/React.createElement(antd.Input.TextArea, _extends({
19
+ autoSize: autoSize
20
+ }, props));
21
+ });
22
+
23
+ exports.default = TextArea;
24
+ // powered by h
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import type { IUrlUploadProps } from "../modal";
3
- declare const _default: ({ placeholder, value, onChange, mediaType, ...props }: IUrlUploadProps) => JSX.Element;
4
- export default _default;
3
+ declare const Index: ({ placeholder, value, onChange, mediaType, ...props }: IUrlUploadProps) => JSX.Element;
4
+ export default Index;
@@ -16,7 +16,7 @@ var index = require('../index.js');
16
16
  var TypeEle = require('../MediaTypeEle/TypeEle.js');
17
17
 
18
18
  var _excluded = ["placeholder", "value", "onChange", "mediaType"];
19
- var HUrlUpload = (function (_ref) {
19
+ var Index = function Index(_ref) {
20
20
  var _ref$placeholder = _ref.placeholder,
21
21
  placeholder = _ref$placeholder === void 0 ? "请输入文件地址" : _ref$placeholder,
22
22
  _ref$value = _ref.value,
@@ -116,7 +116,7 @@ var HUrlUpload = (function (_ref) {
116
116
  onReady: onReady,
117
117
  onError: onError
118
118
  })));
119
- });
119
+ };
120
120
 
121
- exports.default = HUrlUpload;
121
+ exports.default = Index;
122
122
  // powered by h
@@ -1,15 +1,91 @@
1
1
  'use strict';
2
2
 
3
+ var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
4
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js/object/get-own-property-symbols');
5
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptor');
6
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
7
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
8
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
9
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
3
10
  var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
4
- var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
11
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
5
12
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
6
13
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
14
+ var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
7
15
  var React = require('react');
16
+ var antd = require('antd');
8
17
 
9
- var useCustomRequest = function useCustomRequest(_ref) {
10
- var value = _ref.value,
11
- request = _ref.request,
12
- onChange = _ref.onChange;
18
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
20
+ var subReq = /*#__PURE__*/function () {
21
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
22
+ var request, file, _yield$request, url;
23
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
24
+ while (1) switch (_context.prev = _context.next) {
25
+ case 0:
26
+ request = _ref.request, file = _ref.file;
27
+ if (request) {
28
+ _context.next = 3;
29
+ break;
30
+ }
31
+ return _context.abrupt("return", {
32
+ url: "",
33
+ status: "done"
34
+ });
35
+ case 3:
36
+ _context.prev = 3;
37
+ _context.next = 6;
38
+ return request(file);
39
+ case 6:
40
+ _yield$request = _context.sent;
41
+ url = _yield$request.url;
42
+ return _context.abrupt("return", {
43
+ url: url,
44
+ status: "done"
45
+ });
46
+ case 11:
47
+ _context.prev = 11;
48
+ _context.t0 = _context["catch"](3);
49
+ antd.message.error(_context.t0.message);
50
+ return _context.abrupt("return", {
51
+ url: "",
52
+ status: "error"
53
+ });
54
+ case 15:
55
+ case "end":
56
+ return _context.stop();
57
+ }
58
+ }, _callee, null, [[3, 11]]);
59
+ }));
60
+ return function subReq(_x) {
61
+ return _ref2.apply(this, arguments);
62
+ };
63
+ }();
64
+ var fileListProvider = function fileListProvider(changeFile, files) {
65
+ var status = changeFile.status,
66
+ url = changeFile.url,
67
+ uid = changeFile.uid;
68
+ if (status === "error") {
69
+ return files === null || files === void 0 ? void 0 : _filterInstanceProperty(files).call(files, function (item) {
70
+ return item.uid !== uid;
71
+ });
72
+ }
73
+ return files === null || files === void 0 ? void 0 : _mapInstanceProperty(files).call(files, function (item) {
74
+ var resultUrl = url || item.thumbUrl;
75
+ if (item.uid === uid) {
76
+ item.status = status;
77
+ item.response = {
78
+ url: resultUrl
79
+ };
80
+ return item;
81
+ }
82
+ return item;
83
+ });
84
+ };
85
+ var useCustomRequest = function useCustomRequest(_ref3) {
86
+ var value = _ref3.value,
87
+ request = _ref3.request,
88
+ onChange = _ref3.onChange;
13
89
  var valObj = React.useMemo(function () {
14
90
  return {
15
91
  value: value
@@ -19,44 +95,31 @@ var useCustomRequest = function useCustomRequest(_ref) {
19
95
  valObj.value = value;
20
96
  }, [value]);
21
97
  var sendFile = /*#__PURE__*/function () {
22
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file) {
23
- var _valObj$value;
24
- var uid, url, result, fileList;
25
- return _regeneratorRuntime.wrap(function _callee$(_context) {
26
- while (1) switch (_context.prev = _context.next) {
98
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(file) {
99
+ var uid, result, fileList;
100
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
101
+ while (1) switch (_context2.prev = _context2.next) {
27
102
  case 0:
28
103
  uid = file.uid;
29
- url = "";
30
- if (!request) {
31
- _context.next = 7;
32
- break;
33
- }
34
- _context.next = 5;
35
- return request(file);
36
- case 5:
37
- result = _context.sent;
38
- url = result.url;
39
- case 7:
40
- fileList = valObj === null || valObj === void 0 ? void 0 : (_valObj$value = valObj.value) === null || _valObj$value === void 0 ? void 0 : _mapInstanceProperty(_valObj$value).call(_valObj$value, function (item) {
41
- var resultUrl = url || item.thumbUrl;
42
- if (item.uid === uid) {
43
- item.status = "done";
44
- item.response = {
45
- url: resultUrl
46
- };
47
- return item;
48
- }
49
- return item;
104
+ _context2.next = 3;
105
+ return subReq({
106
+ request: request,
107
+ file: file
50
108
  });
109
+ case 3:
110
+ result = _context2.sent;
111
+ fileList = fileListProvider(_objectSpread(_objectSpread({}, result), {}, {
112
+ uid: uid
113
+ }), valObj.value);
51
114
  onChange === null || onChange === void 0 ? void 0 : onChange(fileList || []);
52
- case 9:
115
+ case 6:
53
116
  case "end":
54
- return _context.stop();
117
+ return _context2.stop();
55
118
  }
56
- }, _callee);
119
+ }, _callee2);
57
120
  }));
58
- return function sendFile(_x) {
59
- return _ref2.apply(this, arguments);
121
+ return function sendFile(_x2) {
122
+ return _ref4.apply(this, arguments);
60
123
  };
61
124
  }();
62
125
  return function (fileList) {
@@ -1,4 +1,3 @@
1
1
  import React from "react";
2
- import type { IUpLoadProps, IUploadRefModal } from "./modal";
3
- declare const _default: React.ForwardRefExoticComponent<IUpLoadProps & React.RefAttributes<IUploadRefModal>>;
2
+ declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
4
3
  export default _default;
@@ -14,14 +14,16 @@ var _extends = require('@babel/runtime-corejs3/helpers/extends');
14
14
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
15
15
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
16
16
  var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
17
- var antd = require('antd');
18
- var Btn = require('./Btn.js');
17
+ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
19
18
  var React = require('react');
19
+ var propsMaker = require('./hooks/propsMaker.js');
20
20
  var index = require('./Preview/index.js');
21
21
  var change = require('./hooks/change.js');
22
- var propsMaker = require('./hooks/propsMaker.js');
22
+ var antd = require('antd');
23
+ var Btn = require('./Btn.js');
24
+ var HFormConnect = require('../Form/HFormConnect.js');
23
25
 
24
- var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize"];
26
+ var _excluded = ["value", "onChange", "listType", "exFiles", "maxCount", "maxRowNum", "onPreview", "request", "maxSize", "addFormat"];
25
27
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
28
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
27
29
  var Index = function Index(_ref, ref) {
@@ -38,6 +40,7 @@ var Index = function Index(_ref, ref) {
38
40
  onPreview = _ref.onPreview,
39
41
  request = _ref.request,
40
42
  maxSize = _ref.maxSize,
43
+ addFormat = _ref.addFormat,
41
44
  props = _objectWithoutProperties(_ref, _excluded);
42
45
  var matchProps = propsMaker.useProps({
43
46
  request: request,
@@ -80,6 +83,37 @@ var Index = function Index(_ref, ref) {
80
83
  var maxNum = maxCount === 1 ? maxCount : Number.MAX_VALUE;
81
84
  var visible = previewModal.visible,
82
85
  previewFile = previewModal.file;
86
+ addFormat === null || addFormat === void 0 ? void 0 : addFormat({
87
+ "float": {
88
+ inputValue: function inputValue(item, initValue) {
89
+ var _item$name = item.name,
90
+ name = _item$name === void 0 ? "" : _item$name;
91
+ var initFileList = initValue[name] || [];
92
+ var fileList = _mapInstanceProperty(initFileList).call(initFileList, function (url, index) {
93
+ return {
94
+ name: url,
95
+ response: {
96
+ url: url
97
+ },
98
+ status: "done",
99
+ uid: "init-".concat(index),
100
+ thumbUrl: url
101
+ };
102
+ });
103
+ return _defineProperty({}, name, fileList);
104
+ },
105
+ outputValue: function outputValue(item, _outputValue) {
106
+ var _item$name2 = item.name,
107
+ valueName = _item$name2 === void 0 ? "" : _item$name2;
108
+ var _outputValue$valueNam = _outputValue[valueName],
109
+ itemVal = _outputValue$valueNam === void 0 ? [] : _outputValue$valueNam;
110
+ var urls = _mapInstanceProperty(itemVal).call(itemVal, function (fileItem) {
111
+ return fileItem.response.url;
112
+ });
113
+ return _defineProperty({}, valueName, urls);
114
+ }
115
+ }
116
+ });
83
117
  return /*#__PURE__*/React.createElement("div", {
84
118
  style: contentStyle
85
119
  }, /*#__PURE__*/React.createElement(antd.Upload, _extends({
@@ -103,7 +137,7 @@ var Index = function Index(_ref, ref) {
103
137
  }
104
138
  }));
105
139
  };
106
- var HUpload = /*#__PURE__*/React.forwardRef(Index);
140
+ var HUpload = HFormConnect.default( /*#__PURE__*/React.forwardRef(Index));
107
141
 
108
142
  exports.default = HUpload;
109
143
  // powered by h
@@ -3,6 +3,7 @@ import type { UploadFile } from "antd/es/upload/interface";
3
3
  import type { BeforeUploadFileType, RcFile } from "rc-upload/lib/interface";
4
4
  import type { UploadChangeParam } from "antd/lib/upload/interface";
5
5
  import type { MediaTypeEnum } from "@/components/Upload/enums";
6
+ import type { addFormatItemModal } from "@/components/Form/modal";
6
7
  export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
7
8
  exFiles?: string[];
8
9
  request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
@@ -13,6 +14,7 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
13
14
  value?: UploadFile[];
14
15
  maxRowNum?: number;
15
16
  maxSize?: number;
17
+ addFormat?: (config: Record<string, addFormatItemModal>) => void;
16
18
  }
17
19
  export interface IMediaTypeEleProps {
18
20
  file?: UploadFile;
package/lib/config.js CHANGED
@@ -11,12 +11,12 @@ var baseConfig = {
11
11
  value: "value"
12
12
  },
13
13
  valueCheckMap: {
14
- checked: true,
15
- noChecked: false
14
+ checked: 1,
15
+ noChecked: 0
16
16
  },
17
17
  valueSwitchMap: {
18
- open: true,
19
- close: false
18
+ open: 1,
19
+ close: 0
20
20
  },
21
21
  valueRangePickerValueMap: {
22
22
  start: function start(name) {
package/lib/index.css CHANGED
@@ -10,7 +10,7 @@
10
10
  .ant-hw-form-item-colon:after {
11
11
  position: relative;
12
12
  top: -0.5px;
13
- margin: 0 8px 0 2px;
13
+ margin: 0 0 0 2px;
14
14
  content: ":";
15
15
  }
16
16
  .ant-hw-form-item-required:before {
package/lib/index.d.ts CHANGED
@@ -2,19 +2,23 @@
2
2
  import "./styles/index.less";
3
3
  export { default as HForm } from "./Form";
4
4
  export { default as useHForm } from "./Form/hooks/useHForm";
5
+ export { useHDialogForm } from "./DialogForm/hooks";
5
6
  export declare const HSelect: ({ style, mode, options, modeConfig, value, onChange, fieldNames: propsFieldNames, request, manual, optionLabelProp, filterProvider, optionFilterProp, serviceSearch, onSearch: propsOnSearch, filterOption, showSearch, labelInValue, noMatchItemRender, allSelect, ...props }: import("./Select/modal").HSelectProps) => JSX.Element;
6
7
  export declare const HInput: ({ ...props }: import("antd").InputProps) => JSX.Element;
7
- export declare const HSelectInput: ({ selectProps, value, onChange, valueName, ...props }: import("./Input/modal").HSelectInputProps) => JSX.Element;
8
- export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Upload/modal").IUpLoadProps & import("react").RefAttributes<import("./Upload/modal").IUploadRefModal>>;
8
+ export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
9
+ export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
9
10
  export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
10
11
  export declare const HButtonInput: import("react").FC<import("./Input/modal").HButtonInputProps>;
11
12
  export declare const HCheckBox: import("react").FC<import("./CheckboxGroup/modal").HCheckboxProps>;
12
13
  export declare const HSwitch: import("react").FC<import("./Switch").HSwitchProps>;
13
- export declare const HCheckboxGroup: (props: import("./Form/modal").HFormItemProps) => import("react").ReactElement<import("./Form/modal").ConnectResultProps, string | import("react").JSXElementConstructor<any>>;
14
+ export declare const HCheckboxGroup: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
14
15
  export declare const HDatePicker: ({ value, onChange, showTime, format, ...props }: import("./TDPicker/modal").HDatePickerProps) => JSX.Element;
15
- export declare const HRangePicker: ({ value, onChange, showTime, format, valueMap, ranges, name, ...props }: import("./TDPicker/modal").HRangePickerProps) => JSX.Element;
16
+ export declare const HRangePicker: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
16
17
  export declare const HRadioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("./RadioGroup").HRadioGroupProps) => JSX.Element;
17
18
  export declare const HTimePicker: ({ value, format, onChange, ...props }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
18
19
  export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
19
20
  export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
20
21
  export declare const HFormConfigProvider: import("react").FC<import("./Form/modal").IFormConfigContextProps>;
22
+ export declare const HTextArea: ({ autoSize, ...props }: import("antd/es/input").TextAreaProps) => JSX.Element;
23
+ export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, initialValues, onFinish, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
24
+ export declare const HDrawerForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, dialogForm, closable, initialValues, labelWidth, onOk, onFinish, size, form, footer, ...props }: import("./DialogForm/modal").DialogFormProps) => JSX.Element;
package/lib/index.js CHANGED
@@ -4,6 +4,9 @@ var config = require('./Form/config.js');
4
4
  var index$1 = require('./PageHandler/index.js');
5
5
  var index = require('./Form/index.js');
6
6
  var useHForm = require('./Form/hooks/useHForm.js');
7
+ var hooks = require('./DialogForm/hooks.js');
8
+ var ModalForm = require('./DialogForm/ModalForm.js');
9
+ var index$2 = require('./DialogForm/DrawerForm/index.js');
7
10
 
8
11
  var HSelect = config.default.select;
9
12
  var HInput = config.default.input;
@@ -21,22 +24,29 @@ var HTimePicker = config.default.timePicker;
21
24
  var HInputNumber = config.default.inputNumber;
22
25
  var HPageHandler = index$1.default;
23
26
  var HFormConfigProvider = config.default.formConfigProvider;
27
+ var HTextArea = config.default.textArea;
28
+ var HModalForm = ModalForm.default;
29
+ var HDrawerForm = index$2.default;
24
30
 
25
31
  exports.HForm = index.default;
26
32
  exports.useHForm = useHForm.default;
33
+ exports.useHDialogForm = hooks.useHDialogForm;
27
34
  exports.HButtonInput = HButtonInput;
28
35
  exports.HCheckBox = HCheckBox;
29
36
  exports.HCheckboxGroup = HCheckboxGroup;
30
37
  exports.HDatePicker = HDatePicker;
38
+ exports.HDrawerForm = HDrawerForm;
31
39
  exports.HFormConfigProvider = HFormConfigProvider;
32
40
  exports.HInput = HInput;
33
41
  exports.HInputNumber = HInputNumber;
42
+ exports.HModalForm = HModalForm;
34
43
  exports.HPageHandler = HPageHandler;
35
44
  exports.HRadioGroup = HRadioGroup;
36
45
  exports.HRangePicker = HRangePicker;
37
46
  exports.HSelect = HSelect;
38
47
  exports.HSelectInput = HSelectInput;
39
48
  exports.HSwitch = HSwitch;
49
+ exports.HTextArea = HTextArea;
40
50
  exports.HTimePicker = HTimePicker;
41
51
  exports.HUpload = HUpload;
42
52
  exports.HUrlUpload = HUrlUpload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.2-bate",
3
+ "version": "0.0.2-beta-v1",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,7 +32,7 @@ const Index = ({
32
32
  addFormat?.({
33
33
  float: {
34
34
  inputValue: (item, initValue) => {
35
- const { name } = item;
35
+ const { name = "" } = item;
36
36
  const keys = checkOptions?.map((optItem) => {
37
37
  return optItem.value;
38
38
  });
@@ -45,7 +45,7 @@ const Index = ({
45
45
  };
46
46
  },
47
47
  outputValue: (item, outputValue) => {
48
- const { name } = item;
48
+ const { name = "" } = item;
49
49
  const { [name]: itemVal = {} } = outputValue;
50
50
  return {
51
51
  ...itemVal,
@@ -0,0 +1,19 @@
1
+ import { Row, Space, Button } from "antd";
2
+ import type { DialogFormProps } from "../modal";
3
+
4
+ export default ({
5
+ onCancel,
6
+ onOk,
7
+ confirmLoading,
8
+ }: Omit<DialogFormProps, "configData">) => {
9
+ return (
10
+ <Row justify={"end"}>
11
+ <Space size={"middle"}>
12
+ <Button onClick={onCancel}>关闭</Button>
13
+ <Button type={"primary"} onClick={onOk} loading={confirmLoading}>
14
+ 确定
15
+ </Button>
16
+ </Space>
17
+ </Row>
18
+ );
19
+ };