@mi-avalon/libs 0.0.18 → 0.0.20
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/ItemsRow/index.d.ts +42 -0
- package/dist/components/ItemsRow/index.js +20 -0
- package/dist/components/MBreadcrumb/index.d.ts +17 -0
- package/dist/components/MBreadcrumb/index.js +34 -0
- package/dist/components/MDescriptions/index.js +2 -1
- package/dist/components/MTable/index.d.ts +7 -0
- package/dist/components/MTable/index.js +10 -0
- package/dist/components/ThemeContext/index.d.ts +11 -0
- package/dist/components/ThemeContext/index.js +17 -0
- package/dist/components/index.d.ts +4 -1
- package/dist/components/index.js +4 -5
- package/dist/index.es.js +454 -363
- package/dist/index.umd.js +11 -11
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/components/MyButton/index.d.ts +0 -10
- package/dist/components/MyButton/index.js +0 -7
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ButtonProps } from 'antd';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* 默认配置按钮,也可以通过render() 渲染其他组件
|
|
5
|
+
*/
|
|
6
|
+
export interface IRowItem {
|
|
7
|
+
/**
|
|
8
|
+
* 按钮名称
|
|
9
|
+
*/
|
|
10
|
+
label?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 按钮类型
|
|
13
|
+
*/
|
|
14
|
+
type?: ButtonProps['type'];
|
|
15
|
+
/**
|
|
16
|
+
* 如果没有指定Render,则是按钮的onClick
|
|
17
|
+
*/
|
|
18
|
+
onClick?: (e: any) => void;
|
|
19
|
+
/**
|
|
20
|
+
* 其他按钮属性
|
|
21
|
+
*/
|
|
22
|
+
btnProps?: ButtonProps;
|
|
23
|
+
/**
|
|
24
|
+
* item 的className
|
|
25
|
+
*/
|
|
26
|
+
className?: string;
|
|
27
|
+
/**
|
|
28
|
+
* 自定义渲染
|
|
29
|
+
*/
|
|
30
|
+
render?: () => React.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
export interface IItemRowProps {
|
|
33
|
+
route?: Array<{
|
|
34
|
+
name: string;
|
|
35
|
+
url?: string;
|
|
36
|
+
}>;
|
|
37
|
+
items?: IRowItem[];
|
|
38
|
+
style?: React.CSSProperties;
|
|
39
|
+
className?: string;
|
|
40
|
+
offsetTop?: number;
|
|
41
|
+
}
|
|
42
|
+
export declare const ItemsRow: (props: IItemRowProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from 'antd';
|
|
3
|
+
import { CompThemeProvider } from '../ThemeContext';
|
|
4
|
+
import { getClassName } from '../utils';
|
|
5
|
+
const classname = (n = '') => {
|
|
6
|
+
const cn = 'items-row';
|
|
7
|
+
return getClassName(cn, n);
|
|
8
|
+
};
|
|
9
|
+
export const ItemsRow = (props) => {
|
|
10
|
+
if (!props.items) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return (_jsx(CompThemeProvider, { children: _jsx("div", { className: `${classname()} ${props.className || ''}`, style: props.style, children: (props.items || []).map((item, index) => {
|
|
14
|
+
const className = `${classname('item')} ${item.className}`;
|
|
15
|
+
if (item.render) {
|
|
16
|
+
return (_jsx("span", { className: className, children: item.render() }, index));
|
|
17
|
+
}
|
|
18
|
+
return (_jsx(Button, { className: className, ...item.btnProps, type: item.type || 'primary', onClick: item.onClick, children: item.label }, item.label));
|
|
19
|
+
}) }) }));
|
|
20
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IRowItem } from '../ItemsRow';
|
|
3
|
+
import './index.scss';
|
|
4
|
+
export interface RouteItem {
|
|
5
|
+
name: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IMBreadcrumbProps {
|
|
9
|
+
routes?: RouteItem[];
|
|
10
|
+
customItems?: IRowItem[];
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
className?: string;
|
|
13
|
+
offsetTop?: number;
|
|
14
|
+
mainAppBaseUrl?: string;
|
|
15
|
+
microAppName?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const MBreadcrumb: React.FC<IMBreadcrumbProps>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Affix, Breadcrumb, Card } from 'antd';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ItemsRow } from '../ItemsRow';
|
|
5
|
+
import { CompThemeProvider } from '../ThemeContext';
|
|
6
|
+
import { getClassName } from '../utils';
|
|
7
|
+
import './index.scss';
|
|
8
|
+
const classname = (n = '') => {
|
|
9
|
+
const cn = 'm-breadcrumb';
|
|
10
|
+
return getClassName(cn, n);
|
|
11
|
+
};
|
|
12
|
+
export const MBreadcrumb = props => {
|
|
13
|
+
const { routes, customItems, style, className, offsetTop = 64, mainAppBaseUrl, microAppName, } = props;
|
|
14
|
+
const affixRef = React.useRef(null);
|
|
15
|
+
const onScroll = React.useCallback(() => {
|
|
16
|
+
affixRef.current?.updatePosition?.();
|
|
17
|
+
}, []);
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
window.addEventListener('scroll', onScroll, true);
|
|
20
|
+
return () => window.removeEventListener('scroll', onScroll);
|
|
21
|
+
}, [onScroll]);
|
|
22
|
+
const getUrl = React.useCallback((url) => {
|
|
23
|
+
if (!url)
|
|
24
|
+
return '';
|
|
25
|
+
const cleanedUrl = url.replace(/^\/+/, '');
|
|
26
|
+
const parts = [
|
|
27
|
+
mainAppBaseUrl?.replace(/\/+$/, ''),
|
|
28
|
+
microAppName?.replace(/\/+$/, ''),
|
|
29
|
+
cleanedUrl,
|
|
30
|
+
].filter(Boolean);
|
|
31
|
+
return `/${parts.join('/')}`;
|
|
32
|
+
}, [mainAppBaseUrl, microAppName]);
|
|
33
|
+
return (_jsx(CompThemeProvider, { children: _jsx("div", { className: `${classname()} ${className || ''}`, style: style, children: _jsx(Affix, { ref: affixRef, offsetTop: offsetTop, children: _jsxs(Card, { className: classname('container'), rootClassName: classname('body'), variant: 'borderless', children: [_jsx(Breadcrumb, { className: classname('inner-breadcrumb'), style: { fontSize: '18px' }, children: routes?.map(v => (_jsx(Breadcrumb.Item, { children: v.url ? _jsx("a", { href: `#${getUrl(v.url)}`, children: v.name }) : v.name }, v.url || v.name))) }), _jsx("div", { className: classname('custom-item-wrapper'), children: _jsx(ItemsRow, { items: customItems }) })] }) }) }) }));
|
|
34
|
+
};
|
|
@@ -4,6 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
* 用于展示对象的详细信息,如用户信息、产品详情等
|
|
5
5
|
*/
|
|
6
6
|
import { Descriptions } from 'antd';
|
|
7
|
+
import { CompThemeProvider } from '../ThemeContext';
|
|
7
8
|
const MDescriptions = props => {
|
|
8
9
|
const { data, title, column = 3, lineHeight, align = 'left', itemLayout, colon = true, bordered = false, style, className, labelStyle, contentStyle, } = props;
|
|
9
10
|
// 合并样式
|
|
@@ -18,7 +19,7 @@ const MDescriptions = props => {
|
|
|
18
19
|
...(itemLayout?.value ? { width: `${itemLayout.value}px` } : {}),
|
|
19
20
|
...contentStyle,
|
|
20
21
|
};
|
|
21
|
-
return (_jsx(Descriptions, { title: title, column: column, colon: colon, bordered: bordered, style: style, className: className, labelStyle: mergedLabelStyle, contentStyle: mergedContentStyle, children: data.map((item, index) => (_jsx(Descriptions.Item, { label: item.label, span: item.span, children: item.value || '-' }, item.label?.toString() || index))) }));
|
|
22
|
+
return (_jsx(CompThemeProvider, { children: _jsx(Descriptions, { title: title, column: column, colon: colon, bordered: bordered, style: style, className: className, labelStyle: mergedLabelStyle, contentStyle: mergedContentStyle, children: data.map((item, index) => (_jsx(Descriptions.Item, { label: item.label, span: item.span, children: item.value || '-' }, item.label?.toString() || index))) }) }));
|
|
22
23
|
};
|
|
23
24
|
MDescriptions.displayName = 'MDescriptions';
|
|
24
25
|
export { MDescriptions };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* 表格
|
|
4
|
+
*/
|
|
5
|
+
import { Table } from 'antd';
|
|
6
|
+
import { CompThemeProvider } from '../ThemeContext';
|
|
7
|
+
export function MTable(props) {
|
|
8
|
+
const columns = props.columns?.map(e => ({ ...e, dataIndex: e.key })) ?? [];
|
|
9
|
+
return (_jsxs(CompThemeProvider, { children: [_jsx(Table, { rowKey: e => e.id, ...props, columns: columns }), ";"] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ThemeConfig } from 'antd';
|
|
2
|
+
interface ThemeContextType {
|
|
3
|
+
theme?: ThemeConfig;
|
|
4
|
+
}
|
|
5
|
+
export declare const MiThemeProvider: import("react").Provider<ThemeContextType>;
|
|
6
|
+
export declare function useMiThemeConfig(): ThemeContextType;
|
|
7
|
+
interface IProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function CompThemeProvider(props: IProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ConfigProvider, theme } from 'antd';
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
const ThemeContext = createContext({
|
|
5
|
+
theme: {
|
|
6
|
+
cssVar: true,
|
|
7
|
+
algorithm: [theme.defaultAlgorithm],
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
export const MiThemeProvider = ThemeContext.Provider;
|
|
11
|
+
export function useMiThemeConfig() {
|
|
12
|
+
return useContext(ThemeContext);
|
|
13
|
+
}
|
|
14
|
+
export function CompThemeProvider(props) {
|
|
15
|
+
const { theme } = useMiThemeConfig();
|
|
16
|
+
return _jsx(ConfigProvider, { theme: theme, children: props.children });
|
|
17
|
+
}
|
package/dist/components/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export * from './ItemsRow';
|
|
2
|
+
export * from './MBreadcrumb';
|
|
3
3
|
export * from './MDescriptions';
|
|
4
4
|
// export * from './MForm';
|
|
5
5
|
// export { default as MForm } from './MForm';
|
|
6
6
|
// export * from './MiModal';
|
|
7
7
|
// export { default as MSearch } from './MSearch';
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
// export * from './ThemeContext';
|
|
8
|
+
export * from './MTable';
|
|
9
|
+
export * from './ThemeContext';
|