@hw-component/form 1.9.6 → 1.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ interface UseValuesChangeModal {
7
7
  }
8
8
  export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
9
9
  type ParamsModal = Omit<HFormProps, "configData">;
10
- export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, }: ParamsModal) => {
10
+ export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, preserve }: ParamsModal) => {
11
11
  subControl: import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
12
12
  infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<any, [reqParams?: any]>;
13
13
  };
@@ -27,7 +27,8 @@ var useInfoReq = function useInfoReq(_ref) {
27
27
  form = _ref.form,
28
28
  params = _ref.params,
29
29
  request = _ref.request,
30
- onFinish = _ref.onFinish;
30
+ onFinish = _ref.onFinish,
31
+ preserve = _ref.preserve;
31
32
  var reqData = useMemo(function () {
32
33
  var saveParams = params || {};
33
34
  return {
@@ -40,7 +41,7 @@ var useInfoReq = function useInfoReq(_ref) {
40
41
  return _regeneratorRuntime.wrap(function _callee$(_context) {
41
42
  while (1) switch (_context.prev = _context.next) {
42
43
  case 0:
43
- subVal = form === null || form === void 0 ? void 0 : form.outputValues(value);
44
+ subVal = form === null || form === void 0 ? void 0 : form.outputValues(value, preserve);
44
45
  if (!request) {
45
46
  _context.next = 4;
46
47
  break;
@@ -177,8 +177,8 @@ var useHForm = (function () {
177
177
  }
178
178
  Reflect.deleteProperty(dispatchSourceData, key);
179
179
  },
180
- outputValues: function outputValues(value) {
181
- var val = value || form.getFieldsValue();
180
+ outputValues: function outputValues(value, preserve) {
181
+ var val = value || form.getFieldsValue(preserve);
182
182
  return formatValuesFn(val, "outputValue");
183
183
  }
184
184
  }, form), {}, {
@@ -1,3 +1,3 @@
1
1
  import type { HFormProps } from "./modal";
2
- declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, ...props }: HFormProps) => JSX.Element;
2
+ declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, preserve, ...props }: HFormProps) => JSX.Element;
3
3
  export default _default;
package/es/Form/index.js CHANGED
@@ -18,7 +18,7 @@ import { useState, useEffect } from 'react';
18
18
  import InitSet from './InitSet.js';
19
19
  import Basic from './Basic.js';
20
20
 
21
- var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter"];
21
+ var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter", "preserve"];
22
22
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
23
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
24
  var HForm = (function (_ref) {
@@ -46,6 +46,7 @@ var HForm = (function (_ref) {
46
46
  _ref$colon = _ref.colon,
47
47
  colon = _ref$colon === void 0 ? true : _ref$colon,
48
48
  dismissOnPressEnter = _ref.dismissOnPressEnter,
49
+ preserve = _ref.preserve,
49
50
  props = _objectWithoutProperties(_ref, _excluded);
50
51
  var hForm = useCurrentForm(form);
51
52
  var _useState = useState({}),
@@ -59,7 +60,8 @@ var HForm = (function (_ref) {
59
60
  valueType: valueType,
60
61
  form: hForm,
61
62
  infoRequest: infoRequest,
62
- params: params
63
+ params: params,
64
+ preserve: preserve
63
65
  }),
64
66
  subControl = _useInfoReq.subControl,
65
67
  infoControl = _useInfoReq.infoControl;
@@ -106,7 +108,8 @@ var HForm = (function (_ref) {
106
108
  children: jsxs(Form, _objectSpread(_objectSpread({
107
109
  form: hForm,
108
110
  onFinish: run,
109
- onValuesChange: valuesChange
111
+ onValuesChange: valuesChange,
112
+ preserve: preserve
110
113
  }, props), {}, {
111
114
  children: [jsx(Basic, {
112
115
  configData: configData,
@@ -127,7 +127,7 @@ export interface HFormInstance extends FormInstance {
127
127
  initValues: VoidFunction;
128
128
  formatValues: (values?: Record<string, any>, formatKey?: string) => Record<string, any>;
129
129
  dispatch: (action: ActionModal, ...args: any[]) => void;
130
- outputValues: (values?: Record<string, any>) => Record<string, any>;
130
+ outputValues: (values?: Record<string, any>, preserve?: HFormProps["preserve"]) => Record<string, any>;
131
131
  addDispatchListener: AddDispatchListenerFn;
132
132
  removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
133
133
  reload: PromiseFnResult;
@@ -9,7 +9,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
9
9
  exFiles?: string[] | null;
10
10
  request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
11
11
  url: string;
12
- }> | null;
12
+ thumbUrl?: string;
13
+ }>;
13
14
  errorType?: "alert" | "show";
14
15
  onChange?: (fileList: UploadFile[]) => void;
15
16
  value?: UploadFile[];
@@ -7,7 +7,7 @@ interface UseValuesChangeModal {
7
7
  }
8
8
  export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
9
9
  type ParamsModal = Omit<HFormProps, "configData">;
10
- export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, }: ParamsModal) => {
10
+ export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, preserve }: ParamsModal) => {
11
11
  subControl: import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
12
12
  infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<any, [reqParams?: any]>;
13
13
  };
@@ -28,7 +28,8 @@ var useInfoReq = function useInfoReq(_ref) {
28
28
  form = _ref.form,
29
29
  params = _ref.params,
30
30
  request = _ref.request,
31
- onFinish = _ref.onFinish;
31
+ onFinish = _ref.onFinish,
32
+ preserve = _ref.preserve;
32
33
  var reqData = React.useMemo(function () {
33
34
  var saveParams = params || {};
34
35
  return {
@@ -41,7 +42,7 @@ var useInfoReq = function useInfoReq(_ref) {
41
42
  return _regeneratorRuntime.wrap(function _callee$(_context) {
42
43
  while (1) switch (_context.prev = _context.next) {
43
44
  case 0:
44
- subVal = form === null || form === void 0 ? void 0 : form.outputValues(value);
45
+ subVal = form === null || form === void 0 ? void 0 : form.outputValues(value, preserve);
45
46
  if (!request) {
46
47
  _context.next = 4;
47
48
  break;
@@ -180,8 +180,8 @@ var useHForm = (function () {
180
180
  }
181
181
  Reflect.deleteProperty(dispatchSourceData, key);
182
182
  },
183
- outputValues: function outputValues(value) {
184
- var val = value || form.getFieldsValue();
183
+ outputValues: function outputValues(value, preserve) {
184
+ var val = value || form.getFieldsValue(preserve);
185
185
  return formatValuesFn(val, "outputValue");
186
186
  }
187
187
  }, form), {}, {
@@ -1,3 +1,3 @@
1
1
  import type { HFormProps } from "./modal";
2
- declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, ...props }: HFormProps) => JSX.Element;
2
+ declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, preserve, ...props }: HFormProps) => JSX.Element;
3
3
  export default _default;
package/lib/Form/index.js CHANGED
@@ -21,7 +21,7 @@ var React = require('react');
21
21
  var InitSet = require('./InitSet.js');
22
22
  var Basic = require('./Basic.js');
23
23
 
24
- var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter"];
24
+ var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter", "preserve"];
25
25
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
27
  var HForm = (function (_ref) {
@@ -49,6 +49,7 @@ var HForm = (function (_ref) {
49
49
  _ref$colon = _ref.colon,
50
50
  colon = _ref$colon === void 0 ? true : _ref$colon,
51
51
  dismissOnPressEnter = _ref.dismissOnPressEnter,
52
+ preserve = _ref.preserve,
52
53
  props = _objectWithoutProperties(_ref, _excluded);
53
54
  var hForm = index.useCurrentForm(form);
54
55
  var _useState = React.useState({}),
@@ -62,7 +63,8 @@ var HForm = (function (_ref) {
62
63
  valueType: valueType,
63
64
  form: hForm,
64
65
  infoRequest: infoRequest,
65
- params: params
66
+ params: params,
67
+ preserve: preserve
66
68
  }),
67
69
  subControl = _useInfoReq.subControl,
68
70
  infoControl = _useInfoReq.infoControl;
@@ -109,7 +111,8 @@ var HForm = (function (_ref) {
109
111
  children: jsxRuntime.jsxs(antd.Form, _objectSpread(_objectSpread({
110
112
  form: hForm,
111
113
  onFinish: run,
112
- onValuesChange: valuesChange
114
+ onValuesChange: valuesChange,
115
+ preserve: preserve
113
116
  }, props), {}, {
114
117
  children: [jsxRuntime.jsx(Basic.default, {
115
118
  configData: configData,
@@ -127,7 +127,7 @@ export interface HFormInstance extends FormInstance {
127
127
  initValues: VoidFunction;
128
128
  formatValues: (values?: Record<string, any>, formatKey?: string) => Record<string, any>;
129
129
  dispatch: (action: ActionModal, ...args: any[]) => void;
130
- outputValues: (values?: Record<string, any>) => Record<string, any>;
130
+ outputValues: (values?: Record<string, any>, preserve?: HFormProps["preserve"]) => Record<string, any>;
131
131
  addDispatchListener: AddDispatchListenerFn;
132
132
  removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
133
133
  reload: PromiseFnResult;
@@ -9,7 +9,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
9
9
  exFiles?: string[] | null;
10
10
  request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
11
11
  url: string;
12
- }> | null;
12
+ thumbUrl?: string;
13
+ }>;
13
14
  errorType?: "alert" | "show";
14
15
  onChange?: (fileList: UploadFile[]) => void;
15
16
  value?: UploadFile[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.9.6",
3
+ "version": "1.9.7",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,6 +25,7 @@ export const useInfoReq = ({
25
25
  params,
26
26
  request,
27
27
  onFinish,
28
+ preserve
28
29
  }: ParamsModal) => {
29
30
  const reqData = useMemo(() => {
30
31
  const saveParams = params || {};
@@ -35,7 +36,7 @@ export const useInfoReq = ({
35
36
 
36
37
  const subControl = useRequest(
37
38
  async (value) => {
38
- const subVal = form?.outputValues(value);
39
+ const subVal = form?.outputValues(value,preserve);
39
40
  if (request) {
40
41
  await request(subVal, reqData.params);
41
42
  }
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useMemo, useState } from "react";
1
+ import { useMemo } from "react";
2
2
  import { Form } from "antd";
3
3
  import type { FormatItemModal, HFormInstance } from "../modal";
4
4
  import type { argsFn } from "../modal";
@@ -147,8 +147,8 @@ export default () => {
147
147
  }
148
148
  Reflect.deleteProperty(dispatchSourceData, key);
149
149
  },
150
- outputValues(value) {
151
- const val = value || form.getFieldsValue();
150
+ outputValues(value,preserve) {
151
+ const val = value || form.getFieldsValue((preserve as any));
152
152
  return formatValuesFn(val, "outputValue");
153
153
  },
154
154
  ...form,
@@ -27,6 +27,7 @@ export default ({
27
27
  itemProps: formItemProps = {},
28
28
  colon = true,
29
29
  dismissOnPressEnter,
30
+ preserve,
30
31
  ...props
31
32
  }: HFormProps) => {
32
33
  const hForm = useCurrentForm(form);
@@ -40,6 +41,7 @@ export default ({
40
41
  form: hForm,
41
42
  infoRequest,
42
43
  params,
44
+ preserve
43
45
  });
44
46
  const valuesChange = useValuesChange({
45
47
  onValuesChange,
@@ -93,9 +95,10 @@ export default ({
93
95
  form={hForm}
94
96
  onFinish={run}
95
97
  onValuesChange={valuesChange}
98
+ preserve={preserve}
96
99
  {...props}
97
100
  >
98
- <Basic configData={configData} dismissOnPressEnter={dismissOnPressEnter} gutter={gutter} />
101
+ <Basic configData={configData} dismissOnPressEnter={dismissOnPressEnter} gutter={gutter} />
99
102
  <InitSet />
100
103
  </Form>
101
104
  </FormContext.Provider>
@@ -35,6 +35,7 @@ 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
37
  import type { IUrlUploadProps } from "../Upload/modal";
38
+ import {NamePath} from "rc-field-form/es/interface";
38
39
 
39
40
  type RenderFun = (
40
41
  props: HItemProps,
@@ -183,7 +184,7 @@ export interface HFormInstance extends FormInstance {
183
184
  formatKey?: string
184
185
  ) => Record<string, any>;
185
186
  dispatch: (action: ActionModal, ...args: any[]) => void;
186
- outputValues: (values?: Record<string, any>) => Record<string, any>;
187
+ outputValues: (values?: Record<string, any>,preserve?:HFormProps["preserve"]) => Record<string, any>;
187
188
  addDispatchListener: AddDispatchListenerFn;
188
189
  removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
189
190
  reload: PromiseFnResult;
@@ -3,13 +3,10 @@ import type { UploadFile } from "antd/es/upload/interface";
3
3
  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
- import type { BeforeUploadFileType } from "rc-upload/lib/interface";
7
6
  import { message } from "antd";
8
7
 
9
8
  interface SubReqParamsModal {
10
- request?: (
11
- file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
12
- ) => Promise<{ url: string; thumbUrl?: string }>;
9
+ request?:IUpLoadProps['request'];
13
10
  file: RcFile;
14
11
  }
15
12
  interface ResultModal {
@@ -1,5 +1,4 @@
1
1
  import React, {
2
- useEffect,
3
2
  useImperativeHandle,
4
3
  useMemo,
5
4
  useState,
@@ -10,7 +10,7 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
10
10
  exFiles?: string[] | null;
11
11
  request?: (
12
12
  file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
13
- ) => Promise<{ url: string }>|null;
13
+ ) => Promise<{ url: string; thumbUrl?: string }>;
14
14
  errorType?: "alert" | "show";
15
15
  onChange?: (fileList: UploadFile[]) => void;
16
16
  value?: UploadFile[];