@zykj2024/much-library 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +35 -0
- package/dist/McCascader/city.js +909 -0
- package/dist/McCascader/index.css +60 -0
- package/dist/McCascader/index.d.ts +19 -0
- package/dist/McCascader/index.js +221 -0
- package/dist/McContainer/demo/actionBar.d.ts +8 -0
- package/dist/McContainer/demo/actionBar.js +70 -0
- package/dist/McContainer/demo/base.d.ts +8 -0
- package/dist/McContainer/demo/base.js +80 -0
- package/dist/McContainer/demo/batch.d.ts +8 -0
- package/dist/McContainer/demo/batch.js +89 -0
- package/dist/McContainer/demo/collapse.d.ts +8 -0
- package/dist/McContainer/demo/collapse.js +76 -0
- package/dist/McContainer/demo/expand.d.ts +8 -0
- package/dist/McContainer/demo/expand.js +90 -0
- package/dist/McContainer/demo/pagination.d.ts +7 -0
- package/dist/McContainer/demo/pagination.js +93 -0
- package/dist/McContainer/demo/search.d.ts +7 -0
- package/dist/McContainer/demo/search.js +101 -0
- package/dist/McContainer/demo/standard.d.ts +7 -0
- package/dist/McContainer/demo/standard.js +168 -0
- package/dist/McContainer/index.css +123 -0
- package/dist/McContainer/index.d.ts +49 -0
- package/dist/McContainer/index.js +407 -0
- package/dist/McDateRange/demo/base.d.ts +6 -0
- package/dist/McDateRange/demo/base.js +22 -0
- package/dist/McDateRange/demo/cancelPresets.d.ts +6 -0
- package/dist/McDateRange/demo/cancelPresets.js +23 -0
- package/dist/McDateRange/demo/overlap.d.ts +2 -0
- package/dist/McDateRange/demo/overlap.js +32 -0
- package/dist/McDateRange/index.css +31 -0
- package/dist/McDateRange/index.d.ts +28 -0
- package/dist/McDateRange/index.js +167 -0
- package/dist/McFonts/index.d.ts +7 -0
- package/dist/McFonts/index.js +10 -0
- package/dist/McFonts/public/FF DIN Pro Bold.otf +0 -0
- package/dist/McFonts/public/SourceHanSansCN-Bold.otf +0 -0
- package/dist/McFonts/public/SourceHanSansCN-Light.otf +0 -0
- package/dist/McFonts/public/SourceHanSansCN-Medium.otf +0 -0
- package/dist/McFonts/public/SourceHanSansCN-Regular.otf +0 -0
- package/dist/McGroupPanel/comps/SelectedItem/index.d.ts +4 -0
- package/dist/McGroupPanel/comps/SelectedItem/index.js +76 -0
- package/dist/McGroupPanel/index.css +162 -0
- package/dist/McGroupPanel/index.d.ts +29 -0
- package/dist/McGroupPanel/index.js +411 -0
- package/dist/McIconFont/iconfont.js +1 -0
- package/dist/McIconFont/index.d.ts +5 -0
- package/dist/McIconFont/index.js +8 -0
- package/dist/McIcons/business.json +137 -0
- package/dist/McInput/Input.d.ts +19 -0
- package/dist/McInput/Input.js +48 -0
- package/dist/McInput/Search.d.ts +39 -0
- package/dist/McInput/Search.js +81 -0
- package/dist/McInput/TextArea.d.ts +11 -0
- package/dist/McInput/TextArea.js +37 -0
- package/dist/McInput/demo/Input/addonBefore.d.ts +3 -0
- package/dist/McInput/demo/Input/addonBefore.js +67 -0
- package/dist/McInput/demo/Input/base.d.ts +2 -0
- package/dist/McInput/demo/Input/base.js +31 -0
- package/dist/McInput/demo/Input/isTrim.d.ts +2 -0
- package/dist/McInput/demo/Input/isTrim.js +22 -0
- package/dist/McInput/demo/Input/label.d.ts +2 -0
- package/dist/McInput/demo/Input/label.js +26 -0
- package/dist/McInput/demo/Input/ref.d.ts +3 -0
- package/dist/McInput/demo/Input/ref.js +53 -0
- package/dist/McInput/demo/Input/status.d.ts +2 -0
- package/dist/McInput/demo/Input/status.js +23 -0
- package/dist/McInput/demo/Search/search-base.d.ts +2 -0
- package/dist/McInput/demo/Search/search-base.js +38 -0
- package/dist/McInput/demo/TextArea/text-area-base.d.ts +2 -0
- package/dist/McInput/demo/TextArea/text-area-base.js +38 -0
- package/dist/McInput/index.css +44 -0
- package/dist/McInput/index.d.ts +13 -0
- package/dist/McInput/index.js +7 -0
- package/dist/McInputNumber/demo/index.d.ts +2 -0
- package/dist/McInputNumber/demo/index.js +28 -0
- package/dist/McInputNumber/demo/label.d.ts +2 -0
- package/dist/McInputNumber/demo/label.js +26 -0
- package/dist/McInputNumber/demo/precision.d.ts +2 -0
- package/dist/McInputNumber/demo/precision.js +20 -0
- package/dist/McInputNumber/index.css +9 -0
- package/dist/McInputNumber/index.d.ts +13 -0
- package/dist/McInputNumber/index.js +43 -0
- package/dist/McModalProvider/index.d.ts +174 -0
- package/dist/McModalProvider/index.js +498 -0
- package/dist/McPeriodSelect/demo/base.d.ts +6 -0
- package/dist/McPeriodSelect/demo/base.js +19 -0
- package/dist/McPeriodSelect/demo/half.d.ts +6 -0
- package/dist/McPeriodSelect/demo/half.js +20 -0
- package/dist/McPeriodSelect/index.css +189 -0
- package/dist/McPeriodSelect/index.d.ts +13 -0
- package/dist/McPeriodSelect/index.js +305 -0
- package/dist/McPopoverButton/index.d.ts +14 -0
- package/dist/McPopoverButton/index.js +52 -0
- package/dist/McPopoverForm/index.d.ts +14 -0
- package/dist/McPopoverForm/index.js +95 -0
- package/dist/McResult/default.d.ts +1 -0
- package/dist/McResult/default.js +84 -0
- package/dist/McResult/demo/403.d.ts +6 -0
- package/dist/McResult/demo/403.js +17 -0
- package/dist/McResult/demo/404.d.ts +6 -0
- package/dist/McResult/demo/404.js +17 -0
- package/dist/McResult/demo/500.d.ts +6 -0
- package/dist/McResult/demo/500.js +17 -0
- package/dist/McResult/demo/building.d.ts +6 -0
- package/dist/McResult/demo/building.js +12 -0
- package/dist/McResult/demo/empty.d.ts +2 -0
- package/dist/McResult/demo/empty.js +11 -0
- package/dist/McResult/demo/noFunction.d.ts +2 -0
- package/dist/McResult/demo/noFunction.js +11 -0
- package/dist/McResult/demo/noUser.d.ts +6 -0
- package/dist/McResult/demo/noUser.js +12 -0
- package/dist/McResult/demo/preview.d.ts +2 -0
- package/dist/McResult/demo/preview.js +14 -0
- package/dist/McResult/icon.d.ts +25 -0
- package/dist/McResult/icon.js +946 -0
- package/dist/McResult/index.css +20 -0
- package/dist/McResult/index.d.ts +27 -0
- package/dist/McResult/index.js +103 -0
- package/dist/McResult/public/403.svg +164 -0
- package/dist/McResult/public/404.svg +123 -0
- package/dist/McResult/public/500.svg +129 -0
- package/dist/McResult/public/building.svg +127 -0
- package/dist/McResult/public/code403.svg +7 -0
- package/dist/McResult/public/code404.svg +5 -0
- package/dist/McResult/public/code500.svg +5 -0
- package/dist/McResult/public/empty.svg +1 -0
- package/dist/McResult/public/noFunction.svg +1 -0
- package/dist/McResult/public/noUser.svg +90 -0
- package/dist/McSelect/demo/base.d.ts +2 -0
- package/dist/McSelect/demo/base.js +63 -0
- package/dist/McSelect/demo/changeOnHidden.d.ts +2 -0
- package/dist/McSelect/demo/changeOnHidden.js +43 -0
- package/dist/McSelect/demo/dropdownRender.d.ts +7 -0
- package/dist/McSelect/demo/dropdownRender.js +78 -0
- package/dist/McSelect/demo/fetchOptions.d.ts +7 -0
- package/dist/McSelect/demo/fetchOptions.js +210 -0
- package/dist/McSelect/demo/inexistent.d.ts +2 -0
- package/dist/McSelect/demo/inexistent.js +79 -0
- package/dist/McSelect/demo/labelInValue.d.ts +2 -0
- package/dist/McSelect/demo/labelInValue.js +72 -0
- package/dist/McSelect/demo/maxTagCount.d.ts +3 -0
- package/dist/McSelect/demo/maxTagCount.js +51 -0
- package/dist/McSelect/demo/multiple.d.ts +2 -0
- package/dist/McSelect/demo/multiple.js +46 -0
- package/dist/McSelect/demo/optionRender.d.ts +3 -0
- package/dist/McSelect/demo/optionRender.js +51 -0
- package/dist/McSelect/demo/tagRender.d.ts +3 -0
- package/dist/McSelect/demo/tagRender.js +51 -0
- package/dist/McSelect/index.css +60 -0
- package/dist/McSelect/index.d.ts +40 -0
- package/dist/McSelect/index.js +350 -0
- package/dist/McThemeConfig/customToken.json +38 -0
- package/dist/McThemeConfig/demo/button.d.ts +2 -0
- package/dist/McThemeConfig/demo/button.js +226 -0
- package/dist/McThemeConfig/demo/drawer.d.ts +2 -0
- package/dist/McThemeConfig/demo/drawer.js +59 -0
- package/dist/McThemeConfig/demo/modal.d.ts +2 -0
- package/dist/McThemeConfig/demo/modal.js +78 -0
- package/dist/McThemeConfig/demo/radio.d.ts +2 -0
- package/dist/McThemeConfig/demo/radio.js +97 -0
- package/dist/McThemeConfig/demo/switch.d.ts +2 -0
- package/dist/McThemeConfig/demo/switch.js +96 -0
- package/dist/McThemeConfig/demo/tabs.d.ts +2 -0
- package/dist/McThemeConfig/demo/tabs.js +35 -0
- package/dist/McThemeConfig/globalStyle.d.ts +2 -0
- package/dist/McThemeConfig/globalStyle.js +172 -0
- package/dist/McThemeConfig/index.d.ts +9 -0
- package/dist/McThemeConfig/index.js +16 -0
- package/dist/McThemeConfig/layoutStyle.d.ts +2 -0
- package/dist/McThemeConfig/layoutStyle.js +1 -0
- package/dist/McThemeConfig/provider.d.ts +7 -0
- package/dist/McThemeConfig/provider.js +19 -0
- package/dist/McThemeConfig/themeToken.json +149 -0
- package/dist/McTreePanel/SelectedItem.d.ts +4 -0
- package/dist/McTreePanel/SelectedItem.js +75 -0
- package/dist/McTreePanel/demo/base.d.ts +6 -0
- package/dist/McTreePanel/demo/base.js +45 -0
- package/dist/McTreePanel/demo/fieldNames.d.ts +6 -0
- package/dist/McTreePanel/demo/fieldNames.js +37 -0
- package/dist/McTreePanel/demo/inexistent.d.ts +6 -0
- package/dist/McTreePanel/demo/inexistent.js +56 -0
- package/dist/McTreePanel/demo/labelInValue.d.ts +6 -0
- package/dist/McTreePanel/demo/labelInValue.js +56 -0
- package/dist/McTreePanel/demo/sortable.d.ts +6 -0
- package/dist/McTreePanel/demo/sortable.js +34 -0
- package/dist/McTreePanel/index.css +110 -0
- package/dist/McTreePanel/index.d.ts +27 -0
- package/dist/McTreePanel/index.js +315 -0
- package/dist/McTreeSelect/demo/base.d.ts +5 -0
- package/dist/McTreeSelect/demo/base.js +58 -0
- package/dist/McTreeSelect/demo/inexistent.d.ts +5 -0
- package/dist/McTreeSelect/demo/inexistent.js +63 -0
- package/dist/McTreeSelect/demo/label.d.ts +5 -0
- package/dist/McTreeSelect/demo/label.js +60 -0
- package/dist/McTreeSelect/demo/multiple.d.ts +5 -0
- package/dist/McTreeSelect/demo/multiple.js +71 -0
- package/dist/McTreeSelect/index.css +60 -0
- package/dist/McTreeSelect/index.d.ts +13 -0
- package/dist/McTreeSelect/index.js +182 -0
- package/dist/Utils/index.d.ts +4 -0
- package/dist/Utils/index.js +26 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +19 -0
- package/dist/typings.d.ts +20 -0
- package/package.json +82 -0
@@ -0,0 +1,315 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
5
|
+
import { DndContext } from '@dnd-kit/core';
|
6
|
+
import { SortableContext, arrayMove, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
7
|
+
import { Button, Checkbox, Empty, Tree } from 'antd';
|
8
|
+
import { useEffect, useMemo, useState } from 'react';
|
9
|
+
import SelectedItem from "./SelectedItem";
|
10
|
+
import "./index.css";
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
+
var McTreePanel = function McTreePanel(props) {
|
14
|
+
var style = props.style,
|
15
|
+
className = props.className,
|
16
|
+
treeData = props.treeData,
|
17
|
+
fieldNames = props.fieldNames,
|
18
|
+
disabled = props.disabled,
|
19
|
+
labelInValue = props.labelInValue,
|
20
|
+
_props$inexistent = props.inexistent,
|
21
|
+
inexistent = _props$inexistent === void 0 ? false : _props$inexistent,
|
22
|
+
sortable = props.sortable,
|
23
|
+
value = props.value,
|
24
|
+
onChange = props.onChange;
|
25
|
+
var _ref = typeof inexistent === 'boolean' ? {} : inexistent,
|
26
|
+
_ref$text = _ref.text,
|
27
|
+
text = _ref$text === void 0 ? '不存在' : _ref$text,
|
28
|
+
_ref$color = _ref.color,
|
29
|
+
color = _ref$color === void 0 ? '#ff4d4f' : _ref$color,
|
30
|
+
_ref$reserved = _ref.reserved,
|
31
|
+
reserved = _ref$reserved === void 0 ? false : _ref$reserved;
|
32
|
+
var _ref2 = fieldNames || {},
|
33
|
+
_ref2$key = _ref2.key,
|
34
|
+
key = _ref2$key === void 0 ? 'key' : _ref2$key,
|
35
|
+
_ref2$title = _ref2.title,
|
36
|
+
title = _ref2$title === void 0 ? 'title' : _ref2$title,
|
37
|
+
_ref2$children = _ref2.children,
|
38
|
+
children = _ref2$children === void 0 ? 'children' : _ref2$children;
|
39
|
+
var _useState = useState({
|
40
|
+
checked: []
|
41
|
+
}),
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
43
|
+
checkedKeys = _useState2[0],
|
44
|
+
setCheckedKeys = _useState2[1];
|
45
|
+
var _useState3 = useState(true),
|
46
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
47
|
+
linkage = _useState4[0],
|
48
|
+
setLinkage = _useState4[1];
|
49
|
+
var _useState5 = useState([]),
|
50
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
51
|
+
expandedKeys = _useState6[0],
|
52
|
+
setExpandedKeys = _useState6[1];
|
53
|
+
var _useState7 = useState({}),
|
54
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
55
|
+
itemMap = _useState8[0],
|
56
|
+
setItemMap = _useState8[1];
|
57
|
+
var _allKeys = useMemo(function () {
|
58
|
+
return Object.values(itemMap).map(function (item) {
|
59
|
+
return item.key;
|
60
|
+
});
|
61
|
+
}, [itemMap]);
|
62
|
+
var _useState9 = useState({}),
|
63
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
64
|
+
inexistentItemMap = _useState10[0],
|
65
|
+
setInexistentItemMap = _useState10[1];
|
66
|
+
var _treeData = useMemo(function () {
|
67
|
+
var fn = function fn(arr) {
|
68
|
+
return arr === null || arr === void 0 ? void 0 : arr.map(function (item) {
|
69
|
+
return _objectSpread(_objectSpread({}, item), {}, _defineProperty({
|
70
|
+
disableCheckbox: disabled
|
71
|
+
}, children, fn(item[children])));
|
72
|
+
});
|
73
|
+
};
|
74
|
+
return fn(treeData);
|
75
|
+
}, [treeData, disabled, children]);
|
76
|
+
|
77
|
+
/* 获取选项的映射关系,重置父子联动为true */
|
78
|
+
useEffect(function () {
|
79
|
+
var _itemMap = {};
|
80
|
+
var fn = function fn(arr, parentKeys) {
|
81
|
+
var _subKeys = [];
|
82
|
+
arr.forEach(function (item) {
|
83
|
+
var _item$children;
|
84
|
+
var subKeys = ((_item$children = item[children]) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0 ? fn(item[children], [].concat(_toConsumableArray(parentKeys), [item[key]])) : [];
|
85
|
+
_subKeys.push.apply(_subKeys, [item[key]].concat(_toConsumableArray(subKeys)));
|
86
|
+
_itemMap[item[key]] = {
|
87
|
+
key: item[key],
|
88
|
+
title: item[title],
|
89
|
+
parentKeys: parentKeys,
|
90
|
+
subKeys: subKeys
|
91
|
+
};
|
92
|
+
});
|
93
|
+
return _subKeys;
|
94
|
+
};
|
95
|
+
fn(treeData || [], []);
|
96
|
+
setItemMap(_itemMap);
|
97
|
+
setLinkage(true);
|
98
|
+
}, [treeData]);
|
99
|
+
|
100
|
+
/* 回显 */
|
101
|
+
var echo = function echo(value) {
|
102
|
+
var _inexistentItemMap = {};
|
103
|
+
value === null || value === void 0 || value.forEach(function (item) {
|
104
|
+
var k = labelInValue ? item[key] : item,
|
105
|
+
t = labelInValue ? item[title] || item[key] : item;
|
106
|
+
if (!itemMap[k]) _inexistentItemMap[k] = {
|
107
|
+
key: k,
|
108
|
+
title: t
|
109
|
+
};
|
110
|
+
});
|
111
|
+
setCheckedKeys({
|
112
|
+
checked: value ? labelInValue ? value.map(function (item) {
|
113
|
+
return item[key];
|
114
|
+
}) : value : []
|
115
|
+
});
|
116
|
+
setInexistentItemMap(_inexistentItemMap);
|
117
|
+
};
|
118
|
+
useEffect(function () {
|
119
|
+
echo(value);
|
120
|
+
}, [value]);
|
121
|
+
|
122
|
+
/**
|
123
|
+
* 获取选中项的方法(返回实际的checked)
|
124
|
+
* 0.父子联动时按以下逻辑执行
|
125
|
+
* 1.父级选中或取消,联动其所有子级的选中或取消
|
126
|
+
* 2.子级选中,联动其所有父级的选中
|
127
|
+
* 3.子级取消,不联动其父级的取消
|
128
|
+
*/
|
129
|
+
var getCheckedKeys = function getCheckedKeys(checked, activeKey, status) {
|
130
|
+
var _checked = _toConsumableArray(checked);
|
131
|
+
// 若为父子联动时
|
132
|
+
if (linkage) {
|
133
|
+
if (status) {
|
134
|
+
// 若当前为选中,则联动其所有父级及所有子级的选中
|
135
|
+
_checked = Array.from(new Set([].concat(_toConsumableArray(_checked), _toConsumableArray(itemMap[activeKey].parentKeys), _toConsumableArray(itemMap[activeKey].subKeys))));
|
136
|
+
} else {
|
137
|
+
// 若当前为取消,则联动其所有子级的取消
|
138
|
+
_checked = _checked.filter(function (v) {
|
139
|
+
var _itemMap$activeKey;
|
140
|
+
return !((_itemMap$activeKey = itemMap[activeKey]) !== null && _itemMap$activeKey !== void 0 && (_itemMap$activeKey = _itemMap$activeKey.subKeys) !== null && _itemMap$activeKey !== void 0 && _itemMap$activeKey.includes(v));
|
141
|
+
});
|
142
|
+
}
|
143
|
+
}
|
144
|
+
return _checked;
|
145
|
+
};
|
146
|
+
|
147
|
+
/* 更新选中项状态并触发change事件 */
|
148
|
+
var changeHandle = function changeHandle(v) {
|
149
|
+
// 若无需保留不存在值,则将不存在的项移除
|
150
|
+
var _v = reserved ? _toConsumableArray(v) : v.filter(function (i) {
|
151
|
+
return !!itemMap[i];
|
152
|
+
});
|
153
|
+
setCheckedKeys({
|
154
|
+
checked: _v
|
155
|
+
});
|
156
|
+
onChange === null || onChange === void 0 || onChange(_v.length > 0 ? labelInValue ? _v.map(function (i) {
|
157
|
+
return itemMap[i] || inexistentItemMap[i];
|
158
|
+
}) : _v : undefined);
|
159
|
+
};
|
160
|
+
|
161
|
+
/* 拖拽结束事件 */
|
162
|
+
var dragEnd = function dragEnd(dragItem) {
|
163
|
+
var active = dragItem.active,
|
164
|
+
over = dragItem.over;
|
165
|
+
if (!active || !over) return;
|
166
|
+
if (active.id !== over.id) {
|
167
|
+
var _checked = _toConsumableArray(checkedKeys.checked);
|
168
|
+
var activeIndex = _checked.findIndex(function (v) {
|
169
|
+
return v === active.id;
|
170
|
+
});
|
171
|
+
var overIndex = _checked.findIndex(function (v) {
|
172
|
+
return v === over.id;
|
173
|
+
});
|
174
|
+
changeHandle(arrayMove(_checked, activeIndex, overIndex));
|
175
|
+
}
|
176
|
+
};
|
177
|
+
return /*#__PURE__*/_jsxs("div", {
|
178
|
+
style: style,
|
179
|
+
className: "mc-tree-panel ".concat(className),
|
180
|
+
children: [/*#__PURE__*/_jsx(Checkbox, {
|
181
|
+
style: {
|
182
|
+
lineHeight: '32px',
|
183
|
+
marginBottom: 8
|
184
|
+
},
|
185
|
+
checked: linkage,
|
186
|
+
onChange: function onChange(e) {
|
187
|
+
return setLinkage(e.target.checked);
|
188
|
+
},
|
189
|
+
disabled: disabled,
|
190
|
+
children: "\u7236\u5B50\u8054\u52A8"
|
191
|
+
}), /*#__PURE__*/_jsxs("div", {
|
192
|
+
className: "mc-tree-panel__wrapper",
|
193
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
194
|
+
className: "mc-tree-panel__options",
|
195
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
196
|
+
className: "mc-tree-panel__card-header",
|
197
|
+
children: [/*#__PURE__*/_jsx(Checkbox, {
|
198
|
+
checked: _allKeys.length > 0 && _allKeys.every(function (v) {
|
199
|
+
return checkedKeys.checked.includes(v);
|
200
|
+
}),
|
201
|
+
indeterminate: _allKeys.length > 0 && !_allKeys.every(function (v) {
|
202
|
+
return checkedKeys.checked.includes(v);
|
203
|
+
}) && _allKeys.some(function (v) {
|
204
|
+
return checkedKeys.checked.includes(v);
|
205
|
+
}),
|
206
|
+
onChange: function onChange(e) {
|
207
|
+
return changeHandle(e.target.checked ? Array.from(new Set([].concat(_toConsumableArray(checkedKeys.checked), _toConsumableArray(_allKeys)))) : reserved ? checkedKeys.checked.filter(function (i) {
|
208
|
+
return !itemMap[i];
|
209
|
+
}) : []);
|
210
|
+
},
|
211
|
+
disabled: disabled,
|
212
|
+
children: "\u5168\u9009"
|
213
|
+
}), /*#__PURE__*/_jsx(Button, {
|
214
|
+
type: "link",
|
215
|
+
onClick: function onClick() {
|
216
|
+
return setExpandedKeys([]);
|
217
|
+
},
|
218
|
+
children: "\u6536\u8D77"
|
219
|
+
})]
|
220
|
+
}), treeData && treeData.length > 0 ? /*#__PURE__*/_jsx("div", {
|
221
|
+
className: "mc-tree-panel__card-body",
|
222
|
+
children: /*#__PURE__*/_jsx(Tree, {
|
223
|
+
checkable: true,
|
224
|
+
selectable: false,
|
225
|
+
treeData: _treeData,
|
226
|
+
fieldNames: {
|
227
|
+
title: title,
|
228
|
+
key: key,
|
229
|
+
children: children
|
230
|
+
},
|
231
|
+
expandedKeys: expandedKeys,
|
232
|
+
onExpand: setExpandedKeys,
|
233
|
+
checkStrictly: true,
|
234
|
+
checkedKeys: checkedKeys,
|
235
|
+
onCheck: function onCheck(_ref3, _ref4) {
|
236
|
+
var checked = _ref3.checked;
|
237
|
+
var status = _ref4.checked,
|
238
|
+
node = _ref4.node;
|
239
|
+
return changeHandle(getCheckedKeys(checked, node[key], status));
|
240
|
+
}
|
241
|
+
})
|
242
|
+
}) : /*#__PURE__*/_jsx("div", {
|
243
|
+
style: {
|
244
|
+
height: 'calc(100% - 40px)',
|
245
|
+
display: 'grid',
|
246
|
+
placeItems: 'center'
|
247
|
+
},
|
248
|
+
children: /*#__PURE__*/_jsx(Empty, {
|
249
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE
|
250
|
+
})
|
251
|
+
})]
|
252
|
+
}), /*#__PURE__*/_jsxs("div", {
|
253
|
+
className: "mc-tree-panel__selected",
|
254
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
255
|
+
className: "mc-tree-panel__card-header",
|
256
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
257
|
+
className: "mc-tree-panel__card-title",
|
258
|
+
children: ["\u5DF2\u9009", checkedKeys.checked.length, "\u9879"]
|
259
|
+
}), /*#__PURE__*/_jsx(Button, {
|
260
|
+
type: "link",
|
261
|
+
onClick: function onClick() {
|
262
|
+
return changeHandle(reserved ? checkedKeys.checked.filter(function (i) {
|
263
|
+
return !itemMap[i];
|
264
|
+
}) : []);
|
265
|
+
},
|
266
|
+
disabled: disabled,
|
267
|
+
children: "\u6E05\u7A7A"
|
268
|
+
})]
|
269
|
+
}), checkedKeys.checked.length > 0 ? /*#__PURE__*/_jsx(DndContext, {
|
270
|
+
onDragEnd: dragEnd,
|
271
|
+
children: /*#__PURE__*/_jsx(SortableContext, {
|
272
|
+
items: checkedKeys.checked,
|
273
|
+
strategy: verticalListSortingStrategy,
|
274
|
+
children: /*#__PURE__*/_jsx("div", {
|
275
|
+
style: {
|
276
|
+
overflowX: 'hidden'
|
277
|
+
},
|
278
|
+
className: "mc-tree-panel__card-body",
|
279
|
+
children: checkedKeys.checked.map(function (v) {
|
280
|
+
return /*#__PURE__*/_jsx(SelectedItem, {
|
281
|
+
sortable: sortable,
|
282
|
+
itemMap: itemMap,
|
283
|
+
inexistent: inexistent,
|
284
|
+
text: text,
|
285
|
+
color: color,
|
286
|
+
reserved: reserved,
|
287
|
+
inexistentItemMap: inexistentItemMap,
|
288
|
+
value: v,
|
289
|
+
onRemove: function onRemove() {
|
290
|
+
return changeHandle(getCheckedKeys(checkedKeys.checked.filter(function (i) {
|
291
|
+
return i !== v;
|
292
|
+
}), v, false));
|
293
|
+
}
|
294
|
+
}, v);
|
295
|
+
})
|
296
|
+
})
|
297
|
+
})
|
298
|
+
}) : /*#__PURE__*/_jsx("div", {
|
299
|
+
style: {
|
300
|
+
height: 'calc(100% - 40px)',
|
301
|
+
display: 'grid',
|
302
|
+
placeItems: 'center'
|
303
|
+
},
|
304
|
+
children: /*#__PURE__*/_jsx(Empty, {
|
305
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
306
|
+
description: "\u8BF7\u9009\u62E9"
|
307
|
+
})
|
308
|
+
}), disabled && /*#__PURE__*/_jsx("div", {
|
309
|
+
className: "mc-tree-panel__selected--disabled"
|
310
|
+
})]
|
311
|
+
})]
|
312
|
+
})]
|
313
|
+
});
|
314
|
+
};
|
315
|
+
export default McTreePanel;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
/**
|
3
|
+
* title: 基本使用
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { Space } from 'antd';
|
7
|
+
import { McTreeSelect } from "../..";
|
8
|
+
import { useState } from 'react';
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
11
|
+
export default (function () {
|
12
|
+
var _useState = useState(1),
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
14
|
+
value = _useState2[0],
|
15
|
+
setValue = _useState2[1];
|
16
|
+
var options = [{
|
17
|
+
label: '部门1',
|
18
|
+
value: 1,
|
19
|
+
children: [{
|
20
|
+
label: '部门1-1',
|
21
|
+
value: 11
|
22
|
+
}, {
|
23
|
+
label: '部门1-2',
|
24
|
+
value: 12
|
25
|
+
}]
|
26
|
+
}, {
|
27
|
+
label: '部门2',
|
28
|
+
value: 2,
|
29
|
+
children: [{
|
30
|
+
label: '部门2-1',
|
31
|
+
value: 21
|
32
|
+
}, {
|
33
|
+
label: '部门2-2',
|
34
|
+
value: 22
|
35
|
+
}]
|
36
|
+
}];
|
37
|
+
var handelChange = function handelChange(v) {
|
38
|
+
setValue(v);
|
39
|
+
};
|
40
|
+
return /*#__PURE__*/_jsxs(Space, {
|
41
|
+
size: 16,
|
42
|
+
direction: "vertical",
|
43
|
+
children: [/*#__PURE__*/_jsx(McTreeSelect, {
|
44
|
+
value: value,
|
45
|
+
style: {
|
46
|
+
width: 270
|
47
|
+
},
|
48
|
+
options: options,
|
49
|
+
onChange: handelChange
|
50
|
+
}), /*#__PURE__*/_jsx(McTreeSelect, {
|
51
|
+
style: {
|
52
|
+
width: 270
|
53
|
+
},
|
54
|
+
disabled: true,
|
55
|
+
options: []
|
56
|
+
})]
|
57
|
+
});
|
58
|
+
});
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
/**
|
3
|
+
* title: 回显不存在的选项
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { Col, Space } from 'antd';
|
7
|
+
import { McTreeSelect } from "../..";
|
8
|
+
import { useState } from 'react';
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
11
|
+
export default (function () {
|
12
|
+
var _useState = useState(3),
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
14
|
+
value = _useState2[0],
|
15
|
+
setValue = _useState2[1];
|
16
|
+
var options = [{
|
17
|
+
label: '部门1',
|
18
|
+
value: 1,
|
19
|
+
children: [{
|
20
|
+
label: '部门1-1',
|
21
|
+
value: 11
|
22
|
+
}, {
|
23
|
+
label: '部门1-2',
|
24
|
+
value: 12
|
25
|
+
}]
|
26
|
+
}, {
|
27
|
+
label: '部门2',
|
28
|
+
value: 2,
|
29
|
+
children: [{
|
30
|
+
label: '部门2-1',
|
31
|
+
value: 21
|
32
|
+
}, {
|
33
|
+
label: '部门2-2',
|
34
|
+
value: 22
|
35
|
+
}]
|
36
|
+
}];
|
37
|
+
var handelChange = function handelChange(v) {
|
38
|
+
setValue(v);
|
39
|
+
};
|
40
|
+
return /*#__PURE__*/_jsxs(Space, {
|
41
|
+
size: 16,
|
42
|
+
direction: "vertical",
|
43
|
+
children: [/*#__PURE__*/_jsxs(Col, {
|
44
|
+
children: ["\u5F53\u524D\u503C: ", value]
|
45
|
+
}), /*#__PURE__*/_jsx(McTreeSelect, {
|
46
|
+
value: value,
|
47
|
+
label: "\u90E8\u95E8",
|
48
|
+
style: {
|
49
|
+
width: 270
|
50
|
+
},
|
51
|
+
options: options,
|
52
|
+
onChange: handelChange
|
53
|
+
}), /*#__PURE__*/_jsx(McTreeSelect, {
|
54
|
+
label: "\u90E8\u95E8",
|
55
|
+
value: 3,
|
56
|
+
style: {
|
57
|
+
width: 270
|
58
|
+
},
|
59
|
+
disabled: true,
|
60
|
+
options: options
|
61
|
+
})]
|
62
|
+
});
|
63
|
+
});
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
/**
|
3
|
+
* title: 配置标签
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { Space } from 'antd';
|
7
|
+
import { McTreeSelect } from "../..";
|
8
|
+
import { useState } from 'react';
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
11
|
+
export default (function () {
|
12
|
+
var _useState = useState(2),
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
14
|
+
value = _useState2[0],
|
15
|
+
setValue = _useState2[1];
|
16
|
+
var options = [{
|
17
|
+
label: '部门1',
|
18
|
+
value: 1,
|
19
|
+
children: [{
|
20
|
+
label: '部门1-1',
|
21
|
+
value: 11
|
22
|
+
}, {
|
23
|
+
label: '部门1-2',
|
24
|
+
value: 12
|
25
|
+
}]
|
26
|
+
}, {
|
27
|
+
label: '部门2',
|
28
|
+
value: 2,
|
29
|
+
children: [{
|
30
|
+
label: '部门2-1',
|
31
|
+
value: 21
|
32
|
+
}, {
|
33
|
+
label: '部门2-2',
|
34
|
+
value: 22
|
35
|
+
}]
|
36
|
+
}];
|
37
|
+
var handelChange = function handelChange(v) {
|
38
|
+
setValue(v);
|
39
|
+
};
|
40
|
+
return /*#__PURE__*/_jsxs(Space, {
|
41
|
+
size: 16,
|
42
|
+
direction: "vertical",
|
43
|
+
children: [/*#__PURE__*/_jsx(McTreeSelect, {
|
44
|
+
label: "\u90E8\u95E8",
|
45
|
+
value: value,
|
46
|
+
style: {
|
47
|
+
width: 270
|
48
|
+
},
|
49
|
+
options: options,
|
50
|
+
onChange: handelChange
|
51
|
+
}), /*#__PURE__*/_jsx(McTreeSelect, {
|
52
|
+
label: "\u90E8\u95E8",
|
53
|
+
style: {
|
54
|
+
width: 270
|
55
|
+
},
|
56
|
+
disabled: true,
|
57
|
+
options: []
|
58
|
+
})]
|
59
|
+
});
|
60
|
+
});
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
/**
|
3
|
+
* title: 多选
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { Space } from 'antd';
|
7
|
+
import { McTreeSelect } from "../..";
|
8
|
+
import { useState } from 'react';
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
11
|
+
export default (function () {
|
12
|
+
var _useState = useState([11, 21]),
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
14
|
+
fValue = _useState2[0],
|
15
|
+
setFValue = _useState2[1];
|
16
|
+
var _useState3 = useState([12]),
|
17
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
18
|
+
sValue = _useState4[0],
|
19
|
+
setSValue = _useState4[1];
|
20
|
+
var options = [{
|
21
|
+
label: '部门1',
|
22
|
+
value: 1,
|
23
|
+
children: [{
|
24
|
+
label: '部门1-1',
|
25
|
+
value: 11
|
26
|
+
}, {
|
27
|
+
label: '部门1-2',
|
28
|
+
value: 12
|
29
|
+
}]
|
30
|
+
}, {
|
31
|
+
label: '部门2',
|
32
|
+
value: 2,
|
33
|
+
children: [{
|
34
|
+
label: '部门2-1',
|
35
|
+
value: 21
|
36
|
+
}, {
|
37
|
+
label: '部门2-2',
|
38
|
+
value: 22
|
39
|
+
}]
|
40
|
+
}];
|
41
|
+
var handelFChange = function handelFChange(v) {
|
42
|
+
setFValue(v);
|
43
|
+
};
|
44
|
+
var handelSChange = function handelSChange(v) {
|
45
|
+
setSValue(v);
|
46
|
+
};
|
47
|
+
return /*#__PURE__*/_jsxs(Space, {
|
48
|
+
size: 16,
|
49
|
+
direction: "vertical",
|
50
|
+
children: [/*#__PURE__*/_jsx(McTreeSelect, {
|
51
|
+
value: fValue,
|
52
|
+
treeCheckable: true,
|
53
|
+
maxTagCount: 1,
|
54
|
+
style: {
|
55
|
+
width: 270
|
56
|
+
},
|
57
|
+
options: options,
|
58
|
+
onChange: handelFChange
|
59
|
+
}), /*#__PURE__*/_jsx(McTreeSelect, {
|
60
|
+
label: "\u90E8\u95E8",
|
61
|
+
value: sValue,
|
62
|
+
treeCheckable: true,
|
63
|
+
maxTagCount: 1,
|
64
|
+
style: {
|
65
|
+
width: 270
|
66
|
+
},
|
67
|
+
options: options,
|
68
|
+
onChange: handelSChange
|
69
|
+
})]
|
70
|
+
});
|
71
|
+
});
|
@@ -0,0 +1,60 @@
|
|
1
|
+
.mc-tree-select__label {
|
2
|
+
position: absolute;
|
3
|
+
top: 1px;
|
4
|
+
left: 11px;
|
5
|
+
z-index: 2;
|
6
|
+
display: -webkit-box;
|
7
|
+
display: -ms-flexbox;
|
8
|
+
display: flex;
|
9
|
+
-webkit-box-align: center;
|
10
|
+
-ms-flex-align: center;
|
11
|
+
align-items: center;
|
12
|
+
height: 100%;
|
13
|
+
color: #262626;
|
14
|
+
font-size: 14px;
|
15
|
+
}
|
16
|
+
.mc-tree-select__label::after {
|
17
|
+
margin-left: 2px;
|
18
|
+
content: ':';
|
19
|
+
}
|
20
|
+
.mc-tree-select__label .mc-tree-select--disabled {
|
21
|
+
color: rgba(0, 0, 0, 0.25);
|
22
|
+
cursor: no-drop;
|
23
|
+
}
|
24
|
+
.mc-tree-select__content {
|
25
|
+
width: 100%;
|
26
|
+
height: 100%;
|
27
|
+
}
|
28
|
+
.mc-tree-select__content.ant-tree-select.ant-select .ant-select-selector {
|
29
|
+
padding-left: var(--selector-pl);
|
30
|
+
}
|
31
|
+
.mc-tree-select__content.ant-tree-select.ant-select .ant-select-selector .ant-select-selection-overflow-item-rest .ant-select-selection-item {
|
32
|
+
padding-left: 4px;
|
33
|
+
color: #fff;
|
34
|
+
background: #325cf7;
|
35
|
+
}
|
36
|
+
.mc-tree-select__content.ant-tree-select.ant-select .ant-select-selector .ant-select-selection-overflow-item-rest .ant-select-selection-item .ant-select-selection-item-content {
|
37
|
+
margin-right: 0;
|
38
|
+
}
|
39
|
+
.mc-tree-select__content.ant-tree-select.ant-select .ant-select-selector .ant-select-selection-item[title*='不存在'] {
|
40
|
+
color: #ff4d4f;
|
41
|
+
}
|
42
|
+
.mc-tree-select__content.ant-tree-select.ant-select.ant-select-single .ant-select-selector .ant-select-selection-search {
|
43
|
+
left: var(--selector-pl);
|
44
|
+
}
|
45
|
+
.mc-tree-select__content.ant-tree-select.ant-select.ant-select-multiple .ant-select-selector .ant-select-selection-placeholder {
|
46
|
+
left: var(--selector-pl);
|
47
|
+
}
|
48
|
+
.mc-tree-select__content.ant-tree-select.ant-select.ant-select-multiple .ant-select-selector .ant-select-selection-search {
|
49
|
+
margin-left: 0;
|
50
|
+
}
|
51
|
+
.mc-tree-select--inline .mc-tree-select.ant-select-selection-overflow-item:not(
|
52
|
+
.ant-select-selection-overflow-item-rest,
|
53
|
+
.ant-select-selection-overflow-item-suffix
|
54
|
+
) {
|
55
|
+
-webkit-box-flex: 1;
|
56
|
+
-ms-flex: 1;
|
57
|
+
flex: 1;
|
58
|
+
min-width: 0;
|
59
|
+
margin-right: 4px;
|
60
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { TreeSelectProps } from 'antd';
|
2
|
+
import { CSSProperties, FC } from 'react';
|
3
|
+
import './index.less';
|
4
|
+
export type McTreeSelectProps = TreeSelectProps & {
|
5
|
+
style?: CSSProperties;
|
6
|
+
className?: string;
|
7
|
+
name?: string;
|
8
|
+
label?: string;
|
9
|
+
inexistent?: boolean;
|
10
|
+
[key: string]: any;
|
11
|
+
};
|
12
|
+
declare const McTreeSelect: FC<McTreeSelectProps>;
|
13
|
+
export default McTreeSelect;
|