@zykj2024/much-library 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/dist/McCascader/city.js +909 -0
  4. package/dist/McCascader/index.css +60 -0
  5. package/dist/McCascader/index.d.ts +19 -0
  6. package/dist/McCascader/index.js +221 -0
  7. package/dist/McContainer/demo/actionBar.d.ts +8 -0
  8. package/dist/McContainer/demo/actionBar.js +70 -0
  9. package/dist/McContainer/demo/base.d.ts +8 -0
  10. package/dist/McContainer/demo/base.js +80 -0
  11. package/dist/McContainer/demo/batch.d.ts +8 -0
  12. package/dist/McContainer/demo/batch.js +89 -0
  13. package/dist/McContainer/demo/collapse.d.ts +8 -0
  14. package/dist/McContainer/demo/collapse.js +76 -0
  15. package/dist/McContainer/demo/expand.d.ts +8 -0
  16. package/dist/McContainer/demo/expand.js +90 -0
  17. package/dist/McContainer/demo/pagination.d.ts +7 -0
  18. package/dist/McContainer/demo/pagination.js +93 -0
  19. package/dist/McContainer/demo/search.d.ts +7 -0
  20. package/dist/McContainer/demo/search.js +101 -0
  21. package/dist/McContainer/demo/standard.d.ts +7 -0
  22. package/dist/McContainer/demo/standard.js +168 -0
  23. package/dist/McContainer/index.css +123 -0
  24. package/dist/McContainer/index.d.ts +49 -0
  25. package/dist/McContainer/index.js +407 -0
  26. package/dist/McDateRange/demo/base.d.ts +6 -0
  27. package/dist/McDateRange/demo/base.js +22 -0
  28. package/dist/McDateRange/demo/cancelPresets.d.ts +6 -0
  29. package/dist/McDateRange/demo/cancelPresets.js +23 -0
  30. package/dist/McDateRange/demo/overlap.d.ts +2 -0
  31. package/dist/McDateRange/demo/overlap.js +32 -0
  32. package/dist/McDateRange/index.css +31 -0
  33. package/dist/McDateRange/index.d.ts +28 -0
  34. package/dist/McDateRange/index.js +167 -0
  35. package/dist/McFonts/index.d.ts +7 -0
  36. package/dist/McFonts/index.js +10 -0
  37. package/dist/McFonts/public/FF DIN Pro Bold.otf +0 -0
  38. package/dist/McFonts/public/SourceHanSansCN-Bold.otf +0 -0
  39. package/dist/McFonts/public/SourceHanSansCN-Light.otf +0 -0
  40. package/dist/McFonts/public/SourceHanSansCN-Medium.otf +0 -0
  41. package/dist/McFonts/public/SourceHanSansCN-Regular.otf +0 -0
  42. package/dist/McGroupPanel/comps/SelectedItem/index.d.ts +4 -0
  43. package/dist/McGroupPanel/comps/SelectedItem/index.js +76 -0
  44. package/dist/McGroupPanel/index.css +162 -0
  45. package/dist/McGroupPanel/index.d.ts +29 -0
  46. package/dist/McGroupPanel/index.js +411 -0
  47. package/dist/McIconFont/iconfont.js +1 -0
  48. package/dist/McIconFont/index.d.ts +5 -0
  49. package/dist/McIconFont/index.js +8 -0
  50. package/dist/McIcons/business.json +137 -0
  51. package/dist/McInput/Input.d.ts +19 -0
  52. package/dist/McInput/Input.js +48 -0
  53. package/dist/McInput/Search.d.ts +39 -0
  54. package/dist/McInput/Search.js +81 -0
  55. package/dist/McInput/TextArea.d.ts +11 -0
  56. package/dist/McInput/TextArea.js +37 -0
  57. package/dist/McInput/demo/Input/addonBefore.d.ts +3 -0
  58. package/dist/McInput/demo/Input/addonBefore.js +67 -0
  59. package/dist/McInput/demo/Input/base.d.ts +2 -0
  60. package/dist/McInput/demo/Input/base.js +31 -0
  61. package/dist/McInput/demo/Input/isTrim.d.ts +2 -0
  62. package/dist/McInput/demo/Input/isTrim.js +22 -0
  63. package/dist/McInput/demo/Input/label.d.ts +2 -0
  64. package/dist/McInput/demo/Input/label.js +26 -0
  65. package/dist/McInput/demo/Input/ref.d.ts +3 -0
  66. package/dist/McInput/demo/Input/ref.js +53 -0
  67. package/dist/McInput/demo/Input/status.d.ts +2 -0
  68. package/dist/McInput/demo/Input/status.js +23 -0
  69. package/dist/McInput/demo/Search/search-base.d.ts +2 -0
  70. package/dist/McInput/demo/Search/search-base.js +38 -0
  71. package/dist/McInput/demo/TextArea/text-area-base.d.ts +2 -0
  72. package/dist/McInput/demo/TextArea/text-area-base.js +38 -0
  73. package/dist/McInput/index.css +44 -0
  74. package/dist/McInput/index.d.ts +13 -0
  75. package/dist/McInput/index.js +7 -0
  76. package/dist/McInputNumber/demo/index.d.ts +2 -0
  77. package/dist/McInputNumber/demo/index.js +28 -0
  78. package/dist/McInputNumber/demo/label.d.ts +2 -0
  79. package/dist/McInputNumber/demo/label.js +26 -0
  80. package/dist/McInputNumber/demo/precision.d.ts +2 -0
  81. package/dist/McInputNumber/demo/precision.js +20 -0
  82. package/dist/McInputNumber/index.css +9 -0
  83. package/dist/McInputNumber/index.d.ts +13 -0
  84. package/dist/McInputNumber/index.js +43 -0
  85. package/dist/McModalProvider/index.d.ts +174 -0
  86. package/dist/McModalProvider/index.js +498 -0
  87. package/dist/McPeriodSelect/demo/base.d.ts +6 -0
  88. package/dist/McPeriodSelect/demo/base.js +19 -0
  89. package/dist/McPeriodSelect/demo/half.d.ts +6 -0
  90. package/dist/McPeriodSelect/demo/half.js +20 -0
  91. package/dist/McPeriodSelect/index.css +189 -0
  92. package/dist/McPeriodSelect/index.d.ts +13 -0
  93. package/dist/McPeriodSelect/index.js +305 -0
  94. package/dist/McPopoverButton/index.d.ts +14 -0
  95. package/dist/McPopoverButton/index.js +52 -0
  96. package/dist/McPopoverForm/index.d.ts +14 -0
  97. package/dist/McPopoverForm/index.js +95 -0
  98. package/dist/McResult/default.d.ts +1 -0
  99. package/dist/McResult/default.js +84 -0
  100. package/dist/McResult/demo/403.d.ts +6 -0
  101. package/dist/McResult/demo/403.js +17 -0
  102. package/dist/McResult/demo/404.d.ts +6 -0
  103. package/dist/McResult/demo/404.js +17 -0
  104. package/dist/McResult/demo/500.d.ts +6 -0
  105. package/dist/McResult/demo/500.js +17 -0
  106. package/dist/McResult/demo/building.d.ts +6 -0
  107. package/dist/McResult/demo/building.js +12 -0
  108. package/dist/McResult/demo/empty.d.ts +2 -0
  109. package/dist/McResult/demo/empty.js +11 -0
  110. package/dist/McResult/demo/noFunction.d.ts +2 -0
  111. package/dist/McResult/demo/noFunction.js +11 -0
  112. package/dist/McResult/demo/noUser.d.ts +6 -0
  113. package/dist/McResult/demo/noUser.js +12 -0
  114. package/dist/McResult/demo/preview.d.ts +2 -0
  115. package/dist/McResult/demo/preview.js +14 -0
  116. package/dist/McResult/icon.d.ts +25 -0
  117. package/dist/McResult/icon.js +946 -0
  118. package/dist/McResult/index.css +20 -0
  119. package/dist/McResult/index.d.ts +27 -0
  120. package/dist/McResult/index.js +103 -0
  121. package/dist/McResult/public/403.svg +164 -0
  122. package/dist/McResult/public/404.svg +123 -0
  123. package/dist/McResult/public/500.svg +129 -0
  124. package/dist/McResult/public/building.svg +127 -0
  125. package/dist/McResult/public/code403.svg +7 -0
  126. package/dist/McResult/public/code404.svg +5 -0
  127. package/dist/McResult/public/code500.svg +5 -0
  128. package/dist/McResult/public/empty.svg +1 -0
  129. package/dist/McResult/public/noFunction.svg +1 -0
  130. package/dist/McResult/public/noUser.svg +90 -0
  131. package/dist/McSelect/demo/base.d.ts +2 -0
  132. package/dist/McSelect/demo/base.js +63 -0
  133. package/dist/McSelect/demo/changeOnHidden.d.ts +2 -0
  134. package/dist/McSelect/demo/changeOnHidden.js +43 -0
  135. package/dist/McSelect/demo/dropdownRender.d.ts +7 -0
  136. package/dist/McSelect/demo/dropdownRender.js +78 -0
  137. package/dist/McSelect/demo/fetchOptions.d.ts +7 -0
  138. package/dist/McSelect/demo/fetchOptions.js +210 -0
  139. package/dist/McSelect/demo/inexistent.d.ts +2 -0
  140. package/dist/McSelect/demo/inexistent.js +79 -0
  141. package/dist/McSelect/demo/labelInValue.d.ts +2 -0
  142. package/dist/McSelect/demo/labelInValue.js +72 -0
  143. package/dist/McSelect/demo/maxTagCount.d.ts +3 -0
  144. package/dist/McSelect/demo/maxTagCount.js +51 -0
  145. package/dist/McSelect/demo/multiple.d.ts +2 -0
  146. package/dist/McSelect/demo/multiple.js +46 -0
  147. package/dist/McSelect/demo/optionRender.d.ts +3 -0
  148. package/dist/McSelect/demo/optionRender.js +51 -0
  149. package/dist/McSelect/demo/tagRender.d.ts +3 -0
  150. package/dist/McSelect/demo/tagRender.js +51 -0
  151. package/dist/McSelect/index.css +60 -0
  152. package/dist/McSelect/index.d.ts +40 -0
  153. package/dist/McSelect/index.js +350 -0
  154. package/dist/McThemeConfig/customToken.json +38 -0
  155. package/dist/McThemeConfig/demo/button.d.ts +2 -0
  156. package/dist/McThemeConfig/demo/button.js +226 -0
  157. package/dist/McThemeConfig/demo/drawer.d.ts +2 -0
  158. package/dist/McThemeConfig/demo/drawer.js +59 -0
  159. package/dist/McThemeConfig/demo/modal.d.ts +2 -0
  160. package/dist/McThemeConfig/demo/modal.js +78 -0
  161. package/dist/McThemeConfig/demo/radio.d.ts +2 -0
  162. package/dist/McThemeConfig/demo/radio.js +97 -0
  163. package/dist/McThemeConfig/demo/switch.d.ts +2 -0
  164. package/dist/McThemeConfig/demo/switch.js +96 -0
  165. package/dist/McThemeConfig/demo/tabs.d.ts +2 -0
  166. package/dist/McThemeConfig/demo/tabs.js +35 -0
  167. package/dist/McThemeConfig/globalStyle.d.ts +2 -0
  168. package/dist/McThemeConfig/globalStyle.js +172 -0
  169. package/dist/McThemeConfig/index.d.ts +9 -0
  170. package/dist/McThemeConfig/index.js +16 -0
  171. package/dist/McThemeConfig/layoutStyle.d.ts +2 -0
  172. package/dist/McThemeConfig/layoutStyle.js +1 -0
  173. package/dist/McThemeConfig/provider.d.ts +7 -0
  174. package/dist/McThemeConfig/provider.js +19 -0
  175. package/dist/McThemeConfig/themeToken.json +149 -0
  176. package/dist/McTreePanel/SelectedItem.d.ts +4 -0
  177. package/dist/McTreePanel/SelectedItem.js +75 -0
  178. package/dist/McTreePanel/demo/base.d.ts +6 -0
  179. package/dist/McTreePanel/demo/base.js +45 -0
  180. package/dist/McTreePanel/demo/fieldNames.d.ts +6 -0
  181. package/dist/McTreePanel/demo/fieldNames.js +37 -0
  182. package/dist/McTreePanel/demo/inexistent.d.ts +6 -0
  183. package/dist/McTreePanel/demo/inexistent.js +56 -0
  184. package/dist/McTreePanel/demo/labelInValue.d.ts +6 -0
  185. package/dist/McTreePanel/demo/labelInValue.js +56 -0
  186. package/dist/McTreePanel/demo/sortable.d.ts +6 -0
  187. package/dist/McTreePanel/demo/sortable.js +34 -0
  188. package/dist/McTreePanel/index.css +110 -0
  189. package/dist/McTreePanel/index.d.ts +27 -0
  190. package/dist/McTreePanel/index.js +315 -0
  191. package/dist/McTreeSelect/demo/base.d.ts +5 -0
  192. package/dist/McTreeSelect/demo/base.js +58 -0
  193. package/dist/McTreeSelect/demo/inexistent.d.ts +5 -0
  194. package/dist/McTreeSelect/demo/inexistent.js +63 -0
  195. package/dist/McTreeSelect/demo/label.d.ts +5 -0
  196. package/dist/McTreeSelect/demo/label.js +60 -0
  197. package/dist/McTreeSelect/demo/multiple.d.ts +5 -0
  198. package/dist/McTreeSelect/demo/multiple.js +71 -0
  199. package/dist/McTreeSelect/index.css +60 -0
  200. package/dist/McTreeSelect/index.d.ts +13 -0
  201. package/dist/McTreeSelect/index.js +182 -0
  202. package/dist/Utils/index.d.ts +4 -0
  203. package/dist/Utils/index.js +26 -0
  204. package/dist/index.d.ts +19 -0
  205. package/dist/index.js +19 -0
  206. package/dist/typings.d.ts +20 -0
  207. package/package.json +82 -0
@@ -0,0 +1,350 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
+ var _excluded = ["style", "className", "label", "multiple", "changeOnHidden", "inexistent", "fetchOptions", "pageSize", "extra", "value", "onChange", "labelInValue", "options", "disabled", "maxTagCount", "onSearch", "onPopupScroll", "onBlur", "onDropdownVisibleChange"];
7
+ import { Empty, Popover, Select, Spin } from 'antd';
8
+ import { Utils } from "./..";
9
+ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
10
+ import "./index.css";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ var McSelect = /*#__PURE__*/forwardRef(function (props, ref) {
14
+ var style = props.style,
15
+ className = props.className,
16
+ label = props.label,
17
+ multiple = props.multiple,
18
+ changeOnHidden = props.changeOnHidden,
19
+ _props$inexistent = props.inexistent,
20
+ inexistent = _props$inexistent === void 0 ? false : _props$inexistent,
21
+ fetchOptions = props.fetchOptions,
22
+ _props$pageSize = props.pageSize,
23
+ pageSize = _props$pageSize === void 0 ? 20 : _props$pageSize,
24
+ extra = props.extra,
25
+ value = props.value,
26
+ onChange = props.onChange,
27
+ labelInValue = props.labelInValue,
28
+ options = props.options,
29
+ disabled = props.disabled,
30
+ maxTagCount = props.maxTagCount,
31
+ onSearch = props.onSearch,
32
+ onPopupScroll = props.onPopupScroll,
33
+ onBlur = props.onBlur,
34
+ onDropdownVisibleChange = props.onDropdownVisibleChange,
35
+ rest = _objectWithoutProperties(props, _excluded);
36
+ var _ref = typeof inexistent === 'boolean' ? {} : inexistent,
37
+ _ref$inexistentText = _ref.inexistentText,
38
+ inexistentText = _ref$inexistentText === void 0 ? '不存在' : _ref$inexistentText,
39
+ _ref$inexistentColor = _ref.inexistentColor,
40
+ inexistentColor = _ref$inexistentColor === void 0 ? '#ff4d4f' : _ref$inexistentColor,
41
+ _ref$reserveOriginalV = _ref.reserveOriginalValue,
42
+ reserveOriginalValue = _ref$reserveOriginalV === void 0 ? false : _ref$reserveOriginalV;
43
+ var _maxTagCount = useMemo(function () {
44
+ return props.hasOwnProperty('maxTagCount') ? maxTagCount : 1;
45
+ }, [maxTagCount]);
46
+
47
+ /* 获取label宽度 */
48
+ var labelRef = useRef();
49
+ var _useState = useState(11),
50
+ _useState2 = _slicedToArray(_useState, 2),
51
+ paddingLeft = _useState2[0],
52
+ setPaddingLeft = _useState2[1];
53
+ var labelResizeObserver = new ResizeObserver(function (entries) {
54
+ setPaddingLeft(entries[0].contentRect.width + 11);
55
+ });
56
+ useEffect(function () {
57
+ labelRef.current && labelResizeObserver.observe(labelRef.current);
58
+ return function () {
59
+ return labelResizeObserver.disconnect();
60
+ };
61
+ }, []);
62
+
63
+ /* 基础数据 */
64
+ var _useState3 = useState(),
65
+ _useState4 = _slicedToArray(_useState3, 2),
66
+ selectValue = _useState4[0],
67
+ setSelectValue = _useState4[1];
68
+ var _selectValue = useRef();
69
+ var _useState5 = useState([]),
70
+ _useState6 = _slicedToArray(_useState5, 2),
71
+ selectOptions = _useState6[0],
72
+ setSelectOptions = _useState6[1];
73
+ var _selectOptions = useRef([]);
74
+ var _useState7 = useState(''),
75
+ _useState8 = _slicedToArray(_useState7, 2),
76
+ searchValue = _useState8[0],
77
+ setSearchValue = _useState8[1];
78
+ var _useState9 = useState(false),
79
+ _useState10 = _slicedToArray(_useState9, 2),
80
+ fetching = _useState10[0],
81
+ setFetching = _useState10[1];
82
+ var _extra = useRef(null);
83
+ var _current = useRef(1);
84
+ var _maxPage = useRef(1);
85
+ var _listEl = useRef();
86
+ var _open = useRef(false);
87
+ var _oldValue = useRef();
88
+ var _changeOption = useRef();
89
+ var _inexistent = useRef(false);
90
+
91
+ // 监听值和备选项的变化(赋值备选项,执行不存在值的判断逻辑)
92
+ useEffect(function () {
93
+ // 若已执行不存在外抛undefined逻辑,则不再向下执行后续代码,并重置标记
94
+ if (!fetchOptions && inexistent && _inexistent.current) {
95
+ _inexistent.current = false;
96
+ return;
97
+ }
98
+ var _v = value;
99
+ // 若非异步分页查询时,赋值备选项(执行不存在值的判断逻辑)
100
+ if (!fetchOptions) {
101
+ // 赋值备选项
102
+ setSelectOptions(options || []);
103
+ /* 若inexistent为true,判断不存在情况并重置值 */
104
+ if (inexistent) {
105
+ if (multiple) {
106
+ _v = (_v ? Array.isArray(_v) ? _v : [_v] : []).map(function (i) {
107
+ return options !== null && options !== void 0 && options.some(function (item) {
108
+ return item.value === (labelInValue ? i.value : i);
109
+ }) ? i : labelInValue ? _objectSpread(_objectSpread({}, i), {}, {
110
+ value: i.value + "\u300C".concat(inexistentText, "\u300D"),
111
+ label: (i.label || i.value) + "\u300C".concat(inexistentText, "\u300D")
112
+ }) : i + "\u300C".concat(inexistentText, "\u300D");
113
+ });
114
+ } else {
115
+ _v = _v || _v === 0 || _v === false ? options !== null && options !== void 0 && options.some(function (item) {
116
+ return item.value === (labelInValue ? _v.value : _v);
117
+ }) ? _v : labelInValue ? _objectSpread(_objectSpread({}, _v), {}, {
118
+ value: _v.value + "\u300C".concat(inexistentText, "\u300D"),
119
+ label: (_v.label || _v.value) + "\u300C".concat(inexistentText, "\u300D")
120
+ }) : _v + "\u300C".concat(inexistentText, "\u300D") : undefined;
121
+ }
122
+ // 若当前value包含不存在值,且不保留原值时,则向外抛出undefined,并标记_inexistent为true
123
+ if (_v && JSON.stringify(_v).indexOf("\u300C".concat(inexistentText, "\u300D")) !== -1 && !reserveOriginalValue) {
124
+ _inexistent.current = true;
125
+ onChange === null || onChange === void 0 || onChange(undefined, undefined);
126
+ }
127
+ }
128
+ }
129
+ setSelectValue(_v);
130
+ _selectValue.current = _v;
131
+ }, [value, JSON.stringify(options), fetchOptions, inexistent, multiple, labelInValue]);
132
+
133
+ // 组件change事件
134
+ var change = function change(v, option) {
135
+ var _v = v,
136
+ _option = option;
137
+ // 若inexistent为true且非异步分页查询,当重新触发change事件时,将不存在的项移除(仅多选时需处理)
138
+ if (inexistent && !fetchOptions && multiple) {
139
+ _v = v.filter(function (i) {
140
+ return ('' + (labelInValue ? i.value : i)).indexOf("\u300C".concat(inexistentText, "\u300D")) === -1;
141
+ });
142
+ _option = option.filter(function (i) {
143
+ return ('' + i.value).indexOf("\u300C".concat(inexistentText, "\u300D")) === -1;
144
+ });
145
+ }
146
+ if (multiple && changeOnHidden || !props.hasOwnProperty('value')) {
147
+ setSelectValue(_v);
148
+ }
149
+ _selectValue.current = _v;
150
+ _changeOption.current = _option;
151
+ if (multiple && changeOnHidden) {
152
+ // 若为多选且隐藏时触发onChange事件
153
+ if (!_open.current) {
154
+ onChange === null || onChange === void 0 || onChange(_v, _option);
155
+ }
156
+ } else {
157
+ onChange === null || onChange === void 0 || onChange(_v, _option);
158
+ }
159
+ };
160
+
161
+ /* 异步分页查询 */
162
+ // 异步加载备选项的方法
163
+ var loadOptions = useCallback( /*#__PURE__*/function () {
164
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(keyword, current) {
165
+ var _yield$fetchOptions, data, total, newOptions;
166
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
167
+ while (1) switch (_context.prev = _context.next) {
168
+ case 0:
169
+ if (!fetchOptions) {
170
+ _context.next = 15;
171
+ break;
172
+ }
173
+ _current.current = current;
174
+ if (current === 1) {
175
+ setSelectOptions([]);
176
+ _selectOptions.current = [];
177
+ }
178
+ setFetching(true);
179
+ _context.next = 6;
180
+ return fetchOptions({
181
+ current: current,
182
+ pageSize: pageSize,
183
+ keyword: keyword,
184
+ extra: extra
185
+ });
186
+ case 6:
187
+ _yield$fetchOptions = _context.sent;
188
+ data = _yield$fetchOptions.data;
189
+ total = _yield$fetchOptions.total;
190
+ newOptions = (_selectOptions.current || []).concat(data || []);
191
+ _maxPage.current = Math.ceil(total / pageSize) || 1;
192
+ // 下拉列表滚动至最新数据的位置
193
+ if (_listEl.current) {
194
+ _listEl.current.target.scrollTop = (_selectOptions.current || []).length * 32;
195
+ }
196
+ setSelectOptions(newOptions);
197
+ _selectOptions.current = newOptions;
198
+ setFetching(false);
199
+ case 15:
200
+ case "end":
201
+ return _context.stop();
202
+ }
203
+ }, _callee);
204
+ }));
205
+ return function (_x, _x2) {
206
+ return _ref2.apply(this, arguments);
207
+ };
208
+ }(), [fetchOptions, pageSize, extra, multiple]);
209
+
210
+ // 搜索防抖函数
211
+ var debounceSearcher = useMemo(function () {
212
+ return Utils.debounce(loadOptions, 350);
213
+ }, [loadOptions]);
214
+
215
+ // 文本框值变化时回调
216
+ var search = function search(v) {
217
+ var _v = v.trim();
218
+ setSearchValue(_v);
219
+ if (fetchOptions) {
220
+ debounceSearcher(_v, 1);
221
+ }
222
+ onSearch === null || onSearch === void 0 || onSearch(_v);
223
+ };
224
+
225
+ // 监听分页查询的的额外参数变化,重置查询
226
+ useEffect(function () {
227
+ if (_extra.current !== extra) {
228
+ setSearchValue('');
229
+ loadOptions('', 1);
230
+ }
231
+ _extra.current = extra;
232
+ }, [extra, loadOptions]);
233
+
234
+ // 滚动触底防抖函数
235
+ var debounceScrollor = useMemo(function () {
236
+ var scroll = function scroll(e) {
237
+ var start = e.target.scrollTop + e.target.offsetHeight;
238
+ var end = e.target.scrollHeight;
239
+ // 触底时,若当前不是最后一页,则加载下一页
240
+ if (start === end && _current.current < _maxPage.current) {
241
+ loadOptions(searchValue, _current.current + 1);
242
+ }
243
+ };
244
+ return Utils.debounce(scroll, 350);
245
+ }, [loadOptions, searchValue]);
246
+
247
+ // 下拉列表滚动时的回调
248
+ var popupScroll = function popupScroll(e) {
249
+ if (fetchOptions) {
250
+ if (!_listEl.current) {
251
+ _listEl.current = e;
252
+ }
253
+ debounceScrollor(e);
254
+ }
255
+ onPopupScroll === null || onPopupScroll === void 0 || onPopupScroll(e);
256
+ };
257
+
258
+ // 失去焦点时的回调(若为异步分页查询,需重置查询)
259
+ var blur = function blur(e) {
260
+ // 若当前文本框有值,则清空文本框并重置查询
261
+ if (searchValue) {
262
+ setSearchValue('');
263
+ loadOptions('', 1);
264
+ }
265
+ onBlur === null || onBlur === void 0 || onBlur(e);
266
+ };
267
+
268
+ // 展开下拉菜单的回调
269
+ var dropdownVisibleChange = function dropdownVisibleChange(open) {
270
+ if (multiple && changeOnHidden) {
271
+ _open.current = open;
272
+ if (open) {
273
+ _oldValue.current = _selectValue.current;
274
+ } else {
275
+ if (JSON.stringify(_selectValue.current) !== JSON.stringify(_oldValue.current)) {
276
+ onChange === null || onChange === void 0 || onChange(_selectValue.current, _changeOption.current);
277
+ }
278
+ }
279
+ }
280
+ onDropdownVisibleChange === null || onDropdownVisibleChange === void 0 || onDropdownVisibleChange(open);
281
+ };
282
+ return /*#__PURE__*/_jsxs("div", {
283
+ style: _objectSpread({
284
+ position: label ? 'relative' : 'static',
285
+ height: multiple ? 'auto' : 32,
286
+ '--selector-pl': "".concat(paddingLeft, "px"),
287
+ '--inexistent-color': inexistentColor
288
+ }, style),
289
+ className: "mc-select ".concat(multiple && _maxTagCount === 1 ? 'mc-select--inline' : '', " ").concat(className || ''),
290
+ children: [label && /*#__PURE__*/_jsx("span", {
291
+ ref: labelRef,
292
+ className: "mc-select__label ".concat(disabled ? 'mc-select--disabled' : ''),
293
+ children: label
294
+ }), /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({
295
+ ref: ref,
296
+ className: "mc-select__content",
297
+ value: selectValue,
298
+ onChange: change,
299
+ labelInValue: labelInValue,
300
+ options: selectOptions,
301
+ disabled: disabled,
302
+ placeholder: "\u8BF7\u9009\u62E9",
303
+ showSearch: true,
304
+ optionFilterProp: "label",
305
+ allowClear: true,
306
+ maxTagCount: _maxTagCount,
307
+ maxTagPlaceholder: function maxTagPlaceholder(v) {
308
+ return /*#__PURE__*/_jsx(Popover, {
309
+ overlayStyle: {
310
+ maxWidth: 300
311
+ },
312
+ content: v.map(function (_ref3, index) {
313
+ var _ref4;
314
+ var value = _ref3.value,
315
+ label = _ref3.label;
316
+ return /*#__PURE__*/_jsxs("span", {
317
+ children: [index !== 0 && /*#__PURE__*/_jsx("span", {
318
+ children: ", "
319
+ }), /*#__PURE__*/_jsx("span", {
320
+ style: {
321
+ color: ((_ref4 = '' + value) === null || _ref4 === void 0 ? void 0 : _ref4.indexOf("\u300C".concat(inexistentText, "\u300D"))) === -1 ? 'rgba(0, 0, 0, 0.88)' : inexistentColor
322
+ },
323
+ children: label
324
+ })]
325
+ }, value);
326
+ }),
327
+ children: /*#__PURE__*/_jsx("span", {
328
+ children: '+' + v.length
329
+ })
330
+ });
331
+ },
332
+ filterOption: fetchOptions ? false : true,
333
+ searchValue: searchValue,
334
+ onSearch: search,
335
+ loading: fetching,
336
+ notFoundContent: fetching ? /*#__PURE__*/_jsx(Spin, {
337
+ size: "small"
338
+ }) : /*#__PURE__*/_jsx(Empty, {
339
+ image: Empty.PRESENTED_IMAGE_SIMPLE
340
+ }),
341
+ onPopupScroll: popupScroll,
342
+ onBlur: blur,
343
+ onDropdownVisibleChange: dropdownVisibleChange
344
+ }, rest), {}, {
345
+ mode: multiple ? 'multiple' : undefined,
346
+ fieldNames: undefined
347
+ }))]
348
+ });
349
+ });
350
+ export default McSelect;
@@ -0,0 +1,38 @@
1
+ {
2
+ "CustomToken": {
3
+ "Button": {
4
+ "defaultBorderColorDisable": "rgb(246, 246, 246)",
5
+ "resetBg": "#fff",
6
+ "activeColor": "#284AC6",
7
+ "hoverColor": "#5B7DF9",
8
+ "dangerBg": "rgba(255, 77, 79, 0.1)",
9
+ "dangerBorderColor": "rgba(255, 77, 79, 0.01)",
10
+ "dangerHoverColor": "#FF7172",
11
+ "dangerActiveColor": "#CC3E3F",
12
+ "secondaryBorderColor": "#D9D9D9",
13
+ "secondaryBorderColorDisabled": "#F5F5F5",
14
+ "secondaryColorDisabled": "#B7B3B3",
15
+ "secondaryBgDisabled": "rgba(38, 38, 38, 0.04)",
16
+ "dashedBorderColor": "#D9D9D9",
17
+ "addBg": "#EAEEFE",
18
+ "addHoverBg": "#ECF0FE",
19
+ "primaryColorDisabled": "#fff"
20
+ },
21
+ "Tabs": {
22
+ "cardTabListBg": "#F0F4F9",
23
+ "cardTabRadius": 12,
24
+ "cardTabItemLineColor": "#D8D8D8",
25
+ "cardTabItemBorder": "1px solid #F0F4F9",
26
+ "cardTabItemActiveBorder": "1px solid #FFFFFF"
27
+ },
28
+ "Pagination": {
29
+ "totalTextColor": "rgba(0, 0, 0, 0.43)",
30
+ "itemActiveColor": "#FFFFFF",
31
+ "itemActiveHoverBorderColor": "transparent"
32
+ },
33
+ "Radio": {
34
+ "buttonLineBg": "rgb(216, 216, 216)",
35
+ "buttonLineHeight": 16
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => import("react/jsx-runtime").JSX.Element;
2
+ export default _default;
@@ -0,0 +1,226 @@
1
+ import { Button, Col, Row } from 'antd';
2
+ import { createStyles } from 'antd-style';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { jsxs as _jsxs } from "react/jsx-runtime";
5
+ var useStyles = createStyles(function () {
6
+ return {
7
+ container: {
8
+ '.ant-row': {
9
+ marginBottom: 10
10
+ },
11
+ '.ant-col': {
12
+ textAlign: 'center',
13
+ fontWeight: 'bold'
14
+ }
15
+ }
16
+ };
17
+ });
18
+ export default (function () {
19
+ var _useStyles = useStyles(),
20
+ styles = _useStyles.styles;
21
+ return /*#__PURE__*/_jsxs("div", {
22
+ className: styles.container,
23
+ children: [/*#__PURE__*/_jsxs(Row, {
24
+ style: {
25
+ marginBottom: 20
26
+ },
27
+ children: [/*#__PURE__*/_jsx(Col, {
28
+ span: 4,
29
+ children: " Primary "
30
+ }), /*#__PURE__*/_jsx(Col, {
31
+ span: 4,
32
+ children: " Default "
33
+ }), /*#__PURE__*/_jsx(Col, {
34
+ span: 4,
35
+ children: " Add "
36
+ }), /*#__PURE__*/_jsx(Col, {
37
+ span: 4,
38
+ children: " Secondary "
39
+ }), /*#__PURE__*/_jsx(Col, {
40
+ span: 4,
41
+ children: " Dashed "
42
+ }), /*#__PURE__*/_jsx(Col, {
43
+ span: 4,
44
+ children: " Ghost "
45
+ })]
46
+ }), /*#__PURE__*/_jsxs(Row, {
47
+ children: [/*#__PURE__*/_jsx(Col, {
48
+ span: 4,
49
+ children: /*#__PURE__*/_jsx(Button, {
50
+ type: "primary",
51
+ children: "\u4E3B\u8981\u6309\u94AE"
52
+ })
53
+ }), /*#__PURE__*/_jsx(Col, {
54
+ span: 4,
55
+ children: /*#__PURE__*/_jsx(Button, {
56
+ "data-default": true,
57
+ children: "\u4E3B\u8981\u6309\u94AE"
58
+ })
59
+ }), /*#__PURE__*/_jsx(Col, {
60
+ span: 4,
61
+ children: /*#__PURE__*/_jsx(Button, {
62
+ "data-add": true,
63
+ children: "\u4E3B\u8981\u6309\u94AE"
64
+ })
65
+ }), /*#__PURE__*/_jsx(Col, {
66
+ span: 4,
67
+ children: /*#__PURE__*/_jsx(Button, {
68
+ "data-secondary": true,
69
+ children: "\u4E3B\u8981\u6309\u94AE"
70
+ })
71
+ }), /*#__PURE__*/_jsx(Col, {
72
+ span: 4,
73
+ children: /*#__PURE__*/_jsx(Button, {
74
+ type: "dashed",
75
+ children: "\u4E3B\u8981\u6309\u94AE"
76
+ })
77
+ }), /*#__PURE__*/_jsx(Col, {
78
+ span: 4,
79
+ children: /*#__PURE__*/_jsx(Button, {
80
+ ghost: true,
81
+ children: "\u4E3B\u8981\u6309\u94AE"
82
+ })
83
+ })]
84
+ }), /*#__PURE__*/_jsxs(Row, {
85
+ style: {
86
+ marginBottom: 30
87
+ },
88
+ children: [/*#__PURE__*/_jsx(Col, {
89
+ span: 4,
90
+ children: /*#__PURE__*/_jsx(Button, {
91
+ type: "primary",
92
+ disabled: true,
93
+ children: "\u4E3B\u8981\u6309\u94AE"
94
+ })
95
+ }), /*#__PURE__*/_jsx(Col, {
96
+ span: 4,
97
+ children: /*#__PURE__*/_jsx(Button, {
98
+ "data-default": true,
99
+ disabled: true,
100
+ children: "\u4E3B\u8981\u6309\u94AE"
101
+ })
102
+ }), /*#__PURE__*/_jsx(Col, {
103
+ span: 4,
104
+ children: /*#__PURE__*/_jsx(Button, {
105
+ "data-add": true,
106
+ disabled: true,
107
+ children: "\u4E3B\u8981\u6309\u94AE"
108
+ })
109
+ }), /*#__PURE__*/_jsx(Col, {
110
+ span: 4,
111
+ children: /*#__PURE__*/_jsx(Button, {
112
+ "data-secondary": true,
113
+ disabled: true,
114
+ children: "\u4E3B\u8981\u6309\u94AE"
115
+ })
116
+ }), /*#__PURE__*/_jsx(Col, {
117
+ span: 4,
118
+ children: /*#__PURE__*/_jsx(Button, {
119
+ type: "dashed",
120
+ disabled: true,
121
+ children: "\u4E3B\u8981\u6309\u94AE"
122
+ })
123
+ }), /*#__PURE__*/_jsx(Col, {
124
+ span: 4,
125
+ children: /*#__PURE__*/_jsx(Button, {
126
+ ghost: true,
127
+ disabled: true,
128
+ children: "\u4E3B\u8981\u6309\u94AE"
129
+ })
130
+ })]
131
+ }), /*#__PURE__*/_jsxs(Row, {
132
+ style: {
133
+ marginBottom: 20
134
+ },
135
+ children: [/*#__PURE__*/_jsx(Col, {
136
+ span: 4,
137
+ children: " Text "
138
+ }), /*#__PURE__*/_jsx(Col, {
139
+ span: 4,
140
+ children: " Link "
141
+ }), /*#__PURE__*/_jsx(Col, {
142
+ span: 4,
143
+ children: " Danger "
144
+ }), /*#__PURE__*/_jsx(Col, {
145
+ span: 4,
146
+ children: " Link Danger "
147
+ }), /*#__PURE__*/_jsx(Col, {
148
+ span: 4,
149
+ children: " Dashed Danger "
150
+ })]
151
+ }), /*#__PURE__*/_jsxs(Row, {
152
+ children: [/*#__PURE__*/_jsx(Col, {
153
+ span: 4,
154
+ children: /*#__PURE__*/_jsx(Button, {
155
+ type: "text",
156
+ children: "\u4E3B\u8981\u6309\u94AE"
157
+ })
158
+ }), /*#__PURE__*/_jsx(Col, {
159
+ span: 4,
160
+ children: /*#__PURE__*/_jsx(Button, {
161
+ type: "link",
162
+ children: "\u4E3B\u8981\u6309\u94AE"
163
+ })
164
+ }), /*#__PURE__*/_jsx(Col, {
165
+ span: 4,
166
+ children: /*#__PURE__*/_jsx(Button, {
167
+ danger: true,
168
+ children: "\u4E3B\u8981\u6309\u94AE"
169
+ })
170
+ }), /*#__PURE__*/_jsx(Col, {
171
+ span: 4,
172
+ children: /*#__PURE__*/_jsx(Button, {
173
+ type: "link",
174
+ danger: true,
175
+ children: "\u4E3B\u8981\u6309\u94AE"
176
+ })
177
+ }), /*#__PURE__*/_jsx(Col, {
178
+ span: 4,
179
+ children: /*#__PURE__*/_jsx(Button, {
180
+ type: "dashed",
181
+ danger: true,
182
+ children: "\u4E3B\u8981\u6309\u94AE"
183
+ })
184
+ })]
185
+ }), /*#__PURE__*/_jsxs(Row, {
186
+ children: [/*#__PURE__*/_jsx(Col, {
187
+ span: 4,
188
+ children: /*#__PURE__*/_jsx(Button, {
189
+ type: "text",
190
+ disabled: true,
191
+ children: "\u4E3B\u8981\u6309\u94AE"
192
+ })
193
+ }), /*#__PURE__*/_jsx(Col, {
194
+ span: 4,
195
+ children: /*#__PURE__*/_jsx(Button, {
196
+ type: "link",
197
+ disabled: true,
198
+ children: "\u4E3B\u8981\u6309\u94AE"
199
+ })
200
+ }), /*#__PURE__*/_jsx(Col, {
201
+ span: 4,
202
+ children: /*#__PURE__*/_jsx(Button, {
203
+ danger: true,
204
+ disabled: true,
205
+ children: "\u4E3B\u8981\u6309\u94AE"
206
+ })
207
+ }), /*#__PURE__*/_jsx(Col, {
208
+ span: 4,
209
+ children: /*#__PURE__*/_jsx(Button, {
210
+ type: "link",
211
+ disabled: true,
212
+ danger: true,
213
+ children: "\u4E3B\u8981\u6309\u94AE"
214
+ })
215
+ }), /*#__PURE__*/_jsx(Col, {
216
+ span: 4,
217
+ children: /*#__PURE__*/_jsx(Button, {
218
+ type: "dashed",
219
+ disabled: true,
220
+ danger: true,
221
+ children: "\u4E3B\u8981\u6309\u94AE"
222
+ })
223
+ })]
224
+ })]
225
+ });
226
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: () => import("react/jsx-runtime").JSX.Element;
2
+ export default _default;
@@ -0,0 +1,59 @@
1
+ import { Button, Col, Drawer, Form, Input, Row } from 'antd';
2
+ import { McModalProvider } from "../..";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { jsxs as _jsxs } from "react/jsx-runtime";
5
+ var useModal = McModalProvider.useModal;
6
+ var demoDrawer = McModalProvider.create(function (_ref) {
7
+ var title = _ref.title,
8
+ record = _ref.record;
9
+ var modal = useModal();
10
+ return /*#__PURE__*/_jsx(Drawer, {
11
+ title: title,
12
+ open: modal.visible,
13
+ onClose: function onClose() {
14
+ modal.hide();
15
+ },
16
+ footer: /*#__PURE__*/_jsxs(Row, {
17
+ justify: "end",
18
+ children: [/*#__PURE__*/_jsx(Button, {
19
+ style: {
20
+ marginRight: 10
21
+ },
22
+ onClick: function onClick() {
23
+ modal.hide();
24
+ },
25
+ children: "\u53D6\u6D88"
26
+ }), /*#__PURE__*/_jsx(Button, {
27
+ type: "primary",
28
+ onClick: function onClick() {
29
+ modal.hide();
30
+ },
31
+ children: "\u786E\u8BA4"
32
+ })]
33
+ }),
34
+ children: /*#__PURE__*/_jsx(Form.Item, {
35
+ label: "drawer",
36
+ children: /*#__PURE__*/_jsx(Input, {
37
+ value: record === null || record === void 0 ? void 0 : record.id
38
+ })
39
+ })
40
+ });
41
+ });
42
+ export default (function () {
43
+ return /*#__PURE__*/_jsx(Row, {
44
+ gutter: [16, 20],
45
+ children: /*#__PURE__*/_jsx(Col, {
46
+ children: /*#__PURE__*/_jsx(Button, {
47
+ onClick: function onClick() {
48
+ McModalProvider.show(demoDrawer, {
49
+ title: '编辑抽屉',
50
+ record: {
51
+ id: 123
52
+ }
53
+ });
54
+ },
55
+ children: "Drawer"
56
+ })
57
+ })
58
+ });
59
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: () => import("react/jsx-runtime").JSX.Element;
2
+ export default _default;