fan-standard-comp 3.2.10 → 3.2.12
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/dist/fan-standard-comp.umd.js +150 -150
- package/es/FormComp/FieldComponent/RefactorTreeSelect.d.ts +4 -0
- package/es/FormComp/FieldComponent/RefactorTreeSelect.js +96 -202
- package/es/FormComp/FieldComponent/index.js +1 -1
- package/es/RefactorTree/util.d.ts +4 -3
- package/es/RefactorTree/util.js +52 -8
- package/es/hooks/use-language.d.ts +2 -0
- package/es/hooks/use-language.js +44 -0
- package/es/hooks/use-throttle.d.ts +1 -0
- package/es/hooks/use-throttle.js +33 -0
- package/es/locales/bn-BD/settings.d.ts +34 -0
- package/es/locales/bn-BD/settings.js +36 -0
- package/es/locales/bn-BD.d.ts +35 -0
- package/es/locales/bn-BD.js +4 -0
- package/es/locales/en-US/settings.d.ts +34 -0
- package/es/locales/en-US/settings.js +36 -0
- package/es/locales/en-US.d.ts +35 -0
- package/es/locales/en-US.js +4 -0
- package/es/locales/fa-IR/settings.d.ts +34 -0
- package/es/locales/fa-IR/settings.js +36 -0
- package/es/locales/fa-IR.d.ts +35 -0
- package/es/locales/fa-IR.js +4 -0
- package/es/locales/id-ID/settings.d.ts +34 -0
- package/es/locales/id-ID/settings.js +36 -0
- package/es/locales/id-ID.d.ts +35 -0
- package/es/locales/id-ID.js +4 -0
- package/es/locales/ja-JP/settings.d.ts +33 -0
- package/es/locales/ja-JP/settings.js +35 -0
- package/es/locales/ja-JP.d.ts +34 -0
- package/es/locales/ja-JP.js +4 -0
- package/es/locales/pt-BR/settings.d.ts +34 -0
- package/es/locales/pt-BR/settings.js +36 -0
- package/es/locales/pt-BR.d.ts +35 -0
- package/es/locales/pt-BR.js +4 -0
- package/es/locales/zh-CN/settings.d.ts +34 -0
- package/es/locales/zh-CN/settings.js +36 -0
- package/es/locales/zh-CN.d.ts +35 -0
- package/es/locales/zh-CN.js +4 -0
- package/es/locales/zh-TW/settings.d.ts +34 -0
- package/es/locales/zh-TW/settings.js +36 -0
- package/es/locales/zh-TW.d.ts +34 -0
- package/es/locales/zh-TW.js +2 -0
- package/es/utils/getParentNodes.d.ts +109 -0
- package/es/utils/getParentNodes.js +119 -20
- package/lib/FormComp/FieldComponent/RefactorTreeSelect.d.ts +4 -0
- package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +94 -199
- package/lib/FormComp/FieldComponent/index.js +1 -1
- package/lib/RefactorTree/util.d.ts +4 -3
- package/lib/RefactorTree/util.js +51 -9
- package/lib/hooks/use-language.d.ts +2 -0
- package/lib/hooks/use-language.js +51 -0
- package/lib/hooks/use-throttle.d.ts +1 -0
- package/lib/hooks/use-throttle.js +38 -0
- package/lib/locales/bn-BD/settings.d.ts +34 -0
- package/lib/locales/bn-BD/settings.js +42 -0
- package/lib/locales/bn-BD.d.ts +35 -0
- package/lib/locales/bn-BD.js +11 -0
- package/lib/locales/en-US/settings.d.ts +34 -0
- package/lib/locales/en-US/settings.js +42 -0
- package/lib/locales/en-US.d.ts +35 -0
- package/lib/locales/en-US.js +11 -0
- package/lib/locales/fa-IR/settings.d.ts +34 -0
- package/lib/locales/fa-IR/settings.js +42 -0
- package/lib/locales/fa-IR.d.ts +35 -0
- package/lib/locales/fa-IR.js +11 -0
- package/lib/locales/id-ID/settings.d.ts +34 -0
- package/lib/locales/id-ID/settings.js +42 -0
- package/lib/locales/id-ID.d.ts +35 -0
- package/lib/locales/id-ID.js +11 -0
- package/lib/locales/ja-JP/settings.d.ts +33 -0
- package/lib/locales/ja-JP/settings.js +41 -0
- package/lib/locales/ja-JP.d.ts +34 -0
- package/lib/locales/ja-JP.js +11 -0
- package/lib/locales/pt-BR/settings.d.ts +34 -0
- package/lib/locales/pt-BR/settings.js +42 -0
- package/lib/locales/pt-BR.d.ts +35 -0
- package/lib/locales/pt-BR.js +11 -0
- package/lib/locales/zh-CN/settings.d.ts +34 -0
- package/lib/locales/zh-CN/settings.js +42 -0
- package/lib/locales/zh-CN.d.ts +35 -0
- package/lib/locales/zh-CN.js +11 -0
- package/lib/locales/zh-TW/settings.d.ts +34 -0
- package/lib/locales/zh-TW/settings.js +42 -0
- package/lib/locales/zh-TW.d.ts +34 -0
- package/lib/locales/zh-TW.js +9 -0
- package/lib/utils/getParentNodes.d.ts +109 -0
- package/lib/utils/getParentNodes.js +118 -22
- package/package.json +1 -1
|
@@ -5,36 +5,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
require("antd/es/popover/style");
|
|
9
|
-
var _popover = _interopRequireDefault(require("antd/es/popover"));
|
|
10
|
-
require("antd/es/tag/style");
|
|
11
|
-
var _tag = _interopRequireDefault(require("antd/es/tag"));
|
|
12
8
|
require("antd/es/tree-select/style");
|
|
13
9
|
var _treeSelect = _interopRequireDefault(require("antd/es/tree-select"));
|
|
10
|
+
var _tslib = require("tslib");
|
|
14
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
12
|
require("./style/index.less");
|
|
13
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
16
15
|
var _utils = require("../../utils");
|
|
17
16
|
var _icons = require("@ant-design/icons");
|
|
18
|
-
var
|
|
17
|
+
var _util = require("../../RefactorTree/util");
|
|
18
|
+
var _useLanguage = require("../../hooks/use-language");
|
|
19
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
-
function _objectDestructuringEmpty(t) { if (null == t) throw new TypeError("Cannot destructure " + t); }
|
|
23
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
24
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
27
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
28
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
29
22
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
30
23
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
31
24
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
32
25
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
33
26
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
34
27
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
35
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
36
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
37
|
-
var TreeNode = _treeSelect.default.TreeNode;
|
|
38
28
|
var RefactorTreeSelect = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
39
29
|
var _props$treeData = props.treeData,
|
|
40
30
|
treeData = _props$treeData === void 0 ? [] : _props$treeData,
|
|
@@ -48,6 +38,7 @@ var RefactorTreeSelect = /*#__PURE__*/_react.default.forwardRef(function (props,
|
|
|
48
38
|
_props$treeOptionName = props.treeOptionName,
|
|
49
39
|
treeOptionName = _props$treeOptionName === void 0 ? {
|
|
50
40
|
title: 'title',
|
|
41
|
+
label: 'label',
|
|
51
42
|
value: 'value',
|
|
52
43
|
children: 'children',
|
|
53
44
|
disabled: 'disabled'
|
|
@@ -56,220 +47,124 @@ var RefactorTreeSelect = /*#__PURE__*/_react.default.forwardRef(function (props,
|
|
|
56
47
|
protoTreeNode = props.protoTreeNode,
|
|
57
48
|
_onSelect = props.onSelect,
|
|
58
49
|
labelInValue = props.labelInValue,
|
|
59
|
-
otherProps =
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
console.log(convertToArray(treeData))
|
|
75
|
-
// 还需要按showCheckedStrategy判断选择的节点数量
|
|
76
|
-
otherProps?.onChange(convertToArray(treeData).map(item=> item[treeOptionName.value]))
|
|
77
|
-
} else {
|
|
78
|
-
otherProps?.onChange([])
|
|
79
|
-
}
|
|
80
|
-
}*/
|
|
81
|
-
|
|
82
|
-
var _renderTreeNode = function renderTreeNode(data, dataOptionName) {
|
|
83
|
-
var nodeProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
84
|
-
return data.map(function (dataItem) {
|
|
85
|
-
var prevDataItem = _objectSpread({}, dataItem);
|
|
86
|
-
var item = _extends({}, (_objectDestructuringEmpty(prevDataItem), prevDataItem));
|
|
87
|
-
// 筛选与禁用字段内值相同的节点进行禁用
|
|
88
|
-
var resetByDisabledFields = function resetByDisabledFields(initItem) {
|
|
89
|
-
var oldItem = _objectSpread({}, initItem);
|
|
90
|
-
var nodeItem = _extends({}, (_objectDestructuringEmpty(oldItem), oldItem));
|
|
91
|
-
Object.keys(nodeItem).forEach(function (itemKeyName) {
|
|
92
|
-
var isMatch = disabledFields.find(function (fItem) {
|
|
93
|
-
return fItem.key === itemKeyName;
|
|
94
|
-
});
|
|
95
|
-
if (isMatch) {
|
|
96
|
-
var _isMatch$value$split;
|
|
97
|
-
// 确认是否匹配数据,进行设置 disabled
|
|
98
|
-
if ((_isMatch$value$split = isMatch.value.split(',')) === null || _isMatch$value$split === void 0 ? void 0 : _isMatch$value$split.includes(nodeItem[itemKeyName])) {
|
|
99
|
-
nodeItem.disabled = true;
|
|
100
|
-
} else if (nodeItem.hasOwnProperty(dataOptionName.disabled || 'disabled')) {
|
|
101
|
-
nodeItem.disabled = nodeItem[dataOptionName.disabled || 'disabled'];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
return nodeItem;
|
|
106
|
-
};
|
|
107
|
-
if (disabledFields && Array.isArray(disabledFields)) {
|
|
108
|
-
item = resetByDisabledFields(item);
|
|
109
|
-
}
|
|
110
|
-
if (item[dataOptionName.children] && item[dataOptionName.children].length > 0) {
|
|
111
|
-
return /*#__PURE__*/_react.default.createElement(TreeNode, _extends({
|
|
112
|
-
title: item[dataOptionName.title],
|
|
113
|
-
key: item[dataOptionName.value],
|
|
114
|
-
value: item[dataOptionName.value],
|
|
115
|
-
selectable: item[(dataOptionName === null || dataOptionName === void 0 ? void 0 : dataOptionName.selectable) || 'selectable'],
|
|
116
|
-
checkable: item[(dataOptionName === null || dataOptionName === void 0 ? void 0 : dataOptionName.checkable) || 'checkable'],
|
|
117
|
-
disableCheckbox: item[(dataOptionName === null || dataOptionName === void 0 ? void 0 : dataOptionName.disableCheckbox) || 'disableCheckbox'],
|
|
118
|
-
disabled: item[(dataOptionName === null || dataOptionName === void 0 ? void 0 : dataOptionName.disabled) || 'disabled']
|
|
119
|
-
}, nodeProps), _renderTreeNode(item[dataOptionName.children], dataOptionName));
|
|
120
|
-
}
|
|
121
|
-
return /*#__PURE__*/_react.default.createElement(TreeNode, _extends({
|
|
122
|
-
title: item[dataOptionName.title],
|
|
123
|
-
key: item[dataOptionName.value],
|
|
124
|
-
value: item[dataOptionName.value],
|
|
125
|
-
selectable: item[(dataOptionName === null || dataOptionName === void 0 ? void 0 : dataOptionName.selectable) || 'selectable'],
|
|
126
|
-
checkable: item[(dataOptionName === null || dataOptionName === void 0 ? void 0 : dataOptionName.checkable) || 'checkable'],
|
|
127
|
-
disableCheckbox: item[(dataOptionName === null || dataOptionName === void 0 ? void 0 : dataOptionName.disableCheckbox) || 'disableCheckbox'],
|
|
128
|
-
disabled: item[(dataOptionName === null || dataOptionName === void 0 ? void 0 : dataOptionName.disabled) || 'disabled']
|
|
129
|
-
}, nodeProps));
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
(0, _react.useEffect)(function () {
|
|
133
|
-
if (value) {
|
|
134
|
-
// 获取选中节点相关数据:包括当前完整数据值、当前父节点以上层层级节点数据集合及id集合
|
|
135
|
-
var nodeInfo = (0, _utils.getParentNodes)(treeData, labelInValue ? value.value : value, {
|
|
136
|
-
childrenParam: treeOptionName.children,
|
|
137
|
-
keyParam: treeOptionName.value
|
|
138
|
-
}, _objectSpread({}, otherProps));
|
|
139
|
-
setFullLevelName(renderParenName(nodeInfo));
|
|
140
|
-
} else {
|
|
141
|
-
// value,无值时
|
|
142
|
-
setFullLevelName(null);
|
|
143
|
-
}
|
|
144
|
-
}, [value, treeData, fieldStatus]);
|
|
145
|
-
var renderParenName = function renderParenName(selectNodeInfo) {
|
|
146
|
-
// 有父级节点,及当前模式是showFullLevel时,渲染名称为完整层级名称,否则为当前节点名称
|
|
147
|
-
var parentItems = selectNodeInfo.nodeParent;
|
|
148
|
-
if (parentItems.length > 0 && showFullLevel && !otherProps.showCheckedStrategy) {
|
|
149
|
-
// 当前查找到的父级节点拼合当前节点的标题字段值进行显示
|
|
150
|
-
return parentItems.reverse().map(function (item) {
|
|
151
|
-
return item[treeOptionName.title];
|
|
152
|
-
}).concat(selectNodeInfo.matchNode[0][treeOptionName.title]).join(separator);
|
|
153
|
-
}
|
|
154
|
-
if (Array.isArray(value)) {
|
|
155
|
-
return selectNodeInfo.matchNode.length > 0 ? selectNodeInfo.matchNode.map(function (item) {
|
|
156
|
-
return item[treeOptionName.title] || item[treeOptionName.value];
|
|
157
|
-
}).join(',') : null;
|
|
158
|
-
}
|
|
159
|
-
return selectNodeInfo.matchNode.length > 0 ? selectNodeInfo.matchNode[0][treeOptionName.title] : null;
|
|
160
|
-
};
|
|
161
|
-
var renderTreeSelectNode = function renderTreeSelectNode() {
|
|
162
|
-
// 限制显示多个tag
|
|
163
|
-
if (otherProps.treeCheckable && otherProps.maxTagCount) {
|
|
164
|
-
// 未自行配置`maxTagPlaceholder`时,使用当前结构,点击"+xxx"后,浮层将显示对应的标签
|
|
165
|
-
if (!otherProps.hasOwnProperty('maxTagPlaceholder')) {
|
|
166
|
-
otherProps.maxTagPlaceholder = function (omittedValues) {
|
|
167
|
-
return /*#__PURE__*/_react.default.createElement(_popover.default, {
|
|
168
|
-
zIndex: 10000,
|
|
169
|
-
content: /*#__PURE__*/_react.default.createElement("div", {
|
|
170
|
-
style: {
|
|
171
|
-
maxWidth: '350px'
|
|
172
|
-
}
|
|
173
|
-
}, omittedValues.map(function (item) {
|
|
174
|
-
return /*#__PURE__*/_react.default.createElement(_tag.default, {
|
|
175
|
-
key: item.value
|
|
176
|
-
}, item.label);
|
|
177
|
-
}))
|
|
178
|
-
}, "+", omittedValues.length);
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return /*#__PURE__*/_react.default.createElement(_treeSelect.default, _extends({
|
|
183
|
-
placeholder: placeholder,
|
|
184
|
-
value: value,
|
|
185
|
-
ref: ref
|
|
186
|
-
}, otherProps, {
|
|
187
|
-
labelInValue: labelInValue,
|
|
188
|
-
title: otherProps.title || ((disabled || fieldStatus === 'disabled') && !otherProps.treeCheckable ? fullLevelName : null),
|
|
189
|
-
showCheckedStrategy: otherProps.showCheckedStrategy,
|
|
190
|
-
disabled: disabled,
|
|
191
|
-
onSelect: function onSelect(value, node, extra) {
|
|
192
|
-
var newNodeInfo = (0, _utils.getParentNodes)(treeData, value, {
|
|
193
|
-
childrenParam: treeOptionName.children,
|
|
194
|
-
keyParam: treeOptionName.value
|
|
195
|
-
});
|
|
196
|
-
setFullLevelName(renderParenName(newNodeInfo));
|
|
197
|
-
if (_onSelect) _onSelect(value, _objectSpread(_objectSpread({}, node), newNodeInfo.matchNode[0]), extra, newNodeInfo.nodeParent);
|
|
198
|
-
}
|
|
199
|
-
// 下拉浮层中显示"全选"按钮
|
|
200
|
-
// dropdownRender={(originNode) => {
|
|
201
|
-
// return otherProps?.dropdownRender ? otherProps?.dropdownRender(originNode, <div>
|
|
202
|
-
// <div>
|
|
203
|
-
// <Checkbox indeterminate={indeterminate} onChange={onCheckAllChange} checked={checkAll}>
|
|
204
|
-
// 全选
|
|
205
|
-
// </Checkbox> <span>已选{value?.length}</span></div>
|
|
206
|
-
// </div>) : originNode
|
|
207
|
-
// }}
|
|
208
|
-
}), _renderTreeNode(treeData, treeOptionName, protoTreeNode || {}));
|
|
50
|
+
otherProps = (0, _tslib.__rest)(props, ["treeData", "value", "showFullLevel", "separator", "disabled", "disabledFields", "fieldStatus", "treeOptionName", "placeholder", "protoTreeNode", "onSelect", "labelInValue"]);
|
|
51
|
+
var lang = (0, _useLanguage.useLanguageObject)(); // 当前使用的语言包
|
|
52
|
+
var componentName = 'refactor-tree-select';
|
|
53
|
+
// 重组数据
|
|
54
|
+
var transTreeData = (0, _react.useMemo)(function () {
|
|
55
|
+
var newTree = _lodash.default.cloneDeep(treeData || []);
|
|
56
|
+
return (0, _util.transDataParam)(newTree, (otherProps === null || otherProps === void 0 ? void 0 : otherProps.fieldNames) || treeOptionName, {
|
|
57
|
+
separator: separator,
|
|
58
|
+
disabledFields: disabledFields
|
|
59
|
+
}); // 通过转换后的数据
|
|
60
|
+
}, [treeData, treeOptionName, otherProps.fieldNames, separator, disabledFields]);
|
|
61
|
+
// 设置名称字段值
|
|
62
|
+
var setLabelKeyName = function setLabelKeyName() {
|
|
63
|
+
var _a;
|
|
64
|
+
return showFullLevelKeyName || ((_a = otherProps.fieldNames) === null || _a === void 0 ? void 0 : _a.label) || treeOptionName.title || treeOptionName.label;
|
|
209
65
|
};
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
66
|
+
// 判断是否指定显示完整名称
|
|
67
|
+
var showFullLevelKeyName = (0, _react.useMemo)(function () {
|
|
68
|
+
return showFullLevel ? 'treeFullLevelName' : otherProps === null || otherProps === void 0 ? void 0 : otherProps.treeNodeLabelProp;
|
|
69
|
+
}, [showFullLevel, otherProps === null || otherProps === void 0 ? void 0 : otherProps.treeNodeLabelProp]);
|
|
70
|
+
var _useState = (0, _react.useState)(false),
|
|
71
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
+
showAllPath = _useState2[0],
|
|
73
|
+
setShowAllPath = _useState2[1]; // 显示所有树选择路径
|
|
214
74
|
var renderTreeSelectNodePath = function renderTreeSelectNodePath() {
|
|
215
75
|
//获取节点路径
|
|
216
|
-
var pathNodes = (0, _utils.getNodePaths)(
|
|
76
|
+
var pathNodes = (0, _utils.getNodePaths)(transTreeData, value, {
|
|
217
77
|
childrenParam: treeOptionName.children,
|
|
218
78
|
keyParam: treeOptionName.value
|
|
219
|
-
},
|
|
79
|
+
}, Object.assign({}, otherProps));
|
|
220
80
|
var togglePath = function togglePath() {
|
|
221
81
|
setShowAllPath(!showAllPath);
|
|
222
82
|
};
|
|
223
83
|
if (pathNodes.length > 0) {
|
|
224
84
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
225
85
|
className: "tree-select-viewonly-list ".concat(showAllPath ? 'collapsed' : '')
|
|
226
|
-
},
|
|
86
|
+
},
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
pathNodes.map(function (item, index) {
|
|
227
89
|
if (item.length > 0) {
|
|
228
90
|
// 超过2个且不显示所有
|
|
229
|
-
if (index > 1 && !showAllPath) return;
|
|
91
|
+
if (index > 1 && !showAllPath) return '';
|
|
230
92
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
231
93
|
className: 'tree-select-viewonly-item',
|
|
232
94
|
key: index
|
|
233
95
|
}, /*#__PURE__*/_react.default.createElement("b", null, "\xB7 "), item.map(function (i) {
|
|
234
|
-
return i[
|
|
96
|
+
return i[setLabelKeyName()];
|
|
235
97
|
}).join(separator));
|
|
236
98
|
}
|
|
237
|
-
}), pathNodes.length > 2 ? /*#__PURE__*/_react.default.createElement("div", {
|
|
99
|
+
}), pathNodes.length > 2 ? (/*#__PURE__*/_react.default.createElement("div", {
|
|
238
100
|
className: "toggle-icon",
|
|
239
101
|
onClick: togglePath
|
|
240
|
-
}, !showAllPath ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "
|
|
102
|
+
}, !showAllPath ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (lang === null || lang === void 0 ? void 0 : lang['field.expand']) || '展开', " ", /*#__PURE__*/_react.default.createElement(_icons.DownOutlined, null)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (lang === null || lang === void 0 ? void 0 : lang['field.collapse']) || '收起', " ", /*#__PURE__*/_react.default.createElement(_icons.UpOutlined, null)))) : null));
|
|
241
103
|
} else {
|
|
242
104
|
return '-';
|
|
243
105
|
}
|
|
244
106
|
};
|
|
245
107
|
if (fieldStatus === 'viewOnly') {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
108
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
109
|
+
className: (0, _classnames.default)(componentName, otherProps === null || otherProps === void 0 ? void 0 : otherProps.className, componentName + '-viewOnly')
|
|
110
|
+
}, function () {
|
|
111
|
+
var _a;
|
|
112
|
+
//多选下拉框 详情展示 showCheckedStrategy 有值且显示完整路径时
|
|
113
|
+
if (otherProps.showCheckedStrategy && showFullLevelKeyName) {
|
|
114
|
+
return renderTreeSelectNodePath();
|
|
115
|
+
}
|
|
116
|
+
// 多选状态
|
|
117
|
+
if (otherProps.multiple) {
|
|
118
|
+
if (labelInValue) {
|
|
119
|
+
return value && value.length > 0 ? value.map(function (item) {
|
|
120
|
+
return item[setLabelKeyName()] || item['title'] || item['label'];
|
|
121
|
+
}).join(',') : '-';
|
|
122
|
+
}
|
|
123
|
+
var pathNodes = (0, _utils.getNodePaths)(transTreeData, value, {
|
|
124
|
+
childrenParam: treeOptionName.children,
|
|
125
|
+
keyParam: treeOptionName.value
|
|
126
|
+
}, Object.assign({}, otherProps));
|
|
127
|
+
return pathNodes.length > 0 ? pathNodes.map(function (nItem) {
|
|
128
|
+
var _a;
|
|
129
|
+
return (_a = nItem[nItem.length - 1]) === null || _a === void 0 ? void 0 : _a[setLabelKeyName()];
|
|
255
130
|
}).join(',') : '-';
|
|
256
131
|
}
|
|
257
|
-
var
|
|
132
|
+
var nodeInfo = (0, _utils.getParentNodes)(transTreeData, labelInValue ? value.value : value, {
|
|
258
133
|
childrenParam: treeOptionName.children,
|
|
259
134
|
keyParam: treeOptionName.value
|
|
260
|
-
},
|
|
261
|
-
return
|
|
262
|
-
|
|
263
|
-
return (_nItem = nItem[nItem.length - 1]) === null || _nItem === void 0 ? void 0 : _nItem[treeOptionName.title];
|
|
264
|
-
}).join(',') : '-';
|
|
265
|
-
}
|
|
266
|
-
return fullLevelName || '-'; // 只读显示时,只返回文本
|
|
135
|
+
}, Object.assign({}, otherProps));
|
|
136
|
+
return ((_a = nodeInfo === null || nodeInfo === void 0 ? void 0 : nodeInfo.matchNode[0]) === null || _a === void 0 ? void 0 : _a[setLabelKeyName()]) || '-'; // 只读显示时,只返回文本
|
|
137
|
+
}());
|
|
267
138
|
}
|
|
268
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement(_treeSelect.default, Object.assign({
|
|
140
|
+
placeholder: placeholder,
|
|
141
|
+
value: value,
|
|
142
|
+
ref: ref
|
|
143
|
+
}, otherProps, {
|
|
144
|
+
treeNodeLabelProp: showFullLevel ? 'treeFullLevelName' : otherProps === null || otherProps === void 0 ? void 0 : otherProps.treeNodeLabelProp,
|
|
145
|
+
className: (0, _classnames.default)(componentName, otherProps === null || otherProps === void 0 ? void 0 : otherProps.className),
|
|
146
|
+
labelInValue: labelInValue,
|
|
147
|
+
showCheckedStrategy: otherProps.showCheckedStrategy,
|
|
148
|
+
disabled: disabled,
|
|
149
|
+
onSelect: function onSelect(value, node, extra) {
|
|
150
|
+
var newNodeInfo = (0, _utils.getParentNodes)(transTreeData, value, {
|
|
151
|
+
childrenParam: treeOptionName.children,
|
|
152
|
+
keyParam: treeOptionName.value
|
|
153
|
+
});
|
|
154
|
+
if (_onSelect) _onSelect(value, Object.assign(Object.assign({}, node), newNodeInfo.matchNode[0]), extra, newNodeInfo.nodeParent);
|
|
155
|
+
},
|
|
156
|
+
onDropdownVisibleChange: function onDropdownVisibleChange(open) {
|
|
157
|
+
var _a;
|
|
158
|
+
(_a = otherProps === null || otherProps === void 0 ? void 0 : otherProps.onDropdownVisibleChange) === null || _a === void 0 ? void 0 : _a.call(otherProps, open);
|
|
159
|
+
},
|
|
160
|
+
onSearch: function onSearch(value) {
|
|
161
|
+
var _a;
|
|
162
|
+
(_a = otherProps === null || otherProps === void 0 ? void 0 : otherProps.onSearch) === null || _a === void 0 ? void 0 : _a.call(otherProps, value);
|
|
163
|
+
},
|
|
164
|
+
treeData: transTreeData,
|
|
165
|
+
fieldNames: Object.assign(Object.assign(Object.assign({}, treeOptionName), {
|
|
166
|
+
label: (treeOptionName === null || treeOptionName === void 0 ? void 0 : treeOptionName.title) || (treeOptionName === null || treeOptionName === void 0 ? void 0 : treeOptionName.label)
|
|
167
|
+
}), (otherProps === null || otherProps === void 0 ? void 0 : otherProps.fieldNames) || {})
|
|
168
|
+
}));
|
|
274
169
|
});
|
|
275
170
|
var _default = exports.default = RefactorTreeSelect;
|
|
@@ -34,7 +34,7 @@ var _input = _interopRequireDefault(require("antd/es/input"));
|
|
|
34
34
|
var _react = _interopRequireWildcard(require("react"));
|
|
35
35
|
var _Uploader = _interopRequireDefault(require("../Uploader"));
|
|
36
36
|
var _SpecIcon = _interopRequireDefault(require("../../SpecIcon"));
|
|
37
|
-
var _RefactorTreeSelect = _interopRequireDefault(require("./RefactorTreeSelect
|
|
37
|
+
var _RefactorTreeSelect = _interopRequireDefault(require("./RefactorTreeSelect"));
|
|
38
38
|
var _setReadonlyValues = require("./setReadonlyValues.js");
|
|
39
39
|
var _TitleNode = _interopRequireDefault(require("./TitleNode"));
|
|
40
40
|
var _ReUpload = _interopRequireDefault(require("./ReUpload"));
|
|
@@ -5,15 +5,16 @@ interface optionNameProps {
|
|
|
5
5
|
children?: string;
|
|
6
6
|
disabled?: string;
|
|
7
7
|
selectable?: string;
|
|
8
|
+
label?: string;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* transDataParam 根据指定选项字段名重组数据
|
|
11
12
|
*
|
|
12
13
|
* @params {array} array 树数据集合
|
|
13
|
-
* @params {object} optionName 选项字段值
|
|
14
|
+
* @params {object} optionName 选项字段值(tree-select的标题使用的是label字段)
|
|
14
15
|
*
|
|
15
16
|
* */
|
|
16
|
-
export declare function transDataParam(array
|
|
17
|
+
export declare function transDataParam(array: any[], optionName?: optionNameProps, extra?: any): any[];
|
|
17
18
|
/**
|
|
18
19
|
* 根据限制字段limitKey进行重组数据
|
|
19
20
|
*
|
|
@@ -25,7 +26,7 @@ export declare function transDataParam(array?: any[], optionName?: optionNamePro
|
|
|
25
26
|
* @Return {array} 返回结果数据
|
|
26
27
|
*
|
|
27
28
|
* */
|
|
28
|
-
export declare function resetDataWithLimit(hasKeys: any[], list: any[], optionName
|
|
29
|
+
export declare function resetDataWithLimit(hasKeys: any[], list: any[], optionName: optionNameProps, limitKey: string): any[];
|
|
29
30
|
/**
|
|
30
31
|
* 根据指定禁用字段 disabledFields 进行重组数据
|
|
31
32
|
*
|
package/lib/RefactorTree/util.js
CHANGED
|
@@ -7,17 +7,18 @@ exports.resetDataWithDisabled = resetDataWithDisabled;
|
|
|
7
7
|
exports.resetDataWithLimit = resetDataWithLimit;
|
|
8
8
|
exports.transDataParam = transDataParam;
|
|
9
9
|
var _tslib = require("tslib");
|
|
10
|
+
var _getParentNodes = require("../utils/getParentNodes");
|
|
10
11
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
11
12
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
13
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
14
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
14
15
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
15
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
16
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /* eslint-disable */ // import * as React from 'react';
|
|
16
17
|
/**
|
|
17
18
|
* transDataParam 根据指定选项字段名重组数据
|
|
18
19
|
*
|
|
19
20
|
* @params {array} array 树数据集合
|
|
20
|
-
* @params {object} optionName 选项字段值
|
|
21
|
+
* @params {object} optionName 选项字段值(tree-select的标题使用的是label字段)
|
|
21
22
|
*
|
|
22
23
|
* */
|
|
23
24
|
function transDataParam(array) {
|
|
@@ -25,29 +26,70 @@ function transDataParam(array) {
|
|
|
25
26
|
key: 'key',
|
|
26
27
|
value: 'key',
|
|
27
28
|
title: 'title',
|
|
29
|
+
label: 'label',
|
|
28
30
|
children: 'children',
|
|
29
31
|
disabled: 'disabled',
|
|
30
32
|
selectable: 'selectable'
|
|
31
33
|
};
|
|
34
|
+
var extra = arguments.length > 2 ? arguments[2] : undefined;
|
|
32
35
|
var _trans = function trans(list) {
|
|
33
|
-
if (!list) return
|
|
36
|
+
if (!list) return [];
|
|
34
37
|
return list.map(function (item) {
|
|
35
38
|
if (item.hasOwnProperty(optionName.disabled || 'disabled')) {
|
|
36
|
-
item.disabled = item[optionName.disabled || 'disabled'];
|
|
39
|
+
item[optionName.disabled || 'disabled'] = item[optionName.disabled || 'disabled'];
|
|
37
40
|
}
|
|
38
41
|
if (item.hasOwnProperty(optionName.selectable || 'selectable')) {
|
|
39
|
-
item.selectable = item[optionName.selectable || 'selectable'];
|
|
42
|
+
item[optionName.selectable || 'selectable'] = item[optionName.selectable || 'selectable'];
|
|
40
43
|
}
|
|
41
44
|
if (item.hasOwnProperty(optionName.children || 'children')) {
|
|
42
45
|
item.children = item[optionName.children || 'children'] ? _trans(item[optionName.children || 'children']) : [];
|
|
46
|
+
item[optionName.children || 'children'] = item[optionName.children || 'children'] ? _trans(item[optionName.children || 'children']) : [];
|
|
47
|
+
}
|
|
48
|
+
var newNodeInfo = (0, _getParentNodes.getParentNodes)(array, item[optionName.value || optionName.key || 'key'], {
|
|
49
|
+
childrenParam: (optionName === null || optionName === void 0 ? void 0 : optionName.children) || 'children',
|
|
50
|
+
keyParam: optionName.value || optionName.key || 'key'
|
|
51
|
+
});
|
|
52
|
+
var pathNodes = (0, _getParentNodes.getNodePaths)(array, item[optionName.value || optionName.key || 'key'], {
|
|
53
|
+
childrenParam: (optionName === null || optionName === void 0 ? void 0 : optionName.children) || 'children',
|
|
54
|
+
keyParam: optionName.value || optionName.key || 'key'
|
|
55
|
+
}, {});
|
|
56
|
+
/// disabledFields:指定禁用节点
|
|
57
|
+
var resetByDisabledFields = function resetByDisabledFields(initItem) {
|
|
58
|
+
var oldItem = Object.assign({}, initItem);
|
|
59
|
+
var nodeItem = (0, _tslib.__rest)(oldItem, []);
|
|
60
|
+
Object.keys(nodeItem).forEach(function (itemKeyName) {
|
|
61
|
+
var _a;
|
|
62
|
+
var isMatch = extra.disabledFields.find(function (fItem) {
|
|
63
|
+
return fItem.key === itemKeyName;
|
|
64
|
+
});
|
|
65
|
+
if (isMatch) {
|
|
66
|
+
// 确认是否匹配数据,进行设置 disabled
|
|
67
|
+
if ((_a = isMatch.value.split(',')) === null || _a === void 0 ? void 0 : _a.includes(nodeItem[itemKeyName])) {
|
|
68
|
+
nodeItem[optionName.disabled || 'disabled'] = true;
|
|
69
|
+
} else if (nodeItem.hasOwnProperty(optionName.disabled || 'disabled')) {
|
|
70
|
+
nodeItem[optionName.disabled || 'disabled'] = nodeItem[optionName.disabled || 'disabled'];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return nodeItem;
|
|
75
|
+
};
|
|
76
|
+
if ((extra === null || extra === void 0 ? void 0 : extra.disabledFields) && Array.isArray(extra === null || extra === void 0 ? void 0 : extra.disabledFields)) {
|
|
77
|
+
item = resetByDisabledFields(item);
|
|
43
78
|
}
|
|
44
79
|
return Object.assign(Object.assign({}, item), {
|
|
45
80
|
key: item[optionName.value || optionName.key || 'key'],
|
|
46
|
-
title: item[optionName.title || 'title']
|
|
81
|
+
title: item[optionName.title || optionName.label || 'label' || 'title'],
|
|
82
|
+
label: item[optionName.title || optionName.label || 'label' || 'title'],
|
|
83
|
+
treeFullLevelNamePath: pathNodes,
|
|
84
|
+
treeFullLevelName: pathNodes.map(function (item) {
|
|
85
|
+
return item[optionName.title || optionName.label || 'label' || 'title'];
|
|
86
|
+
}).join((extra === null || extra === void 0 ? void 0 : extra.separator) || '/'),
|
|
87
|
+
treeParentKeys: newNodeInfo.parentKeys.reverse(),
|
|
88
|
+
treeParentNodes: newNodeInfo.nodeParent.reverse()
|
|
47
89
|
});
|
|
48
90
|
});
|
|
49
91
|
};
|
|
50
|
-
return _trans(array);
|
|
92
|
+
return _trans(array || []);
|
|
51
93
|
}
|
|
52
94
|
/**
|
|
53
95
|
* 根据限制字段limitKey进行重组数据
|
|
@@ -89,7 +131,7 @@ function resetDataWithLimit(hasKeys, list) {
|
|
|
89
131
|
var _filterResetSameLevel = function filterResetSameLevel(preList, matchDataValue) {
|
|
90
132
|
if (!preList) return [];
|
|
91
133
|
if (!matchDataValue) return preList;
|
|
92
|
-
return preList
|
|
134
|
+
return (preList || []).map(function (preItem) {
|
|
93
135
|
var oldItem = Object.assign({}, preItem);
|
|
94
136
|
var item = (0, _tslib.__rest)(oldItem, []);
|
|
95
137
|
if (item[limitKey] !== matchDataValue) {
|
|
@@ -136,7 +178,7 @@ function resetDataWithDisabled(list, optionName, disabledFields) {
|
|
|
136
178
|
var item = (0, _tslib.__rest)(oldItem, []);
|
|
137
179
|
Object.keys(item).forEach(function (itemKeyName) {
|
|
138
180
|
var _a;
|
|
139
|
-
var isMatch = fields.find(function (fItem) {
|
|
181
|
+
var isMatch = (fields || []).find(function (fItem) {
|
|
140
182
|
return fItem.key === itemKeyName;
|
|
141
183
|
});
|
|
142
184
|
if (isMatch) {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useLanguageObject = exports.renderLangObject = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _ConfigContext = require("../ConfigContext");
|
|
9
|
+
var _bnBD = _interopRequireDefault(require("../locales/bn-BD"));
|
|
10
|
+
var _enUS = _interopRequireDefault(require("../locales/en-US"));
|
|
11
|
+
var _faIR = _interopRequireDefault(require("../locales/fa-IR"));
|
|
12
|
+
var _idID = _interopRequireDefault(require("../locales/id-ID"));
|
|
13
|
+
var _jaJP = _interopRequireDefault(require("../locales/ja-JP"));
|
|
14
|
+
var _ptBR = _interopRequireDefault(require("../locales/pt-BR"));
|
|
15
|
+
var _zhCN = _interopRequireDefault(require("../locales/zh-CN"));
|
|
16
|
+
var _zhTW = _interopRequireDefault(require("../locales/zh-TW"));
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
var langCompare = {
|
|
19
|
+
'bn': 'bn-BD',
|
|
20
|
+
'en': 'en-US',
|
|
21
|
+
'fa': 'fa-IR',
|
|
22
|
+
'id': 'id-ID',
|
|
23
|
+
'ja': 'ja-JP',
|
|
24
|
+
'pt': 'pt-BR',
|
|
25
|
+
'zh-cn': 'zh-CN',
|
|
26
|
+
'zh-tw': 'zh-TW'
|
|
27
|
+
};
|
|
28
|
+
// 'bn-BD', 'en-US', 'fa-IR', 'id-ID', 'ja-JP', 'pt-BR', 'zh-CN', 'zh-TW'
|
|
29
|
+
var renderLangObject = exports.renderLangObject = function renderLangObject(obj, language) {
|
|
30
|
+
if (!obj) return {};
|
|
31
|
+
if (obj === null || obj === void 0 ? void 0 : obj[language.replace('-', '')]) return obj[language.replace('-', '')];
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
if ((langCompare === null || langCompare === void 0 ? void 0 : langCompare[language]) && (obj === null || obj === void 0 ? void 0 : obj[langCompare === null || langCompare === void 0 ? void 0 : langCompare[language].replace('-', '')])) return obj[langCompare[language].replace('-', '')];
|
|
34
|
+
return obj.zhCN; // Object.values(obj)[0] // 默认使用中文
|
|
35
|
+
};
|
|
36
|
+
var useLanguageObject = exports.useLanguageObject = function useLanguageObject() {
|
|
37
|
+
var _a;
|
|
38
|
+
var InitFanContext = (0, _react.useContext)(_ConfigContext.FanContext);
|
|
39
|
+
var language = ((_a = InitFanContext === null || InitFanContext === void 0 ? void 0 : InitFanContext.locale) === null || _a === void 0 ? void 0 : _a.locale) || 'zh-CN';
|
|
40
|
+
var customObj = (InitFanContext === null || InitFanContext === void 0 ? void 0 : InitFanContext.locale) || {}; // 里面可以配置扩展语言包或者替换原来的语言包
|
|
41
|
+
return renderLangObject(Object.assign({
|
|
42
|
+
zhCN: _zhCN.default,
|
|
43
|
+
enUS: _enUS.default,
|
|
44
|
+
bnBD: _bnBD.default,
|
|
45
|
+
faIR: _faIR.default,
|
|
46
|
+
idID: _idID.default,
|
|
47
|
+
jaJP: _jaJP.default,
|
|
48
|
+
ptBR: _ptBR.default,
|
|
49
|
+
zhTW: _zhTW.default
|
|
50
|
+
}, customObj), language);
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useThrottle: (callback: any, delay: any) => (boolean | ((...args: any) => void))[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useThrottle = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // @ts-nocheck
|
|
14
|
+
// 自定义节流Hook
|
|
15
|
+
var useThrottle = exports.useThrottle = function useThrottle(callback, delay) {
|
|
16
|
+
var _useState = (0, _react.useState)(true),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
isReady = _useState2[0],
|
|
19
|
+
setIsReady = _useState2[1];
|
|
20
|
+
var timerRef = (0, _react.useRef)(null);
|
|
21
|
+
var throttledFn = (0, _react.useCallback)(function () {
|
|
22
|
+
if (isReady) {
|
|
23
|
+
setIsReady(false);
|
|
24
|
+
callback === null || callback === void 0 ? void 0 : callback.apply(void 0, arguments); // 执行回调
|
|
25
|
+
//
|
|
26
|
+
timerRef.current = setTimeout(function () {
|
|
27
|
+
setIsReady(true);
|
|
28
|
+
}, delay);
|
|
29
|
+
}
|
|
30
|
+
}, [callback, delay, isReady]);
|
|
31
|
+
// 清理定时器
|
|
32
|
+
(0, _react.useEffect)(function () {
|
|
33
|
+
return function () {
|
|
34
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
return [throttledFn, isReady]; // 返回函数和就绪状态
|
|
38
|
+
};
|