@chrome-consulting/krit-ui 0.0.49
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/README.md +69 -0
- package/dist/assets/index.d.ts +201 -0
- package/dist/components/ui/attachmentsSection.d.ts +54 -0
- package/dist/components/ui/badge.d.ts +32 -0
- package/dist/components/ui/badgeVariants.d.ts +6 -0
- package/dist/components/ui/banner.d.ts +60 -0
- package/dist/components/ui/bottom-menu.d.ts +41 -0
- package/dist/components/ui/button.d.ts +27 -0
- package/dist/components/ui/buttonVariants.d.ts +4 -0
- package/dist/components/ui/calendar.d.ts +18 -0
- package/dist/components/ui/card.d.ts +87 -0
- package/dist/components/ui/carousel.d.ts +52 -0
- package/dist/components/ui/checkbox.d.ts +30 -0
- package/dist/components/ui/collapsible-section.d.ts +37 -0
- package/dist/components/ui/collapsible.d.ts +18 -0
- package/dist/components/ui/command.d.ts +102 -0
- package/dist/components/ui/confirm-modal.d.ts +33 -0
- package/dist/components/ui/data-table.d.ts +94 -0
- package/dist/components/ui/date-picker.d.ts +69 -0
- package/dist/components/ui/dialog.d.ts +66 -0
- package/dist/components/ui/dot.d.ts +10 -0
- package/dist/components/ui/dropdown-menu.d.ts +67 -0
- package/dist/components/ui/file-input.d.ts +36 -0
- package/dist/components/ui/filters-column-header.d.ts +28 -0
- package/dist/components/ui/form.d.ts +86 -0
- package/dist/components/ui/form.lib.d.ts +23 -0
- package/dist/components/ui/header.d.ts +39 -0
- package/dist/components/ui/input.d.ts +30 -0
- package/dist/components/ui/label.d.ts +23 -0
- package/dist/components/ui/multi-select.d.ts +100 -0
- package/dist/components/ui/nav-panel.d.ts +52 -0
- package/dist/components/ui/nav.d.ts +52 -0
- package/dist/components/ui/network-error-message.d.ts +46 -0
- package/dist/components/ui/notification.d.ts +34 -0
- package/dist/components/ui/notificationVariants.d.ts +4 -0
- package/dist/components/ui/number-input.d.ts +149 -0
- package/dist/components/ui/page-layout.d.ts +28 -0
- package/dist/components/ui/page-view-mode-toggle.d.ts +22 -0
- package/dist/components/ui/pagination.d.ts +121 -0
- package/dist/components/ui/popover.d.ts +36 -0
- package/dist/components/ui/post-card.d.ts +273 -0
- package/dist/components/ui/preloader.d.ts +23 -0
- package/dist/components/ui/previewFull.d.ts +40 -0
- package/dist/components/ui/previews.d.ts +69 -0
- package/dist/components/ui/previewsCompactList.d.ts +18 -0
- package/dist/components/ui/previewsShared.d.ts +8 -0
- package/dist/components/ui/profile.d.ts +41 -0
- package/dist/components/ui/radio-group.d.ts +48 -0
- package/dist/components/ui/resizable.d.ts +65 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/secondary-panel-section.d.ts +20 -0
- package/dist/components/ui/segmented-control.d.ts +35 -0
- package/dist/components/ui/select-header-filter.d.ts +23 -0
- package/dist/components/ui/select.d.ts +91 -0
- package/dist/components/ui/separator.d.ts +34 -0
- package/dist/components/ui/sheet.d.ts +118 -0
- package/dist/components/ui/skeleton.d.ts +24 -0
- package/dist/components/ui/sort-component.d.ts +46 -0
- package/dist/components/ui/sortable-header.d.ts +12 -0
- package/dist/components/ui/switch.d.ts +25 -0
- package/dist/components/ui/table.d.ts +104 -0
- package/dist/components/ui/tabs.d.ts +52 -0
- package/dist/components/ui/tabsVariants.d.ts +6 -0
- package/dist/components/ui/text-area.d.ts +37 -0
- package/dist/components/ui/theme-provider.d.ts +136 -0
- package/dist/components/ui/time-picker.d.ts +29 -0
- package/dist/components/ui/time-picker.lib.d.ts +6 -0
- package/dist/components/ui/toast.d.ts +80 -0
- package/dist/components/ui/toaster.d.ts +22 -0
- package/dist/components/ui/tooltip.d.ts +65 -0
- package/dist/components/ui/tree-view.d.ts +96 -0
- package/dist/components/ui/widget-plan-fact.d.ts +86 -0
- package/dist/date.d.ts +8 -0
- package/dist/hooks/useColumnFilters.d.ts +6 -0
- package/dist/hooks/useColumnSizing.d.ts +20 -0
- package/dist/hooks/useCombinedRefs.d.ts +1 -0
- package/dist/hooks/useConfirm.d.ts +49 -0
- package/dist/hooks/useNotify.d.ts +28 -0
- package/dist/hooks/usePreviewsFilePicker.d.ts +40 -0
- package/dist/hooks/useSidebar.d.ts +10 -0
- package/dist/hooks/useStoredExpand.d.ts +18 -0
- package/dist/hooks/useStoredFields.d.ts +4 -0
- package/dist/hooks/useStoredTabs.d.ts +4 -0
- package/dist/hooks/useTableStates.d.ts +26 -0
- package/dist/hooks/useTheme.d.ts +1 -0
- package/dist/hooks/useToast.d.ts +44 -0
- package/dist/hooks/useTranslation.d.ts +4 -0
- package/dist/krit-ui.d.ts +2 -0
- package/dist/krit-ui.js +27485 -0
- package/dist/krit-ui.umd.cjs +140 -0
- package/dist/lib/attachments.d.ts +245 -0
- package/dist/lib/cookies.d.ts +1 -0
- package/dist/lib/file.d.ts +52 -0
- package/dist/lib/infinite-scroll.d.ts +13 -0
- package/dist/lib/selectUtils.d.ts +14 -0
- package/dist/lib/text.d.ts +1 -0
- package/dist/lib/zod.d.ts +27 -0
- package/dist/main.d.ts +85 -0
- package/dist/style.css +1 -0
- package/dist/utils.d.ts +2 -0
- package/package.json +122 -0
- package/tailwind.config.cjs +273 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
3
|
+
/**
|
|
4
|
+
* Провайдер для системы всплывающих подсказок.
|
|
5
|
+
* Обеспечивает контекст и управление состоянием для всех Tooltip-компонентов.
|
|
6
|
+
*
|
|
7
|
+
* @component
|
|
8
|
+
* @param {React.ComponentProps<typeof TooltipPrimitive.Provider>} props - Свойства провайдера
|
|
9
|
+
* @returns {React.ReactElement} Провайдер системы подсказок
|
|
10
|
+
*/
|
|
11
|
+
declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps>;
|
|
12
|
+
/**
|
|
13
|
+
* Основной компонент всплывающей подсказки.
|
|
14
|
+
*
|
|
15
|
+
* @component
|
|
16
|
+
* @param {React.ComponentProps<typeof TooltipPrimitive.Root>} props - Свойства компонента
|
|
17
|
+
* @returns {React.ReactElement} Компонент подсказки
|
|
18
|
+
*/
|
|
19
|
+
declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
|
|
20
|
+
/**
|
|
21
|
+
* Триггер для отображения всплывающей подсказки.
|
|
22
|
+
*
|
|
23
|
+
* @component
|
|
24
|
+
* @param {React.ComponentProps<typeof TooltipPrimitive.Trigger>} props - Свойства компонента
|
|
25
|
+
* @returns {React.ReactElement} Триггер подсказки
|
|
26
|
+
*/
|
|
27
|
+
declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
28
|
+
/**
|
|
29
|
+
* Контент всплывающей подсказки.
|
|
30
|
+
*
|
|
31
|
+
* @component
|
|
32
|
+
* @param {object} props - Свойства компонента
|
|
33
|
+
* @param {string} [props.className] - Дополнительные CSS-классы
|
|
34
|
+
* @param {number} [props.sideOffset=4] - Смещение от элемента
|
|
35
|
+
* @param {React.Ref<React.ElementRef<typeof TooltipPrimitive.Content>>} ref - React ref
|
|
36
|
+
* @returns {React.ReactElement} Контент подсказки
|
|
37
|
+
*/
|
|
38
|
+
declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
/**
|
|
40
|
+
* Пропсы компонента InfoTooltip
|
|
41
|
+
* @interface InfoTooltipProps
|
|
42
|
+
* @property {React.ReactNode} [children] - Элемент, для которого показывается подсказка
|
|
43
|
+
* @property {string} [text] - Текст подсказки
|
|
44
|
+
* @property {number} [delayDuration] - Задержка перед показом подсказки (мс)
|
|
45
|
+
*/
|
|
46
|
+
interface InfoTooltipProps {
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
text?: string;
|
|
49
|
+
delayDuration?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Упрощенный компонент всплывающей подсказки с предустановленными стилями.
|
|
53
|
+
* Поддерживает форматирование текста с помощью Markdown-подобного синтаксиса.
|
|
54
|
+
*
|
|
55
|
+
* @component
|
|
56
|
+
* @param {InfoTooltipProps} props - Пропсы компонента
|
|
57
|
+
* @returns {React.ReactElement} Компонент информационной подсказки
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* <InfoTooltip text="Это **важная** подсказка">
|
|
61
|
+
* <Button>Наведи меня</Button>
|
|
62
|
+
* </InfoTooltip>
|
|
63
|
+
*/
|
|
64
|
+
declare const InfoTooltip: ({ children, text, delayDuration }: InfoTooltipProps) => import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, InfoTooltip };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ForwardRefExoticComponent, ReactNode, RefAttributes, RefObject } from 'react';
|
|
2
|
+
export interface TreeNode<T = unknown> {
|
|
3
|
+
id: number | string;
|
|
4
|
+
level?: number;
|
|
5
|
+
children?: TreeNode<T>[];
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
onDoubleClick?: () => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Пропсы строки таблицы при использовании `tableRowComponent` или строки по умолчанию в `TreeView`.
|
|
12
|
+
*/
|
|
13
|
+
export interface TreeViewTableRowProps<T extends TreeNode> {
|
|
14
|
+
node: T;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
onClick: () => void;
|
|
17
|
+
onDoubleClick: () => void;
|
|
18
|
+
className: string;
|
|
19
|
+
'data-index'?: number | string;
|
|
20
|
+
}
|
|
21
|
+
export interface TreeViewConfig<T extends TreeNode> {
|
|
22
|
+
getNodeId: (node: T) => number | string;
|
|
23
|
+
getNodeLevel: (node: T) => number;
|
|
24
|
+
getNodeChildren: (node: T) => T[] | undefined;
|
|
25
|
+
hasNestedNodes: (node: T) => boolean;
|
|
26
|
+
isNodeExpanded: (node: T) => boolean;
|
|
27
|
+
isNodeSelected: (node: T, selected: unknown) => boolean;
|
|
28
|
+
getNodeHeadingText: (node: T) => string | number | undefined;
|
|
29
|
+
/** Фактическая высота строки для направляющих дерева. */
|
|
30
|
+
getNodeRowHeight?: (node: T) => number | string | undefined;
|
|
31
|
+
/** Контент перед иконкой раскрытия в колонке названия (например чекбокс). */
|
|
32
|
+
getNodeHeadingPrefix?: (node: T) => ReactNode;
|
|
33
|
+
getNodeFooterText: (node: T) => string | undefined;
|
|
34
|
+
getNodeCellValues: (node: T) => ReactNode[];
|
|
35
|
+
getNodeHeadingClassName?: (node: T) => string | undefined;
|
|
36
|
+
getNodeHeadingMaxLength?: (node: T) => number | undefined;
|
|
37
|
+
/** Возвращает готовый ReactNode для footer (например ссылку). Если undefined — рендерится getNodeFooterText в span. */
|
|
38
|
+
getNodeFooterNode?: (node: T, options: {
|
|
39
|
+
text: string;
|
|
40
|
+
className: string;
|
|
41
|
+
}) => ReactNode | undefined;
|
|
42
|
+
/** Дополнительные CSS-классы для стандартного футера (когда getNodeFooterNode не используется). */
|
|
43
|
+
getNodeFooterClassName?: (node: T) => string | undefined;
|
|
44
|
+
renderTooltip?: (node: T) => ReactNode;
|
|
45
|
+
renderExpandIcon?: (node: T, isExpanded: boolean, onClick: () => void) => ReactNode;
|
|
46
|
+
/** Ширина колонки направляющих дерева, px (по умолчанию 24). */
|
|
47
|
+
treeGuideColumnWidth?: number;
|
|
48
|
+
/** Смещение якоря линии от начала контентной области, px (по умолчанию половина treeGuideColumnWidth). */
|
|
49
|
+
treeLineAnchorOffset?: number;
|
|
50
|
+
/** Вертикальная позиция соединительной линии в строке (по умолчанию середина строки). */
|
|
51
|
+
treeLineAnchorTop?: number | string;
|
|
52
|
+
/** Вертикальные отступы ячеек данных. По умолчанию зависят от density. */
|
|
53
|
+
dataCellVerticalPadding?: 'default' | 'none';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Строка таблицы с ref (виртуализатор dnd-kit и др.).
|
|
57
|
+
*/
|
|
58
|
+
export type TreeViewTableRowComponent<T extends TreeNode> = ForwardRefExoticComponent<TreeViewTableRowProps<T> & RefAttributes<HTMLTableRowElement>>;
|
|
59
|
+
export interface TreeViewProps<T extends TreeNode> {
|
|
60
|
+
nodes: T[];
|
|
61
|
+
selected?: unknown;
|
|
62
|
+
config: TreeViewConfig<T>;
|
|
63
|
+
headers?: string[];
|
|
64
|
+
/** Кастомные ячейки заголовка (например FiltersColumnHeader). Приоритетнее headers. */
|
|
65
|
+
headerCells?: ReactNode[];
|
|
66
|
+
className?: string;
|
|
67
|
+
columnWidths?: (number | string)[];
|
|
68
|
+
columnAlignments?: ('left' | 'center' | 'right')[];
|
|
69
|
+
onExpand: (node: T) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Кастомная строка таблицы (например, с ref для dnd-kit). По умолчанию — стандартная строка.
|
|
72
|
+
* Должна рендерить <tr ref> в корне и вложить `children` (ячейки <td>).
|
|
73
|
+
*/
|
|
74
|
+
tableRowComponent?: TreeViewTableRowComponent<T>;
|
|
75
|
+
virtualized?: boolean;
|
|
76
|
+
estimateRowSize?: number;
|
|
77
|
+
overscan?: number;
|
|
78
|
+
scrollElementRef?: RefObject<HTMLDivElement>;
|
|
79
|
+
/** ID для scroll-контейнера (для синхронизации скролла с другими элементами) */
|
|
80
|
+
scrollContainerId?: string;
|
|
81
|
+
/** Чередование фона строк, как в DataTable */
|
|
82
|
+
striped?: boolean;
|
|
83
|
+
/** Горизонтальные отступы ячеек, как в DataTable; `none` — без доп. отступов (узкие деревья навигации) */
|
|
84
|
+
horizontalPadding?: 'none' | 'small' | 'medium' | 'large';
|
|
85
|
+
/** `compact` — плотные строки без отступов DataTable (дерево настроек Toro) */
|
|
86
|
+
density?: 'default' | 'compact';
|
|
87
|
+
/**
|
|
88
|
+
* Если задан, подменяет содержимое первой ячейки заголовка (например, заголовок + кнопка).
|
|
89
|
+
* Остальные колонки по-прежнему из `headers`. Не используется вместе с `headerCells`.
|
|
90
|
+
*/
|
|
91
|
+
renderFirstColumnHeader?: ReactNode;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* TreeView - компонент для отображения иерархических данных в табличном формате.
|
|
95
|
+
*/
|
|
96
|
+
export declare const TreeView: <T extends TreeNode>(props: TreeViewProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export type TimeBadgeVariant = 'default' | 'warning' | 'error' | 'success';
|
|
2
|
+
interface TimeBadgeProps {
|
|
3
|
+
/** Дата и время в формате "DD.MM.YYYY HH:mm" */
|
|
4
|
+
dateTime?: string;
|
|
5
|
+
/** Длительность в формате "Xd : Yч : Zмин" */
|
|
6
|
+
duration?: string;
|
|
7
|
+
/** Вариант стиля бейджа */
|
|
8
|
+
variant?: TimeBadgeVariant;
|
|
9
|
+
/** Дополнительные CSS-классы */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Компонент для отображения даты/времени и длительности в виде бейджа.
|
|
14
|
+
* Поддерживает различные варианты стилей: default, warning (жёлтый), error (красный), success (зелёный).
|
|
15
|
+
*
|
|
16
|
+
* @component
|
|
17
|
+
* @param {TimeBadgeProps} props - Пропсы компонента
|
|
18
|
+
* @param {string} [props.dateTime] - Дата и время в формате "DD.MM.YYYY HH:mm"
|
|
19
|
+
* @param {string} [props.duration] - Длительность в формате "Xd : Yч : Zмин"
|
|
20
|
+
* @param {TimeBadgeVariant} [props.variant='default'] - Вариант стиля бейджа
|
|
21
|
+
* @param {string} [props.className] - Дополнительные CSS-классы
|
|
22
|
+
* @returns {JSX.Element}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* <TimeBadge
|
|
26
|
+
* dateTime="01.12.2025 10:00"
|
|
27
|
+
* duration="14д : 24ч : 20мин"
|
|
28
|
+
* variant="error"
|
|
29
|
+
* />
|
|
30
|
+
*/
|
|
31
|
+
declare const TimeBadge: {
|
|
32
|
+
({ dateTime, duration, variant, className }: TimeBadgeProps): import("react/jsx-runtime").JSX.Element | null;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
export interface PlanFactRow {
|
|
36
|
+
/** Метка для плана (например, "План начала") */
|
|
37
|
+
planLabel?: string;
|
|
38
|
+
/** Значение плана (например, "01.11.2025 10:00") */
|
|
39
|
+
planValue?: string;
|
|
40
|
+
/** Метка для факта (например, "Факт начала") */
|
|
41
|
+
factLabel?: string;
|
|
42
|
+
/** Значение факта (отображается через TimeBadge) */
|
|
43
|
+
factDateTime?: string;
|
|
44
|
+
factDuration?: string;
|
|
45
|
+
/** Вариант стиля для факта */
|
|
46
|
+
factVariant?: TimeBadgeVariant;
|
|
47
|
+
/** Расхождение (например, "Расхождение 30д : 2ч : 30мин") */
|
|
48
|
+
delta?: string;
|
|
49
|
+
}
|
|
50
|
+
interface WidgetPlanFactProps {
|
|
51
|
+
/** Массив строк с планом и фактом */
|
|
52
|
+
rows: PlanFactRow[];
|
|
53
|
+
/** Ориентация виджета: вертикальная (строки) или горизонтальная (колонки) */
|
|
54
|
+
orientation?: 'vertical' | 'horizontal';
|
|
55
|
+
/** Дополнительные CSS-классы для корневого элемента */
|
|
56
|
+
className?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Виджет для отображения сравнения плановых и фактических значений.
|
|
60
|
+
* Отображает три секции (Начало, Окончание, Длительность) с планом и фактом.
|
|
61
|
+
*
|
|
62
|
+
* @component
|
|
63
|
+
* @param {WidgetPlanFactProps} props - Пропсы компонента
|
|
64
|
+
* @param {PlanFactRow[]} props.rows - Массив строк с планом и фактом
|
|
65
|
+
* @param {'vertical' | 'horizontal'} [props.orientation='vertical'] - Ориентация виджета
|
|
66
|
+
* @param {string} [props.className] - Дополнительные CSS-классы
|
|
67
|
+
* @returns {JSX.Element}
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* <WidgetPlanFact
|
|
71
|
+
* rows={[
|
|
72
|
+
* {
|
|
73
|
+
* planLabel: 'План начала',
|
|
74
|
+
* planValue: '01.11.2025 10:00',
|
|
75
|
+
* factLabel: 'Факт начала',
|
|
76
|
+
* factDateTime: '01.12.2025 10:00',
|
|
77
|
+
* delta: 'Расхождение 30д : 2ч : 30мин',
|
|
78
|
+
* },
|
|
79
|
+
* ]}
|
|
80
|
+
* />
|
|
81
|
+
*/
|
|
82
|
+
declare const WidgetPlanFact: {
|
|
83
|
+
({ rows, orientation, className }: WidgetPlanFactProps): import("react/jsx-runtime").JSX.Element | null;
|
|
84
|
+
displayName: string;
|
|
85
|
+
};
|
|
86
|
+
export { TimeBadge, WidgetPlanFact };
|
package/dist/date.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DateRange } from './main';
|
|
2
|
+
export declare const toRuDateString: (date: Date | string) => string;
|
|
3
|
+
export declare const formatSingleDateMask: (value: string) => string;
|
|
4
|
+
export declare const formatMultipleDatesMask: (value: string) => string;
|
|
5
|
+
export declare const formatRangeMask: (value: string) => string;
|
|
6
|
+
export declare const parseDateString: (value: string) => Date | null;
|
|
7
|
+
export declare const parseMultipleDatesString: (value: string) => Date[];
|
|
8
|
+
export declare const parseRangeString: (value: string) => DateRange | null;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ColumnFiltersState } from '@tanstack/react-table';
|
|
2
|
+
export declare const useColumnFilters: () => {
|
|
3
|
+
state: ColumnFiltersState;
|
|
4
|
+
setState: import('react').Dispatch<import('react').SetStateAction<ColumnFiltersState>>;
|
|
5
|
+
get: <T = string>(id: string, filtersState?: ColumnFiltersState) => T | undefined;
|
|
6
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ColumnSizingState, OnChangeFn } from '@tanstack/react-table';
|
|
2
|
+
/**
|
|
3
|
+
* Хук для управления шириной столбцов таблицы с опциональной персистентностью в localStorage.
|
|
4
|
+
*
|
|
5
|
+
* @param storageKey - Уникальный ключ таблицы для хранения в localStorage.
|
|
6
|
+
* Если не передан — состояние живёт только в рамках сессии (без сохранения).
|
|
7
|
+
* @param defaultSizing - Начальные размеры столбцов (используются если в localStorage ещё нет данных)
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // С сохранением в localStorage
|
|
11
|
+
* const { columnSizing, onColumnSizingChange } = useColumnSizing('orders-table');
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Без сохранения (только в рамках сессии)
|
|
15
|
+
* const { columnSizing, onColumnSizingChange } = useColumnSizing(undefined);
|
|
16
|
+
*/
|
|
17
|
+
export declare function useColumnSizing(storageKey: string | undefined, defaultSizing?: ColumnSizingState): {
|
|
18
|
+
columnSizing: ColumnSizingState;
|
|
19
|
+
onColumnSizingChange: OnChangeFn<ColumnSizingState>;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCombinedRefs: (...refs: React.ForwardedRef<HTMLInputElement>[]) => (node: HTMLInputElement | null) => void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export type ConfirmType = 'theme-filled' | 'warning-filled' | 'fade-contrast-filled' | 'fade-contrast-outlined';
|
|
3
|
+
export type InputComponent = FC<{
|
|
4
|
+
value: string;
|
|
5
|
+
onChange: (value: string) => void;
|
|
6
|
+
}>;
|
|
7
|
+
interface ConfirmState {
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
confirmText: string;
|
|
11
|
+
confirmType: ConfirmType;
|
|
12
|
+
confirmHidden: boolean;
|
|
13
|
+
cancelText: string;
|
|
14
|
+
cancelHidden: boolean;
|
|
15
|
+
input?: InputComponent;
|
|
16
|
+
inputValue: string;
|
|
17
|
+
inputPlaceholder: string;
|
|
18
|
+
inputRequiredLabel: string;
|
|
19
|
+
inputMaxLength?: number;
|
|
20
|
+
inputRequired?: boolean;
|
|
21
|
+
setInput: (inputValue: string) => void;
|
|
22
|
+
confirmed: boolean | null;
|
|
23
|
+
visible: boolean;
|
|
24
|
+
setVisible: (visible: boolean) => void;
|
|
25
|
+
show: (options: PromptOptions) => void;
|
|
26
|
+
hide: () => void;
|
|
27
|
+
confirm: (input?: string) => void;
|
|
28
|
+
cancel: () => void;
|
|
29
|
+
}
|
|
30
|
+
export interface PromptOptions {
|
|
31
|
+
title?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
confirmText?: string;
|
|
34
|
+
confirmType?: ConfirmType;
|
|
35
|
+
confirmHidden?: boolean;
|
|
36
|
+
cancelText?: string;
|
|
37
|
+
cancelHidden?: boolean;
|
|
38
|
+
input?: InputComponent;
|
|
39
|
+
inputPlaceholder?: string;
|
|
40
|
+
inputRequiredLabel?: string;
|
|
41
|
+
inputMaxLength?: number;
|
|
42
|
+
inputRequired?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare const useConfirmStore: import('zustand').UseBoundStore<import('zustand').StoreApi<ConfirmState>>;
|
|
45
|
+
export declare const useConfirm: () => {
|
|
46
|
+
confirm: (options: PromptOptions) => Promise<boolean | null>;
|
|
47
|
+
prompt: (options: PromptOptions) => Promise<string>;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface ErrorsObj {
|
|
2
|
+
errors: {
|
|
3
|
+
[key: string]: string[];
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
export interface ErrorResponse {
|
|
7
|
+
error: string;
|
|
8
|
+
errors: string[] | ErrorsObj;
|
|
9
|
+
message: string;
|
|
10
|
+
detail: string;
|
|
11
|
+
path: string;
|
|
12
|
+
status: number;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const getErrorData: (error: Error | Record<string, unknown>) => ErrorResponse | undefined;
|
|
16
|
+
export declare const parseValueFromError: (key: string, error: string) => string;
|
|
17
|
+
export type MessageFromServer = string;
|
|
18
|
+
export type MessageForUser = string | ((errors?: string[]) => string);
|
|
19
|
+
export declare const useNotify: (text?: string) => {
|
|
20
|
+
toast: typeof import('./useToast').toast;
|
|
21
|
+
notifyError: (text?: string, prefix?: string) => void;
|
|
22
|
+
onError: (error: Error | Record<string, unknown>) => void;
|
|
23
|
+
getErrorHandler: (errorMessageMap: Record<MessageFromServer, MessageForUser>) => (error: Error | Record<string, unknown>) => void;
|
|
24
|
+
getSuccessHandler: (text: string) => () => void;
|
|
25
|
+
notifySuccess: (text?: string) => void;
|
|
26
|
+
onSuccess: () => void;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AttachmentItem, ContentType } from '../lib/attachments';
|
|
2
|
+
export interface PreviewsFilePickerMaxSizes {
|
|
3
|
+
image?: number;
|
|
4
|
+
video?: number;
|
|
5
|
+
total?: number;
|
|
6
|
+
audio?: number;
|
|
7
|
+
pdf?: number;
|
|
8
|
+
word?: number;
|
|
9
|
+
excel?: number;
|
|
10
|
+
archive?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UsePreviewsFilePickerParams {
|
|
13
|
+
accepts?: ContentType[];
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
max?: number;
|
|
16
|
+
maxSizes?: PreviewsFilePickerMaxSizes;
|
|
17
|
+
withCompress?: boolean;
|
|
18
|
+
onAdd?: (files: File[]) => void;
|
|
19
|
+
handleFileLimit?: (filetype: ContentType) => void;
|
|
20
|
+
handleAllFilesLimit?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Текущие вложения: для лимита max, подсчёта слотов и суммарного размера файлов с полем `file`.
|
|
23
|
+
*/
|
|
24
|
+
attachmentData?: AttachmentItem[];
|
|
25
|
+
}
|
|
26
|
+
export interface UsePreviewsFilePickerResult {
|
|
27
|
+
inputRef: React.RefObject<HTMLInputElement>;
|
|
28
|
+
openPicker: () => void;
|
|
29
|
+
processing: boolean;
|
|
30
|
+
/** true, если нельзя открыть диалог (лимит файлов или идёт обработка) */
|
|
31
|
+
pickerDisabled: boolean;
|
|
32
|
+
acceptAttr: string;
|
|
33
|
+
multiple: boolean;
|
|
34
|
+
onFileInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Логика выбора файлов как в Previews: лимиты по типам, общий размер, сжатие, onAdd.
|
|
38
|
+
* Скрытый input рендерит потребитель; триггер вызывает openPicker().
|
|
39
|
+
*/
|
|
40
|
+
export declare const usePreviewsFilePicker: (params: UsePreviewsFilePickerParams) => UsePreviewsFilePickerResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ImperativePanelHandle } from 'react-resizable-panels';
|
|
2
|
+
export declare const useSidebar: (collapsedLayout?: number[], expandedLayout?: number[]) => {
|
|
3
|
+
layoutName: string;
|
|
4
|
+
collapsedName: string;
|
|
5
|
+
defaultLayout: any;
|
|
6
|
+
isCollapsed: boolean;
|
|
7
|
+
ref: import('react').RefObject<ImperativePanelHandle>;
|
|
8
|
+
collapse: () => void;
|
|
9
|
+
expand: () => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export type ExpandState = Record<string | number, boolean>;
|
|
3
|
+
export interface UseStoredExpandOptions {
|
|
4
|
+
storage?: 'localStorage' | 'sessionStorage';
|
|
5
|
+
defaultWhenMissing?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Хук для хранения состояния раскрытия узлов (дерево, аккордеон) в sessionStorage или localStorage.
|
|
9
|
+
*
|
|
10
|
+
* @param storageKey - Ключ для хранения в storage
|
|
11
|
+
* @param options - Опции: storage ('sessionStorage' по умолчанию), defaultWhenMissing (true по умолчанию)
|
|
12
|
+
*/
|
|
13
|
+
export declare const useStoredExpand: (storageKey: string, options?: UseStoredExpandOptions) => {
|
|
14
|
+
expanded: ExpandState;
|
|
15
|
+
setExpanded: Dispatch<SetStateAction<ExpandState>>;
|
|
16
|
+
toggleNode: (id: string | number) => void;
|
|
17
|
+
isNodeExpanded: (id: string | number) => boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ExpandedState, RowSelectionState, SortingState } from '@tanstack/react-table';
|
|
2
|
+
interface IProps {
|
|
3
|
+
paginationInitialState?: {
|
|
4
|
+
pageIndex: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
};
|
|
7
|
+
onSort?: (sort: string, sortType: 'asc' | 'desc') => void;
|
|
8
|
+
onPagination?: (pageIndex: number, pageSize: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const useTableStates: ({ paginationInitialState, onSort, onPagination, }?: IProps) => {
|
|
11
|
+
selection: RowSelectionState;
|
|
12
|
+
setSelection: import('react').Dispatch<import('react').SetStateAction<RowSelectionState>>;
|
|
13
|
+
sorting: SortingState;
|
|
14
|
+
setSorting: import('react').Dispatch<import('react').SetStateAction<SortingState>>;
|
|
15
|
+
pagination: {
|
|
16
|
+
pageIndex: number;
|
|
17
|
+
pageSize: number;
|
|
18
|
+
};
|
|
19
|
+
setPagination: import('react').Dispatch<import('react').SetStateAction<{
|
|
20
|
+
pageIndex: number;
|
|
21
|
+
pageSize: number;
|
|
22
|
+
}>>;
|
|
23
|
+
expanded: ExpandedState;
|
|
24
|
+
setExpanded: import('react').Dispatch<import('react').SetStateAction<ExpandedState>>;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useTheme: () => import('../main').ThemeProviderState;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ToastActionElement, ToastProps } from '../components/ui/toast';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
type ToasterToast = ToastProps & {
|
|
4
|
+
id: string;
|
|
5
|
+
title?: React.ReactNode;
|
|
6
|
+
description?: React.ReactNode;
|
|
7
|
+
action?: ToastActionElement;
|
|
8
|
+
};
|
|
9
|
+
declare const actionTypes: {
|
|
10
|
+
readonly ADD_TOAST: "ADD_TOAST";
|
|
11
|
+
readonly UPDATE_TOAST: "UPDATE_TOAST";
|
|
12
|
+
readonly DISMISS_TOAST: "DISMISS_TOAST";
|
|
13
|
+
readonly REMOVE_TOAST: "REMOVE_TOAST";
|
|
14
|
+
};
|
|
15
|
+
type ActionType = typeof actionTypes;
|
|
16
|
+
type Action = {
|
|
17
|
+
type: ActionType['ADD_TOAST'];
|
|
18
|
+
toast: ToasterToast;
|
|
19
|
+
} | {
|
|
20
|
+
type: ActionType['UPDATE_TOAST'];
|
|
21
|
+
toast: Partial<ToasterToast>;
|
|
22
|
+
} | {
|
|
23
|
+
type: ActionType['DISMISS_TOAST'];
|
|
24
|
+
toastId?: ToasterToast['id'];
|
|
25
|
+
} | {
|
|
26
|
+
type: ActionType['REMOVE_TOAST'];
|
|
27
|
+
toastId?: ToasterToast['id'];
|
|
28
|
+
};
|
|
29
|
+
interface State {
|
|
30
|
+
toasts: ToasterToast[];
|
|
31
|
+
}
|
|
32
|
+
export declare const reducer: (state: State, action: Action) => State;
|
|
33
|
+
type Toast = Omit<ToasterToast, 'id'>;
|
|
34
|
+
declare function toast({ ...props }: Toast): {
|
|
35
|
+
id: string;
|
|
36
|
+
dismiss: () => void;
|
|
37
|
+
update: (props: ToasterToast) => void;
|
|
38
|
+
};
|
|
39
|
+
declare function useToast(): {
|
|
40
|
+
toast: typeof toast;
|
|
41
|
+
dismiss: (toastId?: string) => void;
|
|
42
|
+
toasts: ToasterToast[];
|
|
43
|
+
};
|
|
44
|
+
export { useToast, toast };
|