@mi-avalon/libs 0.0.17 → 0.0.19
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/MDescriptions/index.d.ts +65 -0
- package/dist/components/MDescriptions/index.js +25 -0
- package/dist/components/ThemeContext/index.d.ts +11 -0
- package/dist/components/ThemeContext/index.js +17 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -2
- package/dist/components/utils.d.ts +1 -0
- package/dist/components/utils.js +16 -0
- package/dist/index.es.js +353 -287
- package/dist/index.umd.js +11 -11
- package/package.json +1 -1
|
@@ -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,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IMDescriptionItem {
|
|
3
|
+
label: React.ReactNode;
|
|
4
|
+
value: React.ReactNode;
|
|
5
|
+
span?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface IMDescriptionProps {
|
|
8
|
+
/**
|
|
9
|
+
* 描述列表的数据[{label: '', value: '',}, ...]
|
|
10
|
+
*/
|
|
11
|
+
data: IMDescriptionItem[];
|
|
12
|
+
/**
|
|
13
|
+
* 标题
|
|
14
|
+
*/
|
|
15
|
+
title?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* 需要显示的列数
|
|
18
|
+
* @default 3
|
|
19
|
+
*/
|
|
20
|
+
column?: 1 | 2 | 3 | 4;
|
|
21
|
+
/**
|
|
22
|
+
* 行高
|
|
23
|
+
*/
|
|
24
|
+
lineHeight?: number;
|
|
25
|
+
/**
|
|
26
|
+
* 标签对齐方式
|
|
27
|
+
* @default 'left'
|
|
28
|
+
*/
|
|
29
|
+
align?: 'left' | 'center' | 'right';
|
|
30
|
+
/**
|
|
31
|
+
* 标签和值的布局配置
|
|
32
|
+
*/
|
|
33
|
+
itemLayout?: {
|
|
34
|
+
label?: number | undefined;
|
|
35
|
+
value?: number | undefined;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 是否显示冒号
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
colon?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* 是否显示边框
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
bordered?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 自定义样式
|
|
49
|
+
*/
|
|
50
|
+
style?: React.CSSProperties;
|
|
51
|
+
/**
|
|
52
|
+
* 自定义类名
|
|
53
|
+
*/
|
|
54
|
+
className?: string;
|
|
55
|
+
/**
|
|
56
|
+
* 标签样式
|
|
57
|
+
*/
|
|
58
|
+
labelStyle?: React.CSSProperties;
|
|
59
|
+
/**
|
|
60
|
+
* 内容样式
|
|
61
|
+
*/
|
|
62
|
+
contentStyle?: React.CSSProperties;
|
|
63
|
+
}
|
|
64
|
+
declare const MDescriptions: React.FC<IMDescriptionProps>;
|
|
65
|
+
export { MDescriptions };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* 详情描述列表组件
|
|
4
|
+
* 用于展示对象的详细信息,如用户信息、产品详情等
|
|
5
|
+
*/
|
|
6
|
+
import { Descriptions } from 'antd';
|
|
7
|
+
import { CompThemeProvider } from '../ThemeContext';
|
|
8
|
+
const MDescriptions = props => {
|
|
9
|
+
const { data, title, column = 3, lineHeight, align = 'left', itemLayout, colon = true, bordered = false, style, className, labelStyle, contentStyle, } = props;
|
|
10
|
+
// 合并样式
|
|
11
|
+
const mergedLabelStyle = {
|
|
12
|
+
...(lineHeight ? { lineHeight: `${lineHeight}px` } : {}),
|
|
13
|
+
textAlign: align,
|
|
14
|
+
...(itemLayout?.label ? { width: `${itemLayout.label}px` } : {}),
|
|
15
|
+
...labelStyle,
|
|
16
|
+
};
|
|
17
|
+
const mergedContentStyle = {
|
|
18
|
+
...(lineHeight ? { lineHeight: `${lineHeight}px` } : {}),
|
|
19
|
+
...(itemLayout?.value ? { width: `${itemLayout.value}px` } : {}),
|
|
20
|
+
...contentStyle,
|
|
21
|
+
};
|
|
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))) }) }));
|
|
23
|
+
};
|
|
24
|
+
MDescriptions.displayName = 'MDescriptions';
|
|
25
|
+
export { MDescriptions };
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
// export { default as ItemRow } from './ItemsRow';
|
|
2
2
|
// export { default as MBreadcrumb } 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';
|
|
@@ -8,4 +8,3 @@
|
|
|
8
8
|
// export { default as MTable } from './MTable';
|
|
9
9
|
export { default as MyButton } from './MyButton';
|
|
10
10
|
// export * from './ThemeContext';
|
|
11
|
-
// export { default as CompThemeProvider } from './ThemeContext/CompThemeProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getClassName: (key1: string, key2: string) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// 生成类名
|
|
2
|
+
export const getClassName = (key1, key2) => {
|
|
3
|
+
const cn = key1;
|
|
4
|
+
let str = key1;
|
|
5
|
+
if (key2.includes(' ')) {
|
|
6
|
+
str = '';
|
|
7
|
+
const nArr = key2?.split(' ');
|
|
8
|
+
for (const i of nArr) {
|
|
9
|
+
str += ` ${cn}-${i}`;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else if (key2) {
|
|
13
|
+
str = `${key1}-${key2}`;
|
|
14
|
+
}
|
|
15
|
+
return str;
|
|
16
|
+
};
|