@mi-avalon/libs 0.0.27 → 0.0.28
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/components/MForm/type.d.ts +1 -1
- package/dist/components/MSearch/index.js +2 -3
- package/dist/index.es.js +438 -438
- package/dist/index.umd.js +10 -10
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons';
|
|
3
3
|
import { Button, Card, Form } from 'antd';
|
|
4
|
-
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { getClassName, removeNull } from '../../utils';
|
|
6
6
|
import MForm from '../MForm';
|
|
7
7
|
import { CompThemeProvider } from '../ThemeContext';
|
|
@@ -44,9 +44,9 @@ export const MSearch = props => {
|
|
|
44
44
|
onSearch?.(values, isReset);
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
+
const hasMore = useMemo(() => searchItems?.filter(e => e.show != false).length > 2, [searchItems]);
|
|
47
48
|
// 渲染搜索按钮
|
|
48
49
|
const renderSearchButtons = () => {
|
|
49
|
-
const hasMore = searchItems.length > 2;
|
|
50
50
|
return (_jsxs("div", { className: classname('btn-wrapper'), children: [customButtons?.length > 0 ? (_jsx(_Fragment, { children: customButtons.map((buttonProps, index) => (_jsx(Button, { className: classname('btn'), ...buttonProps, children: buttonProps.children }, `custom-btn-${index}`))) })) : (_jsxs(_Fragment, { children: [_jsx(Button, { className: classname('btn btn-reset'), onClick: reset, children: "\u91CD\u7F6E" }), _jsx(Button, { className: classname('btn btn-search'), onClick: () => search(), type: 'primary', children: "\u641C\u7D22" })] })), hasMore && (_jsxs("div", { className: classname('btn btn-collapse'), onClick: () => setShowAll(!showAll), children: [_jsx("span", { children: showAll ? '收起' : '展开' }), showAll ? _jsx(CaretUpOutlined, {}) : _jsx(CaretDownOutlined, {})] }))] }));
|
|
51
51
|
};
|
|
52
52
|
// 处理搜索项显示/隐藏
|
|
@@ -63,6 +63,5 @@ export const MSearch = props => {
|
|
|
63
63
|
}
|
|
64
64
|
return newItem;
|
|
65
65
|
});
|
|
66
|
-
const hasMore = searchItems.length > 2;
|
|
67
66
|
return (_jsx(CompThemeProvider, { children: _jsx("div", { className: `${classname('')} ${showAll ? '' : classname('collapsed')} ${className || ''}`, ref: searchWrap, children: _jsxs(Card, { children: [_jsxs("div", { className: classname('form'), children: [_jsx(MForm, { form: form, formItems: processedSearchItems, column: 3 }), (!hasMore || (hasMore && !showAll)) && renderSearchButtons()] }), hasMore && showAll && _jsx("div", { className: classname('footer'), children: renderSearchButtons() })] }) }) }));
|
|
68
67
|
};
|