@zat-design/sisyphus-react 3.4.2-beta.12 → 3.4.2-beta.13

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.
@@ -2,6 +2,7 @@ import { ProEnum } from '../propsType';
2
2
  interface Props extends Pick<ProEnum, 'value' | 'onChange' | 'dataSource'> {
3
3
  fieldValue: string;
4
4
  fieldLabel: string;
5
+ disabled?: boolean;
5
6
  }
6
7
  declare const Group: (props: Props) => JSX.Element;
7
8
  export default Group;
@@ -8,7 +8,8 @@ var Group = function Group(props) {
8
8
  onChange = props.onChange,
9
9
  dataSource = props.dataSource,
10
10
  fieldValue = props.fieldValue,
11
- fieldLabel = props.fieldLabel;
11
+ fieldLabel = props.fieldLabel,
12
+ disabled = props.disabled;
12
13
  var idx = useRef(-1);
13
14
  var _useSetState = useSetState({
14
15
  checked: ''
@@ -20,13 +21,25 @@ var Group = function Group(props) {
20
21
  setState({
21
22
  checked: value
22
23
  });
23
- }, [value]);
24
- var handleClick = function handleClick(val, index) {
25
- setState({
26
- checked: val
24
+ var index = dataSource.findIndex(function (item) {
25
+ return item[fieldValue] === value;
27
26
  });
28
27
  idx.current = index;
29
- onChange === null || onChange === void 0 ? void 0 : onChange(val);
28
+ }, [value]);
29
+ var handleClick = function handleClick(val, index) {
30
+ if (state.checked === val) {
31
+ setState({
32
+ checked: ''
33
+ });
34
+ onChange === null || onChange === void 0 ? void 0 : onChange('');
35
+ idx.current = -1;
36
+ } else {
37
+ setState({
38
+ checked: val
39
+ });
40
+ idx.current = index;
41
+ onChange === null || onChange === void 0 ? void 0 : onChange(val);
42
+ }
30
43
  };
31
44
  if (dataSource.length === 0) {
32
45
  return _jsx("span", {
@@ -34,11 +47,11 @@ var Group = function Group(props) {
34
47
  });
35
48
  }
36
49
  return _jsx("div", {
37
- className: "pro-enum-group-root",
50
+ className: classNames('pro-enum-group-root', disabled ? 'pro-enum-group-root-disabled' : ''),
38
51
  children: dataSource.map(function (item, index) {
39
52
  return _jsx("div", {
40
53
  onClick: function onClick() {
41
- if (!item.disabled) {
54
+ if (!item.disabled && !disabled) {
42
55
  handleClick(item[fieldValue], index);
43
56
  }
44
57
  },
@@ -41,7 +41,8 @@ var ProEnum = function ProEnum(props) {
41
41
  enumProps = _objectWithoutProperties(props, _excluded);
42
42
  var _ref = otherProps || {},
43
43
  isView = _ref.isView,
44
- viewEmpty = _ref.viewEmpty;
44
+ viewEmpty = _ref.viewEmpty,
45
+ disabled = _ref.disabled;
45
46
  var _ref2 = useProConfig('ProEnum') || {},
46
47
  fieldNames = _ref2.fieldNames,
47
48
  _ref2$clear = _ref2.clear,
@@ -212,7 +213,8 @@ var ProEnum = function ProEnum(props) {
212
213
  onChange: onChange,
213
214
  fieldLabel: label,
214
215
  fieldValue: fieldValue,
215
- dataSource: list
216
+ dataSource: list,
217
+ disabled: disabled
216
218
  });
217
219
  default:
218
220
  return null;
@@ -7,6 +7,12 @@
7
7
  flex-direction: row;
8
8
  flex-wrap: wrap;
9
9
  }
10
+ &-group-root-disabled {
11
+ color: rgba(0, 0, 0, 0.25);
12
+ .pro-enum-group-item{
13
+ cursor: not-allowed !important;
14
+ }
15
+ }
10
16
  &-tag-item {
11
17
  display: flex;
12
18
  align-items: center;
@@ -71,8 +77,8 @@
71
77
 
72
78
  .pro-enum-group-item-selected {
73
79
  color: var(--zaui-brand);
74
- border: 1px solid var(--zaui-brand);
75
80
  background: #fff;
81
+ border: 1px solid var(--zaui-brand);
76
82
  &::after {
77
83
  background: transparent;
78
84
  }
@@ -2,6 +2,7 @@ import { ProEnum } from '../propsType';
2
2
  interface Props extends Pick<ProEnum, 'value' | 'onChange' | 'dataSource'> {
3
3
  fieldValue: string;
4
4
  fieldLabel: string;
5
+ disabled?: boolean;
5
6
  }
6
7
  declare const Group: (props: Props) => JSX.Element;
7
8
  export default Group;
@@ -15,7 +15,8 @@ var Group = function Group(props) {
15
15
  onChange = props.onChange,
16
16
  dataSource = props.dataSource,
17
17
  fieldValue = props.fieldValue,
18
- fieldLabel = props.fieldLabel;
18
+ fieldLabel = props.fieldLabel,
19
+ disabled = props.disabled;
19
20
  var idx = (0, _react.useRef)(-1);
20
21
  var _useSetState = (0, _ahooks.useSetState)({
21
22
  checked: ''
@@ -27,13 +28,25 @@ var Group = function Group(props) {
27
28
  setState({
28
29
  checked: value
29
30
  });
30
- }, [value]);
31
- var handleClick = function handleClick(val, index) {
32
- setState({
33
- checked: val
31
+ var index = dataSource.findIndex(function (item) {
32
+ return item[fieldValue] === value;
34
33
  });
35
34
  idx.current = index;
36
- onChange === null || onChange === void 0 ? void 0 : onChange(val);
35
+ }, [value]);
36
+ var handleClick = function handleClick(val, index) {
37
+ if (state.checked === val) {
38
+ setState({
39
+ checked: ''
40
+ });
41
+ onChange === null || onChange === void 0 ? void 0 : onChange('');
42
+ idx.current = -1;
43
+ } else {
44
+ setState({
45
+ checked: val
46
+ });
47
+ idx.current = index;
48
+ onChange === null || onChange === void 0 ? void 0 : onChange(val);
49
+ }
37
50
  };
38
51
  if (dataSource.length === 0) {
39
52
  return (0, _jsxRuntime.jsx)("span", {
@@ -41,11 +54,11 @@ var Group = function Group(props) {
41
54
  });
42
55
  }
43
56
  return (0, _jsxRuntime.jsx)("div", {
44
- className: "pro-enum-group-root",
57
+ className: (0, _classnames.default)('pro-enum-group-root', disabled ? 'pro-enum-group-root-disabled' : ''),
45
58
  children: dataSource.map(function (item, index) {
46
59
  return (0, _jsxRuntime.jsx)("div", {
47
60
  onClick: function onClick() {
48
- if (!item.disabled) {
61
+ if (!item.disabled && !disabled) {
49
62
  handleClick(item[fieldValue], index);
50
63
  }
51
64
  },
@@ -42,7 +42,8 @@ var ProEnum = function ProEnum(props) {
42
42
  enumProps = (0, _objectWithoutProperties2.default)(props, _excluded);
43
43
  var _ref = otherProps || {},
44
44
  isView = _ref.isView,
45
- viewEmpty = _ref.viewEmpty;
45
+ viewEmpty = _ref.viewEmpty,
46
+ disabled = _ref.disabled;
46
47
  var _ref2 = (0, _ProConfigProvider.useProConfig)('ProEnum') || {},
47
48
  fieldNames = _ref2.fieldNames,
48
49
  _ref2$clear = _ref2.clear,
@@ -213,7 +214,8 @@ var ProEnum = function ProEnum(props) {
213
214
  onChange: onChange,
214
215
  fieldLabel: label,
215
216
  fieldValue: fieldValue,
216
- dataSource: list
217
+ dataSource: list,
218
+ disabled: disabled
217
219
  });
218
220
  default:
219
221
  return null;
@@ -7,6 +7,12 @@
7
7
  flex-direction: row;
8
8
  flex-wrap: wrap;
9
9
  }
10
+ &-group-root-disabled {
11
+ color: rgba(0, 0, 0, 0.25);
12
+ .pro-enum-group-item{
13
+ cursor: not-allowed !important;
14
+ }
15
+ }
10
16
  &-tag-item {
11
17
  display: flex;
12
18
  align-items: center;
@@ -71,8 +77,8 @@
71
77
 
72
78
  .pro-enum-group-item-selected {
73
79
  color: var(--zaui-brand);
74
- border: 1px solid var(--zaui-brand);
75
80
  background: #fff;
81
+ border: 1px solid var(--zaui-brand);
76
82
  &::after {
77
83
  background: transparent;
78
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.4.2-beta.12",
3
+ "version": "3.4.2-beta.13",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",