@fe-free/core 3.0.46 → 3.0.48

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,21 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 3.0.48
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: upload
8
+ - @fe-free/icons@3.0.48
9
+ - @fe-free/tool@3.0.48
10
+
11
+ ## 3.0.47
12
+
13
+ ### Patch Changes
14
+
15
+ - feat: markdown
16
+ - @fe-free/icons@3.0.47
17
+ - @fe-free/tool@3.0.47
18
+
3
19
  ## 3.0.46
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "3.0.46",
3
+ "version": "3.0.48",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -46,8 +46,8 @@
46
46
  "antd": "^5.27.1",
47
47
  "dayjs": "~1.11.10",
48
48
  "react": "^19.2.0",
49
- "@fe-free/icons": "3.0.46",
50
- "@fe-free/tool": "3.0.46"
49
+ "@fe-free/icons": "3.0.48",
50
+ "@fe-free/tool": "3.0.48"
51
51
  },
52
52
  "scripts": {
53
53
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -267,6 +267,17 @@ export const ProFormUploadComponent: Story = {
267
267
  name="files"
268
268
  fieldProps={{ multiple: true, maxCount: 2, showCount: true, customRequest }}
269
269
  />
270
+ <ProFormUpload
271
+ label="files_custom"
272
+ name="files"
273
+ fieldProps={{
274
+ multiple: true,
275
+ maxCount: 2,
276
+ showCount: true,
277
+ customRequest,
278
+ children: <div>click me</div>,
279
+ }}
280
+ />
270
281
  <ProFormUpload
271
282
  label="files_picture"
272
283
  name="files_picture"
@@ -10,9 +10,10 @@ import './style.scss';
10
10
 
11
11
  interface MarkdownProps {
12
12
  children: string;
13
- knowledgeRefs?: { id: string; title: string }[];
13
+ knowledgeRefs?: { id: string }[];
14
14
  onKnowledgeRef?: (id?: string) => void;
15
15
  }
16
+
16
17
  function Markdown(props: MarkdownProps) {
17
18
  const { children, knowledgeRefs, onKnowledgeRef } = props;
18
19
 
@@ -34,7 +34,7 @@ function KnowledgeRefBlock(props: any) {
34
34
  );
35
35
  }
36
36
 
37
- function processWithKnowledgeRef(text: string, knowledgeRefs?: { id: string; title: string }[]) {
37
+ function processWithKnowledgeRef(text: string, knowledgeRefs?: { id: string }[]) {
38
38
  // 匹配 [^knowledge:X-Y] 格式
39
39
  const knowledgeRefRegex = /\[\^knowledge:(\d+-\d+)\]/g;
40
40
 
@@ -45,7 +45,7 @@ function processWithKnowledgeRef(text: string, knowledgeRefs?: { id: string; tit
45
45
  });
46
46
 
47
47
  if (count > 0 && knowledgeRefs && knowledgeRefs.length > 0) {
48
- newText = `${newText}\n<knowledge-ref>来源&gt;&gt;</knowledge>`;
48
+ newText = `${newText}\n\n<knowledge-ref>来源&gt;&gt;</knowledge>`;
49
49
  }
50
50
 
51
51
  return newText;
@@ -17,6 +17,7 @@ interface UploadBaseProps {
17
17
  listType?: AntdUploadProps['listType'];
18
18
  accept?: string;
19
19
  directory?: AntdUploadProps['directory'];
20
+ children?: ReactNode | ((props: { isDisabled: boolean }) => ReactNode);
20
21
  }
21
22
 
22
23
  interface UploadProps extends UploadBaseProps {
@@ -73,7 +74,7 @@ function useUpload(
73
74
 
74
75
  return true;
75
76
  },
76
- [fileList, multiple, maxCount],
77
+ [multiple, maxCount, fileList.length, message],
77
78
  );
78
79
 
79
80
  // 多选情况下,超出则上传按钮 disabled
@@ -93,9 +94,39 @@ function useUpload(
93
94
  };
94
95
  }
95
96
 
97
+ function defaultChildren(
98
+ props: ImageUploadProps,
99
+ otherProps: { fileList: UploadFile[]; isDisabled: boolean },
100
+ ) {
101
+ const { listType, showCount, multiple, maxCount } = props;
102
+ const { fileList, isDisabled } = otherProps;
103
+
104
+ if (listType === 'picture-card') {
105
+ return (
106
+ <button style={{ border: 0, background: 'none' }} type="button" disabled={isDisabled}>
107
+ <PlusOutlined />
108
+ <div style={{ marginTop: 8 }}>本地上传</div>
109
+ </button>
110
+ );
111
+ }
112
+ return (
113
+ <Button icon={<UploadOutlined />} disabled={isDisabled}>
114
+ 本地上传{showCount && multiple ? `(${fileList.length}/${maxCount})` : ''}
115
+ </Button>
116
+ );
117
+ }
118
+
96
119
  function Upload(props: ImageUploadProps) {
97
- const { multiple, maxCount, showCount, action, customRequest, listType, accept, directory } =
98
- props;
120
+ const {
121
+ multiple,
122
+ maxCount,
123
+ action,
124
+ customRequest,
125
+ listType,
126
+ accept,
127
+ directory,
128
+ children = defaultChildren,
129
+ } = props;
99
130
  const { onChange, beforeUpload, isDisabled, fileList } = useUpload(props);
100
131
 
101
132
  return (
@@ -113,16 +144,7 @@ function Upload(props: ImageUploadProps) {
113
144
  // 不可,否则会没法删除
114
145
  // disabled={isDisabled}
115
146
  >
116
- {listType === 'picture-card' ? (
117
- <button style={{ border: 0, background: 'none' }} type="button" disabled={isDisabled}>
118
- <PlusOutlined />
119
- <div style={{ marginTop: 8 }}>本地上传</div>
120
- </button>
121
- ) : (
122
- <Button icon={<UploadOutlined />} disabled={isDisabled}>
123
- 本地上传{showCount && multiple ? `(${fileList.length}/${maxCount})` : ''}
124
- </Button>
125
- )}
147
+ {typeof children === 'function' ? children(props, { fileList, isDisabled }) : children}
126
148
  </AntdUpload>
127
149
  );
128
150
  }