@fe-free/core 3.0.32 → 3.0.34

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,22 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 3.0.34
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: crud
8
+ - @fe-free/icons@3.0.34
9
+ - @fe-free/tool@3.0.34
10
+
11
+ ## 3.0.33
12
+
13
+ ### Patch Changes
14
+
15
+ - feat: tree
16
+ - Updated dependencies
17
+ - @fe-free/tool@3.0.33
18
+ - @fe-free/icons@3.0.33
19
+
3
20
  ## 3.0.32
4
21
 
5
22
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "3.0.32",
3
+ "version": "3.0.34",
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.32",
50
- "@fe-free/tool": "3.0.32"
49
+ "@fe-free/icons": "3.0.34",
50
+ "@fe-free/tool": "3.0.34"
51
51
  },
52
52
  "scripts": {
53
53
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -2,6 +2,7 @@ import { ProConfigProvider } from '@ant-design/pro-components';
2
2
  import { useTitle } from 'ahooks';
3
3
  import { App, ConfigProvider } from 'antd';
4
4
  import zhCN from 'antd/locale/zh_CN';
5
+ import classNames from 'classnames';
5
6
  import { merge } from 'lodash-es';
6
7
  import { useEffect, useMemo } from 'react';
7
8
  import { BrowserRouter as Router, useNavigate } from 'react-router-dom';
@@ -103,6 +104,9 @@ function CoreApp(props: {
103
104
  appProps?: Omit<React.ComponentProps<typeof App>, 'children'>;
104
105
  routerProps?: Omit<Partial<React.ComponentProps<typeof Router>>, 'children'>;
105
106
  children: React.ReactNode;
107
+ customConfig?: {
108
+ hiddenFormItemLabelColon?: boolean;
109
+ };
106
110
  }) {
107
111
  const {
108
112
  basename,
@@ -113,6 +117,7 @@ function CoreApp(props: {
113
117
  configProviderProps,
114
118
  appProps,
115
119
  routerProps,
120
+ customConfig,
116
121
  } = props;
117
122
 
118
123
  useTitle(name || '');
@@ -140,7 +145,12 @@ function CoreApp(props: {
140
145
  locale={configProviderProps?.locale || zhCN}
141
146
  theme={theme}
142
147
  >
143
- <App {...appProps}>
148
+ <App
149
+ {...appProps}
150
+ className={classNames('fec-app', appProps?.className, {
151
+ 'fec-app-hidden-form-item-label-colon': customConfig?.hiddenFormItemLabelColon,
152
+ })}
153
+ >
144
154
  <Router {...routerProps} basename={basename}>
145
155
  <SetRouteTool basename={basename} />
146
156
  {enableCheckUpdate && <CheckUpdate basename={basename} />}
@@ -171,6 +171,16 @@ export const MoreCustom: Story = {
171
171
  toolBarRender: () => {
172
172
  return [<div key="custom1">自定义1</div>, <div key="custom2">自定义2</div>];
173
173
  },
174
+ search: {
175
+ optionRender: (_, __, dom) => {
176
+ return [
177
+ ...dom,
178
+ <Button key="1" type="primary" className="ml-2">
179
+ 额外的按钮
180
+ </Button>,
181
+ ];
182
+ },
183
+ },
174
184
  }}
175
185
  operateColumnProps={{
176
186
  // 自定义宽度
@@ -13,7 +13,10 @@ interface CRUDOfPureProps<
13
13
  specialToolbar?: boolean;
14
14
  }
15
15
 
16
- function CRUDOfPure(props: CRUDOfPureProps) {
16
+ function CRUDOfPure<
17
+ DataSource extends Record<string, any> = any,
18
+ Key extends string | number = string,
19
+ >(props: CRUDOfPureProps<DataSource, Key>) {
17
20
  const newColumns = props.tableProps.columns?.map((column) => {
18
21
  if (column.search) {
19
22
  return {
package/src/style.scss CHANGED
@@ -14,9 +14,11 @@
14
14
  /* stylelint-disable-next-line at-rule-no-unknown */
15
15
  @tailwind utilities;
16
16
 
17
- // 隐藏 label 的冒号
18
- .ant-form-item .ant-form-item-label > label::after {
19
- visibility: hidden;
17
+ .fec-app-hidden-form-item-label-colon {
18
+ // 隐藏 label 的冒号
19
+ .ant-form-item .ant-form-item-label > label::after {
20
+ visibility: hidden;
21
+ }
20
22
  }
21
23
 
22
24
  .ant-modal-footer {
@@ -198,7 +198,7 @@ function FileTree<D extends DataNode>(props: FileTreeProps<D>) {
198
198
  (nodeData) => {
199
199
  const hasMore = actions?.includes('update') || actions?.includes('delete');
200
200
  return (
201
- <div className="group flex items-center gap-2">
201
+ <div className="group flex items-center gap-1">
202
202
  {nodeData.children ? (
203
203
  <FileCard.FileIcon isDirectory className="text-base" />
204
204
  ) : (
package/src/tree/tree.tsx CHANGED
@@ -108,6 +108,32 @@ function useFilterTreeData({ treeData, search }) {
108
108
  }, [treeData, search]);
109
109
  }
110
110
 
111
+ function useTreeData({ treeData }) {
112
+ return useMemo(() => {
113
+ if (!treeData) {
114
+ return treeData;
115
+ }
116
+
117
+ function process(nodes) {
118
+ // 返回自己。 而非 [] undefined,因为要保留原数据格式。
119
+ if (!nodes || nodes.length === 0) {
120
+ return nodes;
121
+ }
122
+
123
+ return nodes.map((node) => {
124
+ return {
125
+ ...node,
126
+ // 如果没有显式设置 isLeaf,则 children 没传代表是叶子节点,否则还是个 dir
127
+ isLeaf: node.isLeaf ?? !node.children,
128
+ children: process(node.children),
129
+ };
130
+ });
131
+ }
132
+
133
+ return process(treeData);
134
+ }, [treeData]);
135
+ }
136
+
111
137
  function useIsAllLeaf(treeData?: DataNode[]) {
112
138
  return useMemo(() => {
113
139
  if (treeData) {
@@ -134,7 +160,7 @@ function Tree<T extends DataNode>(props: TreeProps<T>) {
134
160
  treeData: filterTreeData,
135
161
  search: debouncedSearch,
136
162
  });
137
- const newTreeData = highlightedTreeData;
163
+ const newTreeData = useTreeData({ treeData: highlightedTreeData });
138
164
 
139
165
  const handleSearch = useCallback((e) => {
140
166
  setSearch(e.target.value);