@fe-free/core 4.1.38 → 4.1.40

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
+ ## 4.1.40
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: ScrollFixed
8
+ - @fe-free/icons@4.1.40
9
+ - @fe-free/tool@4.1.40
10
+
11
+ ## 4.1.39
12
+
13
+ ### Patch Changes
14
+
15
+ - fix: ai
16
+ - @fe-free/icons@4.1.39
17
+ - @fe-free/tool@4.1.39
18
+
3
19
  ## 4.1.38
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "4.1.38",
3
+ "version": "4.1.40",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -50,8 +50,8 @@
50
50
  "i18next-icu": "^2.4.1",
51
51
  "react": "^19.2.0",
52
52
  "react-i18next": "^16.4.0",
53
- "@fe-free/icons": "4.1.38",
54
- "@fe-free/tool": "4.1.38"
53
+ "@fe-free/icons": "4.1.40",
54
+ "@fe-free/tool": "4.1.40"
55
55
  },
56
56
  "scripts": {
57
57
  "i18n-extract": "rm -rf ./src/locales/zh-CN && npx i18next-cli extract"
@@ -5,6 +5,7 @@ import { useImperativeHandle, useRef, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import stringify from 'safe-stable-stringify';
7
7
  import { useGlobalInfiniteScroll } from '../ahooks/use_global_infinite_scroll';
8
+ import { ScrollFixed } from '../scroll';
8
9
 
9
10
  interface ActionType {
10
11
  reload: () => void;
@@ -22,6 +23,7 @@ interface InfiniteListProps<D, P> {
22
23
  gridClassName: string;
23
24
  className?: string;
24
25
  actionRef?: React.Ref<ActionType | undefined>;
26
+ scrollFixed?: boolean;
25
27
  }
26
28
 
27
29
  const emptyParams = {};
@@ -34,6 +36,7 @@ const InfiniteListBase = <D, P>({
34
36
  pageSize,
35
37
  gridClassName,
36
38
  className,
39
+ scrollFixed = false,
37
40
  }: InfiniteListProps<D, P>) => {
38
41
  const { t } = useTranslation();
39
42
  const ref = useRef<HTMLDivElement>(null);
@@ -91,7 +94,7 @@ const InfiniteListBase = <D, P>({
91
94
  }));
92
95
 
93
96
  return (
94
- <div ref={ref} className={classNames('h-full overflow-y-auto', className)}>
97
+ <ScrollFixed refScroll={ref} className={className} disabled={!scrollFixed}>
95
98
  {loading && (
96
99
  <div className="flex h-full w-full items-center justify-center">
97
100
  <Spin />
@@ -116,7 +119,7 @@ const InfiniteListBase = <D, P>({
116
119
  </div>
117
120
  )}
118
121
  </div>
119
- </div>
122
+ </ScrollFixed>
120
123
  );
121
124
  };
122
125
 
@@ -2,7 +2,13 @@ import classNames from 'classnames';
2
2
  import { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { getScrollbarWidth } from './helper';
4
4
 
5
- function useScrollFixed({ ref }: { ref: React.RefObject<HTMLElement | null> }) {
5
+ function useScrollFixed({
6
+ ref,
7
+ disabled,
8
+ }: {
9
+ ref: React.RefObject<HTMLElement | null>;
10
+ disabled?: boolean;
11
+ }) {
6
12
  const [marginRight, setMarginRight] = useState(0);
7
13
 
8
14
  const scrollbarWidth = useMemo(() => {
@@ -10,6 +16,10 @@ function useScrollFixed({ ref }: { ref: React.RefObject<HTMLElement | null> }) {
10
16
  }, []);
11
17
 
12
18
  useEffect(() => {
19
+ if (disabled) {
20
+ return;
21
+ }
22
+
13
23
  const el = ref.current;
14
24
  if (!el) return;
15
25
 
@@ -28,28 +38,30 @@ function useScrollFixed({ ref }: { ref: React.RefObject<HTMLElement | null> }) {
28
38
  resizeObserver.disconnect();
29
39
  el.removeEventListener('scroll', updateMargin);
30
40
  };
31
- }, [ref, scrollbarWidth]);
41
+ }, [ref, scrollbarWidth, disabled]);
32
42
 
33
43
  return { marginRight };
34
44
  }
35
45
 
36
- function ScrollFixed({
37
- refScroll,
38
- className,
39
- children,
40
- ...rest
41
- }: {
46
+ interface ScrollFixedProps {
42
47
  refScroll?: React.RefObject<HTMLDivElement | null>;
48
+ disabled?: boolean;
43
49
  className?: string;
44
50
  style?: React.CSSProperties;
45
51
  children: React.ReactNode;
46
- }) {
52
+ }
53
+
54
+ function ScrollFixed({ refScroll, className, children, disabled, ...rest }: ScrollFixedProps) {
47
55
  const innerRef = useRef<HTMLDivElement>(null);
48
56
  const ref = refScroll || innerRef;
49
- const { marginRight } = useScrollFixed({ ref });
57
+ const { marginRight } = useScrollFixed({ ref, disabled });
50
58
 
51
59
  return (
52
- <div ref={ref} {...rest} className={classNames('h-full w-full overflow-y-auto', className)}>
60
+ <div
61
+ ref={ref}
62
+ {...rest}
63
+ className={classNames('h-full w-full overflow-y-auto overflow-x-hidden', className)}
64
+ >
53
65
  <div style={{ marginRight: `-${marginRight || 0}px` }}>{children}</div>
54
66
  </div>
55
67
  );