@fe-free/core 2.8.2 → 2.8.4
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/form/form.stories.tsx +9 -0
- package/src/form/form_list/form_list.tsx +26 -2
- package/src/form/index.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/route/index.tsx +12 -4
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"remark-gfm": "^4.0.1",
|
|
42
42
|
"vanilla-jsoneditor": "^0.23.1",
|
|
43
43
|
"zustand": "^4.5.4",
|
|
44
|
-
"@fe-free/tool": "2.8.
|
|
44
|
+
"@fe-free/tool": "2.8.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@ant-design/pro-components": "2.8.9",
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ProFormImageUploadDragger,
|
|
6
6
|
ProFormJSON,
|
|
7
7
|
ProFormJavascript,
|
|
8
|
+
ProFormListBoolean,
|
|
8
9
|
ProFormListNumber,
|
|
9
10
|
ProFormListText,
|
|
10
11
|
ProFormRecord,
|
|
@@ -143,6 +144,14 @@ export const ProFormListNumberComponent: Story = {
|
|
|
143
144
|
),
|
|
144
145
|
};
|
|
145
146
|
|
|
147
|
+
export const ProFormListBooleanComponent: Story = {
|
|
148
|
+
render: () => (
|
|
149
|
+
<ProFormBase>
|
|
150
|
+
<ProFormListBoolean name="listBoolean" label="listBoolean" />
|
|
151
|
+
</ProFormBase>
|
|
152
|
+
),
|
|
153
|
+
};
|
|
154
|
+
|
|
146
155
|
function customRequest(option: any) {
|
|
147
156
|
const { file, onProgress, onSuccess } = option;
|
|
148
157
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProFormItemProps } from '@ant-design/pro-components';
|
|
2
2
|
import { ProForm } from '@ant-design/pro-components';
|
|
3
|
-
import { Input, InputNumber } from 'antd';
|
|
3
|
+
import { Input, InputNumber, Switch } from 'antd';
|
|
4
4
|
|
|
5
5
|
import { ProFormListHelper } from './form_list_helper';
|
|
6
6
|
|
|
@@ -71,6 +71,21 @@ function ListNumber(props: ListNumberProps) {
|
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
interface ListBooleanProps {
|
|
75
|
+
value?: boolean[];
|
|
76
|
+
onChange?: (value: boolean[]) => void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function ListBoolean(props: ListBooleanProps) {
|
|
80
|
+
return (
|
|
81
|
+
<ProFormListHelper value={props.value} onChange={props.onChange} getAdd={() => false}>
|
|
82
|
+
{({ item, onItemChange }) => {
|
|
83
|
+
return <Switch {...props} value={item} onChange={(checked) => onItemChange(checked)} />;
|
|
84
|
+
}}
|
|
85
|
+
</ProFormListHelper>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
74
89
|
function ProFormListBase(props) {
|
|
75
90
|
const { fieldProps, ...rest } = props;
|
|
76
91
|
|
|
@@ -124,4 +139,13 @@ function ProFormListNumber(props: ProFormItemProps<ListNumberProps>) {
|
|
|
124
139
|
);
|
|
125
140
|
}
|
|
126
141
|
|
|
127
|
-
|
|
142
|
+
function ProFormListBoolean(props: ProFormItemProps<ListBooleanProps>) {
|
|
143
|
+
const { fieldProps, ...rest } = props;
|
|
144
|
+
return (
|
|
145
|
+
<ProFormListBase {...rest}>
|
|
146
|
+
<ListBoolean {...fieldProps} />
|
|
147
|
+
</ProFormListBase>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { ProFormListBoolean, ProFormListNumber, ProFormListText };
|
package/src/form/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ProFormListNumber, ProFormListText } from './form_list/form_list';
|
|
1
|
+
export { ProFormListBoolean, ProFormListNumber, ProFormListText } from './form_list/form_list';
|
|
2
2
|
export { ProFormListHelper } from './form_list/form_list_helper';
|
|
3
3
|
export { ProFormListModalHelper } from './form_list/form_list_modal_helper';
|
|
4
4
|
export { ProFormEditor } from './pro_form_editor';
|
package/src/index.ts
CHANGED
package/src/route/index.tsx
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import type { NavigateFunction } from 'react-router-dom';
|
|
2
2
|
import { generatePath } from 'react-router-dom';
|
|
3
3
|
|
|
4
|
+
window.__routeTool_navigate = null;
|
|
5
|
+
window.__routeTool_baseName = '';
|
|
6
|
+
|
|
4
7
|
const routeTool = {
|
|
5
8
|
_baseName: '' as string,
|
|
6
9
|
_navigate: null as NavigateFunction | null,
|
|
7
10
|
setNavigate: (navigate: NavigateFunction) => {
|
|
8
11
|
routeTool._navigate = navigate;
|
|
12
|
+
window.__routeTool_navigate = navigate;
|
|
9
13
|
},
|
|
10
14
|
setBaseName: (baseName: string) => {
|
|
11
15
|
routeTool._baseName = baseName;
|
|
16
|
+
window.__routeTool_baseName = baseName;
|
|
12
17
|
},
|
|
13
18
|
getNavigate: () => {
|
|
14
|
-
if (!routeTool._navigate) {
|
|
19
|
+
if (!routeTool._navigate && !window.__routeTool_navigate) {
|
|
15
20
|
throw new Error('routeTool need set navigate first');
|
|
16
21
|
}
|
|
17
|
-
return routeTool._navigate;
|
|
22
|
+
return routeTool._navigate || window.__routeTool_navigate;
|
|
23
|
+
},
|
|
24
|
+
getBaseName: () => {
|
|
25
|
+
return routeTool._baseName || window.__routeTool_baseName;
|
|
18
26
|
},
|
|
19
27
|
setSearchParams: (sp: Record<string, any>) => {
|
|
20
28
|
const url = new URL(window.location.href);
|
|
@@ -30,7 +38,7 @@ const routeTool = {
|
|
|
30
38
|
url.search = p.toString();
|
|
31
39
|
|
|
32
40
|
routeTool.getNavigate()(
|
|
33
|
-
`${url.pathname.replace(routeTool.
|
|
41
|
+
`${url.pathname.replace(routeTool.getBaseName(), '')}${url.search}${url.hash}`,
|
|
34
42
|
);
|
|
35
43
|
},
|
|
36
44
|
changeSearchParams: (sp: Record<string, any>) => {
|
|
@@ -46,7 +54,7 @@ const routeTool = {
|
|
|
46
54
|
});
|
|
47
55
|
|
|
48
56
|
routeTool.getNavigate()(
|
|
49
|
-
`${url.pathname.replace(routeTool.
|
|
57
|
+
`${url.pathname.replace(routeTool.getBaseName(), '')}${url.search}${url.hash}`,
|
|
50
58
|
);
|
|
51
59
|
},
|
|
52
60
|
navigateTo: ({
|