zmdms-webui 0.0.21 → 0.0.24
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/es/applayoutsider/menu/MainMenu.js +1 -1
- package/dist/es/select/hooks.js +89 -0
- package/dist/es/select/index.d.ts +5 -0
- package/dist/es/select/index.js +5 -0
- package/dist/es/select/interface.d.ts +64 -0
- package/dist/es/select/select.d.ts +5 -0
- package/dist/es/select/select.js +109 -0
- package/dist/es/table/hooks.js +0 -1
- package/dist/index.build.d.ts +2 -1
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/dist/index.es.js +2 -1
- package/dist/index.umd.js +2 -2
- package/package.json +7 -3
|
@@ -12,7 +12,7 @@ var MainMenu = function (props) {
|
|
|
12
12
|
// 获取当前菜单的系统id
|
|
13
13
|
var system = menuItem.system, path = menuItem.path;
|
|
14
14
|
var prefix = getPrefixByAppId(system);
|
|
15
|
-
var newPath = prefix ? "/".concat(prefix).concat(path) : path;
|
|
15
|
+
var newPath = path === "/" ? "/" : prefix ? "/".concat(prefix).concat(path) : path;
|
|
16
16
|
// 根据type的类型做出不同的处理 这里只是留个入口 暂时没有特别的处理
|
|
17
17
|
if (menuItem.type === "index") {
|
|
18
18
|
return (jsx(Link, __assign({ to: newPath, onClick: function () {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { unescapeString } from 'zmdms-utils';
|
|
4
|
+
import MemoSelect from './select.js';
|
|
5
|
+
|
|
6
|
+
function useRenderChildren(props) {
|
|
7
|
+
var list = props.list, defaultList = props.defaultList, _a = props.dataKey, dataKey = _a === void 0 ? "id" : _a, _b = props.titleKey, titleKey = _b === void 0 ? "name" : _b, joinKey = props.joinKey, joinStr = props.joinStr, lineFeedKey = props.lineFeedKey, lineFeedStr = props.lineFeedStr, showAll = props.showAll, children = props.children, disabledValues = props.disabledValues;
|
|
8
|
+
var concatHandle = function (arr1, arr2) {
|
|
9
|
+
if (!arr2) {
|
|
10
|
+
return arr1;
|
|
11
|
+
}
|
|
12
|
+
var resultList = (arr1 === null || arr1 === void 0 ? void 0 : arr1.slice()) || [];
|
|
13
|
+
arr2.forEach(function (item, index) {
|
|
14
|
+
if (!item) {
|
|
15
|
+
console.error("\u9ED8\u8BA4\u6570\u636E\u4E2D\u6709\u7A7A\u503C \u4F4D\u7F6E\u518DdefalutList\u4E2D\u7B2C".concat(index + 1, "\u9879"));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
var currentIndex = resultList.findIndex(function (arr1Item) { return arr1Item && dataKey && arr1Item[dataKey] === item[dataKey]; });
|
|
19
|
+
if (currentIndex === -1) {
|
|
20
|
+
resultList.push(item);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// 找到了 需要替换
|
|
24
|
+
var newItem = __assign({}, item);
|
|
25
|
+
if (titleKey && !newItem[titleKey]) {
|
|
26
|
+
Reflect.deleteProperty(newItem, titleKey);
|
|
27
|
+
}
|
|
28
|
+
if (dataKey && !newItem[dataKey]) {
|
|
29
|
+
Reflect.deleteProperty(newItem, dataKey);
|
|
30
|
+
}
|
|
31
|
+
resultList.splice(currentIndex, 1, __assign(__assign({}, resultList[currentIndex]), newItem));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var resultList = concatHandle(list, defaultList);
|
|
36
|
+
var renderChildren = function () {
|
|
37
|
+
if (children) {
|
|
38
|
+
return children;
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(resultList)) {
|
|
41
|
+
return (jsxs(Fragment, { children: [showAll && (jsx(MemoSelect.Option, __assign({ title: "\u5168\u90E8", value: "" }, { children: "\u5168\u90E8" }))), resultList === null || resultList === void 0 ? void 0 : resultList.map(function (item, index) {
|
|
42
|
+
if (!item) {
|
|
43
|
+
console.error("\u9ED8\u8BA4\u6570\u636E\u4E2D\u6709\u7A7A\u503C \u4F4D\u7F6E\u518Dlist\u4E2D\u7B2C".concat(index + 1, "\u9879"));
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
var key = item[dataKey];
|
|
47
|
+
var value = item[dataKey];
|
|
48
|
+
var title = unescapeString(item[titleKey]);
|
|
49
|
+
// 处理拼接展示的数据
|
|
50
|
+
var joinTitle = [];
|
|
51
|
+
var linefeedTitle = [];
|
|
52
|
+
if (joinKey) {
|
|
53
|
+
joinTitle = Array.isArray(joinKey)
|
|
54
|
+
? joinKey.map(function (joinItem) { return unescapeString(item[joinItem]); })
|
|
55
|
+
: item[joinKey]
|
|
56
|
+
? [unescapeString(item[joinKey])]
|
|
57
|
+
: [];
|
|
58
|
+
}
|
|
59
|
+
if (lineFeedKey) {
|
|
60
|
+
linefeedTitle = Array.isArray(lineFeedKey)
|
|
61
|
+
? lineFeedKey.map(function (joinItem) { return unescapeString(item[joinItem]); })
|
|
62
|
+
: item[lineFeedKey]
|
|
63
|
+
? [unescapeString(item[lineFeedKey])]
|
|
64
|
+
: [];
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(joinTitle)) {
|
|
67
|
+
joinTitle.unshift(title);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
joinTitle = [title];
|
|
71
|
+
}
|
|
72
|
+
// 处理是否禁用
|
|
73
|
+
var disabled = item === null || item === void 0 ? void 0 : item.disabled;
|
|
74
|
+
if (Array.isArray(disabledValues) &&
|
|
75
|
+
disabledValues.includes(value)) {
|
|
76
|
+
disabled = true;
|
|
77
|
+
}
|
|
78
|
+
return (jsxs(MemoSelect.Option, __assign({ value: value, title: title, disabled: disabled }, { children: [Array.isArray(joinTitle) ? joinTitle === null || joinTitle === void 0 ? void 0 : joinTitle.join(joinStr) : "", Array.isArray(linefeedTitle) && linefeedTitle.length > 0 ? (jsx("div", __assign({ className: "ztxk-select--feed-item" }, { children: linefeedTitle === null || linefeedTitle === void 0 ? void 0 : linefeedTitle.join(lineFeedStr) }))) : ("")] }), "".concat(key).concat(index)));
|
|
79
|
+
})] }));
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
resultList: resultList,
|
|
85
|
+
renderChildren: renderChildren,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { useRenderChildren };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Select } from 'antd';
|
|
2
|
+
import { SelectProps } from 'antd/es/select';
|
|
3
|
+
|
|
4
|
+
interface ISelectProps extends SelectProps {
|
|
5
|
+
/**
|
|
6
|
+
* 外部传入的需要显示的数据
|
|
7
|
+
*/
|
|
8
|
+
list?: any[];
|
|
9
|
+
/**
|
|
10
|
+
* 默认渲染的列表
|
|
11
|
+
*/
|
|
12
|
+
defaultList?: any[];
|
|
13
|
+
/**
|
|
14
|
+
* data key
|
|
15
|
+
*/
|
|
16
|
+
dataKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* title key
|
|
19
|
+
*/
|
|
20
|
+
titleKey?: string;
|
|
21
|
+
/**
|
|
22
|
+
* join key
|
|
23
|
+
*/
|
|
24
|
+
joinKey?: string | string[];
|
|
25
|
+
/**
|
|
26
|
+
* 拼接形式
|
|
27
|
+
*/
|
|
28
|
+
joinStr?: string;
|
|
29
|
+
/**
|
|
30
|
+
* 换行展示的数据
|
|
31
|
+
*/
|
|
32
|
+
lineFeedKey?: string | string[];
|
|
33
|
+
/**
|
|
34
|
+
* 换行拼接符
|
|
35
|
+
*/
|
|
36
|
+
lineFeedStr?: string;
|
|
37
|
+
/**
|
|
38
|
+
* 是否显示全部
|
|
39
|
+
*/
|
|
40
|
+
showAll?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 禁用的选项列表
|
|
43
|
+
*/
|
|
44
|
+
disabledValues?: string[];
|
|
45
|
+
/**
|
|
46
|
+
* 代理onChange方法
|
|
47
|
+
*/
|
|
48
|
+
onChange?: (value: any, options: any, completeData?: any) => void;
|
|
49
|
+
/**
|
|
50
|
+
* 是否支持远程搜索
|
|
51
|
+
*/
|
|
52
|
+
isRemoteSearch?: boolean;
|
|
53
|
+
}
|
|
54
|
+
type ISECRET_COMBOBOX_MODE_DO_NOT_USE = typeof Select.SECRET_COMBOBOX_MODE_DO_NOT_USE;
|
|
55
|
+
type IOption = typeof Select.Option;
|
|
56
|
+
type IOptGroup = typeof Select.OptGroup;
|
|
57
|
+
interface ISelectComponent extends React.ForwardRefExoticComponent<ISelectProps & React.RefAttributes<unknown>> {
|
|
58
|
+
SECRET_COMBOBOX_MODE_DO_NOT_USE: ISECRET_COMBOBOX_MODE_DO_NOT_USE;
|
|
59
|
+
Option: IOption;
|
|
60
|
+
OptGroup: IOptGroup;
|
|
61
|
+
displayName: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { ISelectComponent, ISelectProps };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { __rest, __assign } from '../_virtual/_tslib.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { memo, forwardRef, useCallback } from 'react';
|
|
4
|
+
import { Select as Select$1 } from 'antd';
|
|
5
|
+
import { useRenderChildren } from './hooks.js';
|
|
6
|
+
import debounce from 'lodash/debounce';
|
|
7
|
+
|
|
8
|
+
function textContent(children) {
|
|
9
|
+
if (!children) {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
if (typeof children === "string") {
|
|
13
|
+
return children;
|
|
14
|
+
}
|
|
15
|
+
if (children instanceof Array) {
|
|
16
|
+
return children
|
|
17
|
+
.map(function (item) {
|
|
18
|
+
var _a;
|
|
19
|
+
var res = typeof item === "string" ? item : ((_a = item === null || item === void 0 ? void 0 : item.props) === null || _a === void 0 ? void 0 : _a.children) || "";
|
|
20
|
+
return textContent(res);
|
|
21
|
+
})
|
|
22
|
+
.join(" ");
|
|
23
|
+
}
|
|
24
|
+
return textContent(children);
|
|
25
|
+
}
|
|
26
|
+
var Select = function (props, ref) {
|
|
27
|
+
var list = props.list, defaultList = props.defaultList, _a = props.dataKey, dataKey = _a === void 0 ? "id" : _a, _b = props.titleKey, titleKey = _b === void 0 ? "name" : _b, joinKey = props.joinKey, _c = props.joinStr, joinStr = _c === void 0 ? "-" : _c, lineFeedKey = props.lineFeedKey, _d = props.lineFeedStr, lineFeedStr = _d === void 0 ? "-" : _d, showAll = props.showAll, children = props.children, disabledValues = props.disabledValues, _e = props.dropdownMatchSelectWidth, dropdownMatchSelectWidth = _e === void 0 ? 100 : _e, onChange = props.onChange, onSearch = props.onSearch, isRemoteSearch = props.isRemoteSearch, resetProps = __rest(props, ["list", "defaultList", "dataKey", "titleKey", "joinKey", "joinStr", "lineFeedKey", "lineFeedStr", "showAll", "children", "disabledValues", "dropdownMatchSelectWidth", "onChange", "onSearch", "isRemoteSearch"]);
|
|
28
|
+
/**
|
|
29
|
+
* 渲染子元素
|
|
30
|
+
*/
|
|
31
|
+
var _f = useRenderChildren({
|
|
32
|
+
list: list,
|
|
33
|
+
defaultList: defaultList,
|
|
34
|
+
dataKey: dataKey,
|
|
35
|
+
titleKey: titleKey,
|
|
36
|
+
joinKey: joinKey,
|
|
37
|
+
joinStr: joinStr,
|
|
38
|
+
lineFeedKey: lineFeedKey,
|
|
39
|
+
lineFeedStr: lineFeedStr,
|
|
40
|
+
showAll: showAll,
|
|
41
|
+
children: children,
|
|
42
|
+
disabledValues: disabledValues,
|
|
43
|
+
}), renderChildren = _f.renderChildren, resultList = _f.resultList;
|
|
44
|
+
/**
|
|
45
|
+
* onChange方法代理
|
|
46
|
+
*/
|
|
47
|
+
var onChangeHandle = function (value, options) {
|
|
48
|
+
if (!Array.isArray(resultList) || resultList.length === 0) {
|
|
49
|
+
onChange && onChange(value, options);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
var currentData;
|
|
53
|
+
var key = dataKey;
|
|
54
|
+
if (props.mode === "multiple") {
|
|
55
|
+
// 多选模式
|
|
56
|
+
currentData = value.map(function (valueItem) {
|
|
57
|
+
return resultList.find(function (item) {
|
|
58
|
+
if (!item) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (item[key] == null) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return item[key] === valueItem;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
currentData = currentData === null || currentData === void 0 ? void 0 : currentData.filter(function (item) { return item; });
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
currentData = resultList.find(function (item) {
|
|
73
|
+
if (!item) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (item[key] == null) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return item[key] === value;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
onChange && onChange(value, options, currentData);
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* onSearch方法代理
|
|
88
|
+
*/
|
|
89
|
+
var onSearchHandle = useCallback(function (value) {
|
|
90
|
+
onSearch && onSearch(value);
|
|
91
|
+
}, [onSearch]);
|
|
92
|
+
var onDebounceSearchHandle = debounce(onSearchHandle, 400);
|
|
93
|
+
/**
|
|
94
|
+
* 本地搜索
|
|
95
|
+
*/
|
|
96
|
+
var filterOptionHandle = function (input, option) {
|
|
97
|
+
var text = textContent(option === null || option === void 0 ? void 0 : option.children);
|
|
98
|
+
return (text === null || text === void 0 ? void 0 : text.toLowerCase().indexOf(input.toLowerCase().trim())) >= 0;
|
|
99
|
+
};
|
|
100
|
+
return (jsx(Select$1, __assign({ dropdownMatchSelectWidth: dropdownMatchSelectWidth, onChange: onChangeHandle, onSearch: onDebounceSearchHandle, filterOption: isRemoteSearch ? false : filterOptionHandle }, resetProps, { ref: ref }, { children: renderChildren() })));
|
|
101
|
+
};
|
|
102
|
+
var MemoSelect = memo(forwardRef(Select));
|
|
103
|
+
MemoSelect.displayName = "ZTXK_WEBUI_Select";
|
|
104
|
+
MemoSelect.SECRET_COMBOBOX_MODE_DO_NOT_USE =
|
|
105
|
+
Select$1.SECRET_COMBOBOX_MODE_DO_NOT_USE;
|
|
106
|
+
MemoSelect.Option = Select$1.Option;
|
|
107
|
+
MemoSelect.OptGroup = Select$1.OptGroup;
|
|
108
|
+
|
|
109
|
+
export { MemoSelect as default };
|
package/dist/es/table/hooks.js
CHANGED
package/dist/index.build.d.ts
CHANGED
|
@@ -23,7 +23,8 @@ export { default as AppLayout } from './es/applayout/appLayout.js';
|
|
|
23
23
|
export { default as AppLayoutHeader } from './es/applayoutheader/appLayoutHeader.js';
|
|
24
24
|
export { default as AppLayoutSider } from './es/applayoutsider/appLayoutSider.js';
|
|
25
25
|
export { default as OperationBtn } from './es/operationbtn/operationBtn.js';
|
|
26
|
-
export {
|
|
26
|
+
export { default as Select } from './es/select/select.js';
|
|
27
|
+
export { Affix, Alert, Anchor, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, Card, Carousel, Cascader, Checkbox, Col, Collapse, Comment, ConfigProvider, Descriptions, Divider, Drawer, Dropdown, Empty, Grid, Image, Layout, List, Mentions, Menu, PageHeader, Popconfirm, Popover, Progress, Radio, Rate, Result, Row, Segmented, Skeleton, Slider, Space, Spin, Statistic, Steps, Switch, Tag, Timeline, Tooltip, Transfer, Tree, TreeSelect, Typography, Upload, message, notification } from 'antd';
|
|
27
28
|
export { IModalOpenOptions, IModalProps, IModalRef } from './es/modal/interface.js';
|
|
28
29
|
export { IFooterDom, IFooterProps } from './es/footer/interface.js';
|
|
29
30
|
export { IColumnsType, ITableProps } from './es/table/interface.js';
|