@astral/ui 4.0.0-alpha.29 → 4.0.0-alpha.30

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.
Files changed (57) hide show
  1. package/components/InfiniteTreeList/InfiniteTreeList.js +2 -2
  2. package/components/InfiniteTreeList/InfiniteTreeListActions/useLogic/useLogic.js +6 -6
  3. package/components/InfiniteTreeList/InfiniteTreeListContext/InfiniteTreeListContext.d.ts +2 -2
  4. package/components/InfiniteTreeList/InfiniteTreeListContext/InfiniteTreeListContext.js +2 -2
  5. package/components/InfiniteTreeList/InfiniteTreeListContext/InfiniteTreeListContextProvider/InfiniteTreeListContextProvider.js +11 -9
  6. package/components/InfiniteTreeList/InfiniteTreeListItem/InfiniteTreeListItem.js +1 -1
  7. package/components/InfiniteTreeList/InfiniteTreeListItem/TreeListItemContext/TreeListItemContext.d.ts +1 -1
  8. package/components/InfiniteTreeList/InfiniteTreeListItem/TreeListItemContext/TreeListItemContext.js +1 -1
  9. package/components/InfiniteTreeList/InfiniteTreeListItem/TreeListItemContext/TreeListItemContextProvider/TreeListItemContextProvider.js +6 -16
  10. package/components/InfiniteTreeList/InfiniteTreeListItem/useLogic/useLogic.d.ts +1 -3
  11. package/components/InfiniteTreeList/InfiniteTreeListItem/useLogic/useLogic.js +9 -4
  12. package/components/InfiniteTreeList/TreeItem/TreeItem.js +2 -1
  13. package/components/InfiniteTreeList/TreeItem/types.d.ts +3 -3
  14. package/components/InfiniteTreeList/TreeItem/useLogic/useLogic.d.ts +2 -2
  15. package/components/InfiniteTreeList/TreeItem/useLogic/useLogic.js +4 -2
  16. package/components/InfiniteTreeList/styles.d.ts +4 -4
  17. package/components/InfiniteTreeList/styles.js +3 -8
  18. package/components/InfiniteTreeList/types.d.ts +10 -7
  19. package/components/InfiniteTreeList/useLogic/useLogic.d.ts +2 -2
  20. package/components/InfiniteTreeList/useLogic/useLogic.js +2 -7
  21. package/components/InfiniteTreeList/useLogic/utils/flattenTree/flattenTree.js +9 -4
  22. package/components/InfiniteTreeList/useLogic/utils/getDescendants/getDescendants.js +2 -2
  23. package/components/InfiniteTreeList/useLogic/utils/getInitialExpandedIds/getInitialExpandedIds.js +1 -2
  24. package/components/InfiniteTreeList/useLogic/utils/sortCollapsed/sortCollapsed.js +3 -3
  25. package/components/PdfViewer/PdfViewer.js +5 -4
  26. package/components/PdfViewer/types.d.ts +6 -0
  27. package/components/PdfViewer/useLogic/useLogic.d.ts +16 -8
  28. package/components/PdfViewer/useLogic/useLogic.js +18 -9
  29. package/node/components/InfiniteTreeList/InfiniteTreeList.js +1 -1
  30. package/node/components/InfiniteTreeList/InfiniteTreeListActions/useLogic/useLogic.js +6 -6
  31. package/node/components/InfiniteTreeList/InfiniteTreeListContext/InfiniteTreeListContext.d.ts +2 -2
  32. package/node/components/InfiniteTreeList/InfiniteTreeListContext/InfiniteTreeListContext.js +2 -2
  33. package/node/components/InfiniteTreeList/InfiniteTreeListContext/InfiniteTreeListContextProvider/InfiniteTreeListContextProvider.js +11 -9
  34. package/node/components/InfiniteTreeList/InfiniteTreeListItem/InfiniteTreeListItem.js +1 -1
  35. package/node/components/InfiniteTreeList/InfiniteTreeListItem/TreeListItemContext/TreeListItemContext.d.ts +1 -1
  36. package/node/components/InfiniteTreeList/InfiniteTreeListItem/TreeListItemContext/TreeListItemContext.js +1 -1
  37. package/node/components/InfiniteTreeList/InfiniteTreeListItem/TreeListItemContext/TreeListItemContextProvider/TreeListItemContextProvider.js +6 -16
  38. package/node/components/InfiniteTreeList/InfiniteTreeListItem/useLogic/useLogic.d.ts +1 -3
  39. package/node/components/InfiniteTreeList/InfiniteTreeListItem/useLogic/useLogic.js +8 -3
  40. package/node/components/InfiniteTreeList/TreeItem/TreeItem.js +2 -1
  41. package/node/components/InfiniteTreeList/TreeItem/types.d.ts +3 -3
  42. package/node/components/InfiniteTreeList/TreeItem/useLogic/useLogic.d.ts +2 -2
  43. package/node/components/InfiniteTreeList/TreeItem/useLogic/useLogic.js +4 -2
  44. package/node/components/InfiniteTreeList/styles.d.ts +4 -4
  45. package/node/components/InfiniteTreeList/styles.js +4 -9
  46. package/node/components/InfiniteTreeList/types.d.ts +10 -7
  47. package/node/components/InfiniteTreeList/useLogic/useLogic.d.ts +2 -2
  48. package/node/components/InfiniteTreeList/useLogic/useLogic.js +2 -7
  49. package/node/components/InfiniteTreeList/useLogic/utils/flattenTree/flattenTree.js +9 -4
  50. package/node/components/InfiniteTreeList/useLogic/utils/getDescendants/getDescendants.js +2 -2
  51. package/node/components/InfiniteTreeList/useLogic/utils/getInitialExpandedIds/getInitialExpandedIds.js +1 -2
  52. package/node/components/InfiniteTreeList/useLogic/utils/sortCollapsed/sortCollapsed.js +3 -3
  53. package/node/components/PdfViewer/PdfViewer.js +5 -4
  54. package/node/components/PdfViewer/types.d.ts +6 -0
  55. package/node/components/PdfViewer/useLogic/useLogic.d.ts +16 -8
  56. package/node/components/PdfViewer/useLogic/useLogic.js +18 -9
  57. package/package.json +28 -10
@@ -2,17 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InfiniteTreeListContextProvider = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
5
+ const hooks_1 = require("../../../hooks");
6
6
  const InfiniteTreeListContext_1 = require("../InfiniteTreeListContext");
7
7
  const InfiniteTreeListContextProvider = ({ children, itemSkeleton, }) => {
8
- const [disabledItemIds, setDisabledItemIds] = (0, react_1.useState)(new Set());
9
- const setDisabledItemId = (itemId, disabled) => {
10
- setDisabledItemIds((prev) => {
11
- const next = new Set(prev);
12
- disabled ? next.add(itemId) : next.delete(itemId);
13
- return next;
14
- });
8
+ const [disabledIdList, disabledIdListActions] = (0, hooks_1.useSet)(new Set());
9
+ const setDisabled = (itemId, disabled) => {
10
+ disabled
11
+ ? disabledIdListActions.add(itemId)
12
+ : disabledIdListActions.remove(itemId);
15
13
  };
16
- return ((0, jsx_runtime_1.jsx)(InfiniteTreeListContext_1.InfiniteTreeListContext.Provider, { value: { itemSkeleton, disabledItemIds, setDisabledItemId }, children: children }));
14
+ return ((0, jsx_runtime_1.jsx)(InfiniteTreeListContext_1.InfiniteTreeListContext.Provider, { value: {
15
+ itemSkeleton,
16
+ disabledIdList,
17
+ setDisabled,
18
+ }, children: children }));
17
19
  };
18
20
  exports.InfiniteTreeListContextProvider = InfiniteTreeListContextProvider;
@@ -13,6 +13,6 @@ const InfiniteTreeListItem = (props) => {
13
13
  return ((0, jsx_runtime_1.jsx)(ContentState_1.ContentState, { isLoading: isLoading, loadingContent: (0, jsx_runtime_1.jsx)(styles_1.Wrapper, { "$isLoading": true, children: itemSkeleton }), isError: isError, errorState: {
14
14
  onRetry,
15
15
  errorList: [errorMsg || ''],
16
- }, children: (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, Object.assign({}, tooltipProps, { children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { onClick: handleClick, className: className, "$isDisabled": isDisabled || isDisabledByActions, "$isLoading": isLoading, "$hasNested": item.hasNested, inert: isDisabled || isDisabledByActions ? '' : undefined, children: [item.hasNested && (0, jsx_runtime_1.jsx)(Chevron_1.Chevron, { isActive: isChevronActive }), children, actions && (0, jsx_runtime_1.jsx)(styles_1.ActionsWrapper, { children: actions })] }, `infinite-tree-list-item-${item.id}`) })) }));
16
+ }, children: (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, Object.assign({}, tooltipProps, { children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { onClick: handleClick, className: className, "$isDisabled": isDisabled || isDisabledByActions, "$isLoading": isLoading, "$hasNested": item.meta.hasNested, inert: isDisabled || isDisabledByActions ? '' : undefined, children: [item.meta.hasNested && (0, jsx_runtime_1.jsx)(Chevron_1.Chevron, { isActive: isChevronActive }), children, actions && (0, jsx_runtime_1.jsx)(styles_1.ActionsWrapper, { children: actions })] }, `infinite-tree-list-item-${item.id}`) })) }));
17
17
  };
18
18
  exports.InfiniteTreeListItem = InfiniteTreeListItem;
@@ -5,6 +5,6 @@ export type TreeListItemContextProps = {
5
5
  onToggle: (item: InfiniteTreeListData) => void;
6
6
  isDisabled: boolean;
7
7
  disabledReason?: string;
8
- setDisabled: (isDisabled: boolean, disabledReason?: string) => void;
8
+ setDisabledReason: (disabledReason?: string) => void;
9
9
  };
10
10
  export declare const TreeListItemContext: import("react").Context<TreeListItemContextProps>;
@@ -6,5 +6,5 @@ exports.TreeListItemContext = (0, react_1.createContext)({
6
6
  item: {},
7
7
  onToggle: () => undefined,
8
8
  isDisabled: false,
9
- setDisabled: () => undefined,
9
+ setDisabledReason: () => undefined,
10
10
  });
@@ -6,27 +6,17 @@ const react_1 = require("react");
6
6
  const InfiniteTreeListContext_1 = require("../../../InfiniteTreeListContext");
7
7
  const TreeListItemContext_1 = require("../TreeListItemContext");
8
8
  const TreeListItemContextProvider = ({ item, children, onToggle, }) => {
9
- const [isDisabled, setIsDisabled] = (0, react_1.useState)(false);
10
9
  const [disabledReason, setDisabledReason] = (0, react_1.useState)();
11
- const { disabledItemIds } = (0, react_1.useContext)(InfiniteTreeListContext_1.InfiniteTreeListContext);
12
- // Проверяем, является ли элемент потомком disabled родителя
13
- const isDisabledByParent = (0, react_1.useMemo)(() => {
14
- // Проверяем, есть ли хотя бы один родитель в Set disabled элементов
15
- // path содержит [parent1, parent2, ..., currentItem], поэтому проверяем все кроме последнего
16
- const parentIds = item.path.slice(0, -1);
17
- return parentIds.some((parentId) => disabledItemIds.has(parentId));
18
- }, [item.path, disabledItemIds]);
19
- const setDisabled = (disabled, reason) => {
20
- setIsDisabled(disabled);
21
- setDisabledReason(disabled ? reason : undefined);
22
- };
23
- const finalIsDisabled = isDisabled || isDisabledByParent;
10
+ const { disabledIdList } = (0, react_1.useContext)(InfiniteTreeListContext_1.InfiniteTreeListContext);
11
+ const isDisabled = (0, react_1.useMemo)(() => {
12
+ return item.meta.path.some((id) => disabledIdList.has(id));
13
+ }, [item.path, disabledIdList]);
24
14
  return ((0, jsx_runtime_1.jsx)(TreeListItemContext_1.TreeListItemContext.Provider, { value: {
25
15
  item,
26
16
  onToggle,
27
- isDisabled: finalIsDisabled,
17
+ isDisabled,
28
18
  disabledReason,
29
- setDisabled,
19
+ setDisabledReason,
30
20
  }, children: children }));
31
21
  };
32
22
  exports.TreeListItemContextProvider = TreeListItemContextProvider;
@@ -1,8 +1,7 @@
1
1
  import { type MouseEvent } from 'react';
2
2
  import { type TooltipProps } from '../../../Tooltip';
3
3
  import { type InfiniteTreeListItemProps } from '../types';
4
- type UseLogicParams = InfiniteTreeListItemProps;
5
- export declare const useLogic: ({ isDisabled, disabledReason }: UseLogicParams) => {
4
+ export declare const useLogic: ({ isDisabled, disabledReason, }: InfiniteTreeListItemProps) => {
6
5
  item: import("../..").FlattenTree<import("../..").InfiniteTreeListData>;
7
6
  handleClick: (event: MouseEvent) => void;
8
7
  itemSkeleton: import("react").ReactNode;
@@ -12,4 +11,3 @@ export declare const useLogic: ({ isDisabled, disabledReason }: UseLogicParams)
12
11
  isDisabledByActions: boolean;
13
12
  isChevronActive: boolean;
14
13
  };
15
- export {};
@@ -4,10 +4,15 @@ exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
5
  const InfiniteTreeListContext_1 = require("../../InfiniteTreeListContext");
6
6
  const TreeListItemContext_1 = require("../TreeListItemContext");
7
- const useLogic = ({ isDisabled, disabledReason }) => {
8
- const { itemSkeleton } = (0, react_1.useContext)(InfiniteTreeListContext_1.InfiniteTreeListContext);
7
+ const useLogic = ({ isDisabled, disabledReason, }) => {
8
+ const { itemSkeleton, setDisabled } = (0, react_1.useContext)(InfiniteTreeListContext_1.InfiniteTreeListContext);
9
9
  const { item, onToggle, isDisabled: isDisabledByActions, disabledReason: disabledReasonByActions, } = (0, react_1.useContext)(TreeListItemContext_1.TreeListItemContext);
10
- const [isChevronActive, setChevronActive] = (0, react_1.useState)(item.isExpanded);
10
+ (0, react_1.useEffect)(() => {
11
+ if (isDisabled) {
12
+ setDisabled(item.id, isDisabled);
13
+ }
14
+ }, [isDisabled]);
15
+ const [isChevronActive, setChevronActive] = (0, react_1.useState)(item.meta.isExpanded);
11
16
  const handleClick = (0, react_1.useCallback)((event) => {
12
17
  event.stopPropagation();
13
18
  setChevronActive((prev) => !prev);
@@ -6,6 +6,7 @@ const styles_1 = require("./styles");
6
6
  const useLogic_1 = require("./useLogic");
7
7
  const TreeItem = (props) => {
8
8
  const { item, renderItem, classname, onAnimationEnd } = (0, useLogic_1.useLogic)(props);
9
- return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { id: item.nodeId, className: classname, "$level": item.level, "$siblingIndex": item.siblingIndex, onAnimationEnd: onAnimationEnd, children: renderItem(item, { level: item.level }) }));
9
+ const { nodeId, level, siblingIndex } = item.meta;
10
+ return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { id: nodeId, className: classname, "$level": level, "$siblingIndex": siblingIndex, onAnimationEnd: onAnimationEnd, children: renderItem(item) }));
10
11
  };
11
12
  exports.TreeItem = TreeItem;
@@ -1,9 +1,9 @@
1
1
  import type { ReactNode, RefObject } from 'react';
2
- import type { FlattenTree, InfiniteTreeListData } from '../types';
2
+ import { type FlattenTree, type InfiniteTreeItemMeta, type InfiniteTreeListData } from '../types';
3
3
  export type TreeItemProps<TData extends InfiniteTreeListData<TData>> = {
4
4
  item: FlattenTree<TData>;
5
- renderItem: (item: TData, meta: {
6
- level: number;
5
+ renderItem: (item: TData & {
6
+ meta: InfiniteTreeItemMeta;
7
7
  }) => ReactNode;
8
8
  recentlyExpandedIds: RefObject<Set<string>>;
9
9
  };
@@ -3,8 +3,8 @@ import type { InfiniteTreeListData } from '../../types';
3
3
  import { type TreeItemProps } from '../types';
4
4
  export declare const useLogic: <TData extends InfiniteTreeListData<TData>>({ item, renderItem, recentlyExpandedIds, }: TreeItemProps<TData>) => {
5
5
  item: import("../../types").FlattenTree<TData>;
6
- renderItem: (item: TData, meta: {
7
- level: number;
6
+ renderItem: (item: TData & {
7
+ meta: import("../../types").InfiniteTreeItemMeta;
8
8
  }) => import("react").ReactNode;
9
9
  classname: string;
10
10
  onAnimationEnd: () => void;
@@ -6,7 +6,8 @@ const constants_1 = require("../../constants");
6
6
  const useLogic = ({ item, renderItem, recentlyExpandedIds, }) => {
7
7
  const deleteRecentlyExpandedId = () => {
8
8
  var _a;
9
- item.parentId && ((_a = recentlyExpandedIds.current) === null || _a === void 0 ? void 0 : _a.delete(item.parentId));
9
+ item.meta.parentId &&
10
+ ((_a = recentlyExpandedIds.current) === null || _a === void 0 ? void 0 : _a.delete(item.meta.parentId));
10
11
  };
11
12
  (0, react_1.useEffect)(() => {
12
13
  return () => {
@@ -18,7 +19,8 @@ const useLogic = ({ item, renderItem, recentlyExpandedIds, }) => {
18
19
  };
19
20
  const classname = (0, react_1.useMemo)(() => {
20
21
  var _a;
21
- if ((item === null || item === void 0 ? void 0 : item.parentId) && ((_a = recentlyExpandedIds.current) === null || _a === void 0 ? void 0 : _a.has(item === null || item === void 0 ? void 0 : item.parentId))) {
22
+ if ((item === null || item === void 0 ? void 0 : item.meta.parentId) &&
23
+ ((_a = recentlyExpandedIds.current) === null || _a === void 0 ? void 0 : _a.has(item === null || item === void 0 ? void 0 : item.meta.parentId))) {
22
24
  return constants_1.infiniteTreeListClassnames.addAnimation;
23
25
  }
24
26
  return '';
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
- export declare const Wrapper: import("@emotion/styled").StyledComponent<{
3
- theme?: import("@emotion/react").Theme | undefined;
4
- as?: import("react").ElementType<any> | undefined;
5
- }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
2
  export declare const Footer: import("@emotion/styled").StyledComponent<{
7
3
  theme?: import("@emotion/react").Theme | undefined;
8
4
  as?: import("react").ElementType<any> | undefined;
9
5
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
6
+ export declare const FooterDummy: import("@emotion/styled").StyledComponent<{
7
+ theme?: import("@emotion/react").Theme | undefined;
8
+ as?: import("react").ElementType<any> | undefined;
9
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -1,15 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Footer = exports.Wrapper = void 0;
3
+ exports.FooterDummy = exports.Footer = void 0;
4
4
  const styles_1 = require("../styles");
5
- exports.Wrapper = styles_1.styled.div `
6
- position: relative;
7
-
8
- display: flex;
9
- flex-direction: column;
10
-
11
- height: 100%;
12
- `;
13
5
  exports.Footer = styles_1.styled.footer `
14
6
  display: flex;
15
7
  flex-shrink: 0;
@@ -19,3 +11,6 @@ exports.Footer = styles_1.styled.footer `
19
11
  min-height: 64px;
20
12
  margin-top: ${({ theme }) => theme.spacing(1)};
21
13
  `;
14
+ exports.FooterDummy = styles_1.styled.div `
15
+ min-height: 20px;
16
+ `;
@@ -7,10 +7,6 @@ export type InfiniteTreeListDataBase = {
7
7
  * Уникальный идентификатор элемента
8
8
  */
9
9
  id: string;
10
- /**
11
- * Флаг наличия дочерних элементов
12
- */
13
- hasNested?: boolean;
14
10
  /**
15
11
  * Дополнительные поля
16
12
  */
@@ -66,8 +62,8 @@ export type InfiniteTreeListProps<TData extends InfiniteTreeListData<TData> = In
66
62
  * </InfiniteTreeListItem>
67
63
  * )}
68
64
  */
69
- renderItem: (item: TData, meta: {
70
- level: number;
65
+ renderItem: (item: TData & {
66
+ meta: InfiniteTreeItemMeta;
71
67
  }) => ReactNode;
72
68
  /**
73
69
  * Уровень раскрытия дерева по умолчанию
@@ -91,7 +87,7 @@ export type InfiniteTreeListProps<TData extends InfiniteTreeListData<TData> = In
91
87
  */
92
88
  errorImgSrc?: string;
93
89
  };
94
- export type FlattenTree<TData extends InfiniteTreeListData<TData>> = TData & {
90
+ export type InfiniteTreeItemMeta = {
95
91
  /**
96
92
  * Уровень вложенности (начинается с 0)
97
93
  */
@@ -108,6 +104,10 @@ export type FlattenTree<TData extends InfiniteTreeListData<TData>> = TData & {
108
104
  * Индекс элемента среди siblings (для каскадной анимации)
109
105
  */
110
106
  siblingIndex: number;
107
+ /**
108
+ * Флаг имеет ли элемент вложенных потомков
109
+ */
110
+ hasNested: boolean;
111
111
  /**
112
112
  * Флаг раскрытия узла
113
113
  */
@@ -117,3 +117,6 @@ export type FlattenTree<TData extends InfiniteTreeListData<TData>> = TData & {
117
117
  */
118
118
  nodeId: string;
119
119
  };
120
+ export type FlattenTree<TData extends InfiniteTreeListData<TData>> = TData & {
121
+ meta: InfiniteTreeItemMeta;
122
+ };
@@ -26,8 +26,8 @@ export declare const useLogic: <TData extends InfiniteTreeListData<TData>>({ ini
26
26
  };
27
27
  endOfScrollMsg: string | undefined;
28
28
  itemSkeleton: import("react").ReactNode;
29
- renderItem: (item: TData, meta: {
30
- level: number;
29
+ renderItem: (item: TData & {
30
+ meta: import("../types").InfiniteTreeItemMeta;
31
31
  }) => import("react").ReactNode;
32
32
  items: TData[];
33
33
  onLoadMore: (() => void) | undefined;
@@ -27,12 +27,7 @@ const useLogic = ({ initialExpandedLevel, items, onRetry, errorMsg, isError, isL
27
27
  /**
28
28
  * Дерево, преобразованное в плоский список. Такая структура необходима для полноценной виртуализации
29
29
  */
30
- const flatList = (0, react_1.useMemo)(() => {
31
- const list = (0, utils_1.flattenTree)(items, internalExpanded);
32
- return list.map((item) => {
33
- return Object.assign(Object.assign({}, item), { isExpanded: internalExpanded.has(item.id) });
34
- });
35
- }, [items, internalExpanded]);
30
+ const flatList = (0, react_1.useMemo)(() => (0, utils_1.flattenTree)(items, internalExpanded), [items, internalExpanded]);
36
31
  const onToggle = ({ id: itemId }) => {
37
32
  const isExpanded = internalExpanded.has(itemId);
38
33
  if (!isExpanded) {
@@ -41,7 +36,7 @@ const useLogic = ({ initialExpandedLevel, items, onRetry, errorMsg, isError, isL
41
36
  }
42
37
  else {
43
38
  const children = (0, utils_1.sortCollapsed)((0, utils_1.getDescendants)(flatList, itemId));
44
- children.forEach(({ nodeId }) => startRemoveAnimation(nodeId));
39
+ children.forEach(({ meta }) => startRemoveAnimation(meta.nodeId));
45
40
  const collapseDurationMs = theme.transitions.duration.shorter;
46
41
  setTimeout(() => {
47
42
  internalExpandedActions.remove(itemId);
@@ -10,10 +10,15 @@ const flattenTree = (items, expandedIds, parentPath = [], level = 0, parentId) =
10
10
  const path = [...parentPath, item.id];
11
11
  const isExpanded = expandedIds.has(item.id);
12
12
  // Создаем flattened item с правильной типизацией
13
- const flattenedItem = Object.assign(Object.assign({}, item), { level,
14
- path,
15
- isExpanded,
16
- parentId, siblingIndex: index, nodeId: `infinite-tree-item-${item.id}` });
13
+ const flattenedItem = Object.assign(Object.assign({}, item), { meta: {
14
+ hasNested: Boolean(item.children),
15
+ level,
16
+ path,
17
+ isExpanded,
18
+ parentId,
19
+ siblingIndex: index,
20
+ nodeId: `infinite-tree-item-${item.id}`,
21
+ } });
17
22
  result.push(flattenedItem);
18
23
  // Рекурсивно обрабатываем детей с сохранением типизации
19
24
  if (isExpanded && item.children && item.children.length > 0) {
@@ -12,10 +12,10 @@ exports.getDescendants = void 0;
12
12
  const getDescendants = (flatList, parentId) => {
13
13
  const result = [];
14
14
  const collectChildren = (id) => {
15
- const children = flatList.filter((item) => item.parentId === id);
15
+ const children = flatList.filter((item) => item.meta.parentId === id);
16
16
  children.forEach((child) => {
17
17
  result.push(child);
18
- if (child.isExpanded) {
18
+ if (child.meta.isExpanded) {
19
19
  collectChildren(child.id);
20
20
  }
21
21
  });
@@ -13,8 +13,7 @@ const getInitialExpandedIds = (prev, items, initialExpandedLevel, currentLevel =
13
13
  const shouldExpand = currentLevel < initialExpandedLevel;
14
14
  items.forEach((item) => {
15
15
  var _a;
16
- const mightHaveChildren = item.hasNested || item.children;
17
- if (shouldExpand && mightHaveChildren) {
16
+ if (shouldExpand && item.children) {
18
17
  if (!(prev === null || prev === void 0 ? void 0 : prev.has(item.id))) {
19
18
  expandedIds.add(item.id);
20
19
  }
@@ -11,10 +11,10 @@ exports.sortCollapsed = void 0;
11
11
  */
12
12
  const sortCollapsed = (items) => {
13
13
  return [...items].sort((a, b) => {
14
- if (a.level !== b.level) {
15
- return b.level - a.level;
14
+ if (a.meta.level !== b.meta.level) {
15
+ return b.meta.level - a.meta.level;
16
16
  }
17
- return a.siblingIndex - b.siblingIndex;
17
+ return a.meta.siblingIndex - b.meta.siblingIndex;
18
18
  });
19
19
  };
20
20
  exports.sortCollapsed = sortCollapsed;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PdfViewer = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
5
6
  const react_pdf_1 = require("react-pdf");
6
7
  const ContentState_1 = require("../ContentState");
7
8
  const placeholders_1 = require("../placeholders");
@@ -19,10 +20,10 @@ react_pdf_1.pdfjs.GlobalWorkerOptions.workerSrc = constants_1.PDFJS_WORKER_URL;
19
20
  * Компонент для просмотра PDF файлов
20
21
  */
21
22
  const PdfViewer = (props) => {
22
- const { file, pageCount, pageHeightList, isError, errorState, onLoadSuccess, onLoadError, scrollRef, paginationRef, changePage, isLoading, isHidePersonalData, initialIndex, isRenderList, isViewerLite, scale, setContainerWidth, zoomOut, zoomIn, isDisabledZoomOutButton, isDisabledZoomInButton, scrollContainerRef, loadingPlaceholderTitle, enabledZoom, } = (0, useLogic_1.useLogic)(props);
23
- return ((0, jsx_runtime_1.jsx)(ContentState_1.ContentState, { isError: isError, errorState: errorState, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { "$isViewerLite": isViewerLite, "$enabledZoom": enabledZoom, children: [(0, jsx_runtime_1.jsx)(styles_1.PDFViewerContainer, { "$isViewerLite": isViewerLite, "$enabledZoom": enabledZoom, children: (0, jsx_runtime_1.jsx)(styles_1.ScrollContainer, { ref: scrollContainerRef, "$isViewerLite": isViewerLite, "$enabledZoom": enabledZoom, children: (0, jsx_runtime_1.jsx)(PdfDocument_1.PDFDocument, { file: file, onLoadSuccess: onLoadSuccess, onLoadError: onLoadError, setContainerWidth: setContainerWidth, isLoading: isLoading, loading: (0, jsx_runtime_1.jsx)(placeholders_1.LoadingPlaceholder, { title: loadingPlaceholderTitle }), isViewerLite: isViewerLite, enabledZoom: enabledZoom, children: isRenderList && ((0, jsx_runtime_1.jsx)(List_1.List, { paginationRef: paginationRef, initialIndex: initialIndex, children: pageHeightList === null || pageHeightList === void 0 ? void 0 : pageHeightList.map((height, index) => ((0, jsx_runtime_1.jsx)(PdfPage_1.PDFPage
24
- // biome-ignore lint/suspicious/noArrayIndexKey: Страницы статичны
25
- , { scrollRef: scrollRef, height: height * scale, pageNumber: index + 1, pageCount: pageCount, onChangePage: changePage, isHidePersonalData: isHidePersonalData, currentPage: Number(initialIndex) + 1, isViewerLite: isViewerLite, scale: scale, enabledZoom: enabledZoom }, index))) }, pageHeightList === null || pageHeightList === void 0 ? void 0 : pageHeightList[0])) }) }) }), (0, jsx_runtime_1.jsx)(ControlBar_1.ControlBar, { zoomOut: zoomOut, zoomIn: zoomIn, pageNumber: Number(initialIndex) + 1, buttonProps: {
23
+ const { documentProps, pageProps, pageCount, pageHeightList, isError, errorState, paginationRef, isLoading, initialIndex, isRenderList, isViewerLite, scale, zoomOut, zoomIn, isDisabledZoomOutButton, isDisabledZoomInButton, scrollContainerRef, loadingPlaceholderTitle, enabledZoom, } = (0, useLogic_1.useLogic)(props);
24
+ return ((0, jsx_runtime_1.jsx)(ContentState_1.ContentState, { isError: isError, errorState: errorState, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { "$isViewerLite": isViewerLite, "$enabledZoom": enabledZoom, children: [(0, jsx_runtime_1.jsx)(styles_1.PDFViewerContainer, { "$isViewerLite": isViewerLite, "$enabledZoom": enabledZoom, children: (0, jsx_runtime_1.jsx)(styles_1.ScrollContainer, { ref: scrollContainerRef, "$isViewerLite": isViewerLite, "$enabledZoom": enabledZoom, children: (0, jsx_runtime_1.jsx)(PdfDocument_1.PDFDocument, Object.assign({}, documentProps, { isLoading: isLoading, loading: (0, jsx_runtime_1.jsx)(placeholders_1.LoadingPlaceholder, { title: loadingPlaceholderTitle }), isViewerLite: isViewerLite, enabledZoom: enabledZoom, children: isRenderList && ((0, jsx_runtime_1.jsx)(List_1.List, { paginationRef: paginationRef, initialIndex: initialIndex, children: pageHeightList === null || pageHeightList === void 0 ? void 0 : pageHeightList.map((height, index) => ((0, react_1.createElement)(PdfPage_1.PDFPage, Object.assign({}, pageProps, {
25
+ // biome-ignore lint/suspicious/noArrayIndexKey: Страницы статичны
26
+ key: index, height: height * scale, pageNumber: index + 1, pageCount: pageCount, isViewerLite: isViewerLite, scale: scale, enabledZoom: enabledZoom })))) }, pageHeightList === null || pageHeightList === void 0 ? void 0 : pageHeightList[0])) })) }) }), (0, jsx_runtime_1.jsx)(ControlBar_1.ControlBar, { zoomOut: zoomOut, zoomIn: zoomIn, pageNumber: Number(initialIndex) + 1, buttonProps: {
26
27
  isDisabledZoomIn: isDisabledZoomInButton,
27
28
  isDisabledZoomOut: isDisabledZoomOutButton,
28
29
  }, isViewerLite: isViewerLite, isLoading: isLoading, pageCount: pageCount, enabledZoom: enabledZoom })] }) }));
@@ -17,6 +17,12 @@ export type PdfViewerProps = {
17
17
  * Файл для отображения
18
18
  */
19
19
  file: Blob | string | null | undefined;
20
+ options?: {
21
+ /**
22
+ * Флаг следует ли включать cookie в запрос. По-умолчанию `true`.
23
+ */
24
+ withCredentials?: boolean | undefined;
25
+ };
20
26
  /**
21
27
  * Будет вызван после успешной загрузки файла
22
28
  */
@@ -1,7 +1,21 @@
1
1
  /// <reference types="react" />
2
2
  import { type PdfViewerOnLoadSuccessProps, type PdfViewerProps } from '../types';
3
- export declare const useLogic: ({ file, scrollRef, paginationRef, isFullHeight, renderPageRange, isHidePersonalData, isViewerLite, enabledZoom, ...props }: PdfViewerProps) => {
4
- file: string | Blob | null | undefined;
3
+ export declare const useLogic: ({ file, scrollRef, paginationRef, isFullHeight, renderPageRange, isHidePersonalData, isViewerLite, enabledZoom, options, ...props }: PdfViewerProps) => {
4
+ documentProps: {
5
+ file: string | Blob | null | undefined;
6
+ options: {
7
+ withCredentials: boolean;
8
+ };
9
+ onLoadSuccess: (pdf: PdfViewerOnLoadSuccessProps) => void;
10
+ onLoadError: (error: Error) => void;
11
+ setContainerWidth: import("react").Dispatch<import("react").SetStateAction<number>>;
12
+ };
13
+ pageProps: {
14
+ scrollRef: import("react").RefObject<HTMLElement>;
15
+ onChangePage: (newPage: number) => void;
16
+ isHidePersonalData: boolean | undefined;
17
+ currentPage: number;
18
+ };
5
19
  pageCount: number;
6
20
  pageHeightList: number[] | null;
7
21
  isError: boolean;
@@ -13,15 +27,9 @@ export declare const useLogic: ({ file, scrollRef, paginationRef, isFullHeight,
13
27
  title: string;
14
28
  errorList: string[];
15
29
  } | undefined;
16
- onLoadSuccess: (pdf: PdfViewerOnLoadSuccessProps) => void;
17
- onLoadError: (error: Error) => void;
18
30
  onRetry: () => void;
19
- scrollRef: import("react").RefObject<HTMLElement>;
20
31
  paginationRef: import("react").RefObject<HTMLDivElement> | undefined;
21
- setContainerWidth: import("react").Dispatch<import("react").SetStateAction<number>>;
22
- changePage: (newPage: number) => void;
23
32
  isLoading: boolean;
24
- isHidePersonalData: boolean | undefined;
25
33
  initialIndex: number | null;
26
34
  isRenderList: boolean;
27
35
  isViewerLite: boolean | undefined;
@@ -17,7 +17,7 @@ const ConfigProvider_1 = require("../../ConfigProvider");
17
17
  const hooks_1 = require("../hooks");
18
18
  const utils_1 = require("../utils");
19
19
  const useLogic = (_a) => {
20
- var { file, scrollRef, paginationRef, isFullHeight, renderPageRange, isHidePersonalData, isViewerLite, enabledZoom = true } = _a, props = __rest(_a, ["file", "scrollRef", "paginationRef", "isFullHeight", "renderPageRange", "isHidePersonalData", "isViewerLite", "enabledZoom"]);
20
+ var { file, scrollRef, paginationRef, isFullHeight, renderPageRange, isHidePersonalData, isViewerLite, enabledZoom = true, options } = _a, props = __rest(_a, ["file", "scrollRef", "paginationRef", "isFullHeight", "renderPageRange", "isHidePersonalData", "isViewerLite", "enabledZoom", "options"]);
21
21
  const [containerWidth, setContainerWidth] = (0, react_1.useState)(1);
22
22
  const scrollContainerRef = (0, react_1.useRef)(null);
23
23
  const { zoomOut, scale, zoomIn, shouldAnimateZoom } = (0, hooks_1.useZoom)({
@@ -71,7 +71,7 @@ const useLogic = (_a) => {
71
71
  (_a = props.onLoadError) === null || _a === void 0 ? void 0 : _a.call(props, error);
72
72
  };
73
73
  const [initialIndex, setInitialIndex] = (0, react_1.useState)(null);
74
- const changePage = (newPage) => {
74
+ const onChangePage = (newPage) => {
75
75
  var _a;
76
76
  (_a = props.onChangePage) === null || _a === void 0 ? void 0 : _a.call(props, newPage);
77
77
  setInitialIndex(newPage - 1);
@@ -80,21 +80,30 @@ const useLogic = (_a) => {
80
80
  const loadingPlaceholderTitle = isViewerLite
81
81
  ? undefined
82
82
  : 'Загрузка данных...';
83
+ const getOptions = (0, react_1.useMemo)(() => {
84
+ return Object.assign({ withCredentials: true }, options);
85
+ }, [options]);
83
86
  return {
84
- file,
87
+ documentProps: {
88
+ file,
89
+ options: getOptions,
90
+ onLoadSuccess,
91
+ onLoadError,
92
+ setContainerWidth,
93
+ },
94
+ pageProps: {
95
+ scrollRef,
96
+ onChangePage,
97
+ isHidePersonalData,
98
+ currentPage: Number(initialIndex) + 1,
99
+ },
85
100
  pageCount: (pdfParams === null || pdfParams === void 0 ? void 0 : pdfParams.numPages) || 0,
86
101
  pageHeightList,
87
102
  isError,
88
103
  errorState,
89
- onLoadSuccess,
90
- onLoadError,
91
104
  onRetry,
92
- scrollRef,
93
105
  paginationRef,
94
- setContainerWidth,
95
- changePage,
96
106
  isLoading,
97
- isHidePersonalData,
98
107
  initialIndex,
99
108
  isRenderList,
100
109
  isViewerLite,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.0.0-alpha.29",
3
+ "version": "4.0.0-alpha.30",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {
@@ -47,7 +47,9 @@
47
47
  "./server": {
48
48
  "module": "./server/index.js",
49
49
  "require": "./node/server/index.js",
50
- "types": "./server/index.d.ts"
50
+ "types": "./server/index.d.ts",
51
+ "default": "./server/index.js",
52
+ "import": "./server/index.js"
51
53
  },
52
54
  "./next": {
53
55
  "module": "./next.js",
@@ -59,42 +61,58 @@
59
61
  "./components/PdfViewer": {
60
62
  "module": "./components/PdfViewer.js",
61
63
  "require": "./node/components/PdfViewer.js",
62
- "types": "./components/PdfViewer.d.ts"
64
+ "types": "./components/PdfViewer.d.ts",
65
+ "default": "./components/PdfViewer.js",
66
+ "import": "./components/PdfViewer.js"
63
67
  },
64
68
  "./components/JsonViewer": {
65
69
  "module": "./components/JsonViewer.js",
66
70
  "require": "./node/components/JsonViewer.js",
67
- "types": "./components/JsonViewer.d.ts"
71
+ "types": "./components/JsonViewer.d.ts",
72
+ "default": "./components/JsonViewer.js",
73
+ "import": "./components/JsonViewer.js"
68
74
  },
69
75
  "./components/Notification": {
70
76
  "module": "./components/Notification.js",
71
77
  "require": "./node/components/Notification.js",
72
- "types": "./components/Notification.d.ts"
78
+ "types": "./components/Notification.d.ts",
79
+ "default": "./components/Notification.js",
80
+ "import": "./components/Notification.js"
73
81
  },
74
82
  "./components/LegacyNotification": {
75
83
  "module": "./components/LegacyNotification.js",
76
84
  "require": "./node/components/LegacyNotification.js",
77
- "types": "./components/LegacyNotification.d.ts"
85
+ "types": "./components/LegacyNotification.d.ts",
86
+ "default": "./components/LegacyNotification.js",
87
+ "import": "./components/LegacyNotification.js"
78
88
  },
79
89
  "./components/Banner": {
80
90
  "module": "./components/Banner.js",
81
91
  "require": "./node/components/Banner.js",
82
- "types": "./components/Banner.d.ts"
92
+ "types": "./components/Banner.d.ts",
93
+ "default": "./components/Banner.js",
94
+ "import": "./components/Banner.js"
83
95
  },
84
96
  "./components/unstable/ResizingDataGrid": {
85
97
  "module": "./components/ResizingDataGrid.js",
86
98
  "require": "./node/components/ResizingDataGrid.js",
87
- "types": "./components/ResizingDataGrid.d.ts"
99
+ "types": "./components/ResizingDataGrid.d.ts",
100
+ "default": "./components/ResizingDataGrid.js",
101
+ "import": "./components/ResizingDataGrid.js"
88
102
  },
89
103
  "./components/unstable/ResizingDataGridInfinite": {
90
104
  "module": "./components/ResizingDataGridInfinite.js",
91
105
  "require": "./node/components/ResizingDataGridInfinite.js",
92
- "types": "./components/ResizingDataGridInfinite.d.ts"
106
+ "types": "./components/ResizingDataGridInfinite.d.ts",
107
+ "default": "./components/ResizingDataGridInfinite.js",
108
+ "import": "./components/ResizingDataGridInfinite.js"
93
109
  },
94
110
  "./components/InfiniteTreeList": {
95
111
  "module": "./components/InfiniteTreeList.js",
96
112
  "require": "./node/components/InfiniteTreeList.js",
97
- "types": "./components/InfiniteTreeList.d.ts"
113
+ "types": "./components/InfiniteTreeList.d.ts",
114
+ "default": "./components/InfiniteTreeList.js",
115
+ "import": "./components/InfiniteTreeList.js"
98
116
  }
99
117
  },
100
118
  "author": "Astral.Soft",