uiw 4.13.11 → 4.14.1
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/cjs/index.d.ts +2 -0
- package/cjs/index.js +21 -0
- package/cjs/index.js.map +2 -2
- package/dist/uiw.css +33 -1
- package/dist/uiw.js +582 -46
- package/dist/uiw.min.css +1 -1
- package/dist/uiw.min.js +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +4 -3
- package/package.json +58 -57
- package/src/index.ts +2 -0
package/dist/uiw.js
CHANGED
|
@@ -190,7 +190,6 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
|
|
190
190
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
191
191
|
|
|
192
192
|
"use strict";
|
|
193
|
-
var __webpack_unused_export__;
|
|
194
193
|
/** @license React v17.0.2
|
|
195
194
|
* react-jsx-runtime.production.min.js
|
|
196
195
|
*
|
|
@@ -199,7 +198,7 @@ var __webpack_unused_export__;
|
|
|
199
198
|
* This source code is licensed under the MIT license found in the
|
|
200
199
|
* LICENSE file in the root directory of this source tree.
|
|
201
200
|
*/
|
|
202
|
-
__webpack_require__(382);var f=__webpack_require__(787),g=60103;
|
|
201
|
+
__webpack_require__(382);var f=__webpack_require__(787),g=60103;exports.Fragment=60107;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;g=h("react.element");exports.Fragment=h("react.fragment")}var m=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n=Object.prototype.hasOwnProperty,p={key:!0,ref:!0,__self:!0,__source:!0};
|
|
203
202
|
function q(c,a,k){var b,d={},e=null,l=null;void 0!==k&&(e=""+k);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(l=a.ref);for(b in a)n.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:g,type:c,key:e,ref:l,props:d,_owner:m.current}}exports.jsx=q;exports.jsxs=q;
|
|
204
203
|
|
|
205
204
|
|
|
@@ -388,6 +387,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
388
387
|
"TimePicker": () => (/* reexport */ TimePicker),
|
|
389
388
|
"TimePickerTime": () => (/* reexport */ TimePickerTime),
|
|
390
389
|
"Tooltip": () => (/* reexport */ react_tooltip_esm),
|
|
390
|
+
"Transfer": () => (/* reexport */ react_transfer_esm),
|
|
391
391
|
"Tree": () => (/* reexport */ Tree),
|
|
392
392
|
"TreeChecked": () => (/* reexport */ TreeChecked),
|
|
393
393
|
"canUseDOM": () => (/* reexport */ canUseDOM),
|
|
@@ -9066,16 +9066,155 @@ function getAllColumnsKeys(data, keys) {
|
|
|
9066
9066
|
return keys;
|
|
9067
9067
|
}
|
|
9068
9068
|
|
|
9069
|
+
;// CONCATENATED MODULE: ../react-table/esm/Expandable.js
|
|
9070
|
+
|
|
9071
|
+
|
|
9072
|
+
|
|
9073
|
+
/**
|
|
9074
|
+
* 可展开配置
|
|
9075
|
+
*/
|
|
9076
|
+
function ExpandableComponent(_ref) {
|
|
9077
|
+
var {
|
|
9078
|
+
defaultExpand,
|
|
9079
|
+
onClick: _onClick,
|
|
9080
|
+
expandIcon
|
|
9081
|
+
} = _ref;
|
|
9082
|
+
var [expand, setExpand] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(defaultExpand);
|
|
9083
|
+
return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
9084
|
+
style: {
|
|
9085
|
+
display: 'flex',
|
|
9086
|
+
justifyContent: 'center',
|
|
9087
|
+
alignItems: 'center'
|
|
9088
|
+
},
|
|
9089
|
+
onClick: () => {
|
|
9090
|
+
setExpand(!expand);
|
|
9091
|
+
|
|
9092
|
+
_onClick(expand); // record: T, index: number, expanded: boolean
|
|
9093
|
+
|
|
9094
|
+
},
|
|
9095
|
+
children: expandIcon(expand)
|
|
9096
|
+
});
|
|
9097
|
+
}
|
|
9098
|
+
|
|
9099
|
+
;// CONCATENATED MODULE: ../react-table/esm/TableTr.js
|
|
9100
|
+
|
|
9101
|
+
|
|
9102
|
+
|
|
9103
|
+
|
|
9104
|
+
|
|
9105
|
+
|
|
9106
|
+
|
|
9107
|
+
|
|
9108
|
+
|
|
9109
|
+
function TableTr(props) {
|
|
9110
|
+
var {
|
|
9111
|
+
rowKey,
|
|
9112
|
+
data,
|
|
9113
|
+
keys,
|
|
9114
|
+
render,
|
|
9115
|
+
ellipsis,
|
|
9116
|
+
prefixCls,
|
|
9117
|
+
onCell = noop,
|
|
9118
|
+
isExpandedDom,
|
|
9119
|
+
hierarchy,
|
|
9120
|
+
indentSize,
|
|
9121
|
+
childrenColumnName
|
|
9122
|
+
} = props;
|
|
9123
|
+
var [expandIndex, setExpandIndex] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
|
|
9124
|
+
var IconDom = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(() => {
|
|
9125
|
+
return (key, isOpacity) => {
|
|
9126
|
+
var flag = expandIndex.includes(key);
|
|
9127
|
+
return /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
|
|
9128
|
+
type: flag ? 'minus-square-o' : 'plus-square-o',
|
|
9129
|
+
style: {
|
|
9130
|
+
marginRight: 10,
|
|
9131
|
+
opacity: isOpacity ? 1 : 0,
|
|
9132
|
+
marginLeft: hierarchy * indentSize
|
|
9133
|
+
},
|
|
9134
|
+
onClick: () => {
|
|
9135
|
+
setExpandIndex(flag ? expandIndex.filter(it => it !== key) : [...expandIndex, key]);
|
|
9136
|
+
}
|
|
9137
|
+
});
|
|
9138
|
+
};
|
|
9139
|
+
}, [expandIndex]);
|
|
9140
|
+
|
|
9141
|
+
if (!Array.isArray(data) || !data.length) {
|
|
9142
|
+
return null;
|
|
9143
|
+
}
|
|
9144
|
+
|
|
9145
|
+
return /*#__PURE__*/(0,jsx_runtime.jsx)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
|
|
9146
|
+
children: data.map((trData, rowNum) => {
|
|
9147
|
+
var key = rowKey ? trData[rowKey] : rowNum;
|
|
9148
|
+
return /*#__PURE__*/(0,jsx_runtime.jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
|
|
9149
|
+
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("tr", {
|
|
9150
|
+
children: keys.map((keyName, colNum) => {
|
|
9151
|
+
var objs = {
|
|
9152
|
+
children: trData[keyName]
|
|
9153
|
+
};
|
|
9154
|
+
|
|
9155
|
+
if (render[keyName]) {
|
|
9156
|
+
var child = render[keyName](trData[keyName], keyName, trData, rowNum, colNum);
|
|
9157
|
+
|
|
9158
|
+
if ( /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().isValidElement(child)) {
|
|
9159
|
+
objs.children = child;
|
|
9160
|
+
} else {
|
|
9161
|
+
if (child.props) {
|
|
9162
|
+
objs = _extends({}, child.props, {
|
|
9163
|
+
children: objs.children
|
|
9164
|
+
});
|
|
9165
|
+
if (child.props.rowSpan === 0 || child.props.colSpan === 0) return null;
|
|
9166
|
+
}
|
|
9167
|
+
|
|
9168
|
+
if (child.children) {
|
|
9169
|
+
objs.children = child.children;
|
|
9170
|
+
}
|
|
9171
|
+
}
|
|
9172
|
+
}
|
|
9173
|
+
|
|
9174
|
+
if (ellipsis && ellipsis[keyName]) {
|
|
9175
|
+
objs.className = prefixCls + "-ellipsis";
|
|
9176
|
+
}
|
|
9177
|
+
|
|
9178
|
+
var isHasChildren = Array.isArray(trData[childrenColumnName]);
|
|
9179
|
+
|
|
9180
|
+
if (colNum === 0 && (hierarchy || isHasChildren)) {
|
|
9181
|
+
objs.className = objs.className + " " + prefixCls + "-has-children";
|
|
9182
|
+
objs.children = /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
9183
|
+
children: [IconDom(key, isHasChildren), objs.children]
|
|
9184
|
+
});
|
|
9185
|
+
}
|
|
9186
|
+
|
|
9187
|
+
return /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement)("td", _extends({}, objs, {
|
|
9188
|
+
key: colNum,
|
|
9189
|
+
onClick: evn => onCell(trData, {
|
|
9190
|
+
rowNum,
|
|
9191
|
+
colNum,
|
|
9192
|
+
keyName
|
|
9193
|
+
}, evn)
|
|
9194
|
+
}));
|
|
9195
|
+
})
|
|
9196
|
+
}, key), expandIndex.includes(key) && /*#__PURE__*/(0,jsx_runtime.jsx)(TableTr, _extends({}, props, {
|
|
9197
|
+
data: trData[childrenColumnName],
|
|
9198
|
+
hierarchy: hierarchy + 1
|
|
9199
|
+
})), isExpandedDom(trData, rowNum)]
|
|
9200
|
+
}, rowNum);
|
|
9201
|
+
})
|
|
9202
|
+
});
|
|
9203
|
+
}
|
|
9204
|
+
|
|
9069
9205
|
;// CONCATENATED MODULE: ../react-table/esm/index.js
|
|
9070
9206
|
|
|
9071
9207
|
|
|
9072
|
-
var react_table_esm_excluded = ["prefixCls", "className", "columns", "data", "title", "footer", "bordered", "onCell", "onCellHead", "empty", "children"];
|
|
9208
|
+
var react_table_esm_excluded = ["prefixCls", "className", "columns", "data", "title", "footer", "bordered", "onCell", "onCellHead", "empty", "children", "expandable", "rowKey"];
|
|
9209
|
+
|
|
9073
9210
|
|
|
9074
9211
|
|
|
9075
9212
|
|
|
9076
9213
|
|
|
9077
9214
|
|
|
9078
9215
|
|
|
9216
|
+
// 展开配置
|
|
9217
|
+
|
|
9079
9218
|
|
|
9080
9219
|
|
|
9081
9220
|
function Table(props) {
|
|
@@ -9093,17 +9232,123 @@ function Table(props) {
|
|
|
9093
9232
|
bordered,
|
|
9094
9233
|
onCell = noop,
|
|
9095
9234
|
onCellHead = noop,
|
|
9096
|
-
empty
|
|
9235
|
+
empty,
|
|
9236
|
+
expandable,
|
|
9237
|
+
rowKey
|
|
9097
9238
|
} = props,
|
|
9098
9239
|
other = _objectWithoutPropertiesLoose(props, react_table_esm_excluded);
|
|
9099
9240
|
|
|
9241
|
+
var [expandIndex, setExpandIndex] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
|
|
9242
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
|
|
9243
|
+
if (expandable) {
|
|
9244
|
+
if (expandable.defaultExpandAllRows) {
|
|
9245
|
+
setExpandIndex(data.map((it, index) => rowKey ? it[rowKey] : index));
|
|
9246
|
+
return;
|
|
9247
|
+
}
|
|
9248
|
+
|
|
9249
|
+
if (expandable.defaultExpandedRowKeys) {
|
|
9250
|
+
setExpandIndex(expandable.defaultExpandedRowKeys);
|
|
9251
|
+
return;
|
|
9252
|
+
}
|
|
9253
|
+
}
|
|
9254
|
+
}, []);
|
|
9255
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
|
|
9256
|
+
if (expandable) {
|
|
9257
|
+
if (expandable.expandedRowKeys && JSON.stringify(expandable.expandedRowKeys) !== JSON.stringify(expandIndex)) {
|
|
9258
|
+
setExpandIndex(expandable.expandedRowKeys);
|
|
9259
|
+
}
|
|
9260
|
+
}
|
|
9261
|
+
}, [expandable == null ? void 0 : expandable.expandedRowKeys]);
|
|
9262
|
+
var isExpandedDom = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(() => {
|
|
9263
|
+
return (record, index) => {
|
|
9264
|
+
if (!expandable) {
|
|
9265
|
+
return false;
|
|
9266
|
+
}
|
|
9267
|
+
|
|
9268
|
+
if (!expandable.expandedRowRender) {
|
|
9269
|
+
return false;
|
|
9270
|
+
}
|
|
9271
|
+
|
|
9272
|
+
var flag = true;
|
|
9273
|
+
|
|
9274
|
+
if (expandable.rowExpandable) {
|
|
9275
|
+
flag = expandable.rowExpandable(record);
|
|
9276
|
+
}
|
|
9277
|
+
|
|
9278
|
+
return flag && /*#__PURE__*/(0,jsx_runtime.jsx)("tr", {
|
|
9279
|
+
style: expandIndex.includes(rowKey ? record[rowKey] : index) ? {} : {
|
|
9280
|
+
display: 'none'
|
|
9281
|
+
},
|
|
9282
|
+
children: /*#__PURE__*/(0,jsx_runtime.jsx)("td", {
|
|
9283
|
+
style: {
|
|
9284
|
+
paddingLeft: 16
|
|
9285
|
+
},
|
|
9286
|
+
colSpan: columns.length + 1,
|
|
9287
|
+
children: expandable.expandedRowRender(record, index, true)
|
|
9288
|
+
})
|
|
9289
|
+
});
|
|
9290
|
+
};
|
|
9291
|
+
}, [expandable, expandIndex]);
|
|
9292
|
+
var self = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(() => {
|
|
9293
|
+
var keys = getAllColumnsKeys(columns);
|
|
9294
|
+
var selfColumns = [];
|
|
9295
|
+
|
|
9296
|
+
if (expandable != null && expandable.expandedRowRender) {
|
|
9297
|
+
keys = ['uiw-expanded', ...keys];
|
|
9298
|
+
selfColumns = [{
|
|
9299
|
+
title: '',
|
|
9300
|
+
key: 'uiw-expanded',
|
|
9301
|
+
width: 50,
|
|
9302
|
+
align: 'center',
|
|
9303
|
+
render: (text, key, record, index) => {
|
|
9304
|
+
var _expandable$defaultEx;
|
|
9305
|
+
|
|
9306
|
+
return /*#__PURE__*/(0,jsx_runtime.jsx)(ExpandableComponent, {
|
|
9307
|
+
defaultExpand: expandable.defaultExpandAllRows === undefined ? !!((_expandable$defaultEx = expandable.defaultExpandedRowKeys) != null && _expandable$defaultEx.includes(rowKey ? record[rowKey] : index)) : !!expandable.defaultExpandAllRows,
|
|
9308
|
+
onClick: expand => {
|
|
9309
|
+
expandable.onExpand == null ? void 0 : expandable.onExpand(expand, record, index);
|
|
9310
|
+
|
|
9311
|
+
if (expand) {
|
|
9312
|
+
var result = expandIndex.filter(it => rowKey ? it !== record[rowKey] : it !== index);
|
|
9313
|
+
expandable.onExpandedRowsChange ? expandable.onExpandedRowsChange(result) : setExpandIndex(result);
|
|
9314
|
+
} else {
|
|
9315
|
+
var _result = [...expandIndex, rowKey ? record[rowKey] : index];
|
|
9316
|
+
expandable.onExpandedRowsChange ? expandable.onExpandedRowsChange(_result) : setExpandIndex(_result);
|
|
9317
|
+
}
|
|
9318
|
+
},
|
|
9319
|
+
expandIcon: expand => {
|
|
9320
|
+
if (expandable.rowExpandable && !(expandable.rowExpandable != null && expandable.rowExpandable(record))) {
|
|
9321
|
+
return null;
|
|
9322
|
+
}
|
|
9323
|
+
|
|
9324
|
+
if (expandable.expandIcon) {
|
|
9325
|
+
return expandable.expandIcon(expand, record, index);
|
|
9326
|
+
}
|
|
9327
|
+
|
|
9328
|
+
return expand ? /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
|
|
9329
|
+
type: "minus-square-o"
|
|
9330
|
+
}) : /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
|
|
9331
|
+
type: "plus-square-o"
|
|
9332
|
+
});
|
|
9333
|
+
}
|
|
9334
|
+
});
|
|
9335
|
+
}
|
|
9336
|
+
}, ...columns];
|
|
9337
|
+
} else {
|
|
9338
|
+
selfColumns = [...columns];
|
|
9339
|
+
}
|
|
9340
|
+
|
|
9341
|
+
return {
|
|
9342
|
+
keys,
|
|
9343
|
+
selfColumns
|
|
9344
|
+
};
|
|
9345
|
+
}, [columns, expandIndex]);
|
|
9100
9346
|
var cls = [prefixCls, className, bordered ? prefixCls + "-bordered" : null].filter(Boolean).join(' ').trim();
|
|
9101
9347
|
var {
|
|
9102
9348
|
header,
|
|
9103
9349
|
render,
|
|
9104
9350
|
ellipsis
|
|
9105
|
-
} = getLevelItems(
|
|
9106
|
-
var keys = getAllColumnsKeys(columns);
|
|
9351
|
+
} = getLevelItems(self.selfColumns);
|
|
9107
9352
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
9108
9353
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", _extends({
|
|
9109
9354
|
style: {
|
|
@@ -9121,45 +9366,19 @@ function Table(props) {
|
|
|
9121
9366
|
onCellHead: onCellHead,
|
|
9122
9367
|
data: header
|
|
9123
9368
|
}), data && data.length > 0 && /*#__PURE__*/(0,jsx_runtime.jsx)("tbody", {
|
|
9124
|
-
children:
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
objs = _extends({}, child.props, {
|
|
9138
|
-
children: objs.children
|
|
9139
|
-
});
|
|
9140
|
-
if (child.props.rowSpan === 0 || child.props.colSpan === 0) return null;
|
|
9141
|
-
}
|
|
9142
|
-
|
|
9143
|
-
if (child.children) {
|
|
9144
|
-
objs.children = child.children;
|
|
9145
|
-
}
|
|
9146
|
-
}
|
|
9147
|
-
}
|
|
9148
|
-
|
|
9149
|
-
if (ellipsis && ellipsis[keyName]) {
|
|
9150
|
-
objs.className = prefixCls + "-ellipsis";
|
|
9151
|
-
}
|
|
9152
|
-
|
|
9153
|
-
return /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement)("td", _extends({}, objs, {
|
|
9154
|
-
key: colNum,
|
|
9155
|
-
onClick: evn => onCell(trData, {
|
|
9156
|
-
rowNum,
|
|
9157
|
-
colNum,
|
|
9158
|
-
keyName
|
|
9159
|
-
}, evn)
|
|
9160
|
-
}));
|
|
9161
|
-
})
|
|
9162
|
-
}, rowNum))
|
|
9369
|
+
children: /*#__PURE__*/(0,jsx_runtime.jsx)(TableTr, {
|
|
9370
|
+
rowKey: rowKey,
|
|
9371
|
+
data: data,
|
|
9372
|
+
keys: self.keys,
|
|
9373
|
+
render: render,
|
|
9374
|
+
ellipsis: ellipsis,
|
|
9375
|
+
prefixCls: prefixCls,
|
|
9376
|
+
onCell: onCell,
|
|
9377
|
+
hierarchy: 0,
|
|
9378
|
+
isExpandedDom: isExpandedDom,
|
|
9379
|
+
indentSize: (expandable == null ? void 0 : expandable.indentSize) || 16,
|
|
9380
|
+
childrenColumnName: (expandable == null ? void 0 : expandable.childrenColumnName) || 'children'
|
|
9381
|
+
})
|
|
9163
9382
|
}), data && data.length === 0 && empty && /*#__PURE__*/(0,jsx_runtime.jsx)("tbody", {
|
|
9164
9383
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("tr", {
|
|
9165
9384
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("td", {
|
|
@@ -9308,7 +9527,7 @@ function Tabs(props) {
|
|
|
9308
9527
|
if (activeItem.current && type === 'line') {
|
|
9309
9528
|
setSlideStyle({
|
|
9310
9529
|
width: activeItem.current.clientWidth,
|
|
9311
|
-
left: activeItem.current.offsetLeft
|
|
9530
|
+
left: activeItem.current.offsetLeft + 15
|
|
9312
9531
|
});
|
|
9313
9532
|
}
|
|
9314
9533
|
}
|
|
@@ -10268,6 +10487,323 @@ function SearchTree(props) {
|
|
|
10268
10487
|
|
|
10269
10488
|
/* harmony default export */ const react_search_tree_esm = (SearchTree);
|
|
10270
10489
|
|
|
10490
|
+
;// CONCATENATED MODULE: ../react-transfer/esm/style/index.css
|
|
10491
|
+
// extracted by mini-css-extract-plugin
|
|
10492
|
+
/* harmony default export */ const react_transfer_esm_style = ({});
|
|
10493
|
+
;// CONCATENATED MODULE: ../react-transfer/esm/index.js
|
|
10494
|
+
|
|
10495
|
+
|
|
10496
|
+
|
|
10497
|
+
|
|
10498
|
+
|
|
10499
|
+
|
|
10500
|
+
|
|
10501
|
+
|
|
10502
|
+
|
|
10503
|
+
|
|
10504
|
+
var CheckedStatus;
|
|
10505
|
+
|
|
10506
|
+
(function (CheckedStatus) {
|
|
10507
|
+
CheckedStatus[CheckedStatus["UnChecked"] = 0] = "UnChecked";
|
|
10508
|
+
CheckedStatus[CheckedStatus["AllChecked"] = 1] = "AllChecked";
|
|
10509
|
+
CheckedStatus[CheckedStatus["Indeterminate"] = 2] = "Indeterminate";
|
|
10510
|
+
})(CheckedStatus || (CheckedStatus = {}));
|
|
10511
|
+
|
|
10512
|
+
function Transfer(props) {
|
|
10513
|
+
var {
|
|
10514
|
+
placeholder,
|
|
10515
|
+
options,
|
|
10516
|
+
value,
|
|
10517
|
+
showSearch = false,
|
|
10518
|
+
selectedAll = false,
|
|
10519
|
+
bodyStyle,
|
|
10520
|
+
style,
|
|
10521
|
+
className,
|
|
10522
|
+
prefixCls = 'w-transfer'
|
|
10523
|
+
} = props;
|
|
10524
|
+
var cls = [prefixCls, className].filter(Boolean).join(' ').trim();
|
|
10525
|
+
var [searchValueLeft, searchValueLeftSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)('');
|
|
10526
|
+
var [searchValueRight, searchValueRightSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)('');
|
|
10527
|
+
var [selectedOptions, selectedOptionSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(options || []);
|
|
10528
|
+
var selectedOptionsShowCount = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(0);
|
|
10529
|
+
var [selectOption, selectOptionSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(new Map());
|
|
10530
|
+
var [leftSelectOption, leftSelectOptionSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(new Map());
|
|
10531
|
+
var [leftSelectedKeys, leftSelectedKeySet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
|
|
10532
|
+
var [rightSelectedKeys, rightSelectedKeySet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
|
|
10533
|
+
var [rightOpions, rightOpionSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
|
|
10534
|
+
var [selectAllChecked, selectAllCheckedSet] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({
|
|
10535
|
+
left: CheckedStatus.UnChecked,
|
|
10536
|
+
right: CheckedStatus.UnChecked
|
|
10537
|
+
});
|
|
10538
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
|
|
10539
|
+
leftSelectedKeySet([]);
|
|
10540
|
+
rightSelectedKeySet([]);
|
|
10541
|
+
rightOpionSet(value || []);
|
|
10542
|
+
value == null ? void 0 : value.forEach(selectd => selectOption.set(selectd.key, selectd.label));
|
|
10543
|
+
hiddenNode(child => !!(value != null && value.find(selectd => child.key === selectd.key)));
|
|
10544
|
+
}, [JSON.stringify(value)]);
|
|
10545
|
+
|
|
10546
|
+
var hiddenNode = callBackfn => {
|
|
10547
|
+
selectedOptionsShowCount.current = 0;
|
|
10548
|
+
|
|
10549
|
+
var hiddenNodeForSeach = childrens => {
|
|
10550
|
+
childrens.forEach(child => {
|
|
10551
|
+
var _child$children;
|
|
10552
|
+
|
|
10553
|
+
var isHide = callBackfn(child); // && parentIsHide;
|
|
10554
|
+
|
|
10555
|
+
if (!!((_child$children = child.children) != null && _child$children.length)) {
|
|
10556
|
+
hiddenNodeForSeach(child.children);
|
|
10557
|
+
var find = child.children.find(item => !item.hideNode);
|
|
10558
|
+
child.hideNode = isHide && !find;
|
|
10559
|
+
} else {
|
|
10560
|
+
child.hideNode = isHide;
|
|
10561
|
+
}
|
|
10562
|
+
|
|
10563
|
+
if (!child.hideNode) {
|
|
10564
|
+
selectedOptionsShowCount.current++;
|
|
10565
|
+
}
|
|
10566
|
+
});
|
|
10567
|
+
};
|
|
10568
|
+
|
|
10569
|
+
hiddenNodeForSeach(selectedOptions);
|
|
10570
|
+
selectedOptionSet([...selectedOptions]);
|
|
10571
|
+
};
|
|
10572
|
+
|
|
10573
|
+
var getOptionsRecursion = (childrens, selectOption, isAdd) => {
|
|
10574
|
+
var addOrDel = (key, label, isAdd) => {
|
|
10575
|
+
if (isAdd) {
|
|
10576
|
+
selectOption.set(key, label);
|
|
10577
|
+
} else {
|
|
10578
|
+
selectOption.delete(key);
|
|
10579
|
+
}
|
|
10580
|
+
};
|
|
10581
|
+
|
|
10582
|
+
var iteratorParent = child => {
|
|
10583
|
+
if (child.parent) {
|
|
10584
|
+
var selectCount = child.parent.children.filter(child => !selectOption.get(child.key)).length;
|
|
10585
|
+
addOrDel(child.parent.key, child.parent.label, selectCount === 0);
|
|
10586
|
+
iteratorParent(child.parent);
|
|
10587
|
+
}
|
|
10588
|
+
};
|
|
10589
|
+
|
|
10590
|
+
childrens.forEach(child => {
|
|
10591
|
+
var _child$children2, _child$label;
|
|
10592
|
+
|
|
10593
|
+
if (!!((_child$children2 = child.children) != null && _child$children2.length)) {
|
|
10594
|
+
selectOption = getOptionsRecursion(child.children, selectOption, isAdd);
|
|
10595
|
+
}
|
|
10596
|
+
|
|
10597
|
+
addOrDel(child.key, (_child$label = child.label) == null ? void 0 : _child$label.toString(), isAdd);
|
|
10598
|
+
iteratorParent(child);
|
|
10599
|
+
});
|
|
10600
|
+
return selectOption;
|
|
10601
|
+
};
|
|
10602
|
+
|
|
10603
|
+
var leftTreeOnSelected = (selectedKeys, _1, isChecked, evn) => {
|
|
10604
|
+
leftSelectedKeySet(selectedKeys);
|
|
10605
|
+
var selectOptionTemp = getOptionsRecursion([evn], leftSelectOption, isChecked);
|
|
10606
|
+
leftSelectOptionSet(selectOptionTemp);
|
|
10607
|
+
};
|
|
10608
|
+
|
|
10609
|
+
var rightTreeOnSelected = selectedKeys => {
|
|
10610
|
+
rightSelectedKeySet(selectedKeys);
|
|
10611
|
+
};
|
|
10612
|
+
|
|
10613
|
+
var transferClick = transferType => {
|
|
10614
|
+
var selectOptionTemp = selectOption;
|
|
10615
|
+
|
|
10616
|
+
if (transferType === 'left') {
|
|
10617
|
+
leftSelectOption.forEach((value, key) => {
|
|
10618
|
+
selectOptionTemp.set(key, value);
|
|
10619
|
+
});
|
|
10620
|
+
} else {
|
|
10621
|
+
rightSelectedKeys.forEach(key => {
|
|
10622
|
+
selectOption.delete(key);
|
|
10623
|
+
});
|
|
10624
|
+
}
|
|
10625
|
+
|
|
10626
|
+
selectOptionSet(selectOptionTemp); // leftSelectOptionSet(selectOptionTemp);
|
|
10627
|
+
|
|
10628
|
+
var option = [];
|
|
10629
|
+
selectOptionTemp.forEach((label, key) => option.push({
|
|
10630
|
+
key,
|
|
10631
|
+
label
|
|
10632
|
+
}));
|
|
10633
|
+
props.onChange == null ? void 0 : props.onChange(transferType, option);
|
|
10634
|
+
};
|
|
10635
|
+
|
|
10636
|
+
var searchValueLeftChange = searchValue => {
|
|
10637
|
+
hiddenNode(child => {
|
|
10638
|
+
var searchIsMatch = !child.label.includes(searchValue.trim());
|
|
10639
|
+
|
|
10640
|
+
if (!searchIsMatch) {
|
|
10641
|
+
var isSekected = rightOpions.find(selected => selected.key === child.key);
|
|
10642
|
+
searchIsMatch = !!isSekected;
|
|
10643
|
+
}
|
|
10644
|
+
|
|
10645
|
+
return searchIsMatch;
|
|
10646
|
+
});
|
|
10647
|
+
searchValueLeftSet(searchValue);
|
|
10648
|
+
props.onSearch == null ? void 0 : props.onSearch('left', searchValue);
|
|
10649
|
+
};
|
|
10650
|
+
|
|
10651
|
+
var searchValueRightChange = searchValue => {
|
|
10652
|
+
searchValueRightSet(searchValue);
|
|
10653
|
+
rightOpions.forEach(option => {
|
|
10654
|
+
var isHide = !option.label.includes(searchValue.trim());
|
|
10655
|
+
option.hideNode = isHide;
|
|
10656
|
+
});
|
|
10657
|
+
rightOpionSet(rightOpions);
|
|
10658
|
+
props.onSearch == null ? void 0 : props.onSearch('right', searchValue);
|
|
10659
|
+
};
|
|
10660
|
+
|
|
10661
|
+
var selectAllLeftChange = e => {
|
|
10662
|
+
var isChecked = e.target.checked;
|
|
10663
|
+
selectAllChecked.left = isChecked ? 1 : 0;
|
|
10664
|
+
|
|
10665
|
+
if (isChecked) {
|
|
10666
|
+
var keys = [];
|
|
10667
|
+
|
|
10668
|
+
var selectedOptionsRecursion = selectedOptions => {
|
|
10669
|
+
selectedOptions.forEach(child => {
|
|
10670
|
+
var _child$children3;
|
|
10671
|
+
|
|
10672
|
+
if ((_child$children3 = child.children) != null && _child$children3.length) {
|
|
10673
|
+
selectedOptionsRecursion(child.children);
|
|
10674
|
+
} else {
|
|
10675
|
+
if (!child.hideNode) {
|
|
10676
|
+
selectOption.set(child.key, child.label);
|
|
10677
|
+
keys.push(child.key);
|
|
10678
|
+
}
|
|
10679
|
+
}
|
|
10680
|
+
});
|
|
10681
|
+
};
|
|
10682
|
+
|
|
10683
|
+
selectedOptionsRecursion(selectedOptions);
|
|
10684
|
+
leftSelectedKeySet(keys);
|
|
10685
|
+
} else {
|
|
10686
|
+
leftSelectedKeySet([]);
|
|
10687
|
+
}
|
|
10688
|
+
|
|
10689
|
+
selectOptionSet(selectOption);
|
|
10690
|
+
selectAllCheckedSet(selectAllChecked);
|
|
10691
|
+
};
|
|
10692
|
+
|
|
10693
|
+
var selectAllRightChange = e => {
|
|
10694
|
+
var isChecked = e.target.checked;
|
|
10695
|
+
selectAllChecked.right = isChecked ? 1 : 0;
|
|
10696
|
+
|
|
10697
|
+
if (isChecked) {
|
|
10698
|
+
var keys = rightOpions.map(child => {
|
|
10699
|
+
selectOption.delete(child.key);
|
|
10700
|
+
return child.key;
|
|
10701
|
+
});
|
|
10702
|
+
rightSelectedKeySet(keys);
|
|
10703
|
+
} else {
|
|
10704
|
+
rightSelectedKeySet([]);
|
|
10705
|
+
}
|
|
10706
|
+
|
|
10707
|
+
selectOptionSet(selectOption);
|
|
10708
|
+
selectAllCheckedSet(selectAllChecked);
|
|
10709
|
+
};
|
|
10710
|
+
|
|
10711
|
+
var Arrow = props => /*#__PURE__*/(0,jsx_runtime.jsx)(Icon, {
|
|
10712
|
+
onClick: () => props.click(),
|
|
10713
|
+
type: "down-square-o",
|
|
10714
|
+
className: prefixCls + "-arrow",
|
|
10715
|
+
style: _extends({
|
|
10716
|
+
fontSize: 20,
|
|
10717
|
+
stroke: '#e9e9e9',
|
|
10718
|
+
fill: '#333'
|
|
10719
|
+
}, props.style)
|
|
10720
|
+
});
|
|
10721
|
+
|
|
10722
|
+
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
10723
|
+
className: cls,
|
|
10724
|
+
style: _extends({
|
|
10725
|
+
width: 400
|
|
10726
|
+
}, style),
|
|
10727
|
+
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(react_card_esm, {
|
|
10728
|
+
bodyStyle: {
|
|
10729
|
+
padding: 5
|
|
10730
|
+
},
|
|
10731
|
+
title: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
10732
|
+
children: [selectedAll && /*#__PURE__*/(0,jsx_runtime.jsx)(react_checkbox_esm, {
|
|
10733
|
+
indeterminate: leftSelectedKeys.length < selectedOptionsShowCount.current && !!leftSelectedKeys.length,
|
|
10734
|
+
checked: leftSelectedKeys.length >= selectedOptionsShowCount.current && !!leftSelectedKeys.length,
|
|
10735
|
+
onChange: selectAllLeftChange
|
|
10736
|
+
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
10737
|
+
style: {
|
|
10738
|
+
marginLeft: 10
|
|
10739
|
+
},
|
|
10740
|
+
children: [leftSelectedKeys.length, "/", selectedOptionsShowCount.current]
|
|
10741
|
+
})]
|
|
10742
|
+
}),
|
|
10743
|
+
className: prefixCls + "-card",
|
|
10744
|
+
children: [showSearch && /*#__PURE__*/(0,jsx_runtime.jsx)(react_input_esm, {
|
|
10745
|
+
placeholder: placeholder,
|
|
10746
|
+
value: searchValueLeft,
|
|
10747
|
+
onChange: e => searchValueLeftChange(e.target.value)
|
|
10748
|
+
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
10749
|
+
className: prefixCls + "-cheked-content",
|
|
10750
|
+
children: /*#__PURE__*/(0,jsx_runtime.jsx)(TreeChecked, {
|
|
10751
|
+
defaultExpandAll: true,
|
|
10752
|
+
placeholder: placeholder || '搜索选项',
|
|
10753
|
+
data: selectedOptions,
|
|
10754
|
+
selectedKeys: leftSelectedKeys,
|
|
10755
|
+
onSelected: leftTreeOnSelected
|
|
10756
|
+
})
|
|
10757
|
+
})]
|
|
10758
|
+
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
10759
|
+
className: prefixCls + "-arrow-content",
|
|
10760
|
+
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(Arrow, {
|
|
10761
|
+
click: () => transferClick('left'),
|
|
10762
|
+
style: {
|
|
10763
|
+
transform: 'rotate(-90deg)'
|
|
10764
|
+
}
|
|
10765
|
+
}), /*#__PURE__*/(0,jsx_runtime.jsx)(Arrow, {
|
|
10766
|
+
click: () => transferClick('right'),
|
|
10767
|
+
style: {
|
|
10768
|
+
transform: 'rotate(90deg)'
|
|
10769
|
+
}
|
|
10770
|
+
})]
|
|
10771
|
+
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(react_card_esm, {
|
|
10772
|
+
bodyStyle: {
|
|
10773
|
+
padding: 5
|
|
10774
|
+
},
|
|
10775
|
+
className: prefixCls + "-card",
|
|
10776
|
+
title: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
10777
|
+
children: [selectedAll && /*#__PURE__*/(0,jsx_runtime.jsx)(react_checkbox_esm, {
|
|
10778
|
+
indeterminate: rightSelectedKeys.length < rightOpions.length && !!rightSelectedKeys.length,
|
|
10779
|
+
checked: rightSelectedKeys.length === rightOpions.length && !!rightSelectedKeys.length,
|
|
10780
|
+
onChange: selectAllRightChange
|
|
10781
|
+
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
10782
|
+
style: {
|
|
10783
|
+
marginLeft: 10
|
|
10784
|
+
},
|
|
10785
|
+
children: [rightSelectedKeys.length, "/", rightOpions.length]
|
|
10786
|
+
})]
|
|
10787
|
+
}),
|
|
10788
|
+
children: [showSearch && /*#__PURE__*/(0,jsx_runtime.jsx)(react_input_esm, {
|
|
10789
|
+
placeholder: placeholder,
|
|
10790
|
+
value: searchValueRight,
|
|
10791
|
+
onChange: e => searchValueRightChange(e.target.value)
|
|
10792
|
+
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
10793
|
+
className: prefixCls + "-cheked-content",
|
|
10794
|
+
style: bodyStyle,
|
|
10795
|
+
children: /*#__PURE__*/(0,jsx_runtime.jsx)(TreeChecked, {
|
|
10796
|
+
data: rightOpions,
|
|
10797
|
+
selectedKeys: rightSelectedKeys,
|
|
10798
|
+
onSelected: rightTreeOnSelected
|
|
10799
|
+
})
|
|
10800
|
+
})]
|
|
10801
|
+
})]
|
|
10802
|
+
});
|
|
10803
|
+
}
|
|
10804
|
+
|
|
10805
|
+
/* harmony default export */ const react_transfer_esm = (Transfer);
|
|
10806
|
+
|
|
10271
10807
|
;// CONCATENATED MODULE: ./src/index.ts
|
|
10272
10808
|
|
|
10273
10809
|
})();
|