@astral/ui 4.54.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/components/fileUploading/hooks/usePreviewFileUploader/usePreviewFileUploader.d.ts +5 -1
- package/components/fileUploading/hooks/usePreviewFileUploader/usePreviewFileUploader.js +2 -1
- 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/node/components/fileUploading/hooks/usePreviewFileUploader/usePreviewFileUploader.d.ts +5 -1
- package/node/components/fileUploading/hooks/usePreviewFileUploader/usePreviewFileUploader.js +2 -1
- 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;
|
|
@@ -106,6 +106,10 @@ export type UsePreviewFileUploaderParams = {
|
|
|
106
106
|
* }
|
|
107
107
|
*/
|
|
108
108
|
onView?: (fileId: FileId, file?: File, fileUrl?: string) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Функция, позволяющая задавать кастомный текст ошибки
|
|
111
|
+
*/
|
|
112
|
+
getErrorMessage?: (fileId: FileId, error: Error) => string;
|
|
109
113
|
/**
|
|
110
114
|
* Функция, вызываемая при изменении списка файлов (добавление/удаление)
|
|
111
115
|
* @param value - Объект загруженного файла или null при удалении
|
|
@@ -133,7 +137,7 @@ export type UsePreviewFileUploaderParams = {
|
|
|
133
137
|
*/
|
|
134
138
|
PdfViewer?: ((props: PdfViewerProps) => ReactElement) | LazyExoticComponent<(props: PdfViewerProps) => ReactElement>;
|
|
135
139
|
};
|
|
136
|
-
export declare const usePreviewFileUploader: ({ value, isDisabled, accept, restrictions, maxFileSize, inputRef, notify, onChange, onUploadFile, onDeleteFile, label, isError, generateDownloadLink, onView, name, helperText, className, placeholder, placeholderImgSrc, isHidePersonalData, PdfViewer, }: UsePreviewFileUploaderParams) => {
|
|
140
|
+
export declare const usePreviewFileUploader: ({ value, isDisabled, accept, restrictions, maxFileSize, inputRef, notify, onChange, onUploadFile, onDeleteFile, label, isError, generateDownloadLink, onView, getErrorMessage, name, helperText, className, placeholder, placeholderImgSrc, isHidePersonalData, PdfViewer, }: UsePreviewFileUploaderParams) => {
|
|
137
141
|
dropZoneProps: {
|
|
138
142
|
isVisibleAddFile: boolean;
|
|
139
143
|
isVisibleFileList: boolean;
|
|
@@ -10,7 +10,7 @@ import { rulePipe } from '../../utils/rulePipe';
|
|
|
10
10
|
import { toArray } from '../../utils/toArray';
|
|
11
11
|
import { useDnD } from '../useDnD';
|
|
12
12
|
import { useUploadFiles } from '../useUploadFiles';
|
|
13
|
-
export const usePreviewFileUploader = ({ value, isDisabled, accept, restrictions = [], maxFileSize, inputRef, notify, onChange, onUploadFile, onDeleteFile, label, isError, generateDownloadLink, onView, name, helperText, className, placeholder, placeholderImgSrc, isHidePersonalData, PdfViewer, }) => {
|
|
13
|
+
export const usePreviewFileUploader = ({ value, isDisabled, accept, restrictions = [], maxFileSize, inputRef, notify, onChange, onUploadFile, onDeleteFile, label, isError, generateDownloadLink, onView, getErrorMessage, name, helperText, className, placeholder, placeholderImgSrc, isHidePersonalData, PdfViewer, }) => {
|
|
14
14
|
const inputId = useId();
|
|
15
15
|
const [deletingFileId, setDeletingFileId] = useState(null);
|
|
16
16
|
const { generateId } = useGenerateLocalId();
|
|
@@ -46,6 +46,7 @@ export const usePreviewFileUploader = ({ value, isDisabled, accept, restrictions
|
|
|
46
46
|
files,
|
|
47
47
|
onChange,
|
|
48
48
|
onUploadFile,
|
|
49
|
+
getErrorMessage,
|
|
49
50
|
});
|
|
50
51
|
const handleChange = (event) => {
|
|
51
52
|
// Преобразуем к массиву и удаляем дубликаты
|
|
@@ -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;
|
package/node/components/fileUploading/hooks/usePreviewFileUploader/usePreviewFileUploader.d.ts
CHANGED
|
@@ -106,6 +106,10 @@ export type UsePreviewFileUploaderParams = {
|
|
|
106
106
|
* }
|
|
107
107
|
*/
|
|
108
108
|
onView?: (fileId: FileId, file?: File, fileUrl?: string) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Функция, позволяющая задавать кастомный текст ошибки
|
|
111
|
+
*/
|
|
112
|
+
getErrorMessage?: (fileId: FileId, error: Error) => string;
|
|
109
113
|
/**
|
|
110
114
|
* Функция, вызываемая при изменении списка файлов (добавление/удаление)
|
|
111
115
|
* @param value - Объект загруженного файла или null при удалении
|
|
@@ -133,7 +137,7 @@ export type UsePreviewFileUploaderParams = {
|
|
|
133
137
|
*/
|
|
134
138
|
PdfViewer?: ((props: PdfViewerProps) => ReactElement) | LazyExoticComponent<(props: PdfViewerProps) => ReactElement>;
|
|
135
139
|
};
|
|
136
|
-
export declare const usePreviewFileUploader: ({ value, isDisabled, accept, restrictions, maxFileSize, inputRef, notify, onChange, onUploadFile, onDeleteFile, label, isError, generateDownloadLink, onView, name, helperText, className, placeholder, placeholderImgSrc, isHidePersonalData, PdfViewer, }: UsePreviewFileUploaderParams) => {
|
|
140
|
+
export declare const usePreviewFileUploader: ({ value, isDisabled, accept, restrictions, maxFileSize, inputRef, notify, onChange, onUploadFile, onDeleteFile, label, isError, generateDownloadLink, onView, getErrorMessage, name, helperText, className, placeholder, placeholderImgSrc, isHidePersonalData, PdfViewer, }: UsePreviewFileUploaderParams) => {
|
|
137
141
|
dropZoneProps: {
|
|
138
142
|
isVisibleAddFile: boolean;
|
|
139
143
|
isVisibleFileList: boolean;
|
package/node/components/fileUploading/hooks/usePreviewFileUploader/usePreviewFileUploader.js
CHANGED
|
@@ -13,7 +13,7 @@ const rulePipe_1 = require("../../utils/rulePipe");
|
|
|
13
13
|
const toArray_1 = require("../../utils/toArray");
|
|
14
14
|
const useDnD_1 = require("../useDnD");
|
|
15
15
|
const useUploadFiles_1 = require("../useUploadFiles");
|
|
16
|
-
const usePreviewFileUploader = ({ value, isDisabled, accept, restrictions = [], maxFileSize, inputRef, notify, onChange, onUploadFile, onDeleteFile, label, isError, generateDownloadLink, onView, name, helperText, className, placeholder, placeholderImgSrc, isHidePersonalData, PdfViewer, }) => {
|
|
16
|
+
const usePreviewFileUploader = ({ value, isDisabled, accept, restrictions = [], maxFileSize, inputRef, notify, onChange, onUploadFile, onDeleteFile, label, isError, generateDownloadLink, onView, getErrorMessage, name, helperText, className, placeholder, placeholderImgSrc, isHidePersonalData, PdfViewer, }) => {
|
|
17
17
|
const inputId = (0, useId_1.useId)();
|
|
18
18
|
const [deletingFileId, setDeletingFileId] = (0, react_1.useState)(null);
|
|
19
19
|
const { generateId } = (0, useGenerateLocalId_1.useGenerateLocalId)();
|
|
@@ -49,6 +49,7 @@ const usePreviewFileUploader = ({ value, isDisabled, accept, restrictions = [],
|
|
|
49
49
|
files,
|
|
50
50
|
onChange,
|
|
51
51
|
onUploadFile,
|
|
52
|
+
getErrorMessage,
|
|
52
53
|
});
|
|
53
54
|
const handleChange = (event) => {
|
|
54
55
|
// Преобразуем к массиву и удаляем дубликаты
|