@krit-llc/krit-ui 0.0.0-stage → 0.0.79

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 (108) hide show
  1. package/README.md +153 -2
  2. package/dist/assets/index.d.ts +204 -0
  3. package/dist/components/ui/attachmentsSection.d.ts +54 -0
  4. package/dist/components/ui/badge.d.ts +32 -0
  5. package/dist/components/ui/badgeVariants.d.ts +6 -0
  6. package/dist/components/ui/banner.d.ts +60 -0
  7. package/dist/components/ui/bottom-menu.d.ts +41 -0
  8. package/dist/components/ui/button.d.ts +27 -0
  9. package/dist/components/ui/buttonVariants.d.ts +4 -0
  10. package/dist/components/ui/calendar.d.ts +18 -0
  11. package/dist/components/ui/card.d.ts +87 -0
  12. package/dist/components/ui/carousel.d.ts +52 -0
  13. package/dist/components/ui/checkbox.d.ts +30 -0
  14. package/dist/components/ui/collapsible-section.d.ts +37 -0
  15. package/dist/components/ui/collapsible.d.ts +18 -0
  16. package/dist/components/ui/command.d.ts +102 -0
  17. package/dist/components/ui/confirm-modal.d.ts +33 -0
  18. package/dist/components/ui/data-table.d.ts +94 -0
  19. package/dist/components/ui/date-picker.d.ts +58 -0
  20. package/dist/components/ui/dialog.d.ts +66 -0
  21. package/dist/components/ui/dot.d.ts +10 -0
  22. package/dist/components/ui/dropdown-menu.d.ts +67 -0
  23. package/dist/components/ui/file-input.d.ts +36 -0
  24. package/dist/components/ui/filters-column-header.d.ts +48 -0
  25. package/dist/components/ui/form.d.ts +86 -0
  26. package/dist/components/ui/form.lib.d.ts +23 -0
  27. package/dist/components/ui/header.d.ts +39 -0
  28. package/dist/components/ui/input.d.ts +30 -0
  29. package/dist/components/ui/label.d.ts +23 -0
  30. package/dist/components/ui/multi-select.d.ts +100 -0
  31. package/dist/components/ui/nav-panel.d.ts +52 -0
  32. package/dist/components/ui/nav.d.ts +52 -0
  33. package/dist/components/ui/network-error-message.d.ts +46 -0
  34. package/dist/components/ui/notification.d.ts +34 -0
  35. package/dist/components/ui/notificationVariants.d.ts +4 -0
  36. package/dist/components/ui/number-input.d.ts +149 -0
  37. package/dist/components/ui/page-layout.d.ts +28 -0
  38. package/dist/components/ui/page-view-mode-toggle.d.ts +22 -0
  39. package/dist/components/ui/pagination.d.ts +122 -0
  40. package/dist/components/ui/popover.d.ts +29 -0
  41. package/dist/components/ui/post-card.d.ts +273 -0
  42. package/dist/components/ui/preloader.d.ts +23 -0
  43. package/dist/components/ui/previewFull.d.ts +40 -0
  44. package/dist/components/ui/previews.d.ts +69 -0
  45. package/dist/components/ui/previewsCompactList.d.ts +18 -0
  46. package/dist/components/ui/previewsShared.d.ts +8 -0
  47. package/dist/components/ui/profile.d.ts +41 -0
  48. package/dist/components/ui/radio-group.d.ts +48 -0
  49. package/dist/components/ui/radix-dialog-dismiss.lib.d.ts +14 -0
  50. package/dist/components/ui/radix-popover-container.lib.d.ts +7 -0
  51. package/dist/components/ui/resizable.d.ts +65 -0
  52. package/dist/components/ui/scroll-area.d.ts +5 -0
  53. package/dist/components/ui/secondary-panel-section.d.ts +20 -0
  54. package/dist/components/ui/segmented-control.d.ts +35 -0
  55. package/dist/components/ui/select-header-filter.d.ts +37 -0
  56. package/dist/components/ui/select.d.ts +91 -0
  57. package/dist/components/ui/separator.d.ts +34 -0
  58. package/dist/components/ui/sheet.d.ts +118 -0
  59. package/dist/components/ui/skeleton.d.ts +24 -0
  60. package/dist/components/ui/sort-component.d.ts +35 -0
  61. package/dist/components/ui/sortable-header.d.ts +25 -0
  62. package/dist/components/ui/switch.d.ts +25 -0
  63. package/dist/components/ui/table-column-resize-handle.d.ts +8 -0
  64. package/dist/components/ui/table-filter-editor.d.ts +11 -0
  65. package/dist/components/ui/table.d.ts +104 -0
  66. package/dist/components/ui/tabs.d.ts +52 -0
  67. package/dist/components/ui/tabsVariants.d.ts +6 -0
  68. package/dist/components/ui/text-area.d.ts +37 -0
  69. package/dist/components/ui/theme-provider.d.ts +205 -0
  70. package/dist/components/ui/time-picker.d.ts +31 -0
  71. package/dist/components/ui/time-picker.lib.d.ts +6 -0
  72. package/dist/components/ui/toast.d.ts +80 -0
  73. package/dist/components/ui/toaster.d.ts +22 -0
  74. package/dist/components/ui/tooltip.d.ts +65 -0
  75. package/dist/components/ui/tree-view.d.ts +96 -0
  76. package/dist/components/ui/widget-plan-fact.d.ts +86 -0
  77. package/dist/date.d.ts +8 -0
  78. package/dist/hooks/useColumnFilters.d.ts +6 -0
  79. package/dist/hooks/useColumnSizing.d.ts +20 -0
  80. package/dist/hooks/useCombinedRefs.d.ts +1 -0
  81. package/dist/hooks/useConfirm.d.ts +49 -0
  82. package/dist/hooks/useNotify.d.ts +28 -0
  83. package/dist/hooks/usePreviewsFilePicker.d.ts +40 -0
  84. package/dist/hooks/useSidebar.d.ts +10 -0
  85. package/dist/hooks/useStoredExpand.d.ts +18 -0
  86. package/dist/hooks/useStoredFields.d.ts +4 -0
  87. package/dist/hooks/useStoredTabs.d.ts +4 -0
  88. package/dist/hooks/useTableStates.d.ts +26 -0
  89. package/dist/hooks/useTheme.d.ts +1 -0
  90. package/dist/hooks/useToast.d.ts +44 -0
  91. package/dist/hooks/useTranslation.d.ts +4 -0
  92. package/dist/krit-ui.d.ts +2 -0
  93. package/dist/krit-ui.js +29694 -0
  94. package/dist/krit-ui.umd.cjs +137 -0
  95. package/dist/lib/attachments.d.ts +245 -0
  96. package/dist/lib/cookies.d.ts +1 -0
  97. package/dist/lib/file.d.ts +52 -0
  98. package/dist/lib/infinite-scroll.d.ts +13 -0
  99. package/dist/lib/selectUtils.d.ts +14 -0
  100. package/dist/lib/table-filter.d.ts +35 -0
  101. package/dist/lib/text.d.ts +1 -0
  102. package/dist/lib/zod.d.ts +27 -0
  103. package/dist/main.d.ts +88 -0
  104. package/dist/style.css +1 -0
  105. package/dist/utils.d.ts +2 -0
  106. package/docs/table-filters.md +481 -0
  107. package/package.json +125 -4
  108. package/tailwind.config.cjs +273 -0
@@ -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.MutableRefObject<HTMLInputElement | null>;
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 | null>;
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,4 @@
1
+ export declare const useStoredFields: (storageKey: string, defaultFields?: string[]) => {
2
+ fields: string[];
3
+ handleFieldsChange: (newFields: string[]) => void;
4
+ };
@@ -0,0 +1,4 @@
1
+ export declare const useStoredTabs: (defaultTab: string, storageKey: string) => {
2
+ tab: string;
3
+ handleTabChange: (newTab: string) => void;
4
+ };
@@ -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 };
@@ -0,0 +1,4 @@
1
+ import { TranslationKey } from '../components/ui/theme-provider';
2
+ export declare const useTranslation: () => {
3
+ t: (key: TranslationKey) => string;
4
+ };
@@ -0,0 +1,2 @@
1
+ export * from './main'
2
+ export {}