@mi-avalon/libs 0.0.27 → 0.0.29
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/index.js +3 -3
- package/dist/components/MForm/type.d.ts +9 -1
- package/dist/components/MSearch/index.js +2 -3
- package/dist/index.es.js +592 -588
- package/dist/index.umd.js +10 -10
- package/dist/style.css +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* 表单组件
|
|
4
4
|
*/
|
|
5
|
-
import { Col, Form, Row } from 'antd';
|
|
5
|
+
import { Col, Form, Row, Space } from 'antd';
|
|
6
6
|
import { getClassName } from '../../utils';
|
|
7
7
|
import { CompThemeProvider } from '../ThemeContext';
|
|
8
8
|
import './index.scss';
|
|
@@ -38,7 +38,7 @@ function MForm(props) {
|
|
|
38
38
|
...itemLayout,
|
|
39
39
|
...item.itemLayout,
|
|
40
40
|
};
|
|
41
|
-
return (_jsx(Col, { span: item.span || 24 / column, children:
|
|
41
|
+
return (_jsx(Col, { span: item.span || 24 / column, children: _jsxs(Space, { className: classname('item-wrapper'), children: [item.prefix, _jsx(Form.Item, { label: item.label, name: item.id, rules: rules, initialValue: item.initialValue, ...formItemLayout, ...item.formItemProps, children: renderItem(item, form) }), item.suffix] }) }, `col-${item.id}`));
|
|
42
42
|
};
|
|
43
43
|
return (_jsx(CompThemeProvider, { children: _jsx(Form, { form: form, ...formProps, className: `${classname()} ${formProps?.className}`, children: _jsx(Row, { gutter: MFormItemConst.defaultRowGutter, ...formRowProps, className: `${classname('grid')} ${formRowProps?.className}`, children: formItems.map(e => renderFormItem(e)) }) }) }));
|
|
44
44
|
}
|
|
@@ -62,7 +62,7 @@ export interface IMFormBaseItem {
|
|
|
62
62
|
/**
|
|
63
63
|
* label名称
|
|
64
64
|
*/
|
|
65
|
-
label:
|
|
65
|
+
label: React.ReactNode;
|
|
66
66
|
/**
|
|
67
67
|
* 组件是否禁用
|
|
68
68
|
*/
|
|
@@ -112,6 +112,14 @@ export interface IMFormBaseItem {
|
|
|
112
112
|
* item组件的其他属性
|
|
113
113
|
*/
|
|
114
114
|
props?: any;
|
|
115
|
+
/**
|
|
116
|
+
* 前缀
|
|
117
|
+
*/
|
|
118
|
+
prefix?: React.ReactNode;
|
|
119
|
+
/**
|
|
120
|
+
* 后缀
|
|
121
|
+
*/
|
|
122
|
+
suffix?: React.ReactNode;
|
|
115
123
|
}
|
|
116
124
|
export interface IMFormInputItem extends IMFormBaseItem {
|
|
117
125
|
type: MFormItemTypeEnum.Input | MFormItemTypeEnum.Password;
|
|
@@ -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
|
};
|