@hw-component/form 1.4.2 → 1.4.5

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.
package/es/Form/config.js CHANGED
@@ -22,7 +22,7 @@ import TrimInput from '../Input/TrimInput.js';
22
22
  import TrimTextArea from '../TextArea/TrimTextArea.js';
23
23
 
24
24
  var placeholderConfig = {
25
- inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload"],
25
+ inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload", "textArea"],
26
26
  selectType: ["select", "datePicker", "timePicker", "colorInput"]
27
27
  };
28
28
  var componentConfig = {
@@ -1,9 +1,12 @@
1
1
  // welcome to hoo hoo hoo
2
2
  import 'core-js/modules/es.array.concat.js';
3
+ import 'core-js/modules/es.array.filter.js';
4
+ import 'core-js/modules/es.object.to-string.js';
3
5
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
6
  import { Space, Checkbox } from 'antd';
5
7
  import { itemOpProvider } from '../utils.js';
6
8
  import { useClassName } from '../../hooks/index.js';
9
+ import { useMemo } from 'react';
7
10
 
8
11
  var useRootClassName = function useRootClassName(checked) {
9
12
  var norClassNames = ["select-item", "select-item-option"];
@@ -19,20 +22,31 @@ var Index = function Index(_ref) {
19
22
  _ref$fieldNames = _ref.fieldNames,
20
23
  fieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
21
24
  children = _ref.children;
22
- var opLen = (options === null || options === void 0 ? void 0 : options.length) || 0;
25
+ var notDisOption = useMemo(function () {
26
+ return options === null || options === void 0 ? void 0 : options.filter(function (item) {
27
+ return !item.disabled;
28
+ });
29
+ }, [options]);
30
+ var opLen = (notDisOption === null || notDisOption === void 0 ? void 0 : notDisOption.length) || 0;
23
31
  var checked = (value === null || value === void 0 ? void 0 : value.length) >= opLen;
24
32
  var classNames = useRootClassName(checked);
25
33
  var optionsClassName = useClassName(classNames);
26
34
  var allCheckBox = useClassName("hw-all-check-box");
35
+ var allCheck = function allCheck() {
36
+ var allCheckOption = options === null || options === void 0 ? void 0 : options.filter(function (item) {
37
+ return !item.disabled;
38
+ });
39
+ var subItemOps = itemOpProvider(allCheckOption, fieldNames);
40
+ onChange === null || onChange === void 0 || onChange(allCheckOption, subItemOps);
41
+ };
27
42
  var change = function change() {
28
43
  if (!checked) {
29
- var subItemOps = itemOpProvider(options, fieldNames);
30
- onChange === null || onChange === void 0 || onChange(options, subItemOps);
44
+ allCheck();
31
45
  return;
32
46
  }
33
47
  onChange === null || onChange === void 0 || onChange([], []);
34
48
  };
35
- if (!allSelect || mode !== "multiple" || serviceSearch) {
49
+ if (!allSelect || mode !== "multiple" || serviceSearch || opLen === 0) {
36
50
  return jsx(Fragment, {
37
51
  children: children
38
52
  });
@@ -2,6 +2,7 @@ import React from "react";
2
2
  interface ICheckBoxOptionProps {
3
3
  label?: React.ReactNode;
4
4
  checked: boolean;
5
+ disabled?: boolean;
5
6
  }
6
- declare const _default: ({ label, checked }: ICheckBoxOptionProps) => JSX.Element;
7
+ declare const _default: ({ label, checked, disabled }: ICheckBoxOptionProps) => JSX.Element;
7
8
  export default _default;
@@ -4,10 +4,12 @@ import { Space, Checkbox } from 'antd';
4
4
 
5
5
  var CheckBoxOption = (function (_ref) {
6
6
  var label = _ref.label,
7
- checked = _ref.checked;
7
+ checked = _ref.checked,
8
+ disabled = _ref.disabled;
8
9
  return jsxs(Space, {
9
10
  children: [jsx(Checkbox, {
10
- checked: checked
11
+ checked: checked,
12
+ disabled: disabled
11
13
  }), label]
12
14
  });
13
15
  });
@@ -11,10 +11,14 @@ var defaultModeConfig = {
11
11
  var checkVal = value === null || value === void 0 ? void 0 : value.map(function (itemVal) {
12
12
  return itemVal.value;
13
13
  });
14
+ var label = item.label,
15
+ disabled = item.disabled,
16
+ itemVal = item.value;
14
17
  var newVal = checkVal || [];
15
- var checked = newVal.indexOf(item.value) !== -1;
18
+ var checked = newVal.indexOf(itemVal) !== -1;
16
19
  return jsx(CheckBoxOption, {
17
- label: item.label,
20
+ disabled: disabled,
21
+ label: label,
18
22
  checked: checked
19
23
  });
20
24
  }
@@ -119,6 +119,7 @@ var Index = function Index(_ref) {
119
119
  mode: mode,
120
120
  value: val,
121
121
  onChange: change,
122
+ fieldNames: fieldNames,
122
123
  children: node
123
124
  })
124
125
  });
@@ -25,7 +25,7 @@ var TrimInput = require('../Input/TrimInput.js');
25
25
  var TrimTextArea = require('../TextArea/TrimTextArea.js');
26
26
 
27
27
  var placeholderConfig = {
28
- inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload"],
28
+ inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload", "textArea"],
29
29
  selectType: ["select", "datePicker", "timePicker", "colorInput"]
30
30
  };
31
31
  var componentConfig = {
@@ -3,10 +3,13 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('core-js/modules/es.array.concat.js');
6
+ require('core-js/modules/es.array.filter.js');
7
+ require('core-js/modules/es.object.to-string.js');
6
8
  var jsxRuntime = require('react/jsx-runtime');
7
9
  var antd = require('antd');
8
10
  var utils = require('../utils.js');
9
11
  var index = require('../../hooks/index.js');
12
+ var React = require('react');
10
13
 
11
14
  var useRootClassName = function useRootClassName(checked) {
12
15
  var norClassNames = ["select-item", "select-item-option"];
@@ -22,20 +25,31 @@ var Index = function Index(_ref) {
22
25
  _ref$fieldNames = _ref.fieldNames,
23
26
  fieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
24
27
  children = _ref.children;
25
- var opLen = (options === null || options === void 0 ? void 0 : options.length) || 0;
28
+ var notDisOption = React.useMemo(function () {
29
+ return options === null || options === void 0 ? void 0 : options.filter(function (item) {
30
+ return !item.disabled;
31
+ });
32
+ }, [options]);
33
+ var opLen = (notDisOption === null || notDisOption === void 0 ? void 0 : notDisOption.length) || 0;
26
34
  var checked = (value === null || value === void 0 ? void 0 : value.length) >= opLen;
27
35
  var classNames = useRootClassName(checked);
28
36
  var optionsClassName = index.useClassName(classNames);
29
37
  var allCheckBox = index.useClassName("hw-all-check-box");
38
+ var allCheck = function allCheck() {
39
+ var allCheckOption = options === null || options === void 0 ? void 0 : options.filter(function (item) {
40
+ return !item.disabled;
41
+ });
42
+ var subItemOps = utils.itemOpProvider(allCheckOption, fieldNames);
43
+ onChange === null || onChange === void 0 || onChange(allCheckOption, subItemOps);
44
+ };
30
45
  var change = function change() {
31
46
  if (!checked) {
32
- var subItemOps = utils.itemOpProvider(options, fieldNames);
33
- onChange === null || onChange === void 0 || onChange(options, subItemOps);
47
+ allCheck();
34
48
  return;
35
49
  }
36
50
  onChange === null || onChange === void 0 || onChange([], []);
37
51
  };
38
- if (!allSelect || mode !== "multiple" || serviceSearch) {
52
+ if (!allSelect || mode !== "multiple" || serviceSearch || opLen === 0) {
39
53
  return jsxRuntime.jsx(jsxRuntime.Fragment, {
40
54
  children: children
41
55
  });
@@ -2,6 +2,7 @@ import React from "react";
2
2
  interface ICheckBoxOptionProps {
3
3
  label?: React.ReactNode;
4
4
  checked: boolean;
5
+ disabled?: boolean;
5
6
  }
6
- declare const _default: ({ label, checked }: ICheckBoxOptionProps) => JSX.Element;
7
+ declare const _default: ({ label, checked, disabled }: ICheckBoxOptionProps) => JSX.Element;
7
8
  export default _default;
@@ -7,10 +7,12 @@ var antd = require('antd');
7
7
 
8
8
  var CheckBoxOption = (function (_ref) {
9
9
  var label = _ref.label,
10
- checked = _ref.checked;
10
+ checked = _ref.checked,
11
+ disabled = _ref.disabled;
11
12
  return jsxRuntime.jsxs(antd.Space, {
12
13
  children: [jsxRuntime.jsx(antd.Checkbox, {
13
- checked: checked
14
+ checked: checked,
15
+ disabled: disabled
14
16
  }), label]
15
17
  });
16
18
  });
@@ -12,10 +12,14 @@ var defaultModeConfig = {
12
12
  var checkVal = value === null || value === void 0 ? void 0 : value.map(function (itemVal) {
13
13
  return itemVal.value;
14
14
  });
15
+ var label = item.label,
16
+ disabled = item.disabled,
17
+ itemVal = item.value;
15
18
  var newVal = checkVal || [];
16
- var checked = newVal.indexOf(item.value) !== -1;
19
+ var checked = newVal.indexOf(itemVal) !== -1;
17
20
  return jsxRuntime.jsx(CheckBoxOption.default, {
18
- label: item.label,
21
+ disabled: disabled,
22
+ label: label,
19
23
  checked: checked
20
24
  });
21
25
  }
@@ -122,6 +122,7 @@ var Index = function Index(_ref) {
122
122
  mode: mode,
123
123
  value: val,
124
124
  onChange: change,
125
+ fieldNames: fieldNames,
125
126
  children: node
126
127
  })
127
128
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.4.2",
3
+ "version": "1.4.5",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,6 +28,7 @@ export const placeholderConfig = {
28
28
  "verificationCodeInput",
29
29
  "trimInput",
30
30
  "urlUpload",
31
+ "textArea"
31
32
  ],
32
33
  selectType: ["select", "datePicker", "timePicker", "colorInput"],
33
34
  };
@@ -2,7 +2,7 @@ import type { HSelectProps } from "@/components/Select/modal";
2
2
  import { Checkbox, Space } from "antd";
3
3
  import { itemOpProvider } from "../utils";
4
4
  import { useClassName } from "../../hooks";
5
- import React from "react";
5
+ import React, {useMemo} from "react";
6
6
 
7
7
  interface IProps extends HSelectProps {
8
8
  checked?: boolean;
@@ -23,20 +23,31 @@ const Index: React.FC<IProps> = ({
23
23
  fieldNames = {},
24
24
  children,
25
25
  }) => {
26
- const opLen = options?.length || 0;
26
+ const notDisOption=useMemo(()=>{
27
+ return options?.filter((item)=>{
28
+ return !item.disabled;
29
+ })
30
+ },[options]);
31
+ const opLen = notDisOption?.length || 0;
27
32
  const checked = (value as any[])?.length >= opLen;
28
33
  const classNames = useRootClassName(checked);
29
34
  const optionsClassName = useClassName(classNames);
30
35
  const allCheckBox = useClassName("hw-all-check-box");
36
+ const allCheck=()=>{
37
+ const allCheckOption=options?.filter((item)=>{
38
+ return !item.disabled;
39
+ });
40
+ const subItemOps=itemOpProvider(allCheckOption,fieldNames);
41
+ onChange?.(allCheckOption, subItemOps);
42
+ }
31
43
  const change = () => {
32
44
  if (!checked) {
33
- const subItemOps = itemOpProvider(options, fieldNames);
34
- onChange?.(options, subItemOps);
45
+ allCheck();
35
46
  return;
36
47
  }
37
48
  onChange?.([], []);
38
49
  };
39
- if (!allSelect || mode !== "multiple" || serviceSearch) {
50
+ if (!allSelect || mode !== "multiple" || serviceSearch||opLen===0) {
40
51
  return <>{children}</>;
41
52
  }
42
53
  return (
@@ -3,11 +3,12 @@ import React from "react";
3
3
  interface ICheckBoxOptionProps {
4
4
  label?: React.ReactNode;
5
5
  checked: boolean;
6
+ disabled?:boolean;
6
7
  }
7
- export default ({ label, checked }: ICheckBoxOptionProps) => {
8
+ export default ({ label, checked ,disabled}: ICheckBoxOptionProps) => {
8
9
  return (
9
10
  <Space>
10
- <Checkbox checked={checked} />
11
+ <Checkbox checked={checked} disabled={disabled}/>
11
12
  {label}
12
13
  </Space>
13
14
  );
@@ -9,9 +9,10 @@ export const defaultModeConfig: HSelectProps["modeConfig"] = {
9
9
  const checkVal = value?.map((itemVal) => {
10
10
  return itemVal.value;
11
11
  });
12
+ const {label,disabled,value:itemVal}=item;
12
13
  const newVal = checkVal || [];
13
- const checked = newVal.indexOf(item.value) !== -1;
14
- return <CheckBoxOption label={item.label} checked={checked} />;
14
+ const checked = newVal.indexOf(itemVal) !== -1;
15
+ return <CheckBoxOption disabled={disabled} label={label} checked={checked} />;
15
16
  },
16
17
  },
17
18
  };
@@ -90,6 +90,7 @@ const Index: React.FC<HSelectProps> = ({
90
90
  mode={mode}
91
91
  value={val}
92
92
  onChange={change}
93
+ fieldNames={fieldNames}
93
94
  >
94
95
  {node}
95
96
  </AllSelect>
@@ -1,8 +1,10 @@
1
1
  import {HForm, HFormConfigProvider, HSwitch, useHForm} from "../../components";
2
2
  import { useState } from "react";
3
- import { Button, DatePicker, Form, Input } from "antd";
3
+ import {Button, DatePicker, Form, Input, Row} from "antd";
4
4
  const Test2=()=>{
5
- return <HSwitch/>
5
+ return <Row style={{background:"red"}}>
6
+
7
+ </Row>
6
8
  }
7
9
  const formData = (options) => {
8
10
  const op = [
@@ -16,6 +18,11 @@ const formData = (options) => {
16
18
  },
17
19
  ];
18
20
  return [
21
+ {
22
+ label: "12321",
23
+ className: "3",
24
+ name:"3",
25
+ },
19
26
  {
20
27
  label: "测试12312",
21
28
  className: "hdjd",
@@ -72,7 +79,6 @@ export default () => {
72
79
  <HForm
73
80
  configData={formData(options)}
74
81
  labelWidth={200}
75
- itemSpan={{ span: 6 }}
76
82
  form={form}
77
83
  labelAlign={"right"}
78
84
  onFinish={(value) => {
@@ -2,7 +2,7 @@ import { HSelect } from "../../components";
2
2
  import { Space } from "antd";
3
3
  import { useState } from "react";
4
4
  export default () => {
5
- const [selectVal, setSelectVal] = useState([10]);
5
+ const [selectVal, setSelectVal] = useState([]);
6
6
  return (
7
7
  <Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
8
8
  <HSelect
@@ -14,13 +14,13 @@ export default () => {
14
14
  <HSelect
15
15
  fieldNames={{ label: "name", value: "value" }}
16
16
  options={[
17
- { name: "测试1", value: 10, userId: 112321 },
17
+ { name: "测试1", value: 10, userId: 112321,disabled:true },
18
18
  { name: "测试2", value: 20, userId: 112321 },
19
19
  ]}
20
20
  placeholder="多选"
21
21
  value={selectVal}
22
22
  onChange={(val, option) => {
23
- console.log(option);
23
+ console.log(option,"optionoptionoption")
24
24
  setSelectVal(val);
25
25
  }}
26
26
  allSelect={true}