@hw-component/form 1.6.5 → 1.6.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.
@@ -9,12 +9,23 @@ import 'core-js/modules/es.object.get-own-property-descriptors.js';
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
10
10
  import { jsx } from 'react/jsx-runtime';
11
11
  import { useFormItemDomControl } from './hooks.js';
12
+ import { useFormContext } from '../Context/index.js';
12
13
 
13
14
  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; }
14
15
  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; }
15
16
  var Item = (function (props) {
17
+ var _useFormContext = useFormContext(),
18
+ formLabelWidth = _useFormContext.labelWidth,
19
+ formLabelAlign = _useFormContext.labelAlign;
20
+ var _props$labelWidth = props.labelWidth,
21
+ labelWidth = _props$labelWidth === void 0 ? formLabelWidth : _props$labelWidth,
22
+ _props$labelAlign = props.labelAlign,
23
+ labelAlign = _props$labelAlign === void 0 ? formLabelAlign : _props$labelAlign;
16
24
  var Component = useFormItemDomControl(props);
17
- return jsx(Component, _objectSpread({}, props));
25
+ return jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
26
+ labelAlign: labelAlign,
27
+ labelWidth: labelWidth
28
+ }));
18
29
  });
19
30
 
20
31
  export { Item as default };
package/es/Form/index.js CHANGED
@@ -94,7 +94,9 @@ var HForm = (function (_ref) {
94
94
  value: {
95
95
  loading: submitLoading || loading,
96
96
  form: hForm,
97
- valueType: valueType
97
+ valueType: valueType,
98
+ labelAlign: formLabelAlign,
99
+ labelWidth: labelWidth
98
100
  },
99
101
  children: jsxs(Form, _objectSpread(_objectSpread({
100
102
  form: hForm,
@@ -81,6 +81,8 @@ export interface FormContextProps {
81
81
  loading?: boolean;
82
82
  form: HFormInstance;
83
83
  valueType?: string;
84
+ labelAlign?: LabelAlignModal;
85
+ labelWidth?: number;
84
86
  }
85
87
  interface ConfigUploadProps {
86
88
  exFiles?: string[];
@@ -75,6 +75,9 @@ var useValueChange = function useValueChange(params) {
75
75
  if (labelInValue) {
76
76
  return val;
77
77
  }
78
+ if (val === undefined || mode === "tags") {
79
+ return val;
80
+ }
78
81
  if (!val) {
79
82
  return val;
80
83
  }
@@ -12,12 +12,23 @@ require('core-js/modules/es.object.get-own-property-descriptors.js');
12
12
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
13
13
  var jsxRuntime = require('react/jsx-runtime');
14
14
  var hooks = require('./hooks.js');
15
+ var index = require('../Context/index.js');
15
16
 
16
17
  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; }
17
18
  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; }
18
19
  var Item = (function (props) {
20
+ var _useFormContext = index.useFormContext(),
21
+ formLabelWidth = _useFormContext.labelWidth,
22
+ formLabelAlign = _useFormContext.labelAlign;
23
+ var _props$labelWidth = props.labelWidth,
24
+ labelWidth = _props$labelWidth === void 0 ? formLabelWidth : _props$labelWidth,
25
+ _props$labelAlign = props.labelAlign,
26
+ labelAlign = _props$labelAlign === void 0 ? formLabelAlign : _props$labelAlign;
19
27
  var Component = hooks.useFormItemDomControl(props);
20
- return jsxRuntime.jsx(Component, _objectSpread({}, props));
28
+ return jsxRuntime.jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
29
+ labelAlign: labelAlign,
30
+ labelWidth: labelWidth
31
+ }));
21
32
  });
22
33
 
23
34
  exports.default = Item;
package/lib/Form/index.js CHANGED
@@ -97,7 +97,9 @@ var HForm = (function (_ref) {
97
97
  value: {
98
98
  loading: submitLoading || loading,
99
99
  form: hForm,
100
- valueType: valueType
100
+ valueType: valueType,
101
+ labelAlign: formLabelAlign,
102
+ labelWidth: labelWidth
101
103
  },
102
104
  children: jsxRuntime.jsxs(antd.Form, _objectSpread(_objectSpread({
103
105
  form: hForm,
@@ -81,6 +81,8 @@ export interface FormContextProps {
81
81
  loading?: boolean;
82
82
  form: HFormInstance;
83
83
  valueType?: string;
84
+ labelAlign?: LabelAlignModal;
85
+ labelWidth?: number;
84
86
  }
85
87
  interface ConfigUploadProps {
86
88
  exFiles?: string[];
@@ -76,6 +76,9 @@ var useValueChange = function useValueChange(params) {
76
76
  if (labelInValue) {
77
77
  return val;
78
78
  }
79
+ if (val === undefined || mode === "tags") {
80
+ return val;
81
+ }
79
82
  if (!val) {
80
83
  return val;
81
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,8 +1,11 @@
1
1
  import { useFormItemDomControl } from "./hooks";
2
2
  import React from "react";
3
3
  import type { HItemProps } from "../modal";
4
+ import {useFormContext} from "../Context";
4
5
 
5
6
  export default (props: HItemProps) => {
7
+ const {labelWidth:formLabelWidth,labelAlign:formLabelAlign}=useFormContext();
8
+ const {labelWidth=formLabelWidth,labelAlign=formLabelAlign}=props;
6
9
  const Component = useFormItemDomControl(props);
7
- return <Component {...props} />;
10
+ return <Component {...props} labelAlign={labelAlign} labelWidth={labelWidth}/>;
8
11
  };
@@ -73,7 +73,12 @@ export default ({
73
73
  reload={infoRun}
74
74
  >
75
75
  <FormContext.Provider
76
- value={{ loading: submitLoading || loading, form: hForm, valueType }}
76
+ value={{
77
+ loading: submitLoading || loading,
78
+ form: hForm, valueType ,
79
+ labelAlign:formLabelAlign,
80
+ labelWidth
81
+ }}
77
82
  >
78
83
  <Form
79
84
  form={hForm}
@@ -130,6 +130,8 @@ export interface FormContextProps {
130
130
  loading?: boolean;
131
131
  form: HFormInstance;
132
132
  valueType?: string;
133
+ labelAlign?:LabelAlignModal;
134
+ labelWidth?:number
133
135
  }
134
136
  interface ConfigUploadProps {
135
137
  exFiles?: string[];
@@ -67,6 +67,9 @@ export const useValueChange = (params: PartialHSelectProps) => {
67
67
  if (labelInValue) {
68
68
  return val;
69
69
  }
70
+ if (val===undefined||mode==="tags"){
71
+ return val
72
+ }
70
73
  if (!val) {
71
74
  return val;
72
75
  }
@@ -18,8 +18,9 @@ export default () => {
18
18
  { name: "测试2", value: 20, userId: 112321 },
19
19
  ]}
20
20
  placeholder="多选"
21
- value={[10, 20]}
21
+ value={null}
22
22
  onChange={(val, option) => {
23
+ console.log(val)
23
24
  setSelectVal(val);
24
25
  }}
25
26
  allSelect={true}
@@ -32,6 +33,7 @@ export default () => {
32
33
  placeholder="tags模式"
33
34
  showSearch={true}
34
35
  allowClear={true}
36
+ value={null}
35
37
  options={[
36
38
  { label: "测试1", value: 10 },
37
39
  { label: "测试2", value: 20 },
@@ -44,18 +46,18 @@ export default () => {
44
46
  labelInValue
45
47
  mode="multiple"
46
48
  value={["21321312"]}
47
- request={(params) => {
49
+ request={async (params) => {
48
50
  const { page, size } = params;
49
51
  const op = [];
50
52
  for (let i = 0; i < size; i += 1) {
51
53
  op.push({ label: `第${page}页第${i}条`, value: i + page });
52
54
  }
53
- return {
54
- page,
55
- size: 100,
56
- total: 1000,
57
- data: op,
58
- };
55
+ return Promise.resolve({
56
+ page,
57
+ size: 100,
58
+ total: 1000,
59
+ data: op,
60
+ })
59
61
  }}
60
62
  isList
61
63
  />