@astral/ui 4.55.0 → 4.55.1
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/components/CardGridInfinite/CardGridInfinite.js +19 -6
- package/components/CardGridInfinite/useLogic/useLogic.d.ts +1 -0
- package/components/CardGridInfinite/useLogic/useLogic.js +1 -0
- package/node/components/CardGridInfinite/CardGridInfinite.js +18 -5
- package/node/components/CardGridInfinite/useLogic/useLogic.d.ts +1 -0
- package/node/components/CardGridInfinite/useLogic/useLogic.js +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useMemo } from 'react';
|
|
3
|
-
import { VirtuosoGrid, } from 'react-virtuoso';
|
|
3
|
+
import { Virtuoso, VirtuosoGrid, } from 'react-virtuoso';
|
|
4
4
|
import { ContentState } from '../ContentState';
|
|
5
5
|
import { Card } from './Card';
|
|
6
6
|
import { cardGridClassnames } from './constants';
|
|
@@ -12,10 +12,23 @@ import { SkeletonGrid } from './SkeletonGrid';
|
|
|
12
12
|
import { ContentStateWrapper } from './styles';
|
|
13
13
|
import { useLogic } from './useLogic';
|
|
14
14
|
export const CardGridInfinite = (props) => {
|
|
15
|
-
const { contentStateProps, desktopCardWidth, virtuosoProps, scrollParent, skeleton, footerProps, onTopButtonProps, list, noDataImgSrc, defineCard, classnames, } = useLogic(props);
|
|
15
|
+
const { contentStateProps, desktopCardWidth, virtuosoProps, scrollParent, skeleton, footerProps, onTopButtonProps, list, noDataImgSrc, defineCard, classnames, isMobile, } = useLogic(props);
|
|
16
16
|
const VirtuosoList = useMemo(() => forwardRef((listProps, ref) => (_jsx(List, { ...listProps, ref: ref, desktopCardWidth: desktopCardWidth }))), [desktopCardWidth]);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const renderVirtuoso = () => {
|
|
18
|
+
if (!scrollParent) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
// VirtuosoGrid не поддерживает работу со списком без grid сетки (на мобиле обычный список) когда высота item разная
|
|
22
|
+
if (isMobile) {
|
|
23
|
+
return (_jsx(Virtuoso, { ...virtuosoProps, data: list, customScrollParent: scrollParent, components: {
|
|
24
|
+
List: VirtuosoList,
|
|
25
|
+
Footer: () => _jsx(Footer, { ...footerProps }),
|
|
26
|
+
}, itemContent: (_, item) => _jsx(Card, { item: item, ...defineCard(item) }) }));
|
|
27
|
+
}
|
|
28
|
+
return (_jsx(VirtuosoGrid, { ...virtuosoProps, data: list, customScrollParent: scrollParent, listClassName: cardGridClassnames.list, components: {
|
|
29
|
+
List: VirtuosoList,
|
|
30
|
+
Footer: () => _jsx(Footer, { ...footerProps }),
|
|
31
|
+
}, itemContent: (_, item) => _jsx(Card, { item: item, ...defineCard(item) }) }));
|
|
32
|
+
};
|
|
33
|
+
return (_jsx(ContentStateWrapper, { className: classnames, children: _jsx(ContentState, { ...contentStateProps, loadingContent: _jsx(SkeletonGrid, { skeleton: skeleton, desktopCardWidth: desktopCardWidth }), children: list?.length ? (_jsxs(_Fragment, { children: [renderVirtuoso(), _jsx(OnTopButton, { ...onTopButtonProps })] })) : (_jsx(NoDataPlaceholder, { noDataImgSrc: noDataImgSrc })) }) }));
|
|
21
34
|
};
|
|
@@ -31,6 +31,7 @@ export declare const useLogic: <TDataItem extends Record<string, unknown>>({ lis
|
|
|
31
31
|
handleScrollToTop: () => void;
|
|
32
32
|
scrollRef: import("react").RefObject<HTMLElement | null>;
|
|
33
33
|
};
|
|
34
|
+
isMobile: boolean;
|
|
34
35
|
scrollParent: HTMLElement | null;
|
|
35
36
|
skeleton: import("../types").SkeletonConfig;
|
|
36
37
|
list: TDataItem[] | undefined;
|
|
@@ -15,11 +15,24 @@ const SkeletonGrid_1 = require("./SkeletonGrid");
|
|
|
15
15
|
const styles_1 = require("./styles");
|
|
16
16
|
const useLogic_1 = require("./useLogic");
|
|
17
17
|
const CardGridInfinite = (props) => {
|
|
18
|
-
const { contentStateProps, desktopCardWidth, virtuosoProps, scrollParent, skeleton, footerProps, onTopButtonProps, list, noDataImgSrc, defineCard, classnames, } = (0, useLogic_1.useLogic)(props);
|
|
18
|
+
const { contentStateProps, desktopCardWidth, virtuosoProps, scrollParent, skeleton, footerProps, onTopButtonProps, list, noDataImgSrc, defineCard, classnames, isMobile, } = (0, useLogic_1.useLogic)(props);
|
|
19
19
|
const VirtuosoList = (0, react_1.useMemo)(() => (0, react_1.forwardRef)((listProps, ref) => ((0, jsx_runtime_1.jsx)(List_1.List, { ...listProps, ref: ref, desktopCardWidth: desktopCardWidth }))), [desktopCardWidth]);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const renderVirtuoso = () => {
|
|
21
|
+
if (!scrollParent) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
// VirtuosoGrid не поддерживает работу со списком без grid сетки (на мобиле обычный список) когда высота item разная
|
|
25
|
+
if (isMobile) {
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ...virtuosoProps, data: list, customScrollParent: scrollParent, components: {
|
|
27
|
+
List: VirtuosoList,
|
|
28
|
+
Footer: () => (0, jsx_runtime_1.jsx)(Footer_1.Footer, { ...footerProps }),
|
|
29
|
+
}, itemContent: (_, item) => (0, jsx_runtime_1.jsx)(Card_1.Card, { item: item, ...defineCard(item) }) }));
|
|
30
|
+
}
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.VirtuosoGrid, { ...virtuosoProps, data: list, customScrollParent: scrollParent, listClassName: constants_1.cardGridClassnames.list, components: {
|
|
32
|
+
List: VirtuosoList,
|
|
33
|
+
Footer: () => (0, jsx_runtime_1.jsx)(Footer_1.Footer, { ...footerProps }),
|
|
34
|
+
}, itemContent: (_, item) => (0, jsx_runtime_1.jsx)(Card_1.Card, { item: item, ...defineCard(item) }) }));
|
|
35
|
+
};
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.ContentStateWrapper, { className: classnames, children: (0, jsx_runtime_1.jsx)(ContentState_1.ContentState, { ...contentStateProps, loadingContent: (0, jsx_runtime_1.jsx)(SkeletonGrid_1.SkeletonGrid, { skeleton: skeleton, desktopCardWidth: desktopCardWidth }), children: list?.length ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [renderVirtuoso(), (0, jsx_runtime_1.jsx)(OnTopButton_1.OnTopButton, { ...onTopButtonProps })] })) : ((0, jsx_runtime_1.jsx)(NoDataPlaceholder_1.NoDataPlaceholder, { noDataImgSrc: noDataImgSrc })) }) }));
|
|
24
37
|
};
|
|
25
38
|
exports.CardGridInfinite = CardGridInfinite;
|
|
@@ -31,6 +31,7 @@ export declare const useLogic: <TDataItem extends Record<string, unknown>>({ lis
|
|
|
31
31
|
handleScrollToTop: () => void;
|
|
32
32
|
scrollRef: import("react").RefObject<HTMLElement | null>;
|
|
33
33
|
};
|
|
34
|
+
isMobile: boolean;
|
|
34
35
|
scrollParent: HTMLElement | null;
|
|
35
36
|
skeleton: import("../types").SkeletonConfig;
|
|
36
37
|
list: TDataItem[] | undefined;
|