@fe-free/core 1.2.3 → 1.3.0
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 +18 -0
- package/package.json +4 -4
- package/src/button/button.stories.ts +34 -0
- package/src/button/index.tsx +1 -1
- package/src/crud/crud.stories.tsx +350 -0
- package/src/crud/crud.tsx +20 -24
- package/src/crud/crud_delete.tsx +3 -2
- package/src/crud/crud_detail.tsx +6 -6
- package/src/crud/demo/data.tsx +6 -6
- package/src/editor_javascript/{index.md → editor_javascript.stories.tsx} +24 -38
- package/src/editor_javascript/index.tsx +2 -1
- package/src/editor_json/{index.md → editor_json.stories.tsx} +42 -67
- package/src/editor_json/index.tsx +1 -0
- package/src/editor_logs/editor_logs.stories.tsx +47 -0
- package/src/editor_logs/index.tsx +4 -3
- package/src/editor_markdown/editor_markdown.stories.tsx +32 -0
- package/src/editor_markdown/index.tsx +1 -0
- package/src/form/form.stories.tsx +65 -0
- package/src/index.ts +13 -9
- package/src/table/table.stories.tsx +80 -0
- package/src/tailwind.config.js +17 -0
- package/src/tailwindcss.stories.tsx +18 -0
- package/src/value_type_map/{index.md → value_type_map.stories.tsx} +22 -52
- package/src/button/index.md +0 -46
- package/src/crud/demo/index.tsx +0 -342
- package/src/crud/index.md +0 -158
- package/src/editor_logs/index.md +0 -48
- package/src/editor_markdown/index.md +0 -40
- package/src/form/index.md +0 -96
- package/src/table/index.md +0 -89
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# EditorJavascript
|
|
7
|
-
|
|
8
|
-
## 代码演示
|
|
1
|
+
import { EditorJavascript } from '@fe-free/core';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { useState } from 'react';
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
const meta: Meta<typeof EditorJavascript> = {
|
|
6
|
+
title: '@fe-free/core/EditorJavascript',
|
|
7
|
+
component: EditorJavascript,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
};
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { EditorJavascript } from '@fe-free/core';
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof EditorJavascript>;
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
// 常规示例
|
|
15
|
+
const BasicDemo = () => {
|
|
17
16
|
const [value, setValue] = useState(
|
|
18
17
|
`const name = 'world';
|
|
19
18
|
console.log('hello', name);
|
|
20
|
-
|
|
19
|
+
`,
|
|
21
20
|
);
|
|
22
21
|
|
|
23
22
|
return (
|
|
@@ -25,22 +24,18 @@ console.log('hello', name);
|
|
|
25
24
|
<EditorJavascript value={value} onChange={setValue} />
|
|
26
25
|
</div>
|
|
27
26
|
);
|
|
28
|
-
}
|
|
27
|
+
};
|
|
29
28
|
|
|
30
|
-
export
|
|
31
|
-
|
|
29
|
+
export const Basic: Story = {
|
|
30
|
+
render: () => <BasicDemo />,
|
|
31
|
+
};
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
```tsx
|
|
36
|
-
import { useState } from 'react';
|
|
37
|
-
import { EditorJavascript } from '@fe-free/core';
|
|
38
|
-
|
|
39
|
-
function Demo() {
|
|
33
|
+
// readonly 示例
|
|
34
|
+
const ReadonlyDemo = () => {
|
|
40
35
|
const [value, setValue] = useState(
|
|
41
36
|
`const name = 'world';
|
|
42
37
|
console.log('hello', name);
|
|
43
|
-
|
|
38
|
+
`,
|
|
44
39
|
);
|
|
45
40
|
|
|
46
41
|
return (
|
|
@@ -48,17 +43,8 @@ console.log('hello', name);
|
|
|
48
43
|
<EditorJavascript value={value} onChange={setValue} readonly />
|
|
49
44
|
</div>
|
|
50
45
|
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default Demo;
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## API
|
|
46
|
+
};
|
|
57
47
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
onChange: (value: string, event?: any) => void;
|
|
62
|
-
readonly?: boolean;
|
|
63
|
-
}
|
|
64
|
-
```
|
|
48
|
+
export const Readonly: Story = {
|
|
49
|
+
render: () => <ReadonlyDemo />,
|
|
50
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import AceEditor from 'react-ace';
|
|
2
2
|
|
|
3
|
+
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
3
4
|
import 'ace-builds/src-noconflict/mode-javascript';
|
|
4
5
|
import 'ace-builds/src-noconflict/theme-monokai';
|
|
5
|
-
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
6
6
|
|
|
7
7
|
const fullStyle = { width: '100%', height: '100%' };
|
|
8
8
|
|
|
@@ -34,3 +34,4 @@ function EditorJavascript({ value, onChange, readonly }: EditorJavascriptProps)
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export { EditorJavascript };
|
|
37
|
+
export type { EditorJavascriptProps };
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# EditorJSON
|
|
7
|
-
|
|
8
|
-
## 代码演示
|
|
1
|
+
import { EditorJSON } from '@fe-free/core';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { useState } from 'react';
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
const meta: Meta<typeof EditorJSON> = {
|
|
6
|
+
title: '@fe-free/core/EditorJSON',
|
|
7
|
+
component: EditorJSON,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
};
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { EditorJSON } from '@fe-free/core';
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof EditorJSON>;
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
// 基础示例
|
|
15
|
+
const BasicDemo = () => {
|
|
17
16
|
const [value, setValue] = useState(
|
|
18
17
|
JSON.stringify(
|
|
19
18
|
{
|
|
20
19
|
name: 'world',
|
|
21
20
|
},
|
|
22
21
|
null,
|
|
23
|
-
2
|
|
24
|
-
)
|
|
22
|
+
2,
|
|
23
|
+
),
|
|
25
24
|
);
|
|
26
25
|
|
|
27
26
|
return (
|
|
@@ -29,26 +28,22 @@ function Demo() {
|
|
|
29
28
|
<EditorJSON value={value} onChange={setValue} />
|
|
30
29
|
</div>
|
|
31
30
|
);
|
|
32
|
-
}
|
|
31
|
+
};
|
|
33
32
|
|
|
34
|
-
export
|
|
35
|
-
|
|
33
|
+
export const Basic: Story = {
|
|
34
|
+
render: () => <BasicDemo />,
|
|
35
|
+
};
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```tsx
|
|
40
|
-
import { useState } from 'react';
|
|
41
|
-
import { EditorJSON } from '@fe-free/core';
|
|
42
|
-
|
|
43
|
-
function Demo() {
|
|
37
|
+
// 只读模式
|
|
38
|
+
const ReadonlyDemo = () => {
|
|
44
39
|
const [value, setValue] = useState(
|
|
45
40
|
JSON.stringify(
|
|
46
41
|
{
|
|
47
42
|
name: 'world',
|
|
48
43
|
},
|
|
49
44
|
null,
|
|
50
|
-
2
|
|
51
|
-
)
|
|
45
|
+
2,
|
|
46
|
+
),
|
|
52
47
|
);
|
|
53
48
|
|
|
54
49
|
return (
|
|
@@ -56,26 +51,22 @@ function Demo() {
|
|
|
56
51
|
<EditorJSON value={value} onChange={setValue} readonly />
|
|
57
52
|
</div>
|
|
58
53
|
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default Demo;
|
|
62
|
-
```
|
|
54
|
+
};
|
|
63
55
|
|
|
64
|
-
|
|
56
|
+
export const Readonly: Story = {
|
|
57
|
+
render: () => <ReadonlyDemo />,
|
|
58
|
+
};
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
import { EditorJSON } from '@fe-free/core';
|
|
69
|
-
|
|
70
|
-
function Demo() {
|
|
60
|
+
// 树形模式
|
|
61
|
+
const TreeModeDemo = () => {
|
|
71
62
|
const [value, setValue] = useState(
|
|
72
63
|
JSON.stringify(
|
|
73
64
|
{
|
|
74
65
|
name: 'world',
|
|
75
66
|
},
|
|
76
67
|
null,
|
|
77
|
-
2
|
|
78
|
-
)
|
|
68
|
+
2,
|
|
69
|
+
),
|
|
79
70
|
);
|
|
80
71
|
|
|
81
72
|
return (
|
|
@@ -83,26 +74,22 @@ function Demo() {
|
|
|
83
74
|
<EditorJSON value={value} onChange={setValue} mode="tree" readonly />
|
|
84
75
|
</div>
|
|
85
76
|
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default Demo;
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### readonly mainMenuBar mode
|
|
77
|
+
};
|
|
92
78
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
79
|
+
export const TreeMode: Story = {
|
|
80
|
+
render: () => <TreeModeDemo />,
|
|
81
|
+
};
|
|
96
82
|
|
|
97
|
-
|
|
83
|
+
// 无菜单栏的只读树形模式
|
|
84
|
+
const NoMenuBarDemo = () => {
|
|
98
85
|
const [value, setValue] = useState(
|
|
99
86
|
JSON.stringify(
|
|
100
87
|
{
|
|
101
88
|
name: 'world',
|
|
102
89
|
},
|
|
103
90
|
null,
|
|
104
|
-
2
|
|
105
|
-
)
|
|
91
|
+
2,
|
|
92
|
+
),
|
|
106
93
|
);
|
|
107
94
|
|
|
108
95
|
return (
|
|
@@ -110,20 +97,8 @@ function Demo() {
|
|
|
110
97
|
<EditorJSON value={value} onChange={setValue} readonly mode="tree" mainMenuBar={false} />
|
|
111
98
|
</div>
|
|
112
99
|
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export default Demo;
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## API
|
|
119
|
-
|
|
120
|
-
```tsx | pure
|
|
121
|
-
import type { JSONEditor } from 'vanilla-jsoneditor';
|
|
100
|
+
};
|
|
122
101
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
readonly?: boolean;
|
|
127
|
-
mode?: JSONEditor['mode'];
|
|
128
|
-
}
|
|
129
|
-
```
|
|
102
|
+
export const NoMenuBar: Story = {
|
|
103
|
+
render: () => <NoMenuBarDemo />,
|
|
104
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { EditorLogs } from '@fe-free/core';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof EditorLogs> = {
|
|
5
|
+
title: '@fe-free/core/EditorLogs',
|
|
6
|
+
component: EditorLogs,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component:
|
|
12
|
+
'一个用于显示日志内容的 React 组件。它使用 CodeMirror 编辑器来呈现日志,提供了语法高亮和主题支持。',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof EditorLogs>;
|
|
20
|
+
|
|
21
|
+
export const Basic: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
logs: [
|
|
24
|
+
{
|
|
25
|
+
timestamp: '2023-01-01 12:00:00',
|
|
26
|
+
level: 'info',
|
|
27
|
+
message: 'This is an info log message.',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
timestamp: '2023-01-01 12:00:00',
|
|
31
|
+
level: 'warn',
|
|
32
|
+
message: 'This is a warning log message.',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
timestamp: '2023-01-01 12:00:00',
|
|
36
|
+
level: 'error',
|
|
37
|
+
message: 'This is an error log message.',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
timestamp: '2023-01-01 12:00:00',
|
|
41
|
+
level: 'system',
|
|
42
|
+
message:
|
|
43
|
+
'This is a debug log message. This is a debug log message This is a debug log message This is a debug log message This is a debug log message',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import CodeMirror from '@uiw/react-codemirror';
|
|
3
1
|
import { StreamLanguage } from '@codemirror/language';
|
|
4
|
-
import { createTheme } from '@uiw/codemirror-themes';
|
|
5
2
|
import { tags as t } from '@lezer/highlight';
|
|
3
|
+
import { createTheme } from '@uiw/codemirror-themes';
|
|
4
|
+
import CodeMirror from '@uiw/react-codemirror';
|
|
5
|
+
import React from 'react';
|
|
6
6
|
|
|
7
7
|
interface EditorLogsProps {
|
|
8
8
|
logs: {
|
|
@@ -67,3 +67,4 @@ const EditorLogs: React.FC<EditorLogsProps> = ({ logs }) => {
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
export { EditorLogs };
|
|
70
|
+
export type { EditorLogsProps };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EditorMarkdown } from '@fe-free/core';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof EditorMarkdown> = {
|
|
6
|
+
title: '@fe-free/core/EditorMarkdown',
|
|
7
|
+
component: EditorMarkdown,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof EditorMarkdown>;
|
|
13
|
+
|
|
14
|
+
// 常规示例
|
|
15
|
+
const BasicDemo = () => {
|
|
16
|
+
const [value] = useState(
|
|
17
|
+
`# hello
|
|
18
|
+
|
|
19
|
+
world
|
|
20
|
+
`,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div style={{ width: '500px', height: '500px' }}>
|
|
25
|
+
<EditorMarkdown value={value} />
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Basic: Story = {
|
|
31
|
+
render: () => <BasicDemo />,
|
|
32
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ProForm } from '@ant-design/pro-components';
|
|
2
|
+
import { ProFormJSON, ProFormJavascript } from '@fe-free/core';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
|
|
5
|
+
const meta: Meta = {
|
|
6
|
+
title: '@fe-free/core/Form',
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
|
|
13
|
+
// ProFormJSON 基础示例
|
|
14
|
+
export const ProFormJSONBasic: Story = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<ProForm>
|
|
17
|
+
<ProFormJSON name="json" initialValue={JSON.stringify({ name: 'world' }, null, 2)} />
|
|
18
|
+
</ProForm>
|
|
19
|
+
),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// ProFormJSON 只读示例
|
|
23
|
+
export const ProFormJSONReadonly: Story = {
|
|
24
|
+
render: () => (
|
|
25
|
+
<ProForm>
|
|
26
|
+
<ProFormJSON
|
|
27
|
+
name="json"
|
|
28
|
+
readonly
|
|
29
|
+
initialValue={JSON.stringify({ name: 'world' }, null, 2)}
|
|
30
|
+
fieldProps={{
|
|
31
|
+
mainMenuBar: false,
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
</ProForm>
|
|
35
|
+
),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// ProFormJavascript 基础示例
|
|
39
|
+
export const ProFormJavascriptBasic: Story = {
|
|
40
|
+
render: () => (
|
|
41
|
+
<ProForm>
|
|
42
|
+
<ProFormJavascript
|
|
43
|
+
name="javascript"
|
|
44
|
+
initialValue={`const name = 'world';
|
|
45
|
+
console.log('hello', name);
|
|
46
|
+
`}
|
|
47
|
+
/>
|
|
48
|
+
</ProForm>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// ProFormJavascript 只读示例
|
|
53
|
+
export const ProFormJavascriptReadonly: Story = {
|
|
54
|
+
render: () => (
|
|
55
|
+
<ProForm>
|
|
56
|
+
<ProFormJavascript
|
|
57
|
+
name="javascript"
|
|
58
|
+
readonly
|
|
59
|
+
initialValue={`const name = 'world';
|
|
60
|
+
console.log('hello', name);
|
|
61
|
+
`}
|
|
62
|
+
/>
|
|
63
|
+
</ProForm>
|
|
64
|
+
),
|
|
65
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
export { CRUD, useDelete, OperateDelete, CRUDDetail } from './crud';
|
|
2
|
-
export type { CRUDProps, CRUDMethods, CRUDDetailProps } from './crud';
|
|
3
|
-
|
|
4
|
-
export { ProFormJSON, ProFormJavascript, proFormSelectSearchProps } from './form';
|
|
5
|
-
|
|
6
1
|
export { LoadingButton } from './button';
|
|
7
2
|
|
|
8
|
-
export {
|
|
9
|
-
export type {
|
|
3
|
+
export { CRUD, CRUDDetail, OperateDelete, useDelete } from './crud';
|
|
4
|
+
export type { CRUDDetailProps, CRUDMethods, CRUDProps } from './crud';
|
|
10
5
|
|
|
11
6
|
export { EditorJavascript } from './editor_javascript';
|
|
7
|
+
export type { EditorJavascriptProps } from './editor_javascript';
|
|
12
8
|
export { EditorJSON } from './editor_json';
|
|
13
|
-
export {
|
|
9
|
+
export type { EditorJSONProps } from './editor_json';
|
|
14
10
|
export { EditorLogs } from './editor_logs';
|
|
11
|
+
export type { EditorLogsProps } from './editor_logs';
|
|
12
|
+
export { EditorMarkdown } from './editor_markdown';
|
|
13
|
+
export type { EditorMarkdownProps } from './editor_markdown';
|
|
14
|
+
|
|
15
|
+
export { ProFormJSON, ProFormJavascript, proFormSelectSearchProps } from './form';
|
|
16
|
+
|
|
17
|
+
export { Table } from './table';
|
|
18
|
+
export type { TableProps } from './table';
|
|
15
19
|
|
|
16
|
-
export {
|
|
20
|
+
export { CustomValueTypeEnum, customValueTypeMap } from './value_type_map';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ProColumns } from '@ant-design/pro-components';
|
|
2
|
+
import { Table } from '@fe-free/core';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import { fakeData } from '../crud/demo/data';
|
|
5
|
+
|
|
6
|
+
const meta: Meta = {
|
|
7
|
+
title: '@fe-free/core/Table',
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
|
|
14
|
+
// 定义列配置
|
|
15
|
+
const columns: ProColumns[] = [
|
|
16
|
+
{
|
|
17
|
+
title: 'id',
|
|
18
|
+
dataIndex: 'id',
|
|
19
|
+
search: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: '名字(省略)',
|
|
23
|
+
dataIndex: 'name',
|
|
24
|
+
search: true,
|
|
25
|
+
ellipsis: true,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: 'city',
|
|
29
|
+
dataIndex: 'city',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'area',
|
|
33
|
+
dataIndex: 'area',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export const Basic: Story = {
|
|
38
|
+
render: () => (
|
|
39
|
+
<Table
|
|
40
|
+
rowKey="id"
|
|
41
|
+
columns={columns}
|
|
42
|
+
request={async (params) => {
|
|
43
|
+
console.log(params);
|
|
44
|
+
return {
|
|
45
|
+
data: fakeData,
|
|
46
|
+
success: true,
|
|
47
|
+
total: fakeData.length,
|
|
48
|
+
};
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Search: Story = {
|
|
55
|
+
render: () => (
|
|
56
|
+
<Table
|
|
57
|
+
columns={[
|
|
58
|
+
{
|
|
59
|
+
title: 'id',
|
|
60
|
+
dataIndex: 'id',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: '名字(省略)',
|
|
64
|
+
dataIndex: 'name',
|
|
65
|
+
|
|
66
|
+
ellipsis: true,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
title: 'city',
|
|
70
|
+
dataIndex: 'city',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
title: 'area',
|
|
74
|
+
dataIndex: 'area',
|
|
75
|
+
},
|
|
76
|
+
]}
|
|
77
|
+
rowKey="id"
|
|
78
|
+
/>
|
|
79
|
+
),
|
|
80
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
theme: {
|
|
4
|
+
extend: {
|
|
5
|
+
colors: {
|
|
6
|
+
primary: '#1677ff',
|
|
7
|
+
/** 次要文本 */
|
|
8
|
+
secondary: 'rgba(0, 0, 0, 0.65)',
|
|
9
|
+
/** 描述文本 */
|
|
10
|
+
desc: 'rgba(0, 0, 0, 0.45)',
|
|
11
|
+
// 价格
|
|
12
|
+
price: '#E7484D',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
plugins: [],
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
title: '@fe-free/core/tailwindcss',
|
|
3
|
+
tags: ['autodocs'],
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const Default = () => {
|
|
7
|
+
return (
|
|
8
|
+
<div>
|
|
9
|
+
<div>@fe-free/core 扩展的</div>
|
|
10
|
+
<div className="flex flex-row gap-2">
|
|
11
|
+
<span className="text-primary">text-primary</span>
|
|
12
|
+
<span className="text-secondary">text-secondary</span>
|
|
13
|
+
<span className="text-desc">text-desc</span>
|
|
14
|
+
<span className="text-price">text-price</span>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -1,49 +1,20 @@
|
|
|
1
|
-
---
|
|
2
|
-
group: 'core'
|
|
3
|
-
toc: content
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# valueTypeMap
|
|
7
|
-
|
|
8
|
-
自定义 valueType
|
|
9
|
-
|
|
10
|
-
## customValueTypeMap
|
|
11
|
-
|
|
12
|
-
配置 customValueTypeMap
|
|
13
|
-
|
|
14
|
-
```tsx | pure
|
|
15
|
-
import { customValueTypeMap } from '@fe-free/core';
|
|
16
1
|
import { ProConfigProvider } from '@ant-design/pro-components';
|
|
2
|
+
import { CRUD, CustomValueTypeEnum, customValueTypeMap } from '@fe-free/core';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import { range } from 'lodash-es';
|
|
17
6
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## CustomValueTypeEnum
|
|
28
|
-
|
|
29
|
-
使用
|
|
30
|
-
|
|
31
|
-
```tsx | pure
|
|
32
|
-
enum CustomValueTypeEnum {
|
|
33
|
-
/** 渲染时间 + 搜索日期范围 */
|
|
34
|
-
CustomDateTimeAndDateRange = 'CustomDateTimeAndDateRange',
|
|
35
|
-
/** 渲染日期 + 搜索日期范围 */
|
|
36
|
-
CustomDateAndDateRange = 'CustomDateAndDateRange',
|
|
37
|
-
/** JSON */
|
|
38
|
-
CustomJSON = 'CustomJSON',
|
|
39
|
-
}
|
|
40
|
-
```
|
|
7
|
+
const meta: Meta = {
|
|
8
|
+
title: '@fe-free/core/ValueTypeMap',
|
|
9
|
+
component: ProConfigProvider,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
};
|
|
41
15
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
import { ProConfigProvider } from '@ant-design/pro-components';
|
|
45
|
-
import { range } from 'lodash-es';
|
|
46
|
-
import dayjs from 'dayjs';
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
47
18
|
|
|
48
19
|
async function fakeRequest() {
|
|
49
20
|
const data = range(5).map((item) => ({
|
|
@@ -94,7 +65,7 @@ const Table = () => {
|
|
|
94
65
|
search: true,
|
|
95
66
|
},
|
|
96
67
|
{
|
|
97
|
-
title: '
|
|
68
|
+
title: '日期 number 秒',
|
|
98
69
|
dataIndex: 'seconds',
|
|
99
70
|
valueType: CustomValueTypeEnum.CustomDateAndDateRange,
|
|
100
71
|
search: true,
|
|
@@ -118,11 +89,10 @@ const Table = () => {
|
|
|
118
89
|
);
|
|
119
90
|
};
|
|
120
91
|
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
```
|
|
92
|
+
export const Default: Story = {
|
|
93
|
+
render: () => (
|
|
94
|
+
<ProConfigProvider valueTypeMap={customValueTypeMap}>
|
|
95
|
+
<Table />
|
|
96
|
+
</ProConfigProvider>
|
|
97
|
+
),
|
|
98
|
+
};
|