@yusr_systems/ui 2.0.3 → 2.0.4

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/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ActionCreatorWithPayload } from '@reduxjs/toolkit';
2
2
  import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
3
3
  import { AsyncThunk } from '@reduxjs/toolkit';
4
4
  import { AsyncThunkConfig } from '@reduxjs/toolkit';
5
- import { AuthState } from '@yusr_systems/core/src/auth';
5
+ import { AuthState } from '@yusr_systems/core/src/auth/authSlice';
6
6
  import * as AvatarPrimitive from '@radix-ui/react-avatar';
7
7
  import { BaseApiService } from '@yusr_systems/core/src/networking';
8
8
  import { BaseEntity } from '@yusr_systems/core/src/entities';
@@ -17,10 +17,11 @@ import { Command as Command_2 } from 'cmdk';
17
17
  import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
18
18
  import { DayButton } from 'react-day-picker';
19
19
  import { DayPicker } from 'react-day-picker';
20
- import { default as default_2 } from 'embla-carousel-react';
20
+ import { default as default_2 } from 'react';
21
+ import { default as default_3 } from 'embla-carousel-react';
21
22
  import * as DialogPrimitive from '@radix-ui/react-dialog';
22
23
  import * as Direction from '@radix-ui/react-direction';
23
- import { Dispatch } from 'redux';
24
+ import { Dispatch } from 'react';
24
25
  import { Draft } from 'immer';
25
26
  import { Drawer as Drawer_2 } from 'vaul';
26
27
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
@@ -38,27 +39,24 @@ import { ReactNode } from 'react';
38
39
  import * as RechartsPrimitive from 'recharts';
39
40
  import { Reducer } from 'redux';
40
41
  import { ReducersMapObject } from '@reduxjs/toolkit';
42
+ import { RefObject } from 'react';
41
43
  import { RequestResult } from '@yusr_systems/core/src/types';
42
44
  import { ResourcePermissions } from '@yusr_systems/core/src/auth/permissionSelector';
43
45
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
44
46
  import * as SelectPrimitive from '@radix-ui/react-select';
45
47
  import * as SeparatorPrimitive from '@radix-ui/react-separator';
48
+ import { SetStateAction } from 'react';
46
49
  import { Slice } from '@reduxjs/toolkit';
47
50
  import { SliceCaseReducers } from '@reduxjs/toolkit';
48
51
  import { SliceSelectors } from '@reduxjs/toolkit';
49
52
  import { StorageFile } from '@yusr_systems/core/src/entities';
50
- import { StoreEnhancer } from 'redux';
51
53
  import * as SwitchPrimitive from '@radix-ui/react-switch';
52
54
  import * as TabsPrimitive from '@radix-ui/react-tabs';
53
- import { ThunkDispatch } from 'redux-thunk';
54
55
  import { ToasterProps } from 'sonner';
55
56
  import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
56
57
  import * as TogglePrimitive from '@radix-ui/react-toggle';
57
58
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
58
- import { Tuple } from '@reduxjs/toolkit';
59
- import { TypedUseSelectorHook } from 'react-redux';
60
59
  import { UnknownAction } from '@reduxjs/toolkit';
61
- import { UnknownAction as UnknownAction_2 } from 'redux';
62
60
  import { UseEmblaCarouselType } from 'embla-carousel-react';
63
61
  import { ValidationRule } from '@yusr_systems/core/src/validation/validationRule';
64
62
  import { VariantProps } from 'class-variance-authority';
@@ -103,6 +101,11 @@ declare const alertVariants: (props?: ({
103
101
 
104
102
  declare type AppStore = ReturnType<typeof createInternalStore>;
105
103
 
104
+ declare interface AuthActions {
105
+ logout: () => any;
106
+ syncFromStorage: () => any;
107
+ }
108
+
106
109
  export declare function Avatar({ className, size, ...props }: React_2.ComponentProps<typeof AvatarPrimitive.Root> & {
107
110
  size?: "default" | "sm" | "lg";
108
111
  }): JSX.Element;
@@ -193,8 +196,8 @@ export declare type CarouselApi = UseEmblaCarouselType[1];
193
196
  export declare function CarouselContent({ className, ...props }: React_2.ComponentProps<"div">): JSX.Element;
194
197
 
195
198
  declare type CarouselContextProps = {
196
- carouselRef: ReturnType<typeof default_2>[0];
197
- api: ReturnType<typeof default_2>[1];
199
+ carouselRef: ReturnType<typeof default_3>[0];
200
+ api: ReturnType<typeof default_3>[1];
198
201
  scrollPrev: () => void;
199
202
  scrollNext: () => void;
200
203
  canScrollPrev: boolean;
@@ -218,6 +221,8 @@ declare type CarouselProps = {
218
221
  setApi?: (api: CarouselApi) => void;
219
222
  };
220
223
 
224
+ export declare function ChangeDialog<T extends BaseEntity>({ title, description, className, formData, dialogMode, service, disable, onSuccess, validate, children }: ChangeDialogProps<T>): JSX.Element;
225
+
221
226
  export declare interface ChangeDialogProps<T extends BaseEntity> extends SaveButtonProps<T>, PropsWithChildren {
222
227
  title: string;
223
228
  description?: string;
@@ -435,13 +440,9 @@ export declare function createGenericEntitySlice<T extends BaseEntity, CR extend
435
440
  };
436
441
  };
437
442
 
438
- export declare const createInternalStore: <TUser extends object, TSetting extends object>(externalReducers?: ReducersMapObject) => EnhancedStore<{
439
- auth: AuthState<object, object>;
440
- }, UnknownAction_2, Tuple<[ StoreEnhancer<{
441
- dispatch: ThunkDispatch<{
442
- auth: AuthState<object, object>;
443
- }, undefined, UnknownAction_2>;
444
- }>, StoreEnhancer]>>;
443
+ export declare const createInternalStore: <TUser extends object, TSetting extends object, R extends ReducersMapObject = ReducersMapObject>(externalReducers: R) => EnhancedStore<{
444
+ auth: AuthState<TUser, TSetting>;
445
+ } & { [K in keyof R]: ReturnType<R[K]>; }>;
445
446
 
446
447
  export declare interface CrudActions<T extends BaseEntity> {
447
448
  filter: AsyncThunk<FilterResult<T> | undefined, FilterCondition | undefined, object>;
@@ -456,6 +457,10 @@ export declare interface CrudActions<T extends BaseEntity> {
456
457
  setCurrentPage: (page: number) => UnknownAction;
457
458
  }
458
459
 
460
+ export declare function CrudEmptyTablePreview({ mode }: EmptyTablePreviewProps): JSX.Element;
461
+
462
+ export declare function CrudPage<T extends BaseEntity>({ permissions, useSlice, entityName, title, addNewItemTitle, cards, columnsToFilter, actions, service, entityState, tableHeadRows, tableRowMapper, ChangeDialog, children }: CrudPageProps<T>): JSX.Element;
463
+
459
464
  export declare type CrudPageProps<T extends BaseEntity> = PropsWithChildren & {
460
465
  entityState: IEntityState<T>;
461
466
  useSlice: () => IDialogState<T>;
@@ -467,11 +472,42 @@ export declare type CrudPageProps<T extends BaseEntity> = PropsWithChildren & {
467
472
  cards: CardProps[];
468
473
  columnsToFilter: ColumnName[];
469
474
  service: BaseApiService<T>;
470
- tableHeadRows: TableHeadRow[];
475
+ tableHeadRows: CrudTableHeadRow[];
471
476
  tableRowMapper: (entity: T) => TableBodyRowInfo[];
472
477
  ChangeDialog: React.ReactNode;
473
478
  };
474
479
 
480
+ export declare function CrudTable({ state, children }: {
481
+ state: IEntityState<any>;
482
+ children: React.ReactNode;
483
+ }): JSX.Element;
484
+
485
+ export declare function CrudTableBodyRow({ tableRows, dropdownMenu, contextMenuContent }: GenericRowProps): JSX.Element;
486
+
487
+ export declare function CrudTableCard({ cards }: {
488
+ cards: CardProps[];
489
+ }): JSX.Element;
490
+
491
+ export declare function CrudTableHeader({ title, buttonTitle, createComp, isButtonVisible }: {
492
+ title: string;
493
+ buttonTitle: string;
494
+ createComp: ReactNode;
495
+ isButtonVisible?: boolean;
496
+ }): JSX.Element;
497
+
498
+ export declare function CrudTableHeaderRows({ tableHeadRows }: {
499
+ tableHeadRows: CrudTableHeadRow[];
500
+ }): JSX.Element;
501
+
502
+ export declare type CrudTableHeadRow = {
503
+ rowName: string;
504
+ rowStyles: string;
505
+ };
506
+
507
+ export declare function CrudTablePagination({ pageSize, totalNumber, currentPage, onPageChanged }: PaginationFooterProps): JSX.Element;
508
+
509
+ export declare function CrudTableRowActionsMenu({ onEditClicked, onDeleteClicked, type, permissions }: Props_2): JSX.Element;
510
+
475
511
  export declare function DateField({ label, error, isInvalid, required, ...props }: DateFieldProps): JSX.Element;
476
512
 
477
513
  declare interface DateFieldProps extends DateInputProps {
@@ -507,6 +543,8 @@ export declare interface DateTimeInputProps {
507
543
  locale?: any;
508
544
  }
509
545
 
546
+ export declare function DeleteDialog<T extends BaseEntity>({ entityName, id, service, onSuccess }: Props<T>): JSX.Element;
547
+
510
548
  export declare function Dialog({ ...props }: React_2.ComponentProps<typeof DialogPrimitive.Root>): JSX.Element;
511
549
 
512
550
  export declare function DialogClose({ ...props }: React_2.ComponentProps<typeof DialogPrimitive.Close>): JSX.Element;
@@ -598,6 +636,19 @@ export declare function DropdownMenuSubTrigger({ className, inset, children, ...
598
636
 
599
637
  export declare function DropdownMenuTrigger({ ...props }: React_2.ComponentProps<typeof DropdownMenuPrimitive.Trigger>): JSX.Element;
600
638
 
639
+ export declare function DynamicListContainer<T>({ title, items, onAdd, addLabel, emptyMessage, error, headers, children }: DynamicListProps<T>): JSX.Element;
640
+
641
+ declare interface DynamicListProps<T> {
642
+ title: string;
643
+ items: T[];
644
+ onAdd: () => void;
645
+ addLabel: string;
646
+ emptyMessage: string;
647
+ error?: string;
648
+ headers: string[];
649
+ children: (item: any, index: number) => React.ReactNode;
650
+ }
651
+
601
652
  export declare function Empty({ className, ...props }: React.ComponentProps<"div">): JSX.Element;
602
653
 
603
654
  export declare function EmptyContent({ className, ...props }: React.ComponentProps<"div">): JSX.Element;
@@ -612,6 +663,12 @@ declare const emptyMediaVariants: (props?: ({
612
663
  variant?: "default" | "icon" | null | undefined;
613
664
  } & ClassProp) | undefined) => string;
614
665
 
666
+ declare type EmptyTableMode = "empty" | "loading" | "error";
667
+
668
+ declare type EmptyTablePreviewProps = {
669
+ mode: EmptyTableMode;
670
+ };
671
+
615
672
  export declare function EmptyTitle({ className, ...props }: React.ComponentProps<"div">): JSX.Element;
616
673
 
617
674
  export declare function Field({ className, orientation, ...props }: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>): JSX.Element;
@@ -667,13 +724,19 @@ declare interface FormFieldProps {
667
724
  required?: boolean;
668
725
  }
669
726
 
727
+ declare interface GenericRowProps {
728
+ tableRows: TableBodyRowInfo[];
729
+ dropdownMenu: ReactNode;
730
+ contextMenuContent: ReactNode;
731
+ }
732
+
670
733
  export declare interface IDialogState<T> {
671
734
  selectedRow: T | null;
672
735
  isChangeDialogOpen: boolean;
673
736
  isDeleteDialogOpen: boolean;
674
737
  }
675
738
 
676
- declare interface IEntityState<T> {
739
+ export declare interface IEntityState<T> {
677
740
  entities: FilterResult<T>;
678
741
  isLoaded: boolean;
679
742
  isLoading: boolean;
@@ -719,6 +782,21 @@ export declare function isPDF(file?: StorageFile): boolean;
719
782
 
720
783
  export declare function Label({ className, ...props }: React_2.ComponentProps<typeof LabelPrimitive.Root>): JSX.Element;
721
784
 
785
+ export declare function Lightbox({ srcLight, srcDark, alt, onClose }: LightboxProps): JSX.Element;
786
+
787
+ declare interface LightboxProps {
788
+ srcLight: string;
789
+ srcDark: string;
790
+ alt: string;
791
+ onClose: () => void;
792
+ }
793
+
794
+ declare type ListType = "dropdown" | "context";
795
+
796
+ export declare function Loading({ entityName }: {
797
+ entityName: string;
798
+ }): JSX.Element;
799
+
722
800
  export declare function NumberField({ label, error, isInvalid, required, ...props }: NumberFieldProps): JSX.Element;
723
801
 
724
802
  declare interface NumberFieldProps extends NumberInputProps {
@@ -740,6 +818,13 @@ export declare function PaginationContent({ className, ...props }: React_2.Compo
740
818
 
741
819
  export declare function PaginationEllipsis({ className, ...props }: React_2.ComponentProps<"span">): JSX.Element;
742
820
 
821
+ declare type PaginationFooterProps = {
822
+ pageSize: number;
823
+ totalNumber: number;
824
+ currentPage: number;
825
+ onPageChanged?: (newPage: number) => void;
826
+ };
827
+
743
828
  export declare function PaginationItem({ ...props }: React_2.ComponentProps<"li">): JSX.Element;
744
829
 
745
830
  export declare function PaginationLink({ className, isActive, size, ...props }: PaginationLinkProps): JSX.Element;
@@ -774,6 +859,29 @@ export declare function PopoverTitle({ className, ...props }: React_2.ComponentP
774
859
 
775
860
  export declare function PopoverTrigger({ ...props }: React_2.ComponentProps<typeof PopoverPrimitive.Trigger>): JSX.Element;
776
861
 
862
+ declare interface Props<T extends BaseEntity> {
863
+ entityName: string;
864
+ id: number;
865
+ service: BaseApiService<T>;
866
+ onSuccess?: () => void;
867
+ }
868
+
869
+ declare interface Props_2 {
870
+ onEditClicked: () => void;
871
+ onDeleteClicked: () => void;
872
+ type: ListType;
873
+ permissions: ResourcePermissions;
874
+ }
875
+
876
+ export declare function ProtectedRoute({ isAuthenticated, loginPath }: ProtectedRouteProps): JSX.Element;
877
+
878
+ declare interface ProtectedRouteProps {
879
+ isAuthenticated: boolean;
880
+ loginPath?: string;
881
+ }
882
+
883
+ export declare function SaveButton<T extends BaseEntity>({ formData, dialogMode, service, disable, onSuccess, validate }: SaveButtonProps<T>): JSX.Element;
884
+
777
885
  export declare interface SaveButtonProps<T extends BaseEntity> {
778
886
  formData: T | Partial<T>;
779
887
  dialogMode?: DialogMode;
@@ -787,6 +895,34 @@ export declare function ScrollArea({ className, children, ...props }: React_2.Co
787
895
 
788
896
  export declare function ScrollBar({ className, orientation, ...props }: React_2.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>): JSX.Element;
789
897
 
898
+ export declare function SearchableSelect<T>({ items, itemLabelKey, itemValueKey, value, onValueChange, disabled, errorInputClass, placeholder, columnsNames, onSearch }: SearchableSelectParams<T>): JSX.Element;
899
+
900
+ declare type SearchableSelectParams<T> = {
901
+ items: T[];
902
+ itemLabelKey: keyof T;
903
+ itemValueKey: keyof T;
904
+ value: string;
905
+ onValueChange: (value: string) => void;
906
+ disabled?: boolean;
907
+ errorInputClass?: string;
908
+ placeholder?: string;
909
+ columnsNames: ColumnName[];
910
+ onSearch: (condition: {
911
+ value: string;
912
+ columnName: string;
913
+ } | undefined) => void;
914
+ };
915
+
916
+ export declare function SearchInput({ columnsNames, onSearch }: SearchInputParams): JSX.Element;
917
+
918
+ declare type SearchInputParams = {
919
+ columnsNames: ColumnName[];
920
+ onSearch: (condition: {
921
+ value: string;
922
+ columnName: string;
923
+ } | undefined) => void;
924
+ };
925
+
790
926
  export declare function Select({ ...props }: React_2.ComponentProps<typeof SelectPrimitive.Root>): JSX.Element;
791
927
 
792
928
  export declare function SelectContent({ className, children, position, align, ...props }: React_2.ComponentProps<typeof SelectPrimitive.Content>): JSX.Element;
@@ -831,6 +967,8 @@ export declare function SelectValue({ ...props }: React_2.ComponentProps<typeof
831
967
 
832
968
  export declare function Separator({ className, orientation, decorative, ...props }: React_2.ComponentProps<typeof SeparatorPrimitive.Root>): JSX.Element;
833
969
 
970
+ export declare const setupAuthListeners: (dispatch: InternalDispatch, actions: AuthActions) => void;
971
+
834
972
  export declare function Sheet({ ...props }: React_2.ComponentProps<typeof DialogPrimitive.Root>): JSX.Element;
835
973
 
836
974
  export declare function SheetClose({ ...props }: React_2.ComponentProps<typeof DialogPrimitive.Close>): JSX.Element;
@@ -895,6 +1033,8 @@ export declare function SidebarInput({ className, ...props }: React_2.ComponentP
895
1033
 
896
1034
  export declare function SidebarInset({ className, ...props }: React_2.ComponentProps<"main">): JSX.Element;
897
1035
 
1036
+ export declare function SidebarLogo({ logos, alt }: SidebarLogoProps): JSX.Element;
1037
+
898
1038
  export declare interface SidebarLogoProps {
899
1039
  logos: {
900
1040
  full: {
@@ -983,6 +1123,22 @@ export declare function SideBarUserData<T extends UsernameObject>({ user }: {
983
1123
 
984
1124
  export declare function Skeleton({ className, ...props }: React.ComponentProps<"div">): JSX.Element;
985
1125
 
1126
+ export declare function StorageFileField({ label, file, onFileChange, onRemove, onDownload, getFileSrc, showPreview, fileInputRef, error, isInvalid, dir }: StorageFileFieldProps): JSX.Element;
1127
+
1128
+ declare interface StorageFileFieldProps {
1129
+ label: string;
1130
+ file: StorageFile | StorageFile[] | undefined;
1131
+ onFileChange: (event: default_2.ChangeEvent<HTMLInputElement>) => void;
1132
+ onRemove: (index: number, file: StorageFile) => void;
1133
+ onDownload: (e: default_2.MouseEvent, file: StorageFile | undefined) => void;
1134
+ getFileSrc: (file: StorageFile | undefined) => string;
1135
+ showPreview: (file: StorageFile | undefined) => boolean;
1136
+ fileInputRef: default_2.RefObject<HTMLInputElement | null>;
1137
+ error?: string;
1138
+ isInvalid?: boolean;
1139
+ dir?: "rtl" | "ltr";
1140
+ }
1141
+
986
1142
  export declare function Switch({ className, size, ...props }: React_2.ComponentProps<typeof SwitchPrimitive.Root> & {
987
1143
  size?: "sm" | "default";
988
1144
  }): JSX.Element;
@@ -1006,11 +1162,6 @@ export declare function TableHead({ className, ...props }: React_2.ComponentProp
1006
1162
 
1007
1163
  export declare function TableHeader({ className, ...props }: React_2.ComponentProps<"thead">): JSX.Element;
1008
1164
 
1009
- export declare type TableHeadRow = {
1010
- rowName: string;
1011
- rowStyles: string;
1012
- };
1013
-
1014
1165
  export declare function TableRow({ className, ...props }: React_2.ComponentProps<"tr">): JSX.Element;
1015
1166
 
1016
1167
  export declare function Tabs({ className, orientation, ...props }: React_2.ComponentProps<typeof TabsPrimitive.Root>): JSX.Element;
@@ -1097,10 +1248,20 @@ export declare function TooltipTrigger({ ...props }: React_2.ComponentProps<type
1097
1248
 
1098
1249
  export declare function useCarousel(): CarouselContextProps;
1099
1250
 
1100
- declare type UseCarouselParameters = Parameters<typeof default_2>;
1251
+ declare type UseCarouselParameters = Parameters<typeof default_3>;
1101
1252
 
1102
1253
  export declare function useComboboxAnchor(): React_2.RefObject<HTMLDivElement | null>;
1103
1254
 
1255
+ export declare function useDialog<T>(): {
1256
+ selectedRow: T | null;
1257
+ isEditDialogOpen: boolean;
1258
+ isDeleteDialogOpen: boolean;
1259
+ setIsEditDialogOpen: Dispatch<SetStateAction<boolean>>;
1260
+ setIsDeleteDialogOpen: Dispatch<SetStateAction<boolean>>;
1261
+ openEditDialog: (entity: T) => void;
1262
+ openDeleteDialog: (entity: T) => void;
1263
+ };
1264
+
1104
1265
  export declare const useDirection: typeof Direction.useDirection;
1105
1266
 
1106
1267
  export declare function useDynamicList<T, K extends keyof T>(fieldName: K, setFormData: (updater: (prev: T) => T) => void, clearError: (field: string) => void): {
@@ -1131,18 +1292,44 @@ export declare function useFormValidation<T>(data: T, rules: ValidationRule<T>[]
1131
1292
 
1132
1293
  export declare function useIsMobile(): boolean;
1133
1294
 
1295
+ export declare function useLightBox(): {
1296
+ lightbox: {
1297
+ srcLight: string;
1298
+ srcDark: string;
1299
+ alt: string;
1300
+ } | null;
1301
+ openLightbox: (srcLight: string, srcDark: string, alt: string) => void;
1302
+ closeLightbox: () => void;
1303
+ };
1304
+
1134
1305
  declare interface UsernameObject {
1135
1306
  username?: string;
1136
1307
  }
1137
1308
 
1138
1309
  export declare function useSidebar(): SidebarContextProps;
1139
1310
 
1311
+ export declare function useStorageFile<T>(setFormData: React.Dispatch<React.SetStateAction<T>>, fieldName: keyof T): {
1312
+ fileInputRef: RefObject<HTMLInputElement | null>;
1313
+ handleFileChange: (event: React.ChangeEvent<HTMLInputElement>) => Promise<void>;
1314
+ handleRemoveFile: (index: number) => void;
1315
+ handleDownload: (e: React.MouseEvent, file: StorageFile | undefined) => Promise<void>;
1316
+ showFilePreview: (file: StorageFile | undefined) => boolean;
1317
+ getFileSrc: (file: StorageFile | undefined) => string;
1318
+ };
1319
+
1140
1320
  export declare const useTheme: () => ThemeProviderState;
1141
1321
 
1142
- export declare const useYusrDispatch: () => ThunkDispatch<{
1143
- auth: AuthState<object, object>;
1144
- }, undefined, UnknownAction_2> & Dispatch<UnknownAction_2>;
1322
+ export declare function YusrBusBackground(): JSX.Element;
1323
+
1324
+ export declare function ZoomableImage({ srcLight, srcDark, alt, className, wrapperClassName, onOpen }: ZoomableImageProps): JSX.Element;
1145
1325
 
1146
- export declare const useYusrSelector: TypedUseSelectorHook<InternalRootState>;
1326
+ declare interface ZoomableImageProps {
1327
+ srcLight: string;
1328
+ srcDark: string;
1329
+ alt: string;
1330
+ className?: string;
1331
+ wrapperClassName?: string;
1332
+ onOpen: (srcLight: string, srcDark: string, alt: string) => void;
1333
+ }
1147
1334
 
1148
1335
  export { }