@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,407 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
4
|
+
import { Button, Spin, Table } from 'antd';
|
5
|
+
import { CaretDownFilled, DoubleLeftOutlined } from 'much-icons';
|
6
|
+
import { Children, cloneElement, forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
7
|
+
import "./index.css";
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
10
|
+
var McContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
11
|
+
var _tableProps$dataSourc;
|
12
|
+
var style = props.style,
|
13
|
+
className = props.className,
|
14
|
+
_props$height = props.height,
|
15
|
+
height = _props$height === void 0 ? 'calc(100vh - 88px)' : _props$height,
|
16
|
+
_props$backgroundColo = props.backgroundColor,
|
17
|
+
backgroundColor = _props$backgroundColo === void 0 ? '#ffffff' : _props$backgroundColo,
|
18
|
+
_props$immediateQuery = props.immediateQuery,
|
19
|
+
immediateQuery = _props$immediateQuery === void 0 ? true : _props$immediateQuery,
|
20
|
+
_props$loading = props.loading,
|
21
|
+
loading = _props$loading === void 0 ? false : _props$loading,
|
22
|
+
queryItems = props.queryItems,
|
23
|
+
_props$showQuery = props.showQuery,
|
24
|
+
showQuery = _props$showQuery === void 0 ? true : _props$showQuery,
|
25
|
+
_props$showReset = props.showReset,
|
26
|
+
showReset = _props$showReset === void 0 ? true : _props$showReset,
|
27
|
+
_props$showCollapse = props.showCollapse,
|
28
|
+
showCollapse = _props$showCollapse === void 0 ? false : _props$showCollapse,
|
29
|
+
collapsibleQueryItems = props.collapsibleQueryItems,
|
30
|
+
onQuery = props.onQuery,
|
31
|
+
onReset = props.onReset,
|
32
|
+
queryRender = props.queryRender,
|
33
|
+
actionBar = props.actionBar,
|
34
|
+
_props$batchNum = props.batchNum,
|
35
|
+
batchNum = _props$batchNum === void 0 ? 0 : _props$batchNum,
|
36
|
+
batchBtns = props.batchBtns,
|
37
|
+
onCancel = props.onCancel,
|
38
|
+
tableProps = props.tableProps,
|
39
|
+
tableRender = props.tableRender;
|
40
|
+
var _useState = useState(false),
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
42
|
+
collapse = _useState2[0],
|
43
|
+
setCollapse = _useState2[1];
|
44
|
+
var allNamesRef = useRef([]);
|
45
|
+
var _useState3 = useState({}),
|
46
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
47
|
+
queryParams = _useState4[0],
|
48
|
+
setQueryParams = _useState4[1];
|
49
|
+
var queryParamsRef = useRef({});
|
50
|
+
var defaultQueryParamsRef = useRef({});
|
51
|
+
var initializedRef = useRef(false);
|
52
|
+
|
53
|
+
/* 获取actionBar高度 */
|
54
|
+
var actionBarRef = useRef();
|
55
|
+
var _useState5 = useState(0),
|
56
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
57
|
+
actionBarHeight = _useState6[0],
|
58
|
+
setActionBarHeight = _useState6[1];
|
59
|
+
var actionBarResizeObserver = new ResizeObserver(function (entries) {
|
60
|
+
setActionBarHeight(entries[0].contentRect.height + 40);
|
61
|
+
});
|
62
|
+
useEffect(function () {
|
63
|
+
if (actionBarRef.current) {
|
64
|
+
actionBarResizeObserver.observe(actionBarRef.current);
|
65
|
+
}
|
66
|
+
return function () {
|
67
|
+
return actionBarResizeObserver.disconnect();
|
68
|
+
};
|
69
|
+
}, []);
|
70
|
+
|
71
|
+
// 为设置过name属性的查询项添加value属性和onChange事件,从而收集查询项的值(查询项自身已绑定value属性的除外,需自行编写相关业务逻辑代码进行状态管理)
|
72
|
+
var mapQuerys = function mapQuerys(items) {
|
73
|
+
var ELs = null;
|
74
|
+
if (items) {
|
75
|
+
ELs = Children.map(items.props.children ? items.props.children : items, function (item) {
|
76
|
+
if (item !== null && item !== void 0 && item.props) {
|
77
|
+
var _item$props = item.props,
|
78
|
+
_name = _item$props.name,
|
79
|
+
_onChange = _item$props.onChange;
|
80
|
+
var canCollect = _name && !item.props.hasOwnProperty('value');
|
81
|
+
if (canCollect) {
|
82
|
+
if (!allNamesRef.current.includes(_name)) {
|
83
|
+
allNamesRef.current.push(_name);
|
84
|
+
}
|
85
|
+
return /*#__PURE__*/cloneElement(item, {
|
86
|
+
value: queryParams[_name],
|
87
|
+
onChange: function onChange(v) {
|
88
|
+
var _params = _objectSpread(_objectSpread({}, queryParamsRef.current), {}, _defineProperty({}, _name, v));
|
89
|
+
queryParamsRef.current = _params;
|
90
|
+
setQueryParams(_params);
|
91
|
+
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
92
|
+
rest[_key - 1] = arguments[_key];
|
93
|
+
}
|
94
|
+
_onChange === null || _onChange === void 0 || _onChange.apply(void 0, [v].concat(rest));
|
95
|
+
}
|
96
|
+
});
|
97
|
+
}
|
98
|
+
}
|
99
|
+
return item;
|
100
|
+
});
|
101
|
+
}
|
102
|
+
return ELs;
|
103
|
+
};
|
104
|
+
|
105
|
+
// 格式化查询参数(返回当前可见的查询项的参数集)
|
106
|
+
var formatQueryParams = function formatQueryParams() {
|
107
|
+
var _tableProps$paginatio;
|
108
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
109
|
+
var _params = tableRender || tableRender === null || (tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination) === false || tableProps !== null && tableProps !== void 0 && (_tableProps$paginatio = tableProps.pagination) !== null && _tableProps$paginatio !== void 0 && _tableProps$paginatio.hasOwnProperty('onChange') || tableProps !== null && tableProps !== void 0 && tableProps.hasOwnProperty('onChange') ? {} : {
|
110
|
+
current: params.current,
|
111
|
+
pageSize: params.pageSize
|
112
|
+
};
|
113
|
+
var fn = function fn(items) {
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
115
|
+
items && Children.map(items.props.children ? items.props.children : items, function (item) {
|
116
|
+
if (item !== null && item !== void 0 && item.props) {
|
117
|
+
var _item$props2;
|
118
|
+
var _name2 = (_item$props2 = item.props) === null || _item$props2 === void 0 ? void 0 : _item$props2.name;
|
119
|
+
if (_name2 && !item.props.hasOwnProperty('value')) {
|
120
|
+
_params[_name2] = params[_name2];
|
121
|
+
}
|
122
|
+
}
|
123
|
+
});
|
124
|
+
};
|
125
|
+
fn(queryItems);
|
126
|
+
fn(collapsibleQueryItems);
|
127
|
+
return _params;
|
128
|
+
};
|
129
|
+
|
130
|
+
// 查询
|
131
|
+
var query = function query(params) {
|
132
|
+
if (params) {
|
133
|
+
var _params = _objectSpread({}, queryParamsRef.current);
|
134
|
+
// 仅支持设置过name属性的查询项(和current、pageSize)
|
135
|
+
Object.entries(params).forEach(function (_ref) {
|
136
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
137
|
+
key = _ref2[0],
|
138
|
+
value = _ref2[1];
|
139
|
+
if (allNamesRef.current.includes(key)) {
|
140
|
+
_params[key] = value;
|
141
|
+
}
|
142
|
+
});
|
143
|
+
queryParamsRef.current = _params;
|
144
|
+
setQueryParams(_params);
|
145
|
+
onQuery === null || onQuery === void 0 || onQuery(formatQueryParams(_params));
|
146
|
+
} else {
|
147
|
+
onQuery === null || onQuery === void 0 || onQuery(formatQueryParams(queryParamsRef.current));
|
148
|
+
}
|
149
|
+
};
|
150
|
+
|
151
|
+
// 重置
|
152
|
+
var reset = function reset() {
|
153
|
+
var _params = _objectSpread({}, defaultQueryParamsRef.current);
|
154
|
+
queryParamsRef.current = _params;
|
155
|
+
setQueryParams(_params);
|
156
|
+
if (props.hasOwnProperty('onReset')) {
|
157
|
+
onReset === null || onReset === void 0 || onReset(formatQueryParams(_params));
|
158
|
+
} else {
|
159
|
+
onQuery === null || onQuery === void 0 || onQuery(formatQueryParams(_params));
|
160
|
+
}
|
161
|
+
};
|
162
|
+
|
163
|
+
// 表格分页、排序、筛选变化时触发
|
164
|
+
var tableChange = function tableChange(pagination, filters, sorter, extra) {
|
165
|
+
var _tableProps$onChange;
|
166
|
+
if (tableProps !== null && tableProps !== void 0 && tableProps.pagination && tableProps.pagination.hasOwnProperty('onChange')) return;
|
167
|
+
var current = pagination.current,
|
168
|
+
pageSize = pagination.pageSize;
|
169
|
+
var _params = _objectSpread(_objectSpread({}, queryParamsRef.current), {}, {
|
170
|
+
current: current,
|
171
|
+
pageSize: pageSize
|
172
|
+
});
|
173
|
+
queryParamsRef.current = _params;
|
174
|
+
setQueryParams(_params);
|
175
|
+
onQuery === null || onQuery === void 0 || onQuery(formatQueryParams(_params), filters, sorter, extra);
|
176
|
+
tableProps === null || tableProps === void 0 || (_tableProps$onChange = tableProps.onChange) === null || _tableProps$onChange === void 0 || _tableProps$onChange.call(tableProps, pagination, filters, sorter, extra);
|
177
|
+
};
|
178
|
+
|
179
|
+
// 设置默认查询参数
|
180
|
+
var setDefaultQueryParams = function setDefaultQueryParams() {
|
181
|
+
var _tableProps$paginatio2;
|
182
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
183
|
+
var _params = tableRender || tableRender === null || (tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination) === false || tableProps !== null && tableProps !== void 0 && (_tableProps$paginatio2 = tableProps.pagination) !== null && _tableProps$paginatio2 !== void 0 && _tableProps$paginatio2.hasOwnProperty('onChange') || tableProps !== null && tableProps !== void 0 && tableProps.hasOwnProperty('onChange') ? {} : {
|
184
|
+
current: 1,
|
185
|
+
pageSize: 20
|
186
|
+
};
|
187
|
+
Object.keys(_params).forEach(function (k) {
|
188
|
+
return !allNamesRef.current.includes(k) && allNamesRef.current.push(k);
|
189
|
+
});
|
190
|
+
// 仅支持设置过name属性的查询项(和current、pageSize)
|
191
|
+
Object.entries(params).forEach(function (_ref3) {
|
192
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
193
|
+
key = _ref4[0],
|
194
|
+
value = _ref4[1];
|
195
|
+
if (allNamesRef.current.includes(key)) {
|
196
|
+
_params[key] = value;
|
197
|
+
}
|
198
|
+
});
|
199
|
+
defaultQueryParamsRef.current = _params;
|
200
|
+
queryParamsRef.current = _params;
|
201
|
+
setQueryParams(_params);
|
202
|
+
};
|
203
|
+
|
204
|
+
// 设置单个查询项的参数
|
205
|
+
var setQueryParam = function setQueryParam(name, value) {
|
206
|
+
if (allNamesRef.current.includes(name)) {
|
207
|
+
var _params = _objectSpread(_objectSpread({}, queryParamsRef.current), {}, _defineProperty({}, name, value));
|
208
|
+
queryParamsRef.current = _params;
|
209
|
+
setQueryParams(_params);
|
210
|
+
}
|
211
|
+
};
|
212
|
+
|
213
|
+
// 获取单个查询项的参数
|
214
|
+
var getQueryParam = function getQueryParam(name) {
|
215
|
+
if (allNamesRef.current.includes(name)) {
|
216
|
+
return formatQueryParams(queryParamsRef.current)[name];
|
217
|
+
} else {
|
218
|
+
console.error("\u672A\u627E\u5230\u4E0E'".concat(name, "'\u76F8\u5173\u7684\u67E5\u8BE2\u53C2\u6570"));
|
219
|
+
}
|
220
|
+
};
|
221
|
+
|
222
|
+
// 获取所有查询项的参数
|
223
|
+
var getQueryParams = function getQueryParams() {
|
224
|
+
return formatQueryParams(queryParamsRef.current);
|
225
|
+
};
|
226
|
+
|
227
|
+
// 重置查询参数(重置为默认查询参数)
|
228
|
+
var resetQueryParams = function resetQueryParams() {
|
229
|
+
var _params = _objectSpread({}, defaultQueryParamsRef.current);
|
230
|
+
queryParamsRef.current = _params;
|
231
|
+
setQueryParams(_params);
|
232
|
+
};
|
233
|
+
|
234
|
+
// 监听immediateQuery,初始设置默认查询参数并判断是否触发首次查询
|
235
|
+
useEffect(function () {
|
236
|
+
if (!initializedRef.current) {
|
237
|
+
initializedRef.current = true;
|
238
|
+
// 初始设置默认查询参数
|
239
|
+
setDefaultQueryParams();
|
240
|
+
// 触发首次查询
|
241
|
+
if (immediateQuery) {
|
242
|
+
query();
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}, [immediateQuery]);
|
246
|
+
useImperativeHandle(ref, function () {
|
247
|
+
return {
|
248
|
+
query: query,
|
249
|
+
reset: reset,
|
250
|
+
setDefaultQueryParams: setDefaultQueryParams,
|
251
|
+
setQueryParam: setQueryParam,
|
252
|
+
getQueryParam: getQueryParam,
|
253
|
+
getQueryParams: getQueryParams,
|
254
|
+
resetQueryParams: resetQueryParams
|
255
|
+
};
|
256
|
+
});
|
257
|
+
return /*#__PURE__*/_jsx(Spin, {
|
258
|
+
style: {
|
259
|
+
maxHeight: 'none'
|
260
|
+
},
|
261
|
+
spinning: loading,
|
262
|
+
children: /*#__PURE__*/_jsxs("div", {
|
263
|
+
className: "mc-container ".concat(className || ''),
|
264
|
+
style: _objectSpread({
|
265
|
+
height: height,
|
266
|
+
backgroundColor: backgroundColor
|
267
|
+
}, style),
|
268
|
+
children: [/*#__PURE__*/_jsx("div", {
|
269
|
+
className: "mc-container__ceiling",
|
270
|
+
style: {
|
271
|
+
backgroundColor: backgroundColor
|
272
|
+
}
|
273
|
+
}), /*#__PURE__*/_jsxs("div", {
|
274
|
+
className: "mc-container__wrapper",
|
275
|
+
style: {
|
276
|
+
paddingBottom: tableRender || tableRender === null || (tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination) === false ? 24 : 64
|
277
|
+
},
|
278
|
+
children: [queryRender || queryRender === null ? queryRender : /*#__PURE__*/_jsxs("div", {
|
279
|
+
className: "mc-container__query",
|
280
|
+
children: [mapQuerys(queryItems), !collapse && mapQuerys(collapsibleQueryItems), (showQuery || showReset || showCollapse) && /*#__PURE__*/_jsxs("div", {
|
281
|
+
style: {
|
282
|
+
marginLeft: 'auto'
|
283
|
+
},
|
284
|
+
children: [showQuery && /*#__PURE__*/_jsx(Button, {
|
285
|
+
type: "primary",
|
286
|
+
onClick: function onClick() {
|
287
|
+
return query({
|
288
|
+
current: 1
|
289
|
+
});
|
290
|
+
},
|
291
|
+
children: "\u67E5\u8BE2"
|
292
|
+
}), showReset && /*#__PURE__*/_jsx(Button, {
|
293
|
+
style: {
|
294
|
+
marginLeft: 8
|
295
|
+
},
|
296
|
+
onClick: reset,
|
297
|
+
children: "\u91CD\u7F6E"
|
298
|
+
}), showCollapse && /*#__PURE__*/_jsxs(Button, {
|
299
|
+
type: "link",
|
300
|
+
style: {
|
301
|
+
marginLeft: 16,
|
302
|
+
fontSize: 12,
|
303
|
+
padding: 0
|
304
|
+
},
|
305
|
+
onClick: function onClick() {
|
306
|
+
return setCollapse(function (os) {
|
307
|
+
return !os;
|
308
|
+
});
|
309
|
+
},
|
310
|
+
children: [collapse ? '展开' : '收起', /*#__PURE__*/_jsx(DoubleLeftOutlined, {
|
311
|
+
style: {
|
312
|
+
fontSize: 12,
|
313
|
+
marginLeft: 2
|
314
|
+
},
|
315
|
+
rotate: collapse ? -90 : 90
|
316
|
+
})]
|
317
|
+
})]
|
318
|
+
})]
|
319
|
+
}), queryRender !== null && /*#__PURE__*/_jsx("div", {
|
320
|
+
className: "mc-container__divider"
|
321
|
+
}), actionBar && /*#__PURE__*/_jsx("div", {
|
322
|
+
ref: actionBarRef,
|
323
|
+
className: "mc-container__action-bar",
|
324
|
+
style: {
|
325
|
+
backgroundColor: backgroundColor
|
326
|
+
},
|
327
|
+
children: actionBar
|
328
|
+
}), batchNum > 0 && /*#__PURE__*/_jsx("div", {
|
329
|
+
className: "mc-container__batch-bar",
|
330
|
+
style: {
|
331
|
+
backgroundColor: backgroundColor,
|
332
|
+
top: actionBarHeight ? actionBarHeight - 24 : 0
|
333
|
+
},
|
334
|
+
children: /*#__PURE__*/_jsxs("div", {
|
335
|
+
className: "mc-container__batch-bar__inner",
|
336
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
337
|
+
className: "mc-container__batch-num",
|
338
|
+
children: ["\u5DF2\u9009\u62E9 ", batchNum, " \u9879"]
|
339
|
+
}), batchBtns && /*#__PURE__*/_jsx("div", {
|
340
|
+
className: "mc-container__batch-btns",
|
341
|
+
children: batchBtns
|
342
|
+
}), /*#__PURE__*/_jsx(Button, {
|
343
|
+
style: {
|
344
|
+
marginLeft: 'auto'
|
345
|
+
},
|
346
|
+
onClick: onCancel,
|
347
|
+
children: "\u53D6\u6D88"
|
348
|
+
})]
|
349
|
+
})
|
350
|
+
}), tableRender || tableRender === null ? tableRender : /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({
|
351
|
+
className: "mc-container__table",
|
352
|
+
size: "small",
|
353
|
+
sticky: {
|
354
|
+
offsetHeader: (actionBarHeight ? actionBarHeight - 24 : 0) + (batchNum > 0 ? 48 : 0)
|
355
|
+
},
|
356
|
+
scroll: {
|
357
|
+
x: (tableProps === null || tableProps === void 0 || (_tableProps$dataSourc = tableProps.dataSource) === null || _tableProps$dataSourc === void 0 ? void 0 : _tableProps$dataSourc.length) > 0 ? 'max-content' : '100%'
|
358
|
+
},
|
359
|
+
onChange: tableChange
|
360
|
+
}, tableProps), {}, {
|
361
|
+
loading: false,
|
362
|
+
pagination: (tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination) === false ? false : _objectSpread({
|
363
|
+
className: 'mc-container__pagination',
|
364
|
+
style: {
|
365
|
+
backgroundColor: backgroundColor
|
366
|
+
},
|
367
|
+
showSizeChanger: true,
|
368
|
+
showQuickJumper: true,
|
369
|
+
showTotal: function showTotal(total) {
|
370
|
+
return "\u5171 ".concat(total, " \u6761\u8BB0\u5F55");
|
371
|
+
},
|
372
|
+
current: queryParams.current,
|
373
|
+
pageSize: queryParams.pageSize
|
374
|
+
}, tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination),
|
375
|
+
expandable: _objectSpread({
|
376
|
+
expandIcon: function expandIcon(_ref5) {
|
377
|
+
var _tableProps$dataSourc2, _record$children;
|
378
|
+
var expanded = _ref5.expanded,
|
379
|
+
onExpand = _ref5.onExpand,
|
380
|
+
record = _ref5.record;
|
381
|
+
return tableProps !== null && tableProps !== void 0 && (_tableProps$dataSourc2 = tableProps.dataSource) !== null && _tableProps$dataSourc2 !== void 0 && _tableProps$dataSourc2.some(function (_ref6) {
|
382
|
+
var children = _ref6.children;
|
383
|
+
return (children === null || children === void 0 ? void 0 : children.length) > 0;
|
384
|
+
}) ? ((_record$children = record.children) === null || _record$children === void 0 ? void 0 : _record$children.length) > 0 ? /*#__PURE__*/_jsx(CaretDownFilled, {
|
385
|
+
className: "mc-container__table__expand-icon",
|
386
|
+
style: {
|
387
|
+
margin: '0 8px',
|
388
|
+
fontSize: 16
|
389
|
+
},
|
390
|
+
rotate: expanded ? 0 : -90,
|
391
|
+
onClick: function onClick(e) {
|
392
|
+
return onExpand(record, e);
|
393
|
+
}
|
394
|
+
}) : /*#__PURE__*/_jsx(CaretDownFilled, {
|
395
|
+
style: {
|
396
|
+
margin: '0 8px',
|
397
|
+
color: 'transparent'
|
398
|
+
}
|
399
|
+
}) : null;
|
400
|
+
}
|
401
|
+
}, tableProps === null || tableProps === void 0 ? void 0 : tableProps.expandable)
|
402
|
+
}))]
|
403
|
+
})]
|
404
|
+
})
|
405
|
+
});
|
406
|
+
});
|
407
|
+
export default McContainer;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/**
|
2
|
+
* title: 基础用法
|
3
|
+
* description: 除值传递方式为字符串数组外,基本使用方法和antd的<a href='https://ant-design.antgroup.com/components/date-picker-cn#components-date-picker-demo-preset-ranges' target='_blank'>DatePicker.RangePicker</a>组件使用方法一致。
|
4
|
+
*/
|
5
|
+
declare const _default: () => import("react/jsx-runtime").JSX.Element;
|
6
|
+
export default _default;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
/**
|
3
|
+
* title: 基础用法
|
4
|
+
* description: 除值传递方式为字符串数组外,基本使用方法和antd的<a href='https://ant-design.antgroup.com/components/date-picker-cn#components-date-picker-demo-preset-ranges' target='_blank'>DatePicker.RangePicker</a>组件使用方法一致。
|
5
|
+
*/
|
6
|
+
|
7
|
+
import { McDateRange } from "../..";
|
8
|
+
import { useState } from 'react';
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
export default (function () {
|
11
|
+
var _useState = useState(),
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
13
|
+
value = _useState2[0],
|
14
|
+
setValue = _useState2[1];
|
15
|
+
return /*#__PURE__*/_jsx(McDateRange, {
|
16
|
+
value: value,
|
17
|
+
style: {
|
18
|
+
width: '330px'
|
19
|
+
},
|
20
|
+
onChange: setValue
|
21
|
+
});
|
22
|
+
});
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
/**
|
3
|
+
* title: 取消当前快捷设置
|
4
|
+
* description: 通过手动取消当前组件内部自定义的时间段预设可以将组件变为为一个值传递格式为字符串数组的普通时间段选择器。
|
5
|
+
*/
|
6
|
+
|
7
|
+
import { McDateRange } from "../..";
|
8
|
+
import { useState } from 'react';
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
export default (function () {
|
11
|
+
var _useState = useState(),
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
13
|
+
value = _useState2[0],
|
14
|
+
setValue = _useState2[1];
|
15
|
+
return /*#__PURE__*/_jsx(McDateRange, {
|
16
|
+
value: value,
|
17
|
+
onChange: setValue,
|
18
|
+
style: {
|
19
|
+
width: '330px'
|
20
|
+
},
|
21
|
+
presets: false
|
22
|
+
});
|
23
|
+
});
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
/**
|
3
|
+
* title: 覆盖默认预设
|
4
|
+
* description: 因为组件本质上就是提供了常用的时间段预设,所以可以使用自定义的时间段预设对其进行覆盖。
|
5
|
+
*/
|
6
|
+
import dayjs from 'dayjs';
|
7
|
+
import { McDateRange } from "../..";
|
8
|
+
import { useState } from 'react';
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
export default (function () {
|
11
|
+
var _useState = useState(),
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
13
|
+
value = _useState2[0],
|
14
|
+
setValue = _useState2[1];
|
15
|
+
return /*#__PURE__*/_jsx(McDateRange, {
|
16
|
+
value: value,
|
17
|
+
onChange: setValue,
|
18
|
+
style: {
|
19
|
+
width: '330px'
|
20
|
+
},
|
21
|
+
presets: [{
|
22
|
+
label: 'Yesterday',
|
23
|
+
value: [dayjs().add(-1, 'd'), dayjs()]
|
24
|
+
}, {
|
25
|
+
label: 'Last Week',
|
26
|
+
value: [dayjs().add(-7, 'd'), dayjs()]
|
27
|
+
}, {
|
28
|
+
label: 'Last Month',
|
29
|
+
value: [dayjs().add(-1, 'month'), dayjs()]
|
30
|
+
}]
|
31
|
+
});
|
32
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
.mc-date-range__label {
|
2
|
+
color: #262626;
|
3
|
+
font-size: 14px;
|
4
|
+
position: absolute;
|
5
|
+
top: 0;
|
6
|
+
left: 11px;
|
7
|
+
z-index: 2;
|
8
|
+
height: 100%;
|
9
|
+
display: -webkit-box;
|
10
|
+
display: -ms-flexbox;
|
11
|
+
display: flex;
|
12
|
+
-webkit-box-align: center;
|
13
|
+
-ms-flex-align: center;
|
14
|
+
align-items: center;
|
15
|
+
}
|
16
|
+
.mc-date-range__label::after {
|
17
|
+
content: ':';
|
18
|
+
margin-left: 2px;
|
19
|
+
}
|
20
|
+
.mc-date-range__label.mc-date-range--disabled {
|
21
|
+
color: rgba(0, 0, 0, 0.25);
|
22
|
+
cursor: no-drop;
|
23
|
+
}
|
24
|
+
.mc-date-range__content {
|
25
|
+
width: 100%;
|
26
|
+
height: 100%;
|
27
|
+
}
|
28
|
+
.mc-date-range__preset-label {
|
29
|
+
margin: -1px -8px;
|
30
|
+
padding: 1px 8px;
|
31
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { RangePickerProps } from 'antd/es/date-picker';
|
2
|
+
import dayjs from 'dayjs';
|
3
|
+
import { CSSProperties, FC, ReactNode } from 'react';
|
4
|
+
import './index.less';
|
5
|
+
declare const shortcutValueMap: {
|
6
|
+
today: string[];
|
7
|
+
yesterday: string[];
|
8
|
+
last7days: string[];
|
9
|
+
last30days: string[];
|
10
|
+
last60days: string[];
|
11
|
+
last90days: string[];
|
12
|
+
};
|
13
|
+
export declare const SHORTCUTprivateValue_MAP: typeof shortcutValueMap & {
|
14
|
+
[key: string]: any;
|
15
|
+
};
|
16
|
+
export type McDateRangeProps = Omit<RangePickerProps, 'value' | 'onChange'> & {
|
17
|
+
style?: CSSProperties;
|
18
|
+
className?: string;
|
19
|
+
name?: string;
|
20
|
+
label?: ReactNode;
|
21
|
+
valueFormat?: string;
|
22
|
+
value?: string[];
|
23
|
+
onChange?: (value?: string[] | null, dayjsValue?: [dayjs.Dayjs, dayjs.Dayjs] | null) => void;
|
24
|
+
onShortcut?: (value?: 'today' | 'yesterday' | 'last7days' | 'last30days' | 'last60days' | 'last90days') => void;
|
25
|
+
[key: string]: any;
|
26
|
+
};
|
27
|
+
declare const McDateRange: FC<McDateRangeProps>;
|
28
|
+
export default McDateRange;
|