@fe-free/core 2.1.4 → 2.1.6
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/CHANGELOG.md +14 -0
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/markdown/chart.tsx +1 -0
- package/src/page_layout/index.tsx +36 -0
- package/src/table/index.tsx +0 -2
- package/src/value_type_map/index.tsx +8 -1
- package/src/value_type_map/json_modal.tsx +56 -0
- package/src/value_type_map/value_type_map.stories.tsx +6 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"remark-gfm": "^4.0.1",
|
|
40
40
|
"vanilla-jsoneditor": "^0.23.1",
|
|
41
41
|
"zustand": "^4.5.4",
|
|
42
|
-
"@fe-free/tool": "2.1.
|
|
42
|
+
"@fe-free/tool": "2.1.6"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@ant-design/pro-components": "^2.8.7",
|
package/src/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export {
|
|
|
27
27
|
proFormSelectSearchProps,
|
|
28
28
|
} from './form';
|
|
29
29
|
export { Markdown } from './markdown';
|
|
30
|
+
export { PageLayout } from './page_layout';
|
|
30
31
|
export { Table } from './table';
|
|
31
32
|
export type { TableProps } from './table';
|
|
32
33
|
export { useLocalforageState } from './use_localforage_state';
|
package/src/markdown/chart.tsx
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
|
|
3
|
+
interface PageLayoutProps {
|
|
4
|
+
direction?: 'horizontal' | 'vertical';
|
|
5
|
+
start?: React.ReactNode;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
end?: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function PageLayout({
|
|
12
|
+
direction = 'horizontal',
|
|
13
|
+
start,
|
|
14
|
+
children,
|
|
15
|
+
end,
|
|
16
|
+
className,
|
|
17
|
+
}: PageLayoutProps) {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
className={cn(
|
|
21
|
+
'flex w-full h-full',
|
|
22
|
+
{
|
|
23
|
+
'flex-row': direction === 'horizontal',
|
|
24
|
+
'flex-col': direction === 'vertical',
|
|
25
|
+
},
|
|
26
|
+
className,
|
|
27
|
+
)}
|
|
28
|
+
>
|
|
29
|
+
<div className="flex-none">{start}</div>
|
|
30
|
+
<div className="flex-1 overflow-auto">{children}</div>
|
|
31
|
+
<div className="flex-none">{end}</div>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { PageLayout };
|
package/src/table/index.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ProRenderFieldPropsType } from '@ant-design/pro-components';
|
|
2
2
|
import { dateRender } from './date';
|
|
3
3
|
import { jsonRender } from './json';
|
|
4
|
+
import { jsonModalRender } from './json_modal';
|
|
4
5
|
|
|
5
6
|
enum CustomValueTypeEnum {
|
|
6
7
|
/** 渲染时间 + 搜索日期范围 */
|
|
@@ -9,6 +10,8 @@ enum CustomValueTypeEnum {
|
|
|
9
10
|
CustomDateAndDateRange = 'CustomDateAndDateRange',
|
|
10
11
|
/** JSON */
|
|
11
12
|
CustomJSON = 'CustomJSON',
|
|
13
|
+
/** JSON Modal */
|
|
14
|
+
CustomJSONModal = 'CustomJSONModal',
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
const customValueTypeMap: Record<string, ProRenderFieldPropsType> = {
|
|
@@ -24,6 +27,10 @@ const customValueTypeMap: Record<string, ProRenderFieldPropsType> = {
|
|
|
24
27
|
render: jsonRender.render,
|
|
25
28
|
renderFormItem: jsonRender.renderFormItem,
|
|
26
29
|
},
|
|
30
|
+
[CustomValueTypeEnum.CustomJSONModal]: {
|
|
31
|
+
render: jsonModalRender.render,
|
|
32
|
+
renderFormItem: jsonModalRender.renderFormItem,
|
|
33
|
+
},
|
|
27
34
|
};
|
|
28
35
|
|
|
29
|
-
export {
|
|
36
|
+
export { CustomValueTypeEnum, customValueTypeMap };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ProFormItemProps } from '@ant-design/pro-components';
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import type { EditorJSONProps } from '../editor_json';
|
|
5
|
+
import { EditorJSON } from '../editor_json';
|
|
6
|
+
|
|
7
|
+
interface JSONModalProps extends EditorJSONProps {
|
|
8
|
+
/** 默认 查看 */
|
|
9
|
+
title?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function Render(text, props: ProFormItemProps<JSONModalProps>) {
|
|
13
|
+
const { title = '查看' } = props.fieldProps || {};
|
|
14
|
+
|
|
15
|
+
const [show, setShow] = useState(false);
|
|
16
|
+
|
|
17
|
+
let jsonText = text;
|
|
18
|
+
|
|
19
|
+
if (!text) {
|
|
20
|
+
return <div>-</div>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
jsonText = JSON.stringify(JSON.parse(text), null, 2);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(e, text);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<a onClick={() => setShow(true)}>{title}</a>
|
|
32
|
+
<Modal
|
|
33
|
+
title={title}
|
|
34
|
+
open={show}
|
|
35
|
+
onCancel={() => setShow(false)}
|
|
36
|
+
onOk={() => setShow(false)}
|
|
37
|
+
cancelButtonProps={{
|
|
38
|
+
style: {
|
|
39
|
+
display: 'none',
|
|
40
|
+
},
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<div className="h-[500px]">
|
|
44
|
+
<EditorJSON value={jsonText} readonly />
|
|
45
|
+
</div>
|
|
46
|
+
</Modal>
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const jsonModalRender = {
|
|
52
|
+
render: Render,
|
|
53
|
+
renderFormItem: () => <></>,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export { jsonModalRender };
|