@gouvfr-lasuite/ui-kit 0.2.0 → 0.4.0
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/cunningham.ts +11 -0
- package/dist/index.cjs +40 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +174 -4
- package/dist/index.js +9621 -5706
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,11 +7,48 @@ import { Key } from 'react-stately';
|
|
|
7
7
|
import { LabelHTMLAttributes } from 'react';
|
|
8
8
|
import { NodeApi } from 'react-arborist';
|
|
9
9
|
import { NodeRendererProps } from 'react-arborist';
|
|
10
|
+
import { Option as Option_2 } from '@openfun/cunningham-react';
|
|
10
11
|
import { PropsWithChildren } from 'react';
|
|
11
12
|
import { ReactNode } from 'react';
|
|
13
|
+
import { SelectProps } from 'react-aria-components';
|
|
12
14
|
import { SetStateAction } from 'react';
|
|
13
15
|
import { TreeApi } from 'react-arborist';
|
|
14
16
|
|
|
17
|
+
export declare type AccessData<UserType, T> = T & {
|
|
18
|
+
id: string;
|
|
19
|
+
role: string;
|
|
20
|
+
user: UserData<UserType>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export declare const AccessRoleDropdown: ({ roles, onSelect, canUpdate, selectedRole, isOpen, onOpenChange, roleTopMessage, }: AccessRoleDropdownProps) => JSX.Element;
|
|
24
|
+
|
|
25
|
+
declare type AccessRoleDropdownProps = {
|
|
26
|
+
selectedRole: string;
|
|
27
|
+
roles: DropdownMenuOption[];
|
|
28
|
+
onSelect: (role: string) => void;
|
|
29
|
+
canUpdate?: boolean;
|
|
30
|
+
isOpen?: boolean;
|
|
31
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
32
|
+
roleTopMessage?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export declare type AddShareUserListProps<UserType> = {
|
|
36
|
+
users: UserData<UserType>[];
|
|
37
|
+
onRemoveUser: (user: UserData<UserType>) => void;
|
|
38
|
+
rightActions?: ReactNode;
|
|
39
|
+
onShare: () => void;
|
|
40
|
+
roles: DropdownMenuOption[];
|
|
41
|
+
selectedRole: string;
|
|
42
|
+
shareButtonLabel?: string;
|
|
43
|
+
onSelectRole: (role: string) => void;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export declare type AvatarProps = {
|
|
47
|
+
fullName: string;
|
|
48
|
+
size?: "xsmall" | "small" | "medium" | "large";
|
|
49
|
+
forceColor?: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
15
52
|
export declare type BaseTreeViewData<T> = {
|
|
16
53
|
id: string;
|
|
17
54
|
childrenCount?: number;
|
|
@@ -112,6 +149,17 @@ export declare const cunninghamConfig: {
|
|
|
112
149
|
"danger-700": string;
|
|
113
150
|
"danger-800": string;
|
|
114
151
|
"danger-900": string;
|
|
152
|
+
"blue-500": string;
|
|
153
|
+
"brown-500": string;
|
|
154
|
+
"cyan-500": string;
|
|
155
|
+
"gold-500": string;
|
|
156
|
+
"green-500": string;
|
|
157
|
+
"olive-500": string;
|
|
158
|
+
"orange-500": string;
|
|
159
|
+
"purple-500": string;
|
|
160
|
+
"red-500": string;
|
|
161
|
+
"yellow-500": string;
|
|
162
|
+
"rose-500": string;
|
|
115
163
|
};
|
|
116
164
|
font: {
|
|
117
165
|
sizes: {
|
|
@@ -327,7 +375,7 @@ export declare const CunninghamProvider: (props: Parameters<typeof CunninghamPro
|
|
|
327
375
|
|
|
328
376
|
export declare const CustomTabs: ({ tabs, defaultSelectedTab, fullWidth, }: TabsProps) => JSX.Element | null;
|
|
329
377
|
|
|
330
|
-
export declare const DropdownMenu: ({ options, isOpen, onOpenChange, children, selectedValues, onSelectValue, }: PropsWithChildren<DropdownMenuProps>) => JSX.Element;
|
|
378
|
+
export declare const DropdownMenu: ({ options, isOpen, onOpenChange, children, selectedValues, onSelectValue, topMessage, shouldCloseOnInteractOutside, }: PropsWithChildren<DropdownMenuProps>) => JSX.Element;
|
|
331
379
|
|
|
332
380
|
export declare type DropdownMenuOption = {
|
|
333
381
|
label: string;
|
|
@@ -347,8 +395,17 @@ export declare type DropdownMenuProps = {
|
|
|
347
395
|
selectedValues?: string[];
|
|
348
396
|
onSelectValue?: (value: string) => void;
|
|
349
397
|
isOpen?: boolean;
|
|
398
|
+
topMessage?: string;
|
|
399
|
+
shouldCloseOnInteractOutside?: (element: Element) => boolean;
|
|
350
400
|
};
|
|
351
401
|
|
|
402
|
+
export declare const Filter: (props: FilterProps) => JSX.Element;
|
|
403
|
+
|
|
404
|
+
export declare type FilterProps = {
|
|
405
|
+
label: string;
|
|
406
|
+
options: Option_2[];
|
|
407
|
+
} & SelectProps;
|
|
408
|
+
|
|
352
409
|
export declare const Footer: () => JSX.Element;
|
|
353
410
|
|
|
354
411
|
export declare function getLocales(): {
|
|
@@ -382,6 +439,17 @@ export declare const HomeGutter: ({ children }: {
|
|
|
382
439
|
|
|
383
440
|
export declare const HorizontalSeparator: ({ withPadding }: Props_3) => JSX.Element;
|
|
384
441
|
|
|
442
|
+
export declare type InvitationData<UserType, T> = T & {
|
|
443
|
+
id: string;
|
|
444
|
+
role: string;
|
|
445
|
+
email: string;
|
|
446
|
+
user: UserData<UserType>;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
export declare const InvitationUserSelectorItem: <UserType>({ user, onRemoveUser, }: ShareSelectedUserItemProps<UserType>) => JSX.Element;
|
|
450
|
+
|
|
451
|
+
export declare const InvitationUserSelectorList: <UserType>({ users, onRemoveUser, rightActions, onShare, shareButtonLabel, roles, selectedRole, onSelectRole, }: AddShareUserListProps<UserType>) => JSX.Element;
|
|
452
|
+
|
|
385
453
|
export declare const isNode: <T>(node?: TreeViewDataType<T>) => boolean;
|
|
386
454
|
|
|
387
455
|
export declare const isSeparator: <T>(node?: TreeViewDataType<T>) => boolean;
|
|
@@ -498,11 +566,94 @@ export declare type QuickSearchProps = {
|
|
|
498
566
|
children?: ReactNode;
|
|
499
567
|
};
|
|
500
568
|
|
|
569
|
+
export declare const SearchUserItem: <UserType>({ user, }: SearchUserItemProps<UserType>) => JSX.Element;
|
|
570
|
+
|
|
571
|
+
declare type SearchUserItemProps<UserType> = {
|
|
572
|
+
user: UserData<UserType>;
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
export declare const ShareInvitationItem: <UserType, InvitationType>({ invitation, roles, updateRole, deleteInvitation, canUpdate, roleTopMessage, }: ShareInvitationItemProps<UserType, InvitationType>) => JSX.Element;
|
|
576
|
+
|
|
577
|
+
export declare type ShareInvitationItemProps<UserType, InvitationType> = {
|
|
578
|
+
invitation: InvitationData<UserType, InvitationType>;
|
|
579
|
+
roles: DropdownMenuOption[];
|
|
580
|
+
updateRole?: (invitation: InvitationData<UserType, InvitationType>, role: string) => void;
|
|
581
|
+
deleteInvitation?: (invitation: InvitationData<UserType, InvitationType>) => void;
|
|
582
|
+
canUpdate?: boolean;
|
|
583
|
+
roleTopMessage?: string;
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
export declare const ShareMemberItem: <UserType, AccessType>({ accessData, roles, updateRole, deleteAccess, canUpdate, roleTopMessage, }: ShareMemberItemProps<UserType, AccessType>) => JSX.Element;
|
|
587
|
+
|
|
588
|
+
export declare type ShareMemberItemProps<UserType, AccessType> = {
|
|
589
|
+
accessData: AccessData<UserType, AccessType>;
|
|
590
|
+
roles: DropdownMenuOption[];
|
|
591
|
+
updateRole?: (access: AccessData<UserType, AccessType>, role: string) => void;
|
|
592
|
+
deleteAccess?: (access: AccessData<UserType, AccessType>) => void;
|
|
593
|
+
canUpdate?: boolean;
|
|
594
|
+
roleTopMessage?: string;
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
export declare const ShareModal: <UserType, InvitationType, AccessType>({ searchUsersResult, children, outsideSearchContent, accesses: members, invitations, hasNextMembers, canUpdate, hasNextInvitations, ...props }: PropsWithChildren<ShareModalProps<UserType, InvitationType, AccessType>>) => JSX.Element;
|
|
598
|
+
|
|
599
|
+
declare type ShareModalAccessProps<UserType, AccessType> = {
|
|
600
|
+
accesses?: AccessData<UserType, AccessType>[];
|
|
601
|
+
hasNextMembers?: boolean;
|
|
602
|
+
onLoadNextMembers?: () => void;
|
|
603
|
+
onDeleteAccess?: (access: AccessData<UserType, AccessType>) => void;
|
|
604
|
+
onUpdateAccess?: (access: AccessData<UserType, AccessType>, role: string) => void;
|
|
605
|
+
accessRoleTopMessage?: (access: AccessData<UserType, AccessType>) => string | undefined;
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
export declare const ShareModalCopyLinkFooter: ({ onCopyLink, onOk, }: ShareModalCopyLinkFooterProps) => JSX.Element;
|
|
609
|
+
|
|
610
|
+
export declare type ShareModalCopyLinkFooterProps = {
|
|
611
|
+
onCopyLink: () => void;
|
|
612
|
+
onOk: () => void;
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
declare type ShareModalInvitationProps<UserType, InvitationType> = {
|
|
616
|
+
invitations?: InvitationData<UserType, InvitationType>[];
|
|
617
|
+
onUpdateInvitation?: (invitation: InvitationData<UserType, InvitationType>, role: string) => void;
|
|
618
|
+
onDeleteInvitation?: (invitation: InvitationData<UserType, InvitationType>) => void;
|
|
619
|
+
hasNextInvitations?: boolean;
|
|
620
|
+
onLoadNextInvitations?: () => void;
|
|
621
|
+
invitationRoleTopMessage?: (invitation: InvitationData<UserType, InvitationType>) => string;
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Only the props for the modal and generic props
|
|
626
|
+
* The modal is generic and can be with all types as long as the types meet the minimum requirements
|
|
627
|
+
* Like the modal, we can search users, list invitations and members and modify them, that's why we give the corresponding types
|
|
628
|
+
*/
|
|
629
|
+
export declare type ShareModalProps<UserType, InvitationType, AccessType> = {
|
|
630
|
+
modalTitle?: string;
|
|
631
|
+
isOpen: boolean;
|
|
632
|
+
canUpdate?: boolean;
|
|
633
|
+
onClose: () => void;
|
|
634
|
+
invitationRoles: DropdownMenuOption[];
|
|
635
|
+
getAccessRoles?: (access: AccessData<UserType, AccessType>) => DropdownMenuOption[];
|
|
636
|
+
outsideSearchContent?: ReactNode;
|
|
637
|
+
} & ShareModalInvitationProps<UserType, InvitationType> & ShareModalAccessProps<UserType, AccessType> & ShareModalSearchProps<UserType>;
|
|
638
|
+
|
|
639
|
+
declare type ShareModalSearchProps<UserType> = {
|
|
640
|
+
searchUsersResult?: UserData<UserType>[];
|
|
641
|
+
onSearchUsers: (search: string) => void;
|
|
642
|
+
searchPlaceholder?: string;
|
|
643
|
+
onInviteUser: (users: UserData<UserType>[], role: string) => void;
|
|
644
|
+
loading?: boolean;
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
export declare type ShareSelectedUserItemProps<UserType> = {
|
|
648
|
+
user: UserData<UserType>;
|
|
649
|
+
onRemoveUser: (user: UserData<UserType>) => void;
|
|
650
|
+
};
|
|
651
|
+
|
|
501
652
|
export declare const Spinner: ({ size }: SpinnerProps) => JSX.Element;
|
|
502
653
|
|
|
503
|
-
declare
|
|
654
|
+
declare type SpinnerProps = {
|
|
504
655
|
size?: "sm" | "md" | "lg" | "xl";
|
|
505
|
-
}
|
|
656
|
+
};
|
|
506
657
|
|
|
507
658
|
export declare type TabData = {
|
|
508
659
|
id: string;
|
|
@@ -551,7 +702,7 @@ export declare type TreeProviderProps<T> = {
|
|
|
551
702
|
onLoadChildren?: (id: string) => Promise<TreeViewDataType<T>[]>;
|
|
552
703
|
};
|
|
553
704
|
|
|
554
|
-
export declare const TreeView: <T>({ initialOpenState, selectedNodeId, rootNodeId, renderNode, canDrop, canDrag, afterMove, }: TreeViewProps<T>) => JSX.Element | undefined;
|
|
705
|
+
export declare const TreeView: <T>({ initialOpenState, selectedNodeId, rootNodeId, renderNode, canDrop, canDrag, afterMove, beforeMove, }: TreeViewProps<T>) => JSX.Element | undefined;
|
|
555
706
|
|
|
556
707
|
export declare type TreeViewDataType<T> = BaseTreeViewData<T>;
|
|
557
708
|
|
|
@@ -594,6 +745,7 @@ export declare type TreeViewProps<T> = {
|
|
|
594
745
|
index: number;
|
|
595
746
|
}) => boolean;
|
|
596
747
|
canDrag?: (node: TreeDataItem<T>) => boolean;
|
|
748
|
+
beforeMove?: (result: TreeViewMoveResult, moveCallback: () => void) => void;
|
|
597
749
|
afterMove?: (result: TreeViewMoveResult) => void;
|
|
598
750
|
renderNode: (props: NodeRendererProps<TreeDataItem<T>>) => React.ReactNode;
|
|
599
751
|
};
|
|
@@ -605,18 +757,36 @@ export declare const useDropdownMenu: () => {
|
|
|
605
757
|
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
|
606
758
|
};
|
|
607
759
|
|
|
760
|
+
export declare const UserAvatar: ({ fullName, size, forceColor, }: AvatarProps) => JSX.Element;
|
|
761
|
+
|
|
762
|
+
export declare type UserData<T> = T & {
|
|
763
|
+
id: string;
|
|
764
|
+
full_name: string;
|
|
765
|
+
email: string;
|
|
766
|
+
};
|
|
767
|
+
|
|
608
768
|
export declare const useResponsive: () => {
|
|
609
769
|
isMobile: boolean;
|
|
610
770
|
isTablet: boolean;
|
|
611
771
|
isDesktop: boolean;
|
|
612
772
|
};
|
|
613
773
|
|
|
774
|
+
declare type UserProps = {
|
|
775
|
+
fullName?: string;
|
|
776
|
+
email?: string;
|
|
777
|
+
showEmail?: boolean;
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
export declare const UserRow: ({ fullName: full_name, email, showEmail, }: UserProps) => JSX.Element;
|
|
781
|
+
|
|
614
782
|
export declare const useTree: <T>(initialItems: TreeViewDataType<T>[], refreshCallback?: (id: string) => Promise<Partial<TreeViewDataType<T>>>, loadChildrenCallback?: (id: string) => Promise<TreeViewDataType<T>[]>) => {
|
|
615
783
|
nodes: TreeDataItem<TreeViewDataType<T>>[];
|
|
616
784
|
addChild: (parentId: string | null, newNode: TreeViewDataType<T>, index?: number) => void;
|
|
617
785
|
updateNode: (nodeId: string, updatedData: Partial<TreeViewDataType<T>>) => void;
|
|
618
786
|
deleteNode: (nodeId: string) => void;
|
|
787
|
+
deleteNodes: (nodeIds: string[]) => void;
|
|
619
788
|
addRootNode: (newNode: TreeViewDataType<T>, index?: number) => void;
|
|
789
|
+
addRootNodes: (newNodes: TreeViewDataType<T>[], index?: number) => void;
|
|
620
790
|
selectedNode: T | undefined;
|
|
621
791
|
setSelectedNode: Dispatch<SetStateAction<T | undefined>>;
|
|
622
792
|
refreshNode: (nodeId: string) => Promise<void>;
|