@fe-free/core 3.0.3 → 3.0.5

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
+ ## 3.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: tree
8
+ - @fe-free/tool@3.0.5
9
+
10
+ ## 3.0.4
11
+
12
+ ### Patch Changes
13
+
14
+ - feat: file tree
15
+ - @fe-free/tool@3.0.4
16
+
3
17
  ## 3.0.3
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -41,7 +41,7 @@
41
41
  "safe-stable-stringify": "^2.5.0",
42
42
  "vanilla-jsoneditor": "^0.23.1",
43
43
  "zustand": "^4.5.4",
44
- "@fe-free/tool": "3.0.3"
44
+ "@fe-free/tool": "3.0.5"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@ant-design/pro-components": "2.8.9",
@@ -99,7 +99,7 @@ const PRESET_FILE_ICONS: {
99
99
  {
100
100
  key: 'folder',
101
101
  icon: <FolderFilled />,
102
- color: '#FFDC00',
102
+ color: '#FFD93B',
103
103
  ext: [],
104
104
  },
105
105
  ];
@@ -8,7 +8,7 @@ const meta: Meta<typeof FileTree> = {
8
8
  decorators: [
9
9
  (Story) => {
10
10
  return (
11
- <div className="w-[200px] overflow-y-auto border border-01">
11
+ <div className="w-[300px] overflow-y-auto border border-01">
12
12
  <Story />
13
13
  </div>
14
14
  );
@@ -117,6 +117,10 @@ export const Default: Story = {
117
117
  operateIsDisabled: (nodeData) => nodeData.key === '5',
118
118
  operateIsHidden: (nodeData) => nodeData.key === '6',
119
119
  },
120
+
121
+ renderTitleRight: () => {
122
+ return <div className="text-03">10</div>;
123
+ },
120
124
  },
121
125
  };
122
126
 
@@ -19,7 +19,6 @@ interface FileTreeProps<D extends DataNode> extends TreeProps<D> {
19
19
  /** 注意,没法控制 title 区域的添加(由 actions 来控制) */
20
20
  createProps?: {
21
21
  operateIsDisabled?: (nodeData: D) => boolean;
22
-
23
22
  operateIsHidden?: (nodeData: D) => boolean;
24
23
  };
25
24
  updateProps?: {
@@ -30,6 +29,8 @@ interface FileTreeProps<D extends DataNode> extends TreeProps<D> {
30
29
  operateIsDisabled?: (nodeData: D) => boolean;
31
30
  operateIsHidden?: (nodeData: D) => boolean;
32
31
  };
32
+
33
+ renderTitleRight?: (nodeData: D) => React.ReactNode;
33
34
  }
34
35
 
35
36
  function Detail<D extends DataNode>({
@@ -164,8 +165,20 @@ function More({
164
165
  }
165
166
 
166
167
  function FileTree<D extends DataNode>(props: FileTreeProps<D>) {
168
+ const {
169
+ actions,
170
+ requestCreateByValues,
171
+ requestUpdateByValues,
172
+ requestDeleteByRecord,
173
+ createProps,
174
+ updateProps,
175
+ deleteProps,
176
+ renderTitleRight,
177
+ treeProps,
178
+ } = props;
179
+
167
180
  const titleExtra = useMemo(() => {
168
- if (!props.actions?.includes('create')) {
181
+ if (!actions?.includes('create')) {
169
182
  return null;
170
183
  }
171
184
 
@@ -173,16 +186,16 @@ function FileTree<D extends DataNode>(props: FileTreeProps<D>) {
173
186
  <Detail
174
187
  action="create"
175
188
  trigger={<PlusOutlined />}
176
- requestCreateByValues={props.requestCreateByValues}
189
+ requestCreateByValues={requestCreateByValues}
177
190
  />
178
191
  );
179
- }, [props.actions, props.requestCreateByValues]);
192
+ }, [actions, requestCreateByValues]);
180
193
 
181
194
  const titleRender = useCallback(
182
195
  (nodeData) => {
183
- const hasMore = props.actions?.includes('update') || props.actions?.includes('delete');
196
+ const hasMore = actions?.includes('update') || actions?.includes('delete');
184
197
  return (
185
- <div className="group flex gap-1">
198
+ <div className="group flex items-center gap-2">
186
199
  {nodeData.children ? (
187
200
  <FileCard.FileIcon isDirectory className="text-base" />
188
201
  ) : (
@@ -192,20 +205,20 @@ function FileTree<D extends DataNode>(props: FileTreeProps<D>) {
192
205
  />
193
206
  )}
194
207
  <div className="flex-1 truncate">{nodeData.title}</div>
195
- <div className={classNames('text-03', { 'group-hover:hidden': hasMore })}>
196
- {nodeData.children?.length || 0}
208
+ <div className={classNames({ 'group-hover:hidden': hasMore })}>
209
+ {renderTitleRight?.(nodeData)}
197
210
  </div>
198
211
  {hasMore && (
199
212
  <div className="hidden group-hover:block">
200
213
  <More
201
- actions={props.actions}
214
+ actions={actions}
202
215
  nodeData={nodeData}
203
- requestCreateByValues={props.requestCreateByValues}
204
- requestUpdateByValues={props.requestUpdateByValues}
205
- requestDeleteByRecord={props.requestDeleteByRecord}
206
- createProps={props.createProps}
207
- updateProps={props.updateProps}
208
- deleteProps={props.deleteProps}
216
+ requestCreateByValues={requestCreateByValues}
217
+ requestUpdateByValues={requestUpdateByValues}
218
+ requestDeleteByRecord={requestDeleteByRecord}
219
+ createProps={createProps}
220
+ updateProps={updateProps}
221
+ deleteProps={deleteProps}
209
222
  />
210
223
  </div>
211
224
  )}
@@ -213,24 +226,26 @@ function FileTree<D extends DataNode>(props: FileTreeProps<D>) {
213
226
  );
214
227
  },
215
228
  [
216
- props.actions,
217
- props.requestCreateByValues,
218
- props.requestDeleteByRecord,
219
- props.requestUpdateByValues,
220
- props.createProps,
221
- props.updateProps,
222
- props.deleteProps,
229
+ actions,
230
+ createProps,
231
+ deleteProps,
232
+ renderTitleRight,
233
+ requestCreateByValues,
234
+ requestDeleteByRecord,
235
+ requestUpdateByValues,
236
+ updateProps,
223
237
  ],
224
238
  );
225
239
 
226
240
  return (
227
241
  <Tree
228
242
  titleExtra={titleExtra}
243
+ size="large"
229
244
  {...props}
230
245
  treeProps={{
231
246
  titleRender,
232
- ...props.treeProps,
233
- className: classNames('fec-file-tree', props.treeProps?.className),
247
+ ...treeProps,
248
+ className: classNames('fec-file-tree', treeProps?.className),
234
249
  }}
235
250
  />
236
251
  );
@@ -8,12 +8,25 @@
8
8
  .ant-tree-switcher {
9
9
  margin-inline-end: 0 !important;
10
10
  }
11
+
12
+ &.fec-tree-large {
13
+ .ant-tree-treenode {
14
+ line-height: 32px;
15
+ }
16
+ }
11
17
  }
12
18
 
13
19
  .fec-file-tree {
14
20
  .ant-tree-node-content-wrapper {
15
21
  overflow: hidden;
16
- padding-inline-start: 0 !important;
22
+ }
23
+
24
+ .ant-tree-switcher {
25
+ &:hover {
26
+ &::before {
27
+ background-color: transparent !important;
28
+ }
29
+ }
17
30
  }
18
31
 
19
32
  &.fec-tree-all-leaf {
package/src/tree/tree.tsx CHANGED
@@ -20,6 +20,8 @@ interface TreeProps<T extends DataNode> {
20
20
  enableSearch?: boolean;
21
21
  /** Antd 树的 props */
22
22
  treeProps?: AntdTreeProps<T>;
23
+ /** 更宽松的布局 */
24
+ size?: 'large';
23
25
  }
24
26
 
25
27
  function useHighLightTreeData({ treeData, search }) {
@@ -167,6 +169,7 @@ function Tree<T extends DataNode>(props: TreeProps<T>) {
167
169
  'fec-tree fec-tree-no-wrap',
168
170
  {
169
171
  'fec-tree-all-leaf': isAllLeaf,
172
+ 'fec-tree-large': props.size === 'large',
170
173
  },
171
174
  treeProps?.className,
172
175
  )}