@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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 2.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: page layout
8
+ - @fe-free/tool@2.1.6
9
+
10
+ ## 2.1.5
11
+
12
+ ### Patch Changes
13
+
14
+ - feat: json modal
15
+ - @fe-free/tool@2.1.5
16
+
3
17
  ## 2.1.4
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "2.1.4",
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.4"
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';
@@ -305,6 +305,7 @@ function ChartBlock(props: any) {
305
305
 
306
306
  // 大模型会返回一些奇怪字符,需要去掉
307
307
  // 不间断空格
308
+ // eslint-disable-next-line no-irregular-whitespace
308
309
  const content = children?.replace(/ /g, '');
309
310
 
310
311
  return (
@@ -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 };
@@ -52,8 +52,6 @@ function Table<
52
52
  };
53
53
  }
54
54
 
55
- console.log('newSearch', newSearch);
56
-
57
55
  return (
58
56
  <ProTable<DataSource, Params>
59
57
  cardBordered
@@ -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 { customValueTypeMap, CustomValueTypeEnum };
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 };
@@ -76,6 +76,12 @@ const Table = () => {
76
76
  ellipsis: true,
77
77
  valueType: CustomValueTypeEnum.CustomJSON,
78
78
  },
79
+ {
80
+ title: 'jsonModal',
81
+ dataIndex: 'jsonText',
82
+ ellipsis: true,
83
+ valueType: CustomValueTypeEnum.CustomJSONModal,
84
+ },
79
85
  ];
80
86
 
81
87
  return (