@ccs-ui/rc-pro 2.3.6-beta-40 → 2.4.0-beta.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/docs-dist/154.1dfbf448.async.js +137 -0
- package/docs-dist/27.cf0e6aaf.async.js +11 -0
- package/docs-dist/272.98b3528d.async.js +15 -0
- package/docs-dist/272.e8c51481.chunk.css +5 -0
- package/docs-dist/313.ee13d2ba.async.js +5 -0
- package/docs-dist/387.c3734c23.async.js +573 -0
- package/docs-dist/404.html +15 -0
- package/docs-dist/859.2ac4ce6d.async.js +18 -0
- package/docs-dist/auth__demos.106c6ce7.async.js +1 -0
- package/docs-dist/button__demos.4c22be73.async.js +1 -0
- package/docs-dist/cascader__demos.46cb399e.async.js +1 -0
- package/docs-dist/date-picker__demos.cb7b5f00.async.js +1 -0
- package/docs-dist/dialog__demos.e4f54d6e.async.js +1 -0
- package/docs-dist/docs__guide.md.33be0665.chunk.css +1 -0
- package/docs-dist/docs__guide.md.fa186b09.async.js +1 -0
- package/docs-dist/docs__index.md.22217718.async.js +1 -0
- package/docs-dist/docs__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/dumi__tmp-production__dumi__theme__ContextWrapper.a5f4a8dc.async.js +1 -0
- package/docs-dist/editor__demos.0b8f6819.async.js +6 -0
- package/docs-dist/favicon.png +0 -0
- package/docs-dist/group-form-item__demos.121f2381.async.js +1 -0
- package/docs-dist/guide/index.html +15 -0
- package/docs-dist/index.html +15 -0
- package/docs-dist/interval-button__demos.a9fa2598.async.js +1 -0
- package/docs-dist/loading__demos.0b2a0a1e.async.js +1 -0
- package/docs-dist/logo.svg +48 -0
- package/docs-dist/meta__docs.58d867fc.async.js +1 -0
- package/docs-dist/meta__packages.20ad7ce8.async.js +10079 -0
- package/docs-dist/meta__packages.9ed2b563.chunk.css +1 -0
- package/docs-dist/nm__dumi__dist__client__pages__404.28f3e467.async.js +1 -0
- package/docs-dist/nm__dumi__dist__client__pages__404.8b85f2d9.chunk.css +1 -0
- package/docs-dist/nm__dumi__dist__client__pages__Demo__index.1d26abae.async.js +1 -0
- package/docs-dist/nm__dumi__dist__client__pages__Demo__index.578aa5c0.chunk.css +1 -0
- package/docs-dist/nm__dumi__theme-default__layouts__DocLayout__index.626881d5.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__auth__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__auth__index.md.80345bcc.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__button__index.md.05cb5ebc.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__button__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__cascader__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__cascader__index.md.d8535a05.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__date-picker__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__date-picker__index.md.bab3c69e.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__dialog__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__dialog__index.md.64ec2666.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__editor__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__editor__index.md.a18cb4dc.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__group-form-item__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__group-form-item__index.md.7d1da762.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__index.md.d9449737.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__interval-button__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__interval-button__index.md.c725522b.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__layout-keep-alive__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__layout-keep-alive__index.md.d39a1325.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__loading__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__loading__index.md.893eb1e0.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__pro-table__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__pro-table__index.md.352db0a4.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__pro-tabs__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__pro-tabs__index.md.f6578fee.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__result__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__result__index.md.737b704c.async.js +2 -0
- package/docs-dist/packages__rc-pro__src__select__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__select__index.md.35981c54.async.js +2 -0
- package/docs-dist/packages__rc-pro__src__time-picker__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__time-picker__index.md.b525b352.async.js +1 -0
- package/docs-dist/packages__rc-pro__src__water-mark__index.md.33be0665.chunk.css +1 -0
- package/docs-dist/packages__rc-pro__src__water-mark__index.md.8e548df5.async.js +1 -0
- package/docs-dist/preload_helper.5f80f118.js +1 -0
- package/docs-dist/pro-table__demos.09e87ab4.async.js +1 -0
- package/docs-dist/pro-tabs__demos.eff953d6.async.js +1 -0
- package/docs-dist/rc-pros/auth/index.html +15 -0
- package/docs-dist/rc-pros/button/index.html +15 -0
- package/docs-dist/rc-pros/cascader/index.html +15 -0
- package/docs-dist/rc-pros/date-picker/index.html +15 -0
- package/docs-dist/rc-pros/dialog/index.html +15 -0
- package/docs-dist/rc-pros/editor/index.html +15 -0
- package/docs-dist/rc-pros/group-form-item/index.html +15 -0
- package/docs-dist/rc-pros/index.html +15 -0
- package/docs-dist/rc-pros/interval-button/index.html +15 -0
- package/docs-dist/rc-pros/layout-keep-alive/index.html +15 -0
- package/docs-dist/rc-pros/loading/index.html +15 -0
- package/docs-dist/rc-pros/pro-table/index.html +15 -0
- package/docs-dist/rc-pros/pro-tabs/index.html +15 -0
- package/docs-dist/rc-pros/result/index.html +15 -0
- package/docs-dist/rc-pros/select/index.html +15 -0
- package/docs-dist/rc-pros/time-picker/index.html +15 -0
- package/docs-dist/rc-pros/water-mark/index.html +15 -0
- package/docs-dist/result__demos.4832bcb4.async.js +1 -0
- package/docs-dist/select__demos.e57e694a.async.js +1 -0
- package/docs-dist/time-picker__demos.518f8acb.async.js +1 -0
- package/docs-dist/umi.4e0bcd92.css +1 -0
- package/docs-dist/umi.cc941610.js +108 -0
- package/docs-dist/water-mark__demos.4e7773cd.async.js +1 -0
- package/docs-dist/~demos/:id/index.html +15 -0
- package/docs-dist/~demos/auth-demo-basic/index.html +15 -0
- package/docs-dist/~demos/button-demo-button/index.html +15 -0
- package/docs-dist/~demos/button-demo-group/index.html +15 -0
- package/docs-dist/~demos/cascader-demo-basic/index.html +15 -0
- package/docs-dist/~demos/cascader-demo-cache/index.html +15 -0
- package/docs-dist/~demos/date-picker-demo-basic/index.html +15 -0
- package/docs-dist/~demos/date-picker-demo-range/index.html +15 -0
- package/docs-dist/~demos/dialog-demo-demos/index.html +15 -0
- package/docs-dist/~demos/editor-demo-demos/index.html +15 -0
- package/docs-dist/~demos/group-form-item-demo-basic/index.html +15 -0
- package/docs-dist/~demos/interval-button-demo-basic/index.html +15 -0
- package/docs-dist/~demos/loading-demo-basic/index.html +15 -0
- package/docs-dist/~demos/pro-table-demo-basic/index.html +15 -0
- package/docs-dist/~demos/pro-table-demo-fixed/index.html +15 -0
- package/docs-dist/~demos/pro-table-demo-selection/index.html +15 -0
- package/docs-dist/~demos/pro-tabs-demo-basic/index.html +15 -0
- package/docs-dist/~demos/pro-tabs-demo-tab/index.html +15 -0
- package/docs-dist/~demos/result-demo-basic/index.html +15 -0
- package/docs-dist/~demos/select-demo-api/index.html +15 -0
- package/docs-dist/~demos/select-demo-basic/index.html +15 -0
- package/docs-dist/~demos/select-demo-customize/index.html +15 -0
- package/docs-dist/~demos/select-demo-customize-label/index.html +15 -0
- package/docs-dist/~demos/time-picker-demo-basic/index.html +15 -0
- package/docs-dist/~demos/water-mark-demo-basic/index.html +15 -0
- package/es/Foo/d +0 -0
- package/es/aj-captcha/index.less +9 -23
- package/es/auth/index.d.ts +7 -0
- package/es/auth/index.js +14 -0
- package/es/cascader/index.js +4 -4
- package/es/ccs.d.ts +7 -13
- package/es/config.js +33 -11
- package/es/context/index.d.ts +2 -2
- package/es/date-picker/index.js +20 -0
- package/es/dialog/button.d.ts +1 -1
- package/es/dialog/button.js +4 -4
- package/es/dialog/index.d.ts +0 -1
- package/es/dialog/index.js +0 -1
- package/es/ellipsis/index.js +4 -2
- package/es/ellipsis/useResizeEffect.js +10 -24
- package/es/group-form-item/index.d.ts +11 -0
- package/es/group-form-item/index.js +124 -0
- package/es/hooks/use-page.d.ts +1 -1
- package/es/hooks/use-selection.d.ts +12 -23
- package/es/hooks/use-selection.js +51 -25
- package/es/index.d.ts +1 -3
- package/es/index.js +1 -3
- package/es/interval-button/index.js +4 -4
- package/es/layout-keep-alive/index.d.ts +1 -1
- package/es/layout-keep-alive/index.js +26 -20
- package/es/layout-keep-alive/index.less +19 -23
- package/es/layout-keep-alive/page.d.ts +3 -2
- package/es/layout-keep-alive/page.js +4 -3
- package/es/layout-single-page/index.d.ts +5 -3
- package/es/layout-single-page/index.js +12 -5
- package/es/layout-single-page/index.less +2 -8
- package/es/layout-single-page/page.d.ts +3 -1
- package/es/layout-single-page/page.js +2 -1
- package/es/pro-table/_utils.d.ts +1 -1
- package/es/pro-table/_utils.js +7 -7
- package/es/pro-table/form-item.d.ts +5 -3
- package/es/pro-table/form-item.js +28 -11
- package/es/pro-table/head.js +88 -63
- package/es/pro-table/index.less +20 -175
- package/es/pro-table/selection-alert.d.ts +4 -2
- package/es/pro-table/selection-alert.js +16 -4
- package/es/pro-table/table.d.ts +13 -24
- package/es/pro-table/table.js +128 -250
- package/es/pro-table/tree.d.ts +3 -3
- package/es/pro-table/tree.js +28 -17
- package/es/select/ modal.d.ts +3 -9
- package/es/select/ modal.js +63 -22
- package/es/select/customize.d.ts +7 -15
- package/es/select/customize.js +58 -48
- package/es/select/index.d.ts +2 -1
- package/es/select/index.js +9 -9
- package/es/table/index.js +12 -14
- package/es/table/index.less +0 -129
- package/package.json +13 -32
- package/LICENSE +0 -21
- package/README.md +0 -37
- package/es/breadcrumb.d.ts +0 -8
- package/es/breadcrumb.js +0 -40
- package/es/dialog/index.less +0 -16
- package/es/pro-grid/index.d.ts +0 -15
- package/es/pro-grid/index.js +0 -58
- package/es/trigger/index.d.ts +0 -43
- package/es/trigger/index.js +0 -298
- package/es/trigger/index.less +0 -42
- package/es/virtual-list/index.d.ts +0 -51
- package/es/virtual-list/index.js +0 -132
package/es/pro-table/tree.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { RefObject } from 'react';
|
|
|
4
4
|
import CCS from '..';
|
|
5
5
|
import { CcsFieldNamesType } from '../context';
|
|
6
6
|
import { TableRefType } from '../table';
|
|
7
|
-
import { CcsProTableProps } from './table';
|
|
7
|
+
import { CcsProTableProps, TableEvent } from './table';
|
|
8
8
|
export type TreeInstance<T> = {
|
|
9
|
-
onRequestTree: (query: any, record: T | any) => void;
|
|
9
|
+
onRequestTree: (eventType: TableEvent, query: any, record: T | any) => void;
|
|
10
10
|
onExpandKeys: (ids: string[]) => void;
|
|
11
11
|
};
|
|
12
|
-
type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'parentFieldName' | 'leafNode'> & {
|
|
12
|
+
type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'parentFieldName' | 'leafNode' | 'onEvent'> & {
|
|
13
13
|
data: CCS.TableData<T>;
|
|
14
14
|
sticky: boolean | TableSticky;
|
|
15
15
|
tableRowSize: TableProps['size'];
|
package/es/pro-table/tree.js
CHANGED
|
@@ -21,7 +21,8 @@ import CcsUtils from '@ccs-ui/utils';
|
|
|
21
21
|
import { useImperativeHandle, useState } from 'react';
|
|
22
22
|
import { CcsTable } from '..';
|
|
23
23
|
import { useProTableTreeFields } from "../hooks/use-app";
|
|
24
|
-
import {
|
|
24
|
+
import { getDataByNamePath } from "../select";
|
|
25
|
+
import { TableEvent } from "./table";
|
|
25
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
27
|
var TableTree = function TableTree(props) {
|
|
27
28
|
var data = props.data,
|
|
@@ -34,7 +35,8 @@ var TableTree = function TableTree(props) {
|
|
|
34
35
|
tableContentRef = props.tableContentRef,
|
|
35
36
|
parentFieldName = props.parentFieldName,
|
|
36
37
|
handlePageChange = props.handlePageChange,
|
|
37
|
-
setData = props.setData
|
|
38
|
+
setData = props.setData,
|
|
39
|
+
onEvent = props.onEvent;
|
|
38
40
|
// async tree expand key
|
|
39
41
|
var _useState = useState([]),
|
|
40
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -53,8 +55,8 @@ var TableTree = function TableTree(props) {
|
|
|
53
55
|
var fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), props.fieldNames);
|
|
54
56
|
|
|
55
57
|
// 获取数据
|
|
56
|
-
var
|
|
57
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
58
|
+
var onRequestTree = /*#__PURE__*/function () {
|
|
59
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(eventType) {
|
|
58
60
|
var query,
|
|
59
61
|
record,
|
|
60
62
|
params,
|
|
@@ -64,13 +66,18 @@ var TableTree = function TableTree(props) {
|
|
|
64
66
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
65
67
|
while (1) switch (_context.prev = _context.next) {
|
|
66
68
|
case 0:
|
|
67
|
-
query = _args.length >
|
|
68
|
-
record = _args.length >
|
|
69
|
+
query = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
70
|
+
record = _args.length > 2 ? _args[2] : undefined;
|
|
69
71
|
params = query;
|
|
70
72
|
if (record) {
|
|
71
73
|
params[parentFieldName] = record[rowKey];
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
// 事件回调,请求中
|
|
77
|
+
onEvent === null || onEvent === void 0 || onEvent(eventType, {
|
|
78
|
+
loading: true,
|
|
79
|
+
params: params
|
|
80
|
+
});
|
|
74
81
|
// 发起请求
|
|
75
82
|
setData(function (d) {
|
|
76
83
|
return _objectSpread(_objectSpread({}, d), {}, {
|
|
@@ -79,19 +86,25 @@ var TableTree = function TableTree(props) {
|
|
|
79
86
|
});
|
|
80
87
|
_context.t0 = httpRequest;
|
|
81
88
|
if (!_context.t0) {
|
|
82
|
-
_context.next =
|
|
89
|
+
_context.next = 11;
|
|
83
90
|
break;
|
|
84
91
|
}
|
|
85
|
-
_context.next =
|
|
92
|
+
_context.next = 10;
|
|
86
93
|
return httpRequest(params);
|
|
87
|
-
case 9:
|
|
88
|
-
_context.t0 = _context.sent;
|
|
89
94
|
case 10:
|
|
95
|
+
_context.t0 = _context.sent;
|
|
96
|
+
case 11:
|
|
90
97
|
requestResult = _context.t0;
|
|
98
|
+
onEvent === null || onEvent === void 0 || onEvent(eventType, {
|
|
99
|
+
loading: true,
|
|
100
|
+
params: params,
|
|
101
|
+
data: requestResult
|
|
102
|
+
});
|
|
103
|
+
|
|
91
104
|
// 请求结果
|
|
92
105
|
if (requestResult) {
|
|
93
106
|
// 获取table数据
|
|
94
|
-
dataSource =
|
|
107
|
+
dataSource = getDataByNamePath(requestResult, fieldNames.dataSource); // 判断非叶子节点,添加children
|
|
95
108
|
if (leafNode && dataSource && Array.isArray(dataSource)) {
|
|
96
109
|
dataSource.forEach(function (d) {
|
|
97
110
|
if (typeof leafNode === 'string' && !d[leafNode]) {
|
|
@@ -126,21 +139,19 @@ var TableTree = function TableTree(props) {
|
|
|
126
139
|
});
|
|
127
140
|
});
|
|
128
141
|
}
|
|
129
|
-
case
|
|
142
|
+
case 14:
|
|
130
143
|
case "end":
|
|
131
144
|
return _context.stop();
|
|
132
145
|
}
|
|
133
146
|
}, _callee);
|
|
134
147
|
}));
|
|
135
|
-
return function onRequestTree() {
|
|
148
|
+
return function onRequestTree(_x) {
|
|
136
149
|
return _ref2.apply(this, arguments);
|
|
137
150
|
};
|
|
138
151
|
}();
|
|
139
152
|
useImperativeHandle(treeRef, function () {
|
|
140
153
|
return {
|
|
141
|
-
onRequestTree:
|
|
142
|
-
_onRequestTree(query, record);
|
|
143
|
-
},
|
|
154
|
+
onRequestTree: onRequestTree,
|
|
144
155
|
onExpandKeys: function onExpandKeys(ids) {
|
|
145
156
|
setExpandKeys(expandKeys.filter(function (e) {
|
|
146
157
|
return !ids.includes(e);
|
|
@@ -158,7 +169,7 @@ var TableTree = function TableTree(props) {
|
|
|
158
169
|
var _record$childrenColum;
|
|
159
170
|
expandKeys.push(expandId);
|
|
160
171
|
if (((_record$childrenColum = record[childrenColumnName]) === null || _record$childrenColum === void 0 ? void 0 : _record$childrenColum.length) > 0) return;
|
|
161
|
-
|
|
172
|
+
onRequestTree(TableEvent.Expand, {}, record);
|
|
162
173
|
} else {
|
|
163
174
|
setExpandKeys(expandKeys.filter(function (e) {
|
|
164
175
|
return e !== expandId;
|
package/es/select/ modal.d.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { ModalProps, SelectProps } from 'antd';
|
|
2
2
|
import { ReactElement, ReactNode } from 'react';
|
|
3
3
|
import { SelectChildrenProps } from './customize';
|
|
4
|
-
export interface ModalSelectProps {
|
|
4
|
+
export interface ModalSelectProps extends Omit<SelectProps, 'children' | 'title'> {
|
|
5
5
|
/** modal props */
|
|
6
6
|
modal?: ModalProps;
|
|
7
|
-
/** select props */
|
|
8
|
-
select?: SelectProps;
|
|
9
7
|
/** 自定义内容 */
|
|
10
|
-
children
|
|
11
|
-
/** form item value */
|
|
12
|
-
value?: any;
|
|
13
|
-
/** form item onChange */
|
|
14
|
-
onChange?: (e: any) => void;
|
|
8
|
+
children?: ReactElement | ((props: SelectChildrenProps) => ReactNode);
|
|
15
9
|
}
|
|
16
|
-
export default function ModalSelect({
|
|
10
|
+
export default function ModalSelect({ style, mode, modal, value, children, labelInValue, onChange: onOkChange, ...otherProps }: ModalSelectProps): import("react/jsx-runtime").JSX.Element;
|
package/es/select/ modal.js
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["style", "mode", "modal", "value", "children", "labelInValue", "onChange"];
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
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); }
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
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."); }
|
|
9
10
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
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; } }
|
|
12
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
|
|
14
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
+
import { LoadingOutlined, SelectOutlined } from '@ant-design/icons';
|
|
14
17
|
import { Modal, Select } from 'antd';
|
|
15
18
|
import React, { useState } from 'react';
|
|
16
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
20
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
21
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
22
|
export default function ModalSelect(_ref) {
|
|
20
|
-
var
|
|
21
|
-
|
|
23
|
+
var style = _ref.style,
|
|
24
|
+
mode = _ref.mode,
|
|
25
|
+
modal = _ref.modal,
|
|
22
26
|
value = _ref.value,
|
|
23
27
|
children = _ref.children,
|
|
24
|
-
|
|
28
|
+
labelInValue = _ref.labelInValue,
|
|
29
|
+
onOkChange = _ref.onChange,
|
|
30
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
25
31
|
var _useState = useState(false),
|
|
26
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
27
33
|
open = _useState2[0],
|
|
@@ -29,14 +35,22 @@ export default function ModalSelect(_ref) {
|
|
|
29
35
|
var onClick = function onClick() {
|
|
30
36
|
setOpen(true);
|
|
31
37
|
};
|
|
32
|
-
var _useState3 = useState(
|
|
38
|
+
var _useState3 = useState(undefined),
|
|
33
39
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var _useState5 = useState(
|
|
40
|
+
labelText = _useState4[0],
|
|
41
|
+
setLabelText = _useState4[1];
|
|
42
|
+
var _useState5 = useState(false),
|
|
37
43
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
loading = _useState6[0],
|
|
45
|
+
setLoading = _useState6[1];
|
|
46
|
+
var _useState7 = useState(value),
|
|
47
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
48
|
+
valueState = _useState8[0],
|
|
49
|
+
setValueState = _useState8[1];
|
|
50
|
+
var _useState9 = useState(undefined),
|
|
51
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
52
|
+
options = _useState10[0],
|
|
53
|
+
setOptions = _useState10[1];
|
|
40
54
|
|
|
41
55
|
// 确定按钮
|
|
42
56
|
var onClose = function onClose(e) {
|
|
@@ -44,15 +58,16 @@ export default function ModalSelect(_ref) {
|
|
|
44
58
|
setOpen(false);
|
|
45
59
|
};
|
|
46
60
|
|
|
47
|
-
// 多选
|
|
48
|
-
var isMulti = (select === null || select === void 0 ? void 0 : select.mode) === 'multiple';
|
|
49
|
-
|
|
50
61
|
// children 参数
|
|
51
62
|
var childrenProps = {
|
|
52
63
|
value: valueState,
|
|
53
|
-
|
|
64
|
+
mode: mode,
|
|
54
65
|
onClose: onClose,
|
|
55
|
-
|
|
66
|
+
onLoading: setLoading,
|
|
67
|
+
onChangeLabel: setLabelText,
|
|
68
|
+
onChange: function onChange(v, option) {
|
|
69
|
+
setValueState(labelInValue ? option : v);
|
|
70
|
+
},
|
|
56
71
|
onChangeOptions: setOptions
|
|
57
72
|
};
|
|
58
73
|
|
|
@@ -67,23 +82,49 @@ export default function ModalSelect(_ref) {
|
|
|
67
82
|
setValueState(value);
|
|
68
83
|
setOpen(false);
|
|
69
84
|
};
|
|
85
|
+
var renderValueText = function renderValueText() {
|
|
86
|
+
if (value === undefined || Array.isArray(value) && value.length === 0) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 优先显示 labelText
|
|
91
|
+
if (!!labelText) return labelText;
|
|
92
|
+
|
|
93
|
+
// 如果value是数组对象,则获取value对象
|
|
94
|
+
if (Array.isArray(value)) {
|
|
95
|
+
return value.map(function (item) {
|
|
96
|
+
var _otherProps$fieldName;
|
|
97
|
+
return _typeof(item) === 'object' ? item[((_otherProps$fieldName = otherProps.fieldNames) === null || _otherProps$fieldName === void 0 ? void 0 : _otherProps$fieldName.value) || 'value'] : item;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 如果value是对象,则获取value
|
|
102
|
+
if (_typeof(value) === 'object') {
|
|
103
|
+
var _otherProps$fieldName2;
|
|
104
|
+
return value[((_otherProps$fieldName2 = otherProps.fieldNames) === null || _otherProps$fieldName2 === void 0 ? void 0 : _otherProps$fieldName2.value) || 'value'];
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
};
|
|
70
108
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
71
|
-
children: [/*#__PURE__*/_jsx(Select, _objectSpread({
|
|
109
|
+
children: [/*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({
|
|
72
110
|
allowClear: true,
|
|
73
|
-
suffixIcon: /*#__PURE__*/_jsx(SelectOutlined, {}),
|
|
111
|
+
suffixIcon: loading ? /*#__PURE__*/_jsx(LoadingOutlined, {}) : /*#__PURE__*/_jsx(SelectOutlined, {}),
|
|
74
112
|
open: false,
|
|
75
113
|
dropdownRender: function dropdownRender() {
|
|
76
114
|
return /*#__PURE__*/_jsx("div", {});
|
|
77
115
|
},
|
|
78
|
-
value:
|
|
116
|
+
value: loading ? undefined : renderValueText(),
|
|
79
117
|
onClick: onClick,
|
|
80
|
-
placeholder:
|
|
118
|
+
placeholder: '请选择'
|
|
119
|
+
}, otherProps), {}, {
|
|
120
|
+
mode: !!labelText ? undefined : mode,
|
|
121
|
+
style: style,
|
|
81
122
|
options: options,
|
|
82
123
|
onChange: function onChange(e) {
|
|
83
124
|
setValueState(e);
|
|
84
125
|
onOkChange === null || onOkChange === void 0 || onOkChange(e);
|
|
85
126
|
}
|
|
86
|
-
}
|
|
127
|
+
})), /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
|
|
87
128
|
open: open,
|
|
88
129
|
onCancel: onModalClose,
|
|
89
130
|
styles: {
|
|
@@ -94,7 +135,7 @@ export default function ModalSelect(_ref) {
|
|
|
94
135
|
forceRender: true,
|
|
95
136
|
onOk: onModalOk
|
|
96
137
|
}, modal), {}, {
|
|
97
|
-
children: typeof children === 'function' ? children(childrenProps) : /*#__PURE__*/React.cloneElement(children, childrenProps)
|
|
138
|
+
children: children && (typeof children === 'function' ? children(childrenProps) : /*#__PURE__*/React.cloneElement(children, childrenProps))
|
|
98
139
|
}))]
|
|
99
140
|
});
|
|
100
141
|
}
|
package/es/select/customize.d.ts
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
import { SelectProps } from 'antd';
|
|
2
2
|
import { ReactElement, ReactNode } from 'react';
|
|
3
|
-
export type SelectChildrenProps = {
|
|
4
|
-
/** 当前选中的值 */
|
|
5
|
-
value?: any;
|
|
6
|
-
/** 是否多选 */
|
|
7
|
-
multiple?: boolean;
|
|
3
|
+
export type SelectChildrenProps = Pick<SelectProps, 'value' | 'onChange' | 'mode'> & {
|
|
8
4
|
/** 关闭弹框 */
|
|
9
5
|
onClose?: (e?: any) => void;
|
|
10
|
-
/** form item onChange */
|
|
11
|
-
onChange?: (value: any) => void;
|
|
12
6
|
/** 更改select options */
|
|
13
7
|
onChangeOptions?: (options: any[]) => void;
|
|
8
|
+
/** 自定义显示选中详情 */
|
|
9
|
+
onChangeLabel?: (labelText?: string) => void;
|
|
10
|
+
/** 加载状态 */
|
|
11
|
+
onLoading?: (loading: boolean) => void;
|
|
14
12
|
};
|
|
15
13
|
export interface CustomizeSelectProps extends Omit<SelectProps, 'children'> {
|
|
16
|
-
/** 选择触发器宽度 */
|
|
17
|
-
width?: number;
|
|
18
14
|
/** 内容宽度 */
|
|
19
15
|
contentWidth?: number;
|
|
20
16
|
/** 自定义内容 */
|
|
21
|
-
children
|
|
22
|
-
/** form item value */
|
|
23
|
-
value?: any;
|
|
24
|
-
/** form item onChange */
|
|
25
|
-
onChange?: (e: any) => void;
|
|
17
|
+
children?: ReactElement | ((props: SelectChildrenProps) => ReactNode);
|
|
26
18
|
}
|
|
27
19
|
/**
|
|
28
20
|
* 自定义弹框
|
|
29
21
|
* @param SelectCustomizeProps
|
|
30
22
|
* @returns
|
|
31
23
|
*/
|
|
32
|
-
declare function SelectIndex({
|
|
24
|
+
declare function SelectIndex({ value, style, mode, children, contentWidth, labelInValue, onChange, ...otherProps }: CustomizeSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
33
25
|
export default SelectIndex;
|
package/es/select/customize.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var _excluded = ["width", "title", "children", "contentWidth", "value", "onChange", "style"];
|
|
1
|
+
var _excluded = ["value", "style", "mode", "children", "contentWidth", "labelInValue", "onChange"];
|
|
3
2
|
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; }
|
|
4
3
|
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; }
|
|
5
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
6
|
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); }
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
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
10
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -13,11 +13,10 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { LoadingOutlined, SelectOutlined } from '@ant-design/icons';
|
|
17
|
+
import { Select } from 'antd';
|
|
18
18
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
20
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
21
|
/**
|
|
23
22
|
* 自定义弹框
|
|
@@ -25,13 +24,13 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
25
24
|
* @returns
|
|
26
25
|
*/
|
|
27
26
|
function SelectIndex(_ref) {
|
|
28
|
-
var
|
|
29
|
-
|
|
27
|
+
var value = _ref.value,
|
|
28
|
+
style = _ref.style,
|
|
29
|
+
mode = _ref.mode,
|
|
30
30
|
children = _ref.children,
|
|
31
31
|
contentWidth = _ref.contentWidth,
|
|
32
|
-
|
|
32
|
+
labelInValue = _ref.labelInValue,
|
|
33
33
|
_onChange = _ref.onChange,
|
|
34
|
-
style = _ref.style,
|
|
35
34
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
36
35
|
// 初始加载
|
|
37
36
|
var _useState = useState(true),
|
|
@@ -39,12 +38,20 @@ function SelectIndex(_ref) {
|
|
|
39
38
|
open = _useState2[0],
|
|
40
39
|
setOpen = _useState2[1];
|
|
41
40
|
var ref = useRef(null);
|
|
42
|
-
|
|
43
|
-
// 选择说明
|
|
44
41
|
var _useState3 = useState(undefined),
|
|
45
42
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
labelText = _useState4[0],
|
|
44
|
+
setLabelText = _useState4[1];
|
|
45
|
+
var _useState5 = useState(false),
|
|
46
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
47
|
+
loading = _useState6[0],
|
|
48
|
+
setLoading = _useState6[1];
|
|
49
|
+
|
|
50
|
+
// 选择说明
|
|
51
|
+
var _useState7 = useState(undefined),
|
|
52
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
53
|
+
options = _useState8[0],
|
|
54
|
+
setOptions = _useState8[1];
|
|
48
55
|
|
|
49
56
|
// 确定按钮
|
|
50
57
|
var onClose = function onClose(e) {
|
|
@@ -52,46 +59,27 @@ function SelectIndex(_ref) {
|
|
|
52
59
|
setOpen(false);
|
|
53
60
|
};
|
|
54
61
|
|
|
55
|
-
// 多选
|
|
56
|
-
var isMulti = otherProps.mode === 'multiple';
|
|
57
|
-
|
|
58
62
|
// children 参数
|
|
59
63
|
var childrenProps = {
|
|
60
64
|
value: value,
|
|
61
65
|
onClose: onClose,
|
|
62
|
-
onChange: function onChange(
|
|
63
|
-
_onChange === null || _onChange === void 0 || _onChange(
|
|
64
|
-
|
|
66
|
+
onChange: function onChange(v, option) {
|
|
67
|
+
_onChange === null || _onChange === void 0 || _onChange(labelInValue ? option : v);
|
|
68
|
+
// 单选关闭弹框
|
|
69
|
+
if (!mode) setOpen(false);
|
|
65
70
|
},
|
|
66
|
-
|
|
71
|
+
onLoading: setLoading,
|
|
72
|
+
onChangeLabel: setLabelText,
|
|
73
|
+
mode: mode,
|
|
67
74
|
onChangeOptions: setOptions
|
|
68
75
|
};
|
|
69
76
|
var _dropdownRender = useMemo(function () {
|
|
70
|
-
return /*#__PURE__*/
|
|
77
|
+
return /*#__PURE__*/_jsx("div", {
|
|
71
78
|
style: {
|
|
72
79
|
display: 'none'
|
|
73
80
|
},
|
|
74
81
|
ref: ref,
|
|
75
|
-
children:
|
|
76
|
-
style: {
|
|
77
|
-
padding: 10,
|
|
78
|
-
borderBottom: '1px solid #f5f5f5',
|
|
79
|
-
display: 'flex',
|
|
80
|
-
justifyContent: 'space-between'
|
|
81
|
-
},
|
|
82
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
83
|
-
children: title
|
|
84
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
85
|
-
type: "text",
|
|
86
|
-
size: "small",
|
|
87
|
-
onClick: onClose,
|
|
88
|
-
children: /*#__PURE__*/_jsx(CloseOutlined, {
|
|
89
|
-
style: {
|
|
90
|
-
color: 'rgba(0,0,0,0.55)'
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
})]
|
|
94
|
-
}), typeof children === 'function' ? children(childrenProps) : /*#__PURE__*/React.cloneElement(children, childrenProps)]
|
|
82
|
+
children: children && (typeof children === 'function' ? children(childrenProps) : /*#__PURE__*/React.cloneElement(children, childrenProps))
|
|
95
83
|
});
|
|
96
84
|
}, [value]);
|
|
97
85
|
useEffect(function () {
|
|
@@ -104,25 +92,47 @@ function SelectIndex(_ref) {
|
|
|
104
92
|
}
|
|
105
93
|
}
|
|
106
94
|
}, [open]);
|
|
95
|
+
var renderValueText = function renderValueText() {
|
|
96
|
+
if (value === undefined || Array.isArray(value) && value.length === 0) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 优先显示 labelText
|
|
101
|
+
if (!!labelText) return labelText;
|
|
102
|
+
|
|
103
|
+
// 如果value是数组对象,则获取value对象
|
|
104
|
+
if (Array.isArray(value)) {
|
|
105
|
+
return value.map(function (item) {
|
|
106
|
+
var _otherProps$fieldName;
|
|
107
|
+
return _typeof(item) === 'object' ? item[((_otherProps$fieldName = otherProps.fieldNames) === null || _otherProps$fieldName === void 0 ? void 0 : _otherProps$fieldName.value) || 'value'] : item;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 如果value是对象,则获取value
|
|
112
|
+
if (_typeof(value) === 'object') {
|
|
113
|
+
var _otherProps$fieldName2;
|
|
114
|
+
return value[((_otherProps$fieldName2 = otherProps.fieldNames) === null || _otherProps$fieldName2 === void 0 ? void 0 : _otherProps$fieldName2.value) || 'value'];
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
};
|
|
107
118
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
108
119
|
children: /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({
|
|
109
120
|
open: open,
|
|
110
121
|
onDropdownVisibleChange: setOpen,
|
|
111
122
|
allowClear: true,
|
|
112
123
|
defaultActiveFirstOption: true,
|
|
113
|
-
suffixIcon: /*#__PURE__*/_jsx(SelectOutlined, {})
|
|
124
|
+
suffixIcon: loading ? /*#__PURE__*/_jsx(LoadingOutlined, {}) : /*#__PURE__*/_jsx(SelectOutlined, {}),
|
|
125
|
+
placeholder: "\u8BF7\u9009\u62E9"
|
|
114
126
|
}, otherProps), {}, {
|
|
115
127
|
popupMatchSelectWidth: contentWidth,
|
|
116
128
|
dropdownRender: function dropdownRender() {
|
|
117
129
|
return _dropdownRender;
|
|
118
130
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}),
|
|
131
|
+
mode: !!labelText ? undefined : mode,
|
|
132
|
+
value: loading ? undefined : renderValueText(),
|
|
133
|
+
style: _objectSpread({}, style),
|
|
123
134
|
onChange: _onChange,
|
|
124
|
-
options: options
|
|
125
|
-
loading: true
|
|
135
|
+
options: options
|
|
126
136
|
}))
|
|
127
137
|
});
|
|
128
138
|
}
|
package/es/select/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SelectProps } from 'antd';
|
|
2
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
2
3
|
import ModalSelect from './ modal';
|
|
3
4
|
import ApiSelect from './api';
|
|
4
5
|
import CustomizeSelect from './customize';
|
|
5
|
-
export declare function
|
|
6
|
+
export declare function getDataByNamePath(data: Record<string, any>, name: NamePath): any;
|
|
6
7
|
export interface CcsSelectProps extends Omit<SelectProps, 'fieldNames'> {
|
|
7
8
|
/** 配置全部选项 */
|
|
8
9
|
showAll?: boolean | {
|
package/es/select/index.js
CHANGED
|
@@ -20,13 +20,16 @@ import ModalSelect from "./ modal";
|
|
|
20
20
|
import ApiSelect from "./api";
|
|
21
21
|
import CustomizeSelect from "./customize";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
export function
|
|
24
|
-
if (!data ||
|
|
25
|
-
|
|
23
|
+
export function getDataByNamePath(data, name) {
|
|
24
|
+
if (!data || !name) return;
|
|
25
|
+
if (typeof name === 'string') {
|
|
26
|
+
return data[name];
|
|
27
|
+
}
|
|
28
|
+
var newFields = _toConsumableArray(name);
|
|
26
29
|
var field = newFields.shift();
|
|
27
30
|
var newData = data[field];
|
|
28
31
|
if (_typeof(newData) === 'object' && newFields.length > 0) {
|
|
29
|
-
return
|
|
32
|
+
return getDataByNamePath(newData, newFields);
|
|
30
33
|
}
|
|
31
34
|
return newData;
|
|
32
35
|
}
|
|
@@ -64,8 +67,8 @@ function InternalSelect(_ref) {
|
|
|
64
67
|
while (labelField.length > 0 || valueField.length > 0) {
|
|
65
68
|
if (Array.isArray(ops)) {
|
|
66
69
|
ops.forEach(function (r) {
|
|
67
|
-
r.label =
|
|
68
|
-
r.value =
|
|
70
|
+
r.label = getDataByNamePath(r, labelField);
|
|
71
|
+
r.value = getDataByNamePath(r, valueField);
|
|
69
72
|
});
|
|
70
73
|
break;
|
|
71
74
|
}
|
|
@@ -87,9 +90,6 @@ function InternalSelect(_ref) {
|
|
|
87
90
|
}, [options]);
|
|
88
91
|
return /*#__PURE__*/_jsx(Select, _objectSpread({
|
|
89
92
|
options: selectOptions,
|
|
90
|
-
style: {
|
|
91
|
-
width: '100%'
|
|
92
|
-
},
|
|
93
93
|
filterOption: onFilterOption,
|
|
94
94
|
placeholder: "\u8BF7\u9009\u62E9",
|
|
95
95
|
allowClear: true,
|