@zykj2024/much-library 1.1.7-beta.3 → 1.1.7-beta.4
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/esm/McCascader/city.js +909 -0
- package/dist/esm/McCascader/index.d.ts +19 -0
- package/dist/esm/McCascader/index.js +221 -0
- package/dist/esm/McCascader/index.less +72 -0
- package/dist/esm/McContainer/index.d.ts +192 -0
- package/dist/esm/McContainer/index.js +522 -0
- package/dist/esm/McContainer/index.less +132 -0
- package/dist/esm/McDateRange/index.d.ts +28 -0
- package/dist/esm/McDateRange/index.js +167 -0
- package/dist/esm/McDateRange/index.less +33 -0
- package/dist/esm/McEllipsis/index.d.ts +40 -0
- package/dist/esm/McEllipsis/index.js +115 -0
- package/dist/esm/McEllipsis/index.less +9 -0
- package/dist/esm/McEllipsisMiddle/index.d.ts +13 -0
- package/dist/esm/McEllipsisMiddle/index.js +42 -0
- package/dist/esm/McEllipsisMiddle/index.less +9 -0
- package/dist/esm/McFonts/index.d.ts +8 -0
- package/dist/esm/McFonts/index.js +7 -0
- package/dist/esm/McGroupPanel/comps/SelectedItem/index.d.ts +4 -0
- package/dist/esm/McGroupPanel/comps/SelectedItem/index.js +75 -0
- package/dist/esm/McGroupPanel/index.d.ts +30 -0
- package/dist/esm/McGroupPanel/index.js +426 -0
- package/dist/esm/McGroupPanel/index.less +161 -0
- package/dist/esm/McIconFont/iconfont.js +1 -0
- package/dist/esm/McIconFont/index.d.ts +5 -0
- package/dist/esm/McIconFont/index.js +8 -0
- package/dist/esm/McIcons/business.json +137 -0
- package/dist/esm/McIcons/index.less +22 -0
- package/dist/esm/McInput/Input.d.ts +19 -0
- package/dist/esm/McInput/Input.js +48 -0
- package/dist/esm/McInput/Search.d.ts +39 -0
- package/dist/esm/McInput/Search.js +81 -0
- package/dist/esm/McInput/TextArea.d.ts +11 -0
- package/dist/esm/McInput/TextArea.js +37 -0
- package/dist/esm/McInput/demo/Input/addonBefore.d.ts +3 -0
- package/dist/esm/McInput/demo/Input/addonBefore.js +67 -0
- package/dist/esm/McInput/demo/Input/base.d.ts +2 -0
- package/dist/esm/McInput/demo/Input/base.js +31 -0
- package/dist/esm/McInput/demo/Input/isTrim.d.ts +2 -0
- package/dist/esm/McInput/demo/Input/isTrim.js +22 -0
- package/dist/esm/McInput/demo/Input/label.d.ts +2 -0
- package/dist/esm/McInput/demo/Input/label.js +26 -0
- package/dist/esm/McInput/demo/Input/ref.d.ts +3 -0
- package/dist/esm/McInput/demo/Input/ref.js +53 -0
- package/dist/esm/McInput/demo/Input/status.d.ts +2 -0
- package/dist/esm/McInput/demo/Input/status.js +23 -0
- package/dist/esm/McInput/demo/Search/search-base.d.ts +2 -0
- package/dist/esm/McInput/demo/Search/search-base.js +38 -0
- package/dist/esm/McInput/demo/TextArea/text-area-base.d.ts +2 -0
- package/dist/esm/McInput/demo/TextArea/text-area-base.js +38 -0
- package/dist/esm/McInput/index.d.ts +13 -0
- package/dist/esm/McInput/index.js +7 -0
- package/dist/esm/McInput/index.less +62 -0
- package/dist/esm/McInputNumber/index.d.ts +16 -0
- package/dist/esm/McInputNumber/index.js +50 -0
- package/dist/esm/McInputNumber/index.less +18 -0
- package/dist/esm/McLazyLoader/index.d.ts +39 -0
- package/dist/esm/McLazyLoader/index.js +88 -0
- package/dist/esm/McListSelect/comps/ListSelect.d.ts +67 -0
- package/dist/esm/McListSelect/comps/ListSelect.js +289 -0
- package/dist/esm/McListSelect/comps/ListSelectPanel.d.ts +138 -0
- package/dist/esm/McListSelect/comps/ListSelectPanel.js +451 -0
- package/dist/esm/McListSelect/comps/SelectedItem.d.ts +17 -0
- package/dist/esm/McListSelect/comps/SelectedItem.js +76 -0
- package/dist/esm/McListSelect/index.d.ts +10 -0
- package/dist/esm/McListSelect/index.js +5 -0
- package/dist/esm/McListSelect/index.less +257 -0
- package/dist/esm/McModalProvider/index.d.ts +174 -0
- package/dist/esm/McModalProvider/index.js +498 -0
- package/dist/esm/McPeriodSelect/index.d.ts +13 -0
- package/dist/esm/McPeriodSelect/index.js +305 -0
- package/dist/esm/McPeriodSelect/index.less +187 -0
- package/dist/esm/McPopoverButton/index.d.ts +14 -0
- package/dist/esm/McPopoverButton/index.js +52 -0
- package/dist/esm/McPopoverForm/index.d.ts +14 -0
- package/dist/esm/McPopoverForm/index.js +95 -0
- package/dist/esm/McProSelect/index.d.ts +35 -0
- package/dist/esm/McProSelect/index.js +152 -0
- package/dist/esm/McResult/default.d.ts +1 -0
- package/dist/esm/McResult/default.js +98 -0
- package/dist/esm/McResult/icon.d.ts +25 -0
- package/dist/esm/McResult/icon.js +1014 -0
- package/dist/esm/McResult/index.d.ts +31 -0
- package/dist/esm/McResult/index.js +119 -0
- package/dist/esm/McResult/index.less +18 -0
- package/dist/esm/McResult/public/403.svg +164 -0
- package/dist/esm/McResult/public/404.svg +123 -0
- package/dist/esm/McResult/public/500.svg +129 -0
- package/dist/esm/McResult/public/building.svg +127 -0
- package/dist/esm/McResult/public/code403.svg +7 -0
- package/dist/esm/McResult/public/code404.svg +5 -0
- package/dist/esm/McResult/public/code500.svg +5 -0
- package/dist/esm/McResult/public/detailEmpty.svg +1 -0
- package/dist/esm/McResult/public/empty.svg +1 -0
- package/dist/esm/McResult/public/noFunction.svg +1 -0
- package/dist/esm/McResult/public/noUser.svg +90 -0
- package/dist/esm/McSelect/components/PanelSearchInput/index.d.ts +12 -0
- package/dist/esm/McSelect/components/PanelSearchInput/index.js +45 -0
- package/dist/esm/McSelect/components/PanelSearchInput/index.less +7 -0
- package/dist/esm/McSelect/index.d.ts +47 -0
- package/dist/esm/McSelect/index.js +436 -0
- package/dist/esm/McSelect/index.less +72 -0
- package/dist/esm/McTag/index.d.ts +22 -0
- package/dist/esm/McTag/index.js +59 -0
- package/dist/esm/McThemeConfig/customToken.json +39 -0
- package/dist/esm/McThemeConfig/globalStyle.d.ts +2 -0
- package/dist/esm/McThemeConfig/globalStyle.js +198 -0
- package/dist/esm/McThemeConfig/index.d.ts +9 -0
- package/dist/esm/McThemeConfig/index.js +16 -0
- package/dist/esm/McThemeConfig/layoutStyle.d.ts +2 -0
- package/dist/esm/McThemeConfig/layoutStyle.js +1 -0
- package/dist/esm/McThemeConfig/provider.d.ts +8 -0
- package/dist/esm/McThemeConfig/provider.js +20 -0
- package/dist/esm/McThemeConfig/themeToken.json +152 -0
- package/dist/esm/McTreePanel/SelectedItem.d.ts +4 -0
- package/dist/esm/McTreePanel/SelectedItem.js +75 -0
- package/dist/esm/McTreePanel/index.d.ts +27 -0
- package/dist/esm/McTreePanel/index.js +315 -0
- package/dist/esm/McTreePanel/index.less +106 -0
- package/dist/esm/McTreeSelect/index.d.ts +13 -0
- package/dist/esm/McTreeSelect/index.js +182 -0
- package/dist/esm/McTreeSelect/index.less +72 -0
- package/dist/esm/McUpload/comps/McFormUpload/comps/UploadForVal/index.d.ts +38 -0
- package/dist/esm/McUpload/comps/McFormUpload/comps/UploadForVal/index.js +209 -0
- package/dist/esm/McUpload/comps/McFormUpload/comps/UploadForVal/index.less +6 -0
- package/dist/esm/McUpload/comps/McFormUpload/index.d.ts +7 -0
- package/dist/esm/McUpload/comps/McFormUpload/index.js +29 -0
- package/dist/esm/McUpload/comps/McUploadCmp/index.d.ts +49 -0
- package/dist/esm/McUpload/comps/McUploadCmp/index.js +396 -0
- package/dist/esm/McUpload/comps/McUploadCmp/index.less +68 -0
- package/dist/esm/McUpload/comps/McUploadDragger/index.d.ts +49 -0
- package/dist/esm/McUpload/comps/McUploadDragger/index.js +264 -0
- package/dist/esm/McUpload/comps/McUploadTrigger/index.d.ts +39 -0
- package/dist/esm/McUpload/comps/McUploadTrigger/index.js +318 -0
- package/dist/esm/McUpload/comps/McUploadTrigger/index.less +204 -0
- package/dist/esm/McUpload/index.d.ts +14 -0
- package/dist/esm/McUpload/index.js +9 -0
- package/dist/esm/McUpload/tools/calculateMD5/index.d.ts +3 -0
- package/dist/esm/McUpload/tools/calculateMD5/index.js +94 -0
- package/dist/esm/McUpload/tools/calculateMD5/md5Worker.js +44 -0
- package/dist/esm/McUpload/tools/getUid.d.ts +1 -0
- package/dist/esm/McUpload/tools/getUid.js +6 -0
- package/dist/esm/McUpload/tools/materialVerification.d.ts +50 -0
- package/dist/esm/McUpload/tools/materialVerification.js +257 -0
- package/dist/esm/McUpload/tools/uploadTools.d.ts +5 -0
- package/dist/esm/McUpload/tools/uploadTools.js +56 -0
- package/dist/esm/Utils/index.d.ts +8 -0
- package/dist/esm/Utils/index.js +9 -0
- package/dist/esm/Utils/lib/Queue/PriorityQueue.d.ts +21 -0
- package/dist/esm/Utils/lib/Queue/PriorityQueue.js +197 -0
- package/dist/esm/Utils/lib/Queue/TaskQueue.d.ts +17 -0
- package/dist/esm/Utils/lib/Queue/TaskQueue.js +199 -0
- package/dist/esm/Utils/lib/Queue/tools/BinaryHeap.d.ts +25 -0
- package/dist/esm/Utils/lib/Queue/tools/BinaryHeap.js +184 -0
- package/dist/esm/Utils/lib/Queue/tools/publicDependencyMethod.d.ts +6 -0
- package/dist/esm/Utils/lib/Queue/tools/publicDependencyMethod.js +26 -0
- package/dist/esm/Utils/lib/Queue/types/baseTaskQueue.d.ts +23 -0
- package/dist/esm/Utils/lib/Queue/types/baseTaskQueue.js +10 -0
- package/dist/esm/Utils/lib/copyToClipboard.d.ts +8 -0
- package/dist/esm/Utils/lib/copyToClipboard.js +54 -0
- package/dist/esm/index.d.ts +34 -0
- package/dist/esm/index.js +33 -0
- package/dist/esm/styles/index.less +2 -0
- package/dist/esm/styles/mixins.less +52 -0
- package/dist/esm/styles/utilities.less +51 -0
- package/dist/esm/typings.d.ts +20 -0
- package/package.json +4 -3
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* title: 基本使用
|
3
|
+
* description: 设置 `enterButton` 使 搜索按钮 为主按钮样式。注意:addonAfter、suffix、onPressEnter 失效不可用
|
4
|
+
*/
|
5
|
+
import { McInput } from "../../..";
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
8
|
+
export default (function () {
|
9
|
+
return /*#__PURE__*/_jsxs("div", {
|
10
|
+
style: {
|
11
|
+
display: 'flex',
|
12
|
+
flexDirection: 'column',
|
13
|
+
gap: 8
|
14
|
+
},
|
15
|
+
children: [/*#__PURE__*/_jsx(McInput.Search, {
|
16
|
+
loading: true,
|
17
|
+
placeholder: "\u57FA\u672C\u4F7F\u7528",
|
18
|
+
count: {
|
19
|
+
show: true,
|
20
|
+
max: 10
|
21
|
+
}
|
22
|
+
}), /*#__PURE__*/_jsx(McInput.Search, {
|
23
|
+
placeholder: "\u57FA\u672C\u4F7F\u7528"
|
24
|
+
}), /*#__PURE__*/_jsx(McInput.Search, {
|
25
|
+
enterButton: true,
|
26
|
+
placeholder: "\u57FA\u672C\u4F7F\u7528",
|
27
|
+
style: {
|
28
|
+
width: 300
|
29
|
+
}
|
30
|
+
}), /*#__PURE__*/_jsx(McInput.Search, {
|
31
|
+
enterButton: "\u641C\u7D22",
|
32
|
+
placeholder: "\u57FA\u672C\u4F7F\u7528",
|
33
|
+
style: {
|
34
|
+
width: 300
|
35
|
+
}
|
36
|
+
})]
|
37
|
+
});
|
38
|
+
});
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* title: 基本使用
|
3
|
+
* description: 支持两种方式的限制最大数字多行文本框,
|
4
|
+
*/
|
5
|
+
import { McInput } from "../../..";
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
8
|
+
export default (function () {
|
9
|
+
return /*#__PURE__*/_jsxs("div", {
|
10
|
+
style: {
|
11
|
+
display: 'flex',
|
12
|
+
flexDirection: 'column',
|
13
|
+
gap: 8
|
14
|
+
},
|
15
|
+
children: [/*#__PURE__*/_jsx(McInput.TextArea, {
|
16
|
+
placeholder: "\u57FA\u672C\u4F7F\u7528\uFF0C\u4E0D\u4F1A\u6839\u636E\u5185\u5BB9\u53D8\u5316\u9AD8\u5EA6"
|
17
|
+
}), /*#__PURE__*/_jsx(McInput.TextArea, {
|
18
|
+
placeholder: "\u7B2C\u4E00\u79CD\u9650\u5236\u5B57\u6570\u65B9\u5F0F",
|
19
|
+
maxLength: 100,
|
20
|
+
showCount: true
|
21
|
+
}), /*#__PURE__*/_jsx(McInput.TextArea, {
|
22
|
+
placeholder: "\u7B2C\u4E8C\u79CD\u9650\u5236\u5B57\u6570\u65B9\u5F0F",
|
23
|
+
count: {
|
24
|
+
show: true,
|
25
|
+
max: 10
|
26
|
+
}
|
27
|
+
}), /*#__PURE__*/_jsx(McInput.TextArea, {
|
28
|
+
placeholder: "\u6839\u636E\u5185\u5BB9\u53D8\u5316\u9AD8\u5EA6",
|
29
|
+
autoSize: true
|
30
|
+
}), /*#__PURE__*/_jsx(McInput.TextArea, {
|
31
|
+
placeholder: "\u6700\u5C0F\u9AD8\u5EA6\u4E3A1\u884C\uFF0C\u6700\u5927\u9AD8\u5EA6\u4E3A5\u884C",
|
32
|
+
autoSize: {
|
33
|
+
minRows: 1,
|
34
|
+
maxRows: 5
|
35
|
+
}
|
36
|
+
})]
|
37
|
+
});
|
38
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
2
|
+
import type { InputRef, McInputProps } from './Input';
|
3
|
+
import Search from './Search';
|
4
|
+
import TextArea from './TextArea';
|
5
|
+
export type { InputRef, McInputProps } from './Input';
|
6
|
+
export type { McSearchProps } from './Search';
|
7
|
+
export type { McTextAreaProps } from './TextArea';
|
8
|
+
type CompoundedComponent = ForwardRefExoticComponent<McInputProps & RefAttributes<InputRef>> & {
|
9
|
+
Search: typeof Search;
|
10
|
+
TextArea: typeof TextArea;
|
11
|
+
};
|
12
|
+
declare const McInput: CompoundedComponent;
|
13
|
+
export default McInput;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
@import '../styles/mixins.less';
|
2
|
+
|
3
|
+
.mc-input,
|
4
|
+
.mc-search {
|
5
|
+
.ant-input-suffix .ant-input-show-count-suffix {
|
6
|
+
color: #b3b3b3;
|
7
|
+
font-size: 12px;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
.mc-input__label {
|
12
|
+
color: #262626;
|
13
|
+
font-size: 14px;
|
14
|
+
margin-right: -4px;
|
15
|
+
|
16
|
+
&::after {
|
17
|
+
content: '\FF1A';
|
18
|
+
margin-left: 2px;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
.mc-search {
|
23
|
+
width: 280px;
|
24
|
+
|
25
|
+
.mc-search__icon {
|
26
|
+
width: auto;
|
27
|
+
height: 22px;
|
28
|
+
padding: 0;
|
29
|
+
color: #8c8c8c;
|
30
|
+
}
|
31
|
+
|
32
|
+
.ant-input-affix-wrapper + .ant-input-group-addon {
|
33
|
+
inset-inline-start: -1px;
|
34
|
+
padding: 0;
|
35
|
+
border: 0;
|
36
|
+
|
37
|
+
.mc-search__button {
|
38
|
+
width: auto;
|
39
|
+
border-radius: 0 4px 4px 0;
|
40
|
+
padding: 0 12px;
|
41
|
+
margin-right: -1px;
|
42
|
+
z-index: 1;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
.mc-textarea .ant-input-suffix {
|
48
|
+
.ant-input-clear-icon {
|
49
|
+
z-index: 1;
|
50
|
+
}
|
51
|
+
|
52
|
+
.ant-input-data-count {
|
53
|
+
bottom: 0;
|
54
|
+
right: 11px;
|
55
|
+
color: #b3b3b3;
|
56
|
+
font-size: 12px;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
.mc-input .ant-input-wrapper .ant-input-group-addon {
|
61
|
+
.input-vertical-line();
|
62
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { InputNumberProps } from 'antd';
|
2
|
+
import { FC, ReactNode } from 'react';
|
3
|
+
import './index.less';
|
4
|
+
type McInputNumberProps = Omit<InputNumberProps, 'precision' | 'value' | 'onChange'> & {
|
5
|
+
/** 查询项的字段名(配合McContainer组件的查询功能使用) */
|
6
|
+
name?: string;
|
7
|
+
/** 查询项的标签文字(若未设置,样式为表单项形态) */
|
8
|
+
label?: ReactNode;
|
9
|
+
/** 最多保留多少位小数,默认0 */
|
10
|
+
precision?: number;
|
11
|
+
value?: number | null;
|
12
|
+
onChange?: (value?: number | null) => void;
|
13
|
+
[key: string]: any;
|
14
|
+
};
|
15
|
+
declare const McInputNumber: FC<McInputNumberProps>;
|
16
|
+
export default McInputNumber;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
4
|
+
var _excluded = ["label", "precision", "value", "onChange", "className"];
|
5
|
+
import { InputNumber } from 'antd';
|
6
|
+
import NP from 'number-precision';
|
7
|
+
import { forwardRef, useEffect, useState } from 'react';
|
8
|
+
import "./index.less";
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
var McInputNumber = /*#__PURE__*/forwardRef(function (props, ref) {
|
11
|
+
var label = props.label,
|
12
|
+
_props$precision = props.precision,
|
13
|
+
precision = _props$precision === void 0 ? 0 : _props$precision,
|
14
|
+
value = props.value,
|
15
|
+
onChange = props.onChange,
|
16
|
+
className = props.className,
|
17
|
+
rest = _objectWithoutProperties(props, _excluded);
|
18
|
+
var _useState = useState(null),
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
20
|
+
inputNumberValue = _useState2[0],
|
21
|
+
setInputNumberValue = _useState2[1];
|
22
|
+
useEffect(function () {
|
23
|
+
setInputNumberValue(typeof value === 'number' ? value : null);
|
24
|
+
}, [value]);
|
25
|
+
var handleChange = function handleChange(v) {
|
26
|
+
var formattedValue = null;
|
27
|
+
if (v !== null && v !== '') {
|
28
|
+
var num = typeof v === 'string' ? parseFloat(v) : v;
|
29
|
+
if (!isNaN(num)) {
|
30
|
+
formattedValue = NP.round(num, precision);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
if (!props.hasOwnProperty('value')) {
|
34
|
+
setInputNumberValue(formattedValue);
|
35
|
+
}
|
36
|
+
onChange === null || onChange === void 0 || onChange(formattedValue);
|
37
|
+
};
|
38
|
+
return /*#__PURE__*/_jsx(InputNumber, _objectSpread({
|
39
|
+
ref: ref,
|
40
|
+
className: "mc-input-number ".concat(className || ''),
|
41
|
+
prefix: label && /*#__PURE__*/_jsx("span", {
|
42
|
+
className: "mc-input-number__label",
|
43
|
+
children: label
|
44
|
+
}),
|
45
|
+
value: inputNumberValue,
|
46
|
+
onChange: handleChange,
|
47
|
+
placeholder: "\u8BF7\u8F93\u5165"
|
48
|
+
}, rest));
|
49
|
+
});
|
50
|
+
export default McInputNumber;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
@import '../styles/mixins.less';
|
2
|
+
|
3
|
+
.mc-input-number {
|
4
|
+
&__label {
|
5
|
+
color: #262626;
|
6
|
+
font-size: 14px;
|
7
|
+
margin-right: -4px;
|
8
|
+
|
9
|
+
&::after {
|
10
|
+
content: '\FF1A';
|
11
|
+
margin-left: 2px;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
.ant-input-number-wrapper .ant-input-number-group-addon {
|
16
|
+
.input-vertical-line();
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
interface ObserverInsertionWrapperProps {
|
3
|
+
children: React.ReactNode[];
|
4
|
+
/**
|
5
|
+
* @description 最小高度,不能为0。为0时懒加载可能会无效
|
6
|
+
* @default 20
|
7
|
+
*/
|
8
|
+
itemMinHeight: number;
|
9
|
+
/**
|
10
|
+
* @description 最小宽度,水平排列时不能为0
|
11
|
+
* @default unset
|
12
|
+
*/
|
13
|
+
itemMinWidth?: number;
|
14
|
+
/**
|
15
|
+
* @description 元素进入视图回调
|
16
|
+
*/
|
17
|
+
onItemVisible?: (index: number, key: string) => void;
|
18
|
+
/**
|
19
|
+
* @description 距离视图多少像素时触发。出于用户体验考虑,建议设置一个正数
|
20
|
+
* @default 0
|
21
|
+
*/
|
22
|
+
offset?: number;
|
23
|
+
/**
|
24
|
+
* @description 重叠比例为多少时触发
|
25
|
+
* @default 0
|
26
|
+
*/
|
27
|
+
threshold?: number;
|
28
|
+
/**
|
29
|
+
* @description 监听的根元素,不传则监听浏览器窗口
|
30
|
+
* @default null
|
31
|
+
*/
|
32
|
+
root?: Element | Document | null;
|
33
|
+
/**
|
34
|
+
* @description 外层容器样式
|
35
|
+
*/
|
36
|
+
style?: React.CSSProperties;
|
37
|
+
}
|
38
|
+
declare const ObserverInsertionWrapper: React.FC<ObserverInsertionWrapperProps>;
|
39
|
+
export default ObserverInsertionWrapper;
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
+
var getKey = function getKey(child, index) {
|
5
|
+
var _child$key;
|
6
|
+
return /*#__PURE__*/React.isValidElement(child) ? String((_child$key = child.key) !== null && _child$key !== void 0 ? _child$key : index) : String(index);
|
7
|
+
};
|
8
|
+
var ObserverInsertionWrapper = function ObserverInsertionWrapper(_ref) {
|
9
|
+
var children = _ref.children,
|
10
|
+
style = _ref.style,
|
11
|
+
_ref$offset = _ref.offset,
|
12
|
+
offset = _ref$offset === void 0 ? 0 : _ref$offset,
|
13
|
+
_ref$threshold = _ref.threshold,
|
14
|
+
threshold = _ref$threshold === void 0 ? 0 : _ref$threshold,
|
15
|
+
_ref$root = _ref.root,
|
16
|
+
root = _ref$root === void 0 ? null : _ref$root,
|
17
|
+
_ref$itemMinHeight = _ref.itemMinHeight,
|
18
|
+
itemMinHeight = _ref$itemMinHeight === void 0 ? 20 : _ref$itemMinHeight,
|
19
|
+
itemMinWidth = _ref.itemMinWidth,
|
20
|
+
onItemVisible = _ref.onItemVisible;
|
21
|
+
var wrapperRef = useRef(null);
|
22
|
+
|
23
|
+
// 已经显示过的 key 列表
|
24
|
+
var _useState = useState(new Set()),
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
26
|
+
visibleItems = _useState2[0],
|
27
|
+
setVisibleItems = _useState2[1];
|
28
|
+
|
29
|
+
// 为避免 children 每次渲染变化导致 useEffect 重复执行,构建一个 keyList 哈希
|
30
|
+
var keyListHash = useMemo(function () {
|
31
|
+
var list = React.Children.toArray(children).map(function (child, index) {
|
32
|
+
return getKey(child, index);
|
33
|
+
});
|
34
|
+
return JSON.stringify(list);
|
35
|
+
}, [children]);
|
36
|
+
|
37
|
+
// 每次 keyList 变动重置显示列表
|
38
|
+
useEffect(function () {
|
39
|
+
setVisibleItems(new Set());
|
40
|
+
}, [keyListHash]);
|
41
|
+
useEffect(function () {
|
42
|
+
var _wrapperRef$current;
|
43
|
+
var observer = new IntersectionObserver(function (entries) {
|
44
|
+
entries.forEach(function (entry) {
|
45
|
+
var index = Number(entry.target.getAttribute('data-index'));
|
46
|
+
var key = String(entry.target.getAttribute('data-key'));
|
47
|
+
if (entry.isIntersecting && !visibleItems.has(key)) {
|
48
|
+
setVisibleItems(function (prev) {
|
49
|
+
var next = new Set(prev);
|
50
|
+
next.add(key);
|
51
|
+
onItemVisible === null || onItemVisible === void 0 || onItemVisible(index, key);
|
52
|
+
return next;
|
53
|
+
});
|
54
|
+
}
|
55
|
+
});
|
56
|
+
}, {
|
57
|
+
root: root,
|
58
|
+
rootMargin: "".concat(offset, "px"),
|
59
|
+
threshold: threshold
|
60
|
+
});
|
61
|
+
var elements = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.children;
|
62
|
+
elements && Array.from(elements).forEach(function (element) {
|
63
|
+
observer.observe(element);
|
64
|
+
});
|
65
|
+
return function () {
|
66
|
+
elements && Array.from(elements).forEach(function (element) {
|
67
|
+
observer.unobserve(element);
|
68
|
+
});
|
69
|
+
};
|
70
|
+
}, [offset, threshold, root, keyListHash, visibleItems]);
|
71
|
+
return /*#__PURE__*/_jsx("div", {
|
72
|
+
ref: wrapperRef,
|
73
|
+
style: style,
|
74
|
+
children: React.Children.map(children, function (child, index) {
|
75
|
+
var key = getKey(child, index);
|
76
|
+
return /*#__PURE__*/_jsx("div", {
|
77
|
+
"data-key": key,
|
78
|
+
"data-index": index,
|
79
|
+
style: {
|
80
|
+
minHeight: itemMinHeight,
|
81
|
+
minWidth: itemMinWidth !== null && itemMinWidth !== void 0 ? itemMinWidth : 'unset'
|
82
|
+
},
|
83
|
+
children: visibleItems.has(key) ? child : null
|
84
|
+
}, key);
|
85
|
+
})
|
86
|
+
});
|
87
|
+
};
|
88
|
+
export default ObserverInsertionWrapper;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { FC } from 'react';
|
2
|
+
import '../index.less';
|
3
|
+
import { McListSelectPanelProps } from './ListSelectPanel';
|
4
|
+
/**
|
5
|
+
* @author: wangzt
|
6
|
+
* @description: 下拉列表选择器-仅支持多选
|
7
|
+
*/
|
8
|
+
interface Inexistent {
|
9
|
+
/**
|
10
|
+
* 不存在值的文字描述
|
11
|
+
* @defaultValue '不存在'
|
12
|
+
*/
|
13
|
+
text?: string;
|
14
|
+
/**
|
15
|
+
* 不存在值的文字颜色
|
16
|
+
* @defaultValue '#ff4d4f'
|
17
|
+
*/
|
18
|
+
color?: string;
|
19
|
+
/**
|
20
|
+
* 是否保留原值
|
21
|
+
* @remarks 若为 true,则在执行不存在值的处理逻辑时,不向外抛出 undefined
|
22
|
+
* @defaultValue false
|
23
|
+
*/
|
24
|
+
reserveOriginalValue?: boolean;
|
25
|
+
}
|
26
|
+
export type McListSelectProps = Omit<McListSelectPanelProps, 'PanelInexistent'> & {
|
27
|
+
/**
|
28
|
+
* 查询项的字段名
|
29
|
+
* @remarks 配合 McContainer 组件的查询功能使用
|
30
|
+
*/
|
31
|
+
name?: string;
|
32
|
+
/**
|
33
|
+
* 查询项的标签文字
|
34
|
+
* @remarks 若未设置,样式为表单项形态
|
35
|
+
*/
|
36
|
+
label?: React.ReactNode;
|
37
|
+
/**
|
38
|
+
* 选择框默认文本
|
39
|
+
* @defaultValue '请选择'
|
40
|
+
*/
|
41
|
+
placeholder?: string;
|
42
|
+
/**
|
43
|
+
* 最多显示多少个 tag
|
44
|
+
* @remarks 响应式模式会对性能产生损耗
|
45
|
+
* @defaultValue 1
|
46
|
+
*/
|
47
|
+
maxTagCount?: number | 'responsive';
|
48
|
+
/**
|
49
|
+
* 是否每次展开下拉菜单时都初始化(重置查询)
|
50
|
+
* @defaultValue true
|
51
|
+
*/
|
52
|
+
initOnOpen?: boolean;
|
53
|
+
/**
|
54
|
+
* 是否执行不存在值的处理逻辑
|
55
|
+
* @remarks
|
56
|
+
* - 异步查询时无效
|
57
|
+
* - 为保证该属性的相关功能生效,options 无数据的情况下请配置为空数组 []
|
58
|
+
* @defaultValue false
|
59
|
+
*/
|
60
|
+
inexistent?: boolean | Inexistent;
|
61
|
+
};
|
62
|
+
export type McListSelectRef = {
|
63
|
+
/** 初始化方法(显示下拉菜单并重置查询) */
|
64
|
+
init: () => void;
|
65
|
+
};
|
66
|
+
declare const McListSelect: FC<McListSelectProps>;
|
67
|
+
export default McListSelect;
|