@hw-component/form 0.0.9-beta-v2 → 0.0.9-beta-v4

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.
@@ -27,7 +27,8 @@ var Index = function Index(_ref) {
27
27
  disabled = _ref.disabled,
28
28
  _ref$keyInValue = _ref.keyInValue,
29
29
  keyInValue = _ref$keyInValue === void 0 ? true : _ref$keyInValue,
30
- addFormat = _ref.addFormat;
30
+ addFormat = _ref.addFormat,
31
+ direction = _ref.direction;
31
32
  var _useMatchConfigProps = useMatchConfigProps({
32
33
  fieldNames: fieldNames,
33
34
  valueCheckMap: valueMap
@@ -74,6 +75,7 @@ var Index = function Index(_ref) {
74
75
  }
75
76
  });
76
77
  return jsx(Space, {
78
+ direction: direction,
77
79
  children: checkOptions === null || checkOptions === void 0 ? void 0 : checkOptions.map(function (item) {
78
80
  var label = item.label,
79
81
  itemVal = item.value;
@@ -11,4 +11,5 @@ export interface HCheckboxProps extends Omit<CheckboxProps, "value" | "onChange"
11
11
  onChange?: (value: Record<string, any> | any[]) => void;
12
12
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
13
13
  subParams?: (formatValue: Record<string, any>, sourceValue: any[]) => any;
14
+ direction?: 'horizontal' | 'vertical';
14
15
  }
@@ -84,7 +84,6 @@ var useHForm = (function () {
84
84
  return {};
85
85
  }
86
86
  var newValue = _objectSpread({}, value);
87
- console.log(formatSourceData, "formatSourceData");
88
87
  var keys = Object.keys(formatSourceData);
89
88
  keys.forEach(function (key) {
90
89
  var _formatSourceData$key;
@@ -96,7 +95,6 @@ var useHForm = (function () {
96
95
  Reflect.deleteProperty(newValue, key);
97
96
  newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
98
97
  });
99
- console.log(newValue, "newVal");
100
98
  return newValue;
101
99
  },
102
100
  dispatch: function dispatch(action) {
@@ -13,7 +13,7 @@ import { DatePicker } from 'antd';
13
13
  import { useTimeVal, useTimeChange } from './hooks.js';
14
14
  import HFormConnect from '../Form/HFormConnect.js';
15
15
 
16
- var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat"];
16
+ var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat", "style"];
17
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; }
18
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; }
19
19
  var Picker = DatePicker;
@@ -26,6 +26,10 @@ var Index = function Index(_ref) {
26
26
  format = _ref$format === void 0 ? "X" : _ref$format,
27
27
  _disabledDate = _ref.disabledDate,
28
28
  addFormat = _ref.addFormat,
29
+ _ref$style = _ref.style,
30
+ style = _ref$style === void 0 ? {
31
+ width: "100%"
32
+ } : _ref$style,
29
33
  props = _objectWithoutProperties(_ref, _excluded);
30
34
  addFormat === null || addFormat === void 0 || addFormat({});
31
35
  var timeVal = useTimeVal({
@@ -40,6 +44,7 @@ var Index = function Index(_ref) {
40
44
  value: timeVal,
41
45
  onChange: change,
42
46
  showTime: showTime,
47
+ style: style,
43
48
  disabledDate: function disabledDate(currentDate) {
44
49
  return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
45
50
  }
@@ -30,7 +30,8 @@ var Index = function Index(_ref) {
30
30
  disabled = _ref.disabled,
31
31
  _ref$keyInValue = _ref.keyInValue,
32
32
  keyInValue = _ref$keyInValue === void 0 ? true : _ref$keyInValue,
33
- addFormat = _ref.addFormat;
33
+ addFormat = _ref.addFormat,
34
+ direction = _ref.direction;
34
35
  var _useMatchConfigProps = index.useMatchConfigProps({
35
36
  fieldNames: fieldNames,
36
37
  valueCheckMap: valueMap
@@ -77,6 +78,7 @@ var Index = function Index(_ref) {
77
78
  }
78
79
  });
79
80
  return jsxRuntime.jsx(antd.Space, {
81
+ direction: direction,
80
82
  children: checkOptions === null || checkOptions === void 0 ? void 0 : checkOptions.map(function (item) {
81
83
  var label = item.label,
82
84
  itemVal = item.value;
@@ -11,4 +11,5 @@ export interface HCheckboxProps extends Omit<CheckboxProps, "value" | "onChange"
11
11
  onChange?: (value: Record<string, any> | any[]) => void;
12
12
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
13
13
  subParams?: (formatValue: Record<string, any>, sourceValue: any[]) => any;
14
+ direction?: 'horizontal' | 'vertical';
14
15
  }
@@ -87,7 +87,6 @@ var useHForm = (function () {
87
87
  return {};
88
88
  }
89
89
  var newValue = _objectSpread({}, value);
90
- console.log(formatSourceData, "formatSourceData");
91
90
  var keys = Object.keys(formatSourceData);
92
91
  keys.forEach(function (key) {
93
92
  var _formatSourceData$key;
@@ -99,7 +98,6 @@ var useHForm = (function () {
99
98
  Reflect.deleteProperty(newValue, key);
100
99
  newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
101
100
  });
102
- console.log(newValue, "newVal");
103
101
  return newValue;
104
102
  },
105
103
  dispatch: function dispatch(action) {
@@ -16,7 +16,7 @@ var antd = require('antd');
16
16
  var hooks = require('./hooks.js');
17
17
  var HFormConnect = require('../Form/HFormConnect.js');
18
18
 
19
- var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat"];
19
+ var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat", "style"];
20
20
  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; }
21
21
  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; }
22
22
  var Picker = antd.DatePicker;
@@ -29,6 +29,10 @@ var Index = function Index(_ref) {
29
29
  format = _ref$format === void 0 ? "X" : _ref$format,
30
30
  _disabledDate = _ref.disabledDate,
31
31
  addFormat = _ref.addFormat,
32
+ _ref$style = _ref.style,
33
+ style = _ref$style === void 0 ? {
34
+ width: "100%"
35
+ } : _ref$style,
32
36
  props = _objectWithoutProperties(_ref, _excluded);
33
37
  addFormat === null || addFormat === void 0 || addFormat({});
34
38
  var timeVal = hooks.useTimeVal({
@@ -43,6 +47,7 @@ var Index = function Index(_ref) {
43
47
  value: timeVal,
44
48
  onChange: change,
45
49
  showTime: showTime,
50
+ style: style,
46
51
  disabledDate: function disabledDate(currentDate) {
47
52
  return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
48
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.9-beta-v2",
3
+ "version": "0.0.9-beta-v4",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,6 +15,7 @@ const Index = ({
15
15
  disabled,
16
16
  keyInValue = true,
17
17
  addFormat,
18
+ direction
18
19
  }: HCheckboxProps) => {
19
20
  const { valueCheckMap: resultValueCheckMap, fieldNames: resultFieldNames } =
20
21
  useMatchConfigProps({ fieldNames, valueCheckMap: valueMap }); //匹配全局
@@ -59,7 +60,7 @@ const Index = ({
59
60
  },
60
61
  });
61
62
  return (
62
- <Space>
63
+ <Space direction={direction}>
63
64
  {checkOptions?.map((item) => {
64
65
  const { label, value: itemVal } = item;
65
66
  const checked = val[itemVal];
@@ -13,4 +13,5 @@ export interface HCheckboxProps
13
13
  onChange?: (value: Record<string, any> | any[]) => void;
14
14
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
15
15
  subParams?: (formatValue: Record<string, any>, sourceValue: any[]) => any;
16
+ direction?:'horizontal' | 'vertical'
16
17
  }
@@ -16,7 +16,7 @@ export default () => {
16
16
  const initDispatch: Record<string, argsFn> = {};
17
17
  let cacheValues: Record<string, any> = {};
18
18
  let isLoading = false;
19
- let initSaveValue={};
19
+ let initSaveValue = {};
20
20
  const norAddItemDispatch = (name, manual, fn) => {
21
21
  if (manual === false && name) {
22
22
  initDispatch[name] = fn;
@@ -42,7 +42,7 @@ export default () => {
42
42
  let newValue = {};
43
43
  if (cacheValues) {
44
44
  newValue = this.formatValues(cacheValues);
45
- initSaveValue=newValue;
45
+ initSaveValue = newValue;
46
46
  form.setFieldsValue(newValue);
47
47
  }
48
48
  const initKeys = Object.keys(initDispatch);
@@ -67,7 +67,6 @@ export default () => {
67
67
  return {};
68
68
  }
69
69
  let newValue = { ...value };
70
- console.log(formatSourceData,"formatSourceData")
71
70
  const keys = Object.keys(formatSourceData);
72
71
  keys.forEach((key) => {
73
72
  const format = formatSourceData[key]?.[formatKey];
@@ -81,7 +80,6 @@ export default () => {
81
80
  ...resultValue,
82
81
  };
83
82
  });
84
- console.log(newValue,"newVal")
85
83
  return newValue;
86
84
  }, //转化方法
87
85
  dispatch(action, ...args) {
@@ -163,17 +161,17 @@ export default () => {
163
161
  });
164
162
  });
165
163
  },
166
- resetFieldsInitValue:()=>{
167
- const oldValue=form.getFieldsValue();
168
- const keys=Object.keys(oldValue);
169
- const newVale={};
170
- keys.forEach((key)=>{
171
- newVale[key]=undefined;
172
- });
173
- form.setFieldsValue({
174
- ...newVale,
175
- ...initSaveValue,
176
- });
164
+ resetFieldsInitValue: () => {
165
+ const oldValue = form.getFieldsValue();
166
+ const keys = Object.keys(oldValue);
167
+ const newVale = {};
168
+ keys.forEach((key) => {
169
+ newVale[key] = undefined;
170
+ });
171
+ form.setFieldsValue({
172
+ ...newVale,
173
+ ...initSaveValue,
174
+ });
177
175
  },
178
176
  clear: () => {
179
177
  form.resetFields();
@@ -160,7 +160,7 @@ export interface HFormInstance extends FormInstance {
160
160
  removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
161
161
  reload: PromiseFnResult;
162
162
  clear: VoidFunction;
163
- resetFieldsInitValue:VoidFunction;
163
+ resetFieldsInitValue: VoidFunction;
164
164
  }
165
165
 
166
166
  export interface ConnectConfigModal {
@@ -11,6 +11,7 @@ const Index: React.FC<HDatePickerProps> = ({
11
11
  format = "X",
12
12
  disabledDate,
13
13
  addFormat,
14
+ style={width:"100%"},
14
15
  ...props
15
16
  }) => {
16
17
  addFormat?.({});
@@ -21,6 +22,7 @@ const Index: React.FC<HDatePickerProps> = ({
21
22
  value={timeVal}
22
23
  onChange={change}
23
24
  showTime={showTime}
25
+ style={style}
24
26
  disabledDate={(currentDate) => {
25
27
  return !!disabledDate?.(currentDate, timeVal);
26
28
  }}
@@ -1,6 +1,6 @@
1
1
  import { HForm, HFormConfigProvider, useHForm } from "../../components";
2
2
  import { useState } from "react";
3
- import {Button, DatePicker, Form, Input} from "antd";
3
+ import { Button, DatePicker, Form, Input } from "antd";
4
4
 
5
5
  const formData = (options) => {
6
6
  const op = [
@@ -77,6 +77,7 @@ const formData = (options) => {
77
77
  { value: "选择1", key: "check1" },
78
78
  { value: "选择2", key: "check2" },
79
79
  ],
80
+ direction:"vertical"
80
81
  },
81
82
  {
82
83
  label: "开关",
@@ -241,12 +242,12 @@ const Test = (props) => {
241
242
  export default () => {
242
243
  const form = useHForm();
243
244
  const [options, setOptions] = useState([{ label: "1", value: 1 }]);
244
- const [aForm]=Form.useForm();
245
+ const [aForm] = Form.useForm();
245
246
  return (
246
247
  <div style={{ overflow: "auto", height: "90vh" }}>
247
- <Form form={aForm} initialValues={{ttim:"132123"}}>
248
- <Form.Item name="ttim" rules={[{required:true}]}>
249
- <Input/>
248
+ <Form form={aForm} initialValues={{ ttim: "132123" }}>
249
+ <Form.Item name="ttim" rules={[{ required: true }]}>
250
+ <Input />
250
251
  </Form.Item>
251
252
  </Form>
252
253
  <HFormConfigProvider