@fe-free/core 1.5.1 → 1.5.3

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
+ ## 1.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: ProFormListModalHelper
8
+ - @fe-free/tool@1.5.3
9
+
10
+ ## 1.5.2
11
+
12
+ ### Patch Changes
13
+
14
+ - fix: crud search
15
+ - @fe-free/tool@1.5.2
16
+
3
17
  ## 1.5.1
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -36,7 +36,7 @@
36
36
  "react-syntax-highlighter": "^15.5.0",
37
37
  "vanilla-jsoneditor": "^0.23.1",
38
38
  "zustand": "^4.5.4",
39
- "@fe-free/tool": "1.5.1"
39
+ "@fe-free/tool": "1.5.3"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@ant-design/pro-components": "^2.8.7",
@@ -101,6 +101,8 @@ function CRUDOfSimpleComponent(props: CRUDOfSimpleProps, ref: React.ForwardedRef
101
101
  ghost: true,
102
102
  columns: newColumns,
103
103
  toolBarRender,
104
+ // 简单的隐藏搜索栏
105
+ search: false,
104
106
  }}
105
107
  />
106
108
  </div>
@@ -5,6 +5,25 @@ import React from 'react';
5
5
 
6
6
  const emptyArr = [];
7
7
 
8
+ interface ProFormListModalHelperProps<T> {
9
+ value?: T[];
10
+ onChange?: (value: T[]) => void;
11
+ children: (props: { value?: T[]; item: T; index: number }) => React.ReactNode;
12
+ readOnly?: boolean;
13
+ detailForm: JSX.Element;
14
+ // 如果 addForm 存在,则使用 addForm 作为添加按钮
15
+ addForm?: JSX.Element;
16
+ // 禁用添加的提交按钮
17
+ disabledSubmitter?: boolean;
18
+ // 禁用添加
19
+ disabledAdd?: boolean;
20
+ // 禁用编辑
21
+ disabledEdit?: boolean;
22
+ // 触发添加
23
+ addTrigger?: JSX.Element;
24
+ editForm?: any;
25
+ }
26
+
8
27
  function Edit<T>(props: {
9
28
  children: JSX.Element;
10
29
  values?: T;
@@ -33,24 +52,6 @@ function Edit<T>(props: {
33
52
  );
34
53
  }
35
54
 
36
- interface ProFormListModalHelperProps<T> {
37
- value?: T[];
38
- onChange?: (value: T[]) => void;
39
- children: (props: { value?: T[]; item: T; index: number }) => React.ReactNode;
40
- readOnly?: boolean;
41
- detailForm: JSX.Element;
42
- // 如果 addForm 存在,则使用 addForm 作为添加按钮
43
- addForm?: JSX.Element;
44
- // 禁用添加的提交按钮
45
- disabledSubmitter?: boolean;
46
-
47
- disabledAdd?: boolean;
48
- // 触发添加
49
- addTrigger?: JSX.Element;
50
-
51
- editForm?: any;
52
- }
53
-
54
55
  function ProFormListModalHelper<T = any>(props: ProFormListModalHelperProps<T>) {
55
56
  const options = props.value || emptyArr;
56
57
 
@@ -69,18 +70,20 @@ function ProFormListModalHelper<T = any>(props: ProFormListModalHelperProps<T>)
69
70
  </div>
70
71
  {!props.readOnly && (
71
72
  <div className="absolute right-1 top-1 hidden items-center bg-white group-hover:flex">
72
- <Edit<T>
73
- values={item}
74
- onChange={(newValues) => {
75
- const newOptions = [...options];
76
- newOptions[index] = newValues;
77
- props.onChange?.(newOptions);
78
- }}
79
- detailForm={props.detailForm}
80
- editForm={props?.editForm}
81
- >
82
- <Button icon={<EditOutlined />} type="text" size="small" />
83
- </Edit>
73
+ {!props.disabledEdit && (
74
+ <Edit<T>
75
+ values={item}
76
+ onChange={(newValues) => {
77
+ const newOptions = [...options];
78
+ newOptions[index] = newValues;
79
+ props.onChange?.(newOptions);
80
+ }}
81
+ detailForm={props.detailForm}
82
+ editForm={props?.editForm}
83
+ >
84
+ <Button icon={<EditOutlined />} type="text" size="small" />
85
+ </Edit>
86
+ )}
84
87
  <Button
85
88
  icon={<DeleteOutlined />}
86
89
  type="text"
@@ -37,6 +37,23 @@ function Table<
37
37
 
38
38
  const hasSearch = !!newColumns?.find((column) => column.search);
39
39
 
40
+ let newSearch: any = undefined;
41
+ if (hasSearch) {
42
+ newSearch = {
43
+ labelWidth: 'auto',
44
+ defaultCollapsed: false,
45
+ ...search,
46
+ };
47
+ } else if (search === false) {
48
+ newSearch = false;
49
+ } else {
50
+ newSearch = {
51
+ ...search,
52
+ };
53
+ }
54
+
55
+ console.log('newSearch', newSearch);
56
+
40
57
  return (
41
58
  <ProTable<DataSource, Params>
42
59
  cardBordered
@@ -46,17 +63,7 @@ function Table<
46
63
  // @ts-ignore 不会处理这里的 ts,或者成本大
47
64
  columns={newColumns}
48
65
  scroll={getTableScroll(newColumns)}
49
- search={
50
- hasSearch
51
- ? {
52
- labelWidth: 'auto',
53
- defaultCollapsed: false,
54
- ...search,
55
- }
56
- : {
57
- ...search,
58
- }
59
- }
66
+ search={newSearch}
60
67
  {...rest}
61
68
  />
62
69
  );