@titaui/pc 1.9.62 → 1.9.63

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.
@@ -39,24 +39,29 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
39
39
 
40
40
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
41
41
 
42
- var visibilityList = [{
43
- value: 1,
44
- label: (0, _getLocale.getLocale)("OKR_MyO_Pop_Public")
45
- }, {
46
- value: 2,
47
- label: (0, _getLocale.getLocale)("OKR_MyO_From_Associatedmem")
48
- }, {
49
- value: 3,
50
- label: (0, _getLocale.getLocale)("OKR_MyO_Pop_Directrep")
51
- }, {
52
- value: 4,
53
- label: (0, _getLocale.getLocale)("OKR_MyO_Pop_Specified")
54
- }];
55
- var visibilityMapText = {
56
- 1: (0, _getLocale.getLocale)("OKR_MyO_Pop_Public"),
57
- 2: (0, _getLocale.getLocale)("OKR_MyO_From_Associatedmem"),
58
- 3: (0, _getLocale.getLocale)("OKR_MyO_Pop_Directrep"),
59
- 4: (0, _getLocale.getLocale)("OKR_MyO_Pop_Specified")
42
+ var getVisibilityList = function getVisibilityList() {
43
+ return [{
44
+ value: 1,
45
+ label: (0, _getLocale.getLocale)("OKR_MyO_Pop_Public")
46
+ }, {
47
+ value: 2,
48
+ label: (0, _getLocale.getLocale)("OKR_MyO_From_Associatedmem")
49
+ }, {
50
+ value: 3,
51
+ label: (0, _getLocale.getLocale)("OKR_MyO_Pop_Directrep")
52
+ }, {
53
+ value: 4,
54
+ label: (0, _getLocale.getLocale)("OKR_MyO_Pop_Specified")
55
+ }];
56
+ };
57
+
58
+ var getVisibilityMapText = function getVisibilityMapText() {
59
+ return {
60
+ 1: (0, _getLocale.getLocale)("OKR_MyO_Pop_Public"),
61
+ 2: (0, _getLocale.getLocale)("OKR_MyO_From_Associatedmem"),
62
+ 3: (0, _getLocale.getLocale)("OKR_MyO_Pop_Directrep"),
63
+ 4: (0, _getLocale.getLocale)("OKR_MyO_Pop_Specified")
64
+ };
60
65
  };
61
66
 
62
67
  var Visibility = function Visibility(_ref) {
@@ -80,55 +85,77 @@ var Visibility = function Visibility(_ref) {
80
85
  users = selectNodes.users;
81
86
 
82
87
  if (departments.length === 0 && groups.length === 0 && users.length === 0) {
83
- setVisibilityState(oldSelect.current); // @ts-ignore
88
+ setVisibilityState(oldSelect.current);
89
+
90
+ if (selectorRef.current) {
91
+ // @ts-ignore
92
+ selectorRef.current.close();
93
+ }
84
94
 
85
- selectorRef.current && selectorRef.current.close();
86
95
  return;
87
96
  }
88
97
 
89
- onChangeVisiableLimit && onChangeVisiableLimit(4, selectNodes); // @ts-ignore
98
+ if (onChangeVisiableLimit) {
99
+ onChangeVisiableLimit(4, selectNodes);
100
+ }
90
101
 
91
- selectorRef.current && selectorRef.current.close();
102
+ if (selectorRef.current) {
103
+ // @ts-ignore
104
+ selectorRef.current.close();
105
+ }
92
106
  }, [onChangeVisiableLimit]);
93
107
  var handleChangeVisibility = (0, _react.useCallback)(function (data) {
94
108
  setVisibilityState(data.value);
95
109
 
96
110
  if (data.value === 4) {
97
- // @ts-ignore
98
- selectorRef.current && selectorRef.current.open();
111
+ if (selectorRef.current) {
112
+ // @ts-ignore
113
+ selectorRef.current.open();
114
+ }
99
115
  } else {
100
116
  oldSelect.current = data.value;
101
- onChangeVisiableLimit && onChangeVisiableLimit(data.value);
117
+
118
+ if (onChangeVisiableLimit) {
119
+ onChangeVisiableLimit(data.value);
120
+ }
102
121
  }
103
122
  }, [onChangeVisiableLimit]);
104
123
  var renderText = (0, _react.useMemo)(function () {
105
124
  var result = [];
106
125
 
107
126
  if (visiableLimit) {
108
- visiableLimit.users && visiableLimit.users.length > 0 && visiableLimit.users.forEach(function (item, index) {
109
- if (index !== 0) {
110
- result.push("、");
111
- }
112
-
113
- result.push( /*#__PURE__*/_react["default"].createElement(_openData.OpenUserName, {
114
- name: item.name,
115
- id: item.userId
116
- }));
117
- });
118
- visiableLimit.departments && visiableLimit.departments.length > 0 ? visiableLimit.departments.forEach(function (item, index) {
119
- result.push(index === 0 && result.length === 0 ? "" : "、");
120
- result.push( /*#__PURE__*/_react["default"].createElement(_openData.OpenDepartmentName, {
121
- name: item.name,
122
- id: item.id
123
- }));
124
- }) : "";
125
- visiableLimit.groups && visiableLimit.groups.length > 0 ? visiableLimit.groups.forEach(function (item, index) {
126
- result.push(index === 0 && result.length === 0 ? "" : "、");
127
- result.push(item.name);
128
- }) : "";
127
+ if (visiableLimit.users && visiableLimit.users.length > 0) {
128
+ visiableLimit.users.forEach(function (item, index) {
129
+ if (index !== 0) {
130
+ result.push("、");
131
+ }
132
+
133
+ result.push( /*#__PURE__*/_react["default"].createElement(_openData.OpenUserName, {
134
+ name: item.name,
135
+ id: item.userId
136
+ }));
137
+ });
138
+ }
139
+
140
+ if (visiableLimit.departments && visiableLimit.departments.length > 0) {
141
+ visiableLimit.departments.forEach(function (item, index) {
142
+ result.push(index === 0 && result.length === 0 ? "" : "、");
143
+ result.push( /*#__PURE__*/_react["default"].createElement(_openData.OpenDepartmentName, {
144
+ name: item.name,
145
+ id: item.id
146
+ }));
147
+ });
148
+ }
149
+
150
+ if (visiableLimit.groups && visiableLimit.groups.length > 0) {
151
+ visiableLimit.groups.forEach(function (item, index) {
152
+ result.push(index === 0 && result.length === 0 ? "" : "、");
153
+ result.push(item.name);
154
+ });
155
+ }
129
156
  }
130
157
 
131
- return result.length > 0 ? result : visibilityMapText[visibilityState];
158
+ return result.length > 0 ? result : getVisibilityMapText()[visibilityState];
132
159
  }, [visiableLimit, visibilityState]);
133
160
  (0, _react.useEffect)(function () {
134
161
  setVisibilityState(visibility);
@@ -158,7 +185,7 @@ var Visibility = function Visibility(_ref) {
158
185
  textClass: "base-info-other-infos__visibility-select-text",
159
186
  forceRenderText: visibility === 4,
160
187
  initText: renderText,
161
- items: visibilityList,
188
+ items: getVisibilityList(),
162
189
  initValue: visibilityState,
163
190
  onChangeSelect: handleChangeVisibility
164
191
  }), canEdit ? /*#__PURE__*/_react["default"].createElement(_index["default"], {
@@ -172,5 +199,8 @@ var Visibility = function Visibility(_ref) {
172
199
  }) : null);
173
200
  };
174
201
 
202
+ Visibility.defaultProps = {
203
+ canEdit: false
204
+ };
175
205
  var _default = Visibility;
176
206
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titaui/pc",
3
- "version": "1.9.62",
3
+ "version": "1.9.63",
4
4
  "nameCN": "",
5
5
  "description": "",
6
6
  "main": "src/index.js",
@@ -8,19 +8,19 @@ import Tooltip from "../../../../tooltip";
8
8
  import { OpenDepartmentName, OpenUserName } from "../../../../../utils/open-data";
9
9
  import { getLocale } from "../../../../../utils/getLocale";
10
10
 
11
- const visibilityList = [
11
+ const getVisibilityList = () => [
12
12
  { value: 1, label: getLocale("OKR_MyO_Pop_Public") },
13
13
  { value: 2, label: getLocale("OKR_MyO_From_Associatedmem") },
14
14
  { value: 3, label: getLocale("OKR_MyO_Pop_Directrep") },
15
15
  { value: 4, label: getLocale("OKR_MyO_Pop_Specified") },
16
16
  ];
17
17
 
18
- const visibilityMapText = {
18
+ const getVisibilityMapText = () => ({
19
19
  1: getLocale("OKR_MyO_Pop_Public"),
20
20
  2: getLocale("OKR_MyO_From_Associatedmem"),
21
21
  3: getLocale("OKR_MyO_Pop_Directrep"),
22
22
  4: getLocale("OKR_MyO_Pop_Specified"),
23
- };
23
+ });
24
24
 
25
25
  interface IVisibilityProps {
26
26
  visibility: any;
@@ -41,43 +41,59 @@ const Visibility: FC<IVisibilityProps> = ({
41
41
  const { departments, groups, users } = selectNodes;
42
42
  if (departments.length === 0 && groups.length === 0 && users.length === 0) {
43
43
  setVisibilityState(oldSelect.current);
44
- // @ts-ignore
45
- selectorRef.current && selectorRef.current.close();
44
+ if (selectorRef.current) {
45
+ // @ts-ignore
46
+ selectorRef.current.close();
47
+ }
46
48
  return;
47
49
  }
48
- onChangeVisiableLimit && onChangeVisiableLimit(4, selectNodes);
49
- // @ts-ignore
50
- selectorRef.current && selectorRef.current.close();
50
+ if (onChangeVisiableLimit) {
51
+ onChangeVisiableLimit(4, selectNodes);
52
+ }
53
+ if (selectorRef.current) {
54
+ // @ts-ignore
55
+ selectorRef.current.close();
56
+ }
51
57
  }, [onChangeVisiableLimit]);
52
58
 
53
59
  const handleChangeVisibility = useCallback((data) => {
54
60
  setVisibilityState(data.value);
55
61
  if (data.value === 4) {
56
- // @ts-ignore
57
- selectorRef.current && selectorRef.current.open();
62
+ if (selectorRef.current) {
63
+ // @ts-ignore
64
+ selectorRef.current.open();
65
+ }
58
66
  } else {
59
67
  oldSelect.current = data.value;
60
- onChangeVisiableLimit && onChangeVisiableLimit(data.value);
68
+ if (onChangeVisiableLimit) {
69
+ onChangeVisiableLimit(data.value);
70
+ }
61
71
  }
62
72
  }, [onChangeVisiableLimit]);
63
73
 
64
74
  const renderText = useMemo(() => {
65
75
  const result = [];
66
76
  if (visiableLimit) {
67
- visiableLimit.users && visiableLimit.users.length > 0 && visiableLimit.users.forEach((item, index) => {
68
- if (index !== 0) { result.push("、"); }
69
- result.push(<OpenUserName name={item.name} id={item.userId} />);
70
- });
71
- visiableLimit.departments && visiableLimit.departments.length > 0 ? visiableLimit.departments.forEach((item, index) => {
72
- result.push(index === 0 && result.length === 0 ? "" : "、");
73
- result.push(<OpenDepartmentName name={item.name} id={item.id} />);
74
- }) : "";
75
- visiableLimit.groups && visiableLimit.groups.length > 0 ? visiableLimit.groups.forEach((item, index) => {
76
- result.push(index === 0 && result.length === 0 ? "" : "、");
77
- result.push(item.name);
78
- }) : "";
77
+ if (visiableLimit.users && visiableLimit.users.length > 0) {
78
+ visiableLimit.users.forEach((item, index) => {
79
+ if (index !== 0) { result.push("、"); }
80
+ result.push(<OpenUserName name={item.name} id={item.userId} />);
81
+ });
82
+ }
83
+ if (visiableLimit.departments && visiableLimit.departments.length > 0) {
84
+ visiableLimit.departments.forEach((item, index) => {
85
+ result.push(index === 0 && result.length === 0 ? "" : "、");
86
+ result.push(<OpenDepartmentName name={item.name} id={item.id} />);
87
+ });
88
+ }
89
+ if (visiableLimit.groups && visiableLimit.groups.length > 0) {
90
+ visiableLimit.groups.forEach((item, index) => {
91
+ result.push(index === 0 && result.length === 0 ? "" : "、");
92
+ result.push(item.name);
93
+ });
94
+ }
79
95
  }
80
- return result.length > 0 ? result : visibilityMapText[visibilityState];
96
+ return result.length > 0 ? result : getVisibilityMapText()[visibilityState];
81
97
  }, [visiableLimit, visibilityState]);
82
98
 
83
99
  useEffect(() => {
@@ -112,7 +128,7 @@ const Visibility: FC<IVisibilityProps> = ({
112
128
  textClass="base-info-other-infos__visibility-select-text"
113
129
  forceRenderText={visibility === 4}
114
130
  initText={renderText as any}
115
- items={visibilityList}
131
+ items={getVisibilityList()}
116
132
  initValue={visibilityState}
117
133
  onChangeSelect={handleChangeVisibility}
118
134
  />
@@ -131,4 +147,8 @@ const Visibility: FC<IVisibilityProps> = ({
131
147
  );
132
148
  };
133
149
 
150
+ Visibility.defaultProps = {
151
+ canEdit: false,
152
+ };
153
+
134
154
  export default Visibility;