@lnco-ai/ui 1.0.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/CHANGELOG.md +1323 -0
- package/LICENSE +661 -0
- package/README.md +60 -0
- package/dist/Authorization/PreventGuestWrapper.d.ts +19 -0
- package/dist/Authorization/PreventGuestWrapper.js +15 -0
- package/dist/Authorization/RedirectionContent.d.ts +9 -0
- package/dist/Authorization/RedirectionContent.js +24 -0
- package/dist/Authorization/SignedInWrapper.d.ts +10 -0
- package/dist/Authorization/SignedInWrapper.js +21 -0
- package/dist/Avatar/Avatar.d.ts +24 -0
- package/dist/Avatar/Avatar.js +22 -0
- package/dist/Avatar/stringToColor.d.ts +12 -0
- package/dist/Avatar/stringToColor.js +31 -0
- package/dist/Avatar/stringToColor.test.d.ts +1 -0
- package/dist/Avatar/stringToColor.test.js +8 -0
- package/dist/Card/Card.d.ts +39 -0
- package/dist/Card/Card.js +76 -0
- package/dist/Card/CardHeader.d.ts +12 -0
- package/dist/Card/CardHeader.js +8 -0
- package/dist/Card/CardThumbnail.d.ts +10 -0
- package/dist/Card/CardThumbnail.js +14 -0
- package/dist/Card/FolderCard.d.ts +14 -0
- package/dist/Card/FolderCard.js +44 -0
- package/dist/Card/LinkCard.d.ts +11 -0
- package/dist/Card/LinkCard.js +41 -0
- package/dist/Card/components/CardThumbnail.d.ts +8 -0
- package/dist/Card/components/CardThumbnail.js +15 -0
- package/dist/Card/constants.d.ts +1 -0
- package/dist/Card/constants.js +1 -0
- package/dist/Collapse/Collapse.d.ts +10 -0
- package/dist/Collapse/Collapse.js +48 -0
- package/dist/Collapse/withCollapse.d.ts +7 -0
- package/dist/Collapse/withCollapse.js +8 -0
- package/dist/CookiesBanner/CookiesBanner.d.ts +10 -0
- package/dist/CookiesBanner/CookiesBanner.js +60 -0
- package/dist/CreativeCommons/CreativeCommons.d.ts +14 -0
- package/dist/CreativeCommons/CreativeCommons.js +75 -0
- package/dist/CreativeCommons/icons/By.d.ts +3 -0
- package/dist/CreativeCommons/icons/By.js +3 -0
- package/dist/CreativeCommons/icons/CCIconsProps.d.ts +3 -0
- package/dist/CreativeCommons/icons/CCIconsProps.js +1 -0
- package/dist/CreativeCommons/icons/Cc.d.ts +3 -0
- package/dist/CreativeCommons/icons/Cc.js +3 -0
- package/dist/CreativeCommons/icons/Cc0.d.ts +3 -0
- package/dist/CreativeCommons/icons/Cc0.js +3 -0
- package/dist/CreativeCommons/icons/Nc.d.ts +3 -0
- package/dist/CreativeCommons/icons/Nc.js +3 -0
- package/dist/CreativeCommons/icons/Nd.d.ts +3 -0
- package/dist/CreativeCommons/icons/Nd.js +3 -0
- package/dist/CreativeCommons/icons/Sa.d.ts +3 -0
- package/dist/CreativeCommons/icons/Sa.js +3 -0
- package/dist/CustomInitialLoader/CustomInitialLoader.d.ts +5 -0
- package/dist/CustomInitialLoader/CustomInitialLoader.js +25 -0
- package/dist/DrawerHeader/DrawerHeader.d.ts +7 -0
- package/dist/DrawerHeader/DrawerHeader.js +16 -0
- package/dist/GraaspLogo/EpflLogo.d.ts +5 -0
- package/dist/GraaspLogo/EpflLogo.js +3 -0
- package/dist/GraaspLogo/GraaspLogo.d.ts +8 -0
- package/dist/GraaspLogo/GraaspLogo.js +5 -0
- package/dist/Header/Header.d.ts +21 -0
- package/dist/Header/Header.js +33 -0
- package/dist/HeaderUserInformation/HeaderUserInformation.d.ts +22 -0
- package/dist/HeaderUserInformation/HeaderUserInformation.js +23 -0
- package/dist/ItemBadges/ItemBadges.d.ts +17 -0
- package/dist/ItemBadges/ItemBadges.js +10 -0
- package/dist/ItemFlag/ItemFlagButton.d.ts +9 -0
- package/dist/ItemFlag/ItemFlagButton.js +11 -0
- package/dist/ItemFlag/ItemFlagDialog.d.ts +14 -0
- package/dist/ItemFlag/ItemFlagDialog.js +25 -0
- package/dist/Loader/Loader.d.ts +7 -0
- package/dist/Loader/Loader.js +4 -0
- package/dist/Main/LogoHeader.d.ts +2 -0
- package/dist/Main/LogoHeader.js +5 -0
- package/dist/Main/Main.d.ts +59 -0
- package/dist/Main/Main.js +82 -0
- package/dist/MainMenu/MainMenu.d.ts +10 -0
- package/dist/MainMenu/MainMenu.js +6 -0
- package/dist/MainMenu/MenuItem/MenuItem.d.ts +16 -0
- package/dist/MainMenu/MenuItem/MenuItem.js +16 -0
- package/dist/MainMenu/hooks.d.ts +10 -0
- package/dist/MainMenu/hooks.js +21 -0
- package/dist/Navigation/CurrentItemNavigation.d.ts +15 -0
- package/dist/Navigation/CurrentItemNavigation.js +12 -0
- package/dist/Navigation/ExtraItemsMenu.d.ts +10 -0
- package/dist/Navigation/ExtraItemsMenu.js +24 -0
- package/dist/Navigation/ExtraItemsNavigation.d.ts +11 -0
- package/dist/Navigation/ExtraItemsNavigation.js +11 -0
- package/dist/Navigation/HomeMenu.d.ts +17 -0
- package/dist/Navigation/HomeMenu.js +28 -0
- package/dist/Navigation/ItemMenu.d.ts +16 -0
- package/dist/Navigation/ItemMenu.js +32 -0
- package/dist/Navigation/Navigation.d.ts +26 -0
- package/dist/Navigation/Navigation.js +15 -0
- package/dist/Navigation/ParentsNavigation.d.ts +10 -0
- package/dist/Navigation/ParentsNavigation.js +8 -0
- package/dist/Navigation/common/CenterAlignWrapper.d.ts +3 -0
- package/dist/Navigation/common/CenterAlignWrapper.js +7 -0
- package/dist/Navigation/common/NavigationLink.d.ts +8 -0
- package/dist/Navigation/common/NavigationLink.js +7 -0
- package/dist/Navigation/common/constants.d.ts +1 -0
- package/dist/Navigation/common/constants.js +1 -0
- package/dist/PlatformSwitch/PlatformSwitch.d.ts +57 -0
- package/dist/PlatformSwitch/PlatformSwitch.js +66 -0
- package/dist/PlatformSwitch/hooks.d.ts +30 -0
- package/dist/PlatformSwitch/hooks.js +49 -0
- package/dist/SearchInput/SearchInput.d.ts +20 -0
- package/dist/SearchInput/SearchInput.js +14 -0
- package/dist/Select/Select.d.ts +24 -0
- package/dist/Select/Select.js +7 -0
- package/dist/Sidebar/Sidebar.d.ts +11 -0
- package/dist/Sidebar/Sidebar.js +25 -0
- package/dist/StyledComponents/StyledBaseComponents.d.ts +11 -0
- package/dist/StyledComponents/StyledBaseComponents.js +11 -0
- package/dist/TextDisplay/TextDisplay.d.ts +5 -0
- package/dist/TextDisplay/TextDisplay.js +24 -0
- package/dist/TextDisplay/fixtures.d.ts +3 -0
- package/dist/TextDisplay/fixtures.js +84 -0
- package/dist/TextDisplay/withFlavor.d.ts +8 -0
- package/dist/TextDisplay/withFlavor.js +25 -0
- package/dist/TextEditor/TextEditor.d.ts +16 -0
- package/dist/TextEditor/TextEditor.js +74 -0
- package/dist/ThemeContext/LanguageSelect.d.ts +15 -0
- package/dist/ThemeContext/LanguageSelect.js +19 -0
- package/dist/ThemeContext/ThemeContext.d.ts +22 -0
- package/dist/ThemeContext/ThemeContext.js +31 -0
- package/dist/Thumbnail/Thumbnail.d.ts +28 -0
- package/dist/Thumbnail/Thumbnail.js +27 -0
- package/dist/Tree/Breadcrumbs.d.ts +14 -0
- package/dist/Tree/Breadcrumbs.js +30 -0
- package/dist/Tree/RowMenu.d.ts +12 -0
- package/dist/Tree/RowMenu.js +37 -0
- package/dist/Tree/RowMenus.d.ts +18 -0
- package/dist/Tree/RowMenus.js +7 -0
- package/dist/Tree/types.d.ts +6 -0
- package/dist/Tree/types.js +1 -0
- package/dist/UserSwitch/UserSwitch.d.ts +17 -0
- package/dist/UserSwitch/UserSwitch.js +46 -0
- package/dist/UserSwitch/UserSwitchWrapper.d.ts +37 -0
- package/dist/UserSwitch/UserSwitchWrapper.js +74 -0
- package/dist/appComponents/ErrorFallback.d.ts +57 -0
- package/dist/appComponents/ErrorFallback.js +72 -0
- package/dist/appComponents/QuestionLabel.d.ts +9 -0
- package/dist/appComponents/QuestionLabel.js +4 -0
- package/dist/appComponents/index.d.ts +6 -0
- package/dist/appComponents/index.js +5 -0
- package/dist/appComponents/statusChips/RequiredChip.d.ts +3 -0
- package/dist/appComponents/statusChips/RequiredChip.js +5 -0
- package/dist/appComponents/statusChips/SavedChip.d.ts +3 -0
- package/dist/appComponents/statusChips/SavedChip.js +5 -0
- package/dist/appComponents/statusChips/SubmittedChip.d.ts +3 -0
- package/dist/appComponents/statusChips/SubmittedChip.js +5 -0
- package/dist/appComponents/statusChips/types.d.ts +5 -0
- package/dist/appComponents/statusChips/types.js +1 -0
- package/dist/appComponents/types.d.ts +8 -0
- package/dist/appComponents/types.js +1 -0
- package/dist/apps.d.ts +1 -0
- package/dist/apps.js +1 -0
- package/dist/buttons/BookmarkButton/BookmarkButton.d.ts +24 -0
- package/dist/buttons/BookmarkButton/BookmarkButton.js +24 -0
- package/dist/buttons/Button/Button.d.ts +37 -0
- package/dist/buttons/Button/Button.js +4 -0
- package/dist/buttons/ChatboxButton/ChatboxButton.d.ts +15 -0
- package/dist/buttons/ChatboxButton/ChatboxButton.js +21 -0
- package/dist/buttons/CopyButton/CopyButton.d.ts +13 -0
- package/dist/buttons/CopyButton/CopyButton.js +14 -0
- package/dist/buttons/DeleteButton/DeleteButton.d.ts +12 -0
- package/dist/buttons/DeleteButton/DeleteButton.js +17 -0
- package/dist/buttons/DownloadButton/DownloadButton.d.ts +30 -0
- package/dist/buttons/DownloadButton/DownloadButton.js +20 -0
- package/dist/buttons/EditButton/EditButton.d.ts +13 -0
- package/dist/buttons/EditButton/EditButton.js +17 -0
- package/dist/buttons/LikeButton/LikeButton.d.ts +28 -0
- package/dist/buttons/LikeButton/LikeButton.js +10 -0
- package/dist/buttons/MenuItemButton.d.ts +11 -0
- package/dist/buttons/MenuItemButton.js +12 -0
- package/dist/buttons/MoveButton/MoveButton.d.ts +13 -0
- package/dist/buttons/MoveButton/MoveButton.js +19 -0
- package/dist/buttons/PinButton/PinButton.d.ts +15 -0
- package/dist/buttons/PinButton/PinButton.js +21 -0
- package/dist/buttons/SaveButton/SaveButton.d.ts +24 -0
- package/dist/buttons/SaveButton/SaveButton.js +4 -0
- package/dist/buttons/ShareButton/ShareButton.d.ts +14 -0
- package/dist/buttons/ShareButton/ShareButton.js +17 -0
- package/dist/buttons/hooks.d.ts +5 -0
- package/dist/buttons/hooks.js +14 -0
- package/dist/buttons/index.d.ts +12 -0
- package/dist/buttons/index.js +12 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +12 -0
- package/dist/draggable/DraggableElement.d.ts +11 -0
- package/dist/draggable/DraggableElement.js +42 -0
- package/dist/draggable/DraggingWrapper.d.ts +23 -0
- package/dist/draggable/DraggingWrapper.js +20 -0
- package/dist/draggable/InBetween.d.ts +10 -0
- package/dist/draggable/InBetween.js +34 -0
- package/dist/draggable/types.d.ts +10 -0
- package/dist/draggable/types.js +1 -0
- package/dist/enums/errors.d.ts +3 -0
- package/dist/enums/errors.js +3 -0
- package/dist/hooks/useFullscreen.d.ts +5 -0
- package/dist/hooks/useFullscreen.js +37 -0
- package/dist/hooks/useMobileView.d.ts +4 -0
- package/dist/hooks/useMobileView.js +6 -0
- package/dist/icons/AnalyticsIcon.d.ts +15 -0
- package/dist/icons/AnalyticsIcon.js +7 -0
- package/dist/icons/BuildIcon.d.ts +15 -0
- package/dist/icons/BuildIcon.js +7 -0
- package/dist/icons/EtherpadIcon.d.ts +7 -0
- package/dist/icons/EtherpadIcon.js +7 -0
- package/dist/icons/H5PIcon.d.ts +6 -0
- package/dist/icons/H5PIcon.js +6 -0
- package/dist/icons/ItemIcon.d.ts +23 -0
- package/dist/icons/ItemIcon.js +75 -0
- package/dist/icons/LibraryIcon.d.ts +16 -0
- package/dist/icons/LibraryIcon.js +7 -0
- package/dist/icons/PlayIcon.d.ts +15 -0
- package/dist/icons/PlayIcon.js +7 -0
- package/dist/icons/ResizingIcon.d.ts +2 -0
- package/dist/icons/ResizingIcon.js +21 -0
- package/dist/icons/StyledSVGComponents.d.ts +35 -0
- package/dist/icons/StyledSVGComponents.js +53 -0
- package/dist/icons/index.d.ts +6 -0
- package/dist/icons/index.js +6 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +60 -0
- package/dist/itemLogin/ForbiddenContent.d.ts +20 -0
- package/dist/itemLogin/ForbiddenContent.js +4 -0
- package/dist/itemLogin/ForbiddenText.d.ts +8 -0
- package/dist/itemLogin/ForbiddenText.js +6 -0
- package/dist/itemLogin/ItemLoginScreen.d.ts +26 -0
- package/dist/itemLogin/ItemLoginScreen.js +72 -0
- package/dist/itemLogin/ItemLoginWrapper.d.ts +23 -0
- package/dist/itemLogin/ItemLoginWrapper.js +43 -0
- package/dist/itemLogin/constants.d.ts +1 -0
- package/dist/itemLogin/constants.js +1 -0
- package/dist/items/AppItem.d.ts +60 -0
- package/dist/items/AppItem.js +69 -0
- package/dist/items/DocumentItem.d.ts +19 -0
- package/dist/items/DocumentItem.js +25 -0
- package/dist/items/DownloadButtonFileItem.d.ts +9 -0
- package/dist/items/DownloadButtonFileItem.js +10 -0
- package/dist/items/EtherpadItem.d.ts +26 -0
- package/dist/items/EtherpadItem.js +15 -0
- package/dist/items/FileAudio.d.ts +9 -0
- package/dist/items/FileAudio.js +10 -0
- package/dist/items/FileImage.d.ts +7 -0
- package/dist/items/FileImage.js +10 -0
- package/dist/items/FileItem.d.ts +25 -0
- package/dist/items/FileItem.js +81 -0
- package/dist/items/FilePdf.d.ts +14 -0
- package/dist/items/FilePdf.js +29 -0
- package/dist/items/FileVideo.d.ts +8 -0
- package/dist/items/FileVideo.js +9 -0
- package/dist/items/H5PItem.d.ts +20 -0
- package/dist/items/H5PItem.js +80 -0
- package/dist/items/ItemSkeleton/ItemSkeleton.d.ts +12 -0
- package/dist/items/ItemSkeleton/ItemSkeleton.js +35 -0
- package/dist/items/LinkItem.d.ts +43 -0
- package/dist/items/LinkItem.js +97 -0
- package/dist/items/SizingWrapper.d.ts +6 -0
- package/dist/items/SizingWrapper.js +23 -0
- package/dist/items/appItemHooks.d.ts +27 -0
- package/dist/items/appItemHooks.js +124 -0
- package/dist/items/constants.d.ts +1 -0
- package/dist/items/constants.js +1 -0
- package/dist/items/iframeStyles.d.ts +4 -0
- package/dist/items/iframeStyles.js +5 -0
- package/dist/items/index.d.ts +5 -0
- package/dist/items/index.js +5 -0
- package/dist/items/withCaption.d.ts +19 -0
- package/dist/items/withCaption.js +58 -0
- package/dist/items/withResizing.d.ts +9 -0
- package/dist/items/withResizing.js +42 -0
- package/dist/text-editor.d.ts +2 -0
- package/dist/text-editor.js +2 -0
- package/dist/theme.d.ts +108 -0
- package/dist/theme.js +214 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.js +32 -0
- package/dist/upload/FileDropper/FileDropper.d.ts +50 -0
- package/dist/upload/FileDropper/FileDropper.js +43 -0
- package/dist/upload/UploadFileButton/UploadFileButton.d.ts +35 -0
- package/dist/upload/UploadFileButton/UploadFileButton.js +17 -0
- package/dist/utils/fixtures.d.ts +3 -0
- package/dist/utils/fixtures.js +7 -0
- package/dist/utils/storybook.d.ts +5 -0
- package/dist/utils/storybook.js +5 -0
- package/package.json +172 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SkeletonProps, SxProps } from '@mui/material';
|
|
2
|
+
import { ThumbnailSizeType } from '@lnco-ai/sdk';
|
|
3
|
+
type ThumbnailProps = {
|
|
4
|
+
alt: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
/**
|
|
7
|
+
* default thumbnail component
|
|
8
|
+
*/
|
|
9
|
+
defaultComponent?: JSX.Element;
|
|
10
|
+
isLoading?: boolean;
|
|
11
|
+
maxWidth?: string | number;
|
|
12
|
+
maxHeight?: string | number;
|
|
13
|
+
/**
|
|
14
|
+
* size of the thumbnail to fetch
|
|
15
|
+
*/
|
|
16
|
+
size?: ThumbnailSizeType;
|
|
17
|
+
sx?: SxProps;
|
|
18
|
+
/**
|
|
19
|
+
* default thumbnail src link, override defaultValue
|
|
20
|
+
*/
|
|
21
|
+
url?: string;
|
|
22
|
+
/**
|
|
23
|
+
* skeleton's variant
|
|
24
|
+
*/
|
|
25
|
+
variant?: SkeletonProps['variant'];
|
|
26
|
+
};
|
|
27
|
+
declare const Thumbnail: ({ id, url, defaultComponent, alt, sx, maxWidth, maxHeight, variant, isLoading, }: ThumbnailProps) => JSX.Element | null;
|
|
28
|
+
export default Thumbnail;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Skeleton } from '@mui/material';
|
|
3
|
+
import { StyledImage } from '../StyledComponents/StyledBaseComponents.js';
|
|
4
|
+
import { Variant } from '../types.js';
|
|
5
|
+
const Thumbnail = ({ id, url, defaultComponent, alt, sx, maxWidth = '100%', maxHeight = '100%', variant = Variant.RECT, isLoading = false, }) => {
|
|
6
|
+
if (url) {
|
|
7
|
+
return (_jsx(StyledImage, { src: url, id: id, alt: alt, sx: [
|
|
8
|
+
{
|
|
9
|
+
objectFit: 'cover',
|
|
10
|
+
width: maxWidth,
|
|
11
|
+
height: maxHeight,
|
|
12
|
+
maxWidth,
|
|
13
|
+
maxHeight,
|
|
14
|
+
},
|
|
15
|
+
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
16
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
17
|
+
] }));
|
|
18
|
+
}
|
|
19
|
+
if (defaultComponent) {
|
|
20
|
+
return defaultComponent;
|
|
21
|
+
}
|
|
22
|
+
if (isLoading) {
|
|
23
|
+
return _jsx(Skeleton, { variant: variant, width: maxWidth, height: maxHeight });
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
export default Thumbnail;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NavigationElement } from './types.js';
|
|
2
|
+
export type BreadcrumbsProps = {
|
|
3
|
+
onSelect: (el: NavigationElement) => void;
|
|
4
|
+
elements: NavigationElement[];
|
|
5
|
+
rootElements?: NavigationElement[];
|
|
6
|
+
/**
|
|
7
|
+
* defines whether a root item should be displayed
|
|
8
|
+
* does not filter over elements
|
|
9
|
+
*/
|
|
10
|
+
selectedId?: string;
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
};
|
|
13
|
+
declare const Breadcrumbs: ({ onSelect, elements, rootElements, selectedId, maxLength, }: BreadcrumbsProps) => JSX.Element | null;
|
|
14
|
+
export default Breadcrumbs;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import truncate from 'lodash.truncate';
|
|
3
|
+
import { Button, Breadcrumbs as MuiBreadcrumbs, Stack, Tooltip, } from '@mui/material';
|
|
4
|
+
const DEFAULT_MAX_LENGTH = 15;
|
|
5
|
+
const Breadcrumbs = ({ onSelect, elements, rootElements = [], selectedId, maxLength = DEFAULT_MAX_LENGTH, }) => {
|
|
6
|
+
if (!elements) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
// include root if selected or show elements
|
|
10
|
+
const idx = rootElements.findIndex(({ id }) => id == selectedId);
|
|
11
|
+
const showRootIdx = idx < 0 ? rootElements.length : idx + 1;
|
|
12
|
+
const allElements = [
|
|
13
|
+
// show rootElements until selectedId
|
|
14
|
+
...rootElements.slice(0, showRootIdx),
|
|
15
|
+
// show elements if selected id not in rootElements
|
|
16
|
+
...(idx < 0 ? elements : []),
|
|
17
|
+
];
|
|
18
|
+
return (_jsx(MuiBreadcrumbs, { separator: '\u203A', "aria-label": 'breadcrumb', children: allElements.map((ele) => (_jsx(Tooltip, { title: ele.name, children: _jsx(Button, { variant: 'text', color: 'inherit', sx: {
|
|
19
|
+
textTransform: 'none',
|
|
20
|
+
p: 0,
|
|
21
|
+
minWidth: 0,
|
|
22
|
+
'&:hover': {
|
|
23
|
+
textDecoration: 'underline',
|
|
24
|
+
background: 'none',
|
|
25
|
+
},
|
|
26
|
+
}, onClick: () => {
|
|
27
|
+
onSelect(ele);
|
|
28
|
+
}, children: _jsxs(Stack, { direction: 'row', gap: 1, children: [ele.icon, truncate(ele.name, { length: maxLength })] }) }, ele.id) }))) }));
|
|
29
|
+
};
|
|
30
|
+
export default Breadcrumbs;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NavigationElement } from './types.js';
|
|
2
|
+
export interface RowMenuProps {
|
|
3
|
+
item: NavigationElement;
|
|
4
|
+
onNavigate: (item: NavigationElement) => void;
|
|
5
|
+
selectedId?: string;
|
|
6
|
+
onClick: (item: NavigationElement) => void;
|
|
7
|
+
isDisabled?: (item: NavigationElement) => boolean;
|
|
8
|
+
id?: string;
|
|
9
|
+
arrowId?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const RowMenu: ({ item, onNavigate, onClick, selectedId, isDisabled, id, arrowId, }: RowMenuProps) => JSX.Element | null;
|
|
12
|
+
export default RowMenu;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { KeyboardArrowRight } from '@mui/icons-material';
|
|
3
|
+
import { Button, CircularProgress, IconButton, Stack, Typography, styled, } from '@mui/material';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { ItemType } from '@lnco-ai/sdk';
|
|
6
|
+
import ItemIcon from '../icons/ItemIcon.js';
|
|
7
|
+
const StyledButton = styled(Button, {
|
|
8
|
+
shouldForwardProp: (prop) => prop !== 'isSelected',
|
|
9
|
+
})(({ theme, isSelected }) => ({
|
|
10
|
+
color: theme.palette.text.primary,
|
|
11
|
+
width: '100%',
|
|
12
|
+
justifyContent: 'start',
|
|
13
|
+
background: isSelected ? theme.palette.grey[200] : 'none',
|
|
14
|
+
textTransform: 'none',
|
|
15
|
+
pl: 1,
|
|
16
|
+
}));
|
|
17
|
+
const RowMenu = ({ item, onNavigate, onClick, selectedId, isDisabled, id, arrowId, }) => {
|
|
18
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
19
|
+
return (_jsx(Stack, { direction: 'row', justifyContent: 'space-between', id: id, sx: {
|
|
20
|
+
'& .arrow': {
|
|
21
|
+
visibility: 'hidden',
|
|
22
|
+
},
|
|
23
|
+
'&:hover .arrow': {
|
|
24
|
+
visibility: 'unset',
|
|
25
|
+
},
|
|
26
|
+
}, children: _jsxs(Stack, { direction: 'row', alignItems: 'center', width: '100%', children: [_jsx(StyledButton, { onClick: () => {
|
|
27
|
+
onClick(item);
|
|
28
|
+
}, isSelected: selectedId === item.id, disabled: isDisabled?.(item), startIcon: _jsx(ItemIcon, { size: '20px', alt: `${item.name} icon`, type: ItemType.FOLDER }), children: _jsx(Typography, { sx: {
|
|
29
|
+
textOverflow: 'ellipsis',
|
|
30
|
+
overflow: 'hidden',
|
|
31
|
+
whiteSpace: 'nowrap',
|
|
32
|
+
}, variant: 'body1', children: item.name }) }), isLoading && _jsx(CircularProgress, { size: 20 }), !isLoading && (_jsx(IconButton, { className: 'arrow', onClick: () => {
|
|
33
|
+
setIsLoading(true);
|
|
34
|
+
onNavigate(item);
|
|
35
|
+
}, id: arrowId, size: 'small', children: _jsx(KeyboardArrowRight, {}) }))] }) }));
|
|
36
|
+
};
|
|
37
|
+
export default RowMenu;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DiscriminatedItem } from '@lnco-ai/sdk';
|
|
2
|
+
import { RowMenuProps } from './RowMenu.js';
|
|
3
|
+
import { NavigationElement } from './types.js';
|
|
4
|
+
export type RowMenusProps = {
|
|
5
|
+
elements?: NavigationElement[];
|
|
6
|
+
onNavigate: RowMenuProps['onNavigate'];
|
|
7
|
+
selectedId?: RowMenuProps['selectedId'];
|
|
8
|
+
onClick: RowMenuProps['onClick'];
|
|
9
|
+
isDisabled?: RowMenuProps['isDisabled'];
|
|
10
|
+
setPage?: (page: number) => void;
|
|
11
|
+
nbPages?: number;
|
|
12
|
+
page?: number;
|
|
13
|
+
emptyContent?: JSX.Element;
|
|
14
|
+
buildRowMenuId?: (id: DiscriminatedItem['id']) => string;
|
|
15
|
+
buildRowMenuArrowId?: (id: DiscriminatedItem['id']) => string;
|
|
16
|
+
};
|
|
17
|
+
declare const RowMenus: ({ elements, onNavigate, selectedId, onClick, isDisabled, setPage, nbPages, page, emptyContent, buildRowMenuId, buildRowMenuArrowId, }: RowMenusProps) => JSX.Element;
|
|
18
|
+
export default RowMenus;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Pagination, Stack } from '@mui/material';
|
|
3
|
+
import RowMenu from './RowMenu.js';
|
|
4
|
+
const RowMenus = ({ elements, onNavigate, selectedId, onClick, isDisabled, setPage, nbPages, page, emptyContent = _jsx(_Fragment, {}), buildRowMenuId = (id) => id, buildRowMenuArrowId = (id) => id, }) => {
|
|
5
|
+
return (_jsxs(Stack, { height: '100%', flex: 1, direction: 'column', justifyContent: 'space-between', children: [_jsxs(Stack, { children: [elements?.map((ele) => (_jsx(RowMenu, { item: ele, onNavigate: onNavigate, selectedId: selectedId, onClick: onClick, isDisabled: isDisabled, id: buildRowMenuId(ele.id), arrowId: buildRowMenuArrowId(ele.id) }, ele.id))), !elements?.length && emptyContent] }), nbPages && (_jsx(Stack, { direction: 'row', justifyContent: 'end', children: nbPages > 1 && (_jsx(Pagination, { sx: { justifyContent: 'end' }, size: 'small', count: nbPages, page: page, onChange: (_, p) => setPage?.(p) })) }))] }));
|
|
6
|
+
};
|
|
7
|
+
export default RowMenus;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MouseEventHandler } from 'react';
|
|
2
|
+
import { CurrentAccount } from '@lnco-ai/sdk';
|
|
3
|
+
type Props = {
|
|
4
|
+
Actions?: JSX.Element | JSX.Element[];
|
|
5
|
+
buildMemberMenuItemId?: (id: string) => string;
|
|
6
|
+
ButtonContent?: JSX.Element;
|
|
7
|
+
buttonId?: string;
|
|
8
|
+
isMemberLoading?: boolean;
|
|
9
|
+
currentMember?: CurrentAccount | null;
|
|
10
|
+
menuId?: string;
|
|
11
|
+
onMemberClick?: (_id: string) => MouseEventHandler;
|
|
12
|
+
avatar?: JSX.Element;
|
|
13
|
+
signedOutTooltipText?: string;
|
|
14
|
+
dataUmamiEvent?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const UserSwitch: ({ Actions, ButtonContent, buttonId, isMemberLoading, currentMember, menuId, avatar, dataUmamiEvent, signedOutTooltipText, }: Props) => JSX.Element;
|
|
17
|
+
export default UserSwitch;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Divider, Menu, MenuItem, Skeleton, Tooltip, Typography, styled, useMediaQuery, useTheme, } from '@mui/material';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { AccountType } from '@lnco-ai/sdk';
|
|
5
|
+
import { SHORT_TEXT_WIDTH, SMALL_AVATAR_SIZE } from '../constants.js';
|
|
6
|
+
import { Variant } from '../types.js';
|
|
7
|
+
const HEADER_USERNAME_MAX_WIDTH = 120;
|
|
8
|
+
const StyledWrapper = styled(Box)(() => ({
|
|
9
|
+
display: 'flex',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
'&:hover': {
|
|
12
|
+
cursor: 'pointer',
|
|
13
|
+
},
|
|
14
|
+
}));
|
|
15
|
+
export const UserSwitch = ({ Actions, ButtonContent, buttonId, isMemberLoading = false, currentMember, menuId, avatar, dataUmamiEvent, signedOutTooltipText = 'You are not signed in.', }) => {
|
|
16
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
|
|
19
|
+
const memberName = currentMember?.name;
|
|
20
|
+
const handleClick = (event) => {
|
|
21
|
+
setAnchorEl(event.currentTarget);
|
|
22
|
+
};
|
|
23
|
+
const handleClose = () => {
|
|
24
|
+
setAnchorEl(null);
|
|
25
|
+
};
|
|
26
|
+
const renderCurrentMemberInfo = () => {
|
|
27
|
+
if (!currentMember || !currentMember.id) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return (_jsxs(MenuItem, { children: [avatar, _jsxs("div", { children: [_jsx(Typography, { variant: 'h6', noWrap: true, children: memberName }), currentMember.type === AccountType.Individual && (_jsx(_Fragment, { children: _jsx(Typography, { variant: 'subtitle2', noWrap: true, children: currentMember.email }) }))] })] }));
|
|
31
|
+
};
|
|
32
|
+
// renders default button
|
|
33
|
+
// shows given content or current member information
|
|
34
|
+
const renderButtonContent = () => {
|
|
35
|
+
if (ButtonContent) {
|
|
36
|
+
return ButtonContent;
|
|
37
|
+
}
|
|
38
|
+
if (isMemberLoading) {
|
|
39
|
+
return (_jsxs(StyledWrapper, { children: [_jsx(Skeleton, { variant: Variant.CIRCLE, width: SMALL_AVATAR_SIZE, height: SMALL_AVATAR_SIZE }), _jsx(Skeleton, { variant: 'text', width: SHORT_TEXT_WIDTH, sx: { mx: 2 } })] }));
|
|
40
|
+
}
|
|
41
|
+
return (_jsxs(_Fragment, { children: [_jsx(Tooltip, { title: memberName ?? signedOutTooltipText, children: _jsx("span", { children: avatar }) }), memberName && !isMobile && (_jsx(Typography, { variant: 'subtitle1', sx: { mx: 2, maxWidth: HEADER_USERNAME_MAX_WIDTH }, noWrap: true, children: memberName }))] }));
|
|
42
|
+
};
|
|
43
|
+
const currentMemberInfo = renderCurrentMemberInfo();
|
|
44
|
+
return (_jsxs(_Fragment, { children: [_jsx(StyledWrapper, { onClick: handleClick, id: buttonId, role: 'button', "aria-haspopup": 'menu', "aria-controls": menuId, "aria-expanded": Boolean(anchorEl), tabIndex: 0, "data-umami-event": dataUmamiEvent, children: renderButtonContent() }), _jsxs(Menu, { id: menuId, anchorEl: anchorEl, keepMounted: true, open: Boolean(anchorEl), onClose: handleClose, children: [currentMemberInfo, Boolean(currentMemberInfo && Actions) && _jsx(Divider, {}), Actions] })] }));
|
|
45
|
+
};
|
|
46
|
+
export default UserSwitch;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CurrentAccount } from '@lnco-ai/sdk';
|
|
2
|
+
type UserMenuItem = {
|
|
3
|
+
icon: JSX.Element;
|
|
4
|
+
text: string;
|
|
5
|
+
redirect_path: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
};
|
|
8
|
+
type Props = {
|
|
9
|
+
buildMemberMenuItemId?: (id: string) => string;
|
|
10
|
+
ButtonContent?: JSX.Element;
|
|
11
|
+
buttonId?: string;
|
|
12
|
+
currentMember?: CurrentAccount | null;
|
|
13
|
+
isCurrentMemberLoading?: boolean;
|
|
14
|
+
profilePath: string;
|
|
15
|
+
redirectPath: string;
|
|
16
|
+
avatar: JSX.Element;
|
|
17
|
+
seeProfileButtonId?: string;
|
|
18
|
+
seeProfileText?: string;
|
|
19
|
+
signedOutTooltipText?: string;
|
|
20
|
+
signInMenuItemId?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Async function used to perform the sign out
|
|
23
|
+
* @param memberId Id of the user to sign out (current user)
|
|
24
|
+
* @returns Promise of void
|
|
25
|
+
*/
|
|
26
|
+
signOut: () => Promise<void>;
|
|
27
|
+
signOutMenuItemId?: string;
|
|
28
|
+
signOutText?: string;
|
|
29
|
+
switchMemberText?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Name of the event that will be sent to Umami for tracking user actions
|
|
32
|
+
*/
|
|
33
|
+
dataUmamiEvent?: string;
|
|
34
|
+
userMenuItems?: UserMenuItem[];
|
|
35
|
+
};
|
|
36
|
+
export declare const UserSwitchWrapper: ({ buildMemberMenuItemId, ButtonContent, buttonId, currentMember, isCurrentMemberLoading, profilePath, redirectPath, avatar, seeProfileButtonId, seeProfileText, signedOutTooltipText, signInMenuItemId, signOut, signOutMenuItemId, signOutText, switchMemberText, userMenuItems, dataUmamiEvent, }: Props) => JSX.Element;
|
|
37
|
+
export default UserSwitchWrapper;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AccountCircle as AccountCircleIcon, MeetingRoom as MeetingRoomIcon, } from '@mui/icons-material';
|
|
3
|
+
import { ListItemIcon, MenuItem, Typography } from '@mui/material';
|
|
4
|
+
import { AccountType, redirect } from '@lnco-ai/sdk';
|
|
5
|
+
import Loader from '../Loader/Loader.js';
|
|
6
|
+
import { UserSwitch } from './UserSwitch.js';
|
|
7
|
+
export const UserSwitchWrapper = ({ buildMemberMenuItemId, ButtonContent, buttonId, currentMember,
|
|
8
|
+
// domain,
|
|
9
|
+
isCurrentMemberLoading = false,
|
|
10
|
+
// isCurrentMemberSuccess,
|
|
11
|
+
profilePath, redirectPath, avatar, seeProfileButtonId, seeProfileText = 'See Profile', signedOutTooltipText = 'You are not signed in.', signInMenuItemId, signOut, signOutMenuItemId, signOutText = 'Sign Out',
|
|
12
|
+
// switchMember,
|
|
13
|
+
switchMemberText = 'Sign in', userMenuItems = [], dataUmamiEvent, }) => {
|
|
14
|
+
// get stored sessions
|
|
15
|
+
// const sessions = getStoredSessions();
|
|
16
|
+
// const { data } = useMembers(sessions.map(({ id }) => id));
|
|
17
|
+
// const members = data?.data?.toSeq()?.toList();
|
|
18
|
+
// save current member in sessions if it doesn't exist
|
|
19
|
+
// it is not possible to do it on /auth since it's a backend call
|
|
20
|
+
// useEffect(() => {
|
|
21
|
+
// if (currentMember && isCurrentMemberSuccess) {
|
|
22
|
+
// const token = getCurrentSession();
|
|
23
|
+
// if (token) {
|
|
24
|
+
// storeSession(
|
|
25
|
+
// { id: currentMember.get('id'), token, createdAt: Date.now() },
|
|
26
|
+
// domain,
|
|
27
|
+
// );
|
|
28
|
+
// }
|
|
29
|
+
// }
|
|
30
|
+
// }, [currentMember, isCurrentMemberSuccess]);
|
|
31
|
+
if (isCurrentMemberLoading) {
|
|
32
|
+
return _jsx(Loader, {});
|
|
33
|
+
}
|
|
34
|
+
const handleSignOut = async () => {
|
|
35
|
+
if (currentMember) {
|
|
36
|
+
await signOut();
|
|
37
|
+
}
|
|
38
|
+
// on sign out success should redirect to sign in
|
|
39
|
+
redirect(window, redirectPath);
|
|
40
|
+
};
|
|
41
|
+
const handleSignIn = () => {
|
|
42
|
+
// setCurrentSession(null, domain);
|
|
43
|
+
// saveUrlForRedirection(window.location.href, domain);
|
|
44
|
+
return redirect(window, redirectPath);
|
|
45
|
+
};
|
|
46
|
+
const goToProfile = () => {
|
|
47
|
+
redirect(window, profilePath);
|
|
48
|
+
};
|
|
49
|
+
// const onMemberClick = (memberId: string) => () =>
|
|
50
|
+
// switchMember({ memberId, domain });
|
|
51
|
+
let Actions;
|
|
52
|
+
const MenuItems = userMenuItems.map((item) => (_jsxs(MenuItem, { onClick: () => redirect(window, item.redirect_path), id: item.id, children: [_jsx(ListItemIcon, { children: item.icon }), _jsx(Typography, { variant: 'subtitle2', children: item.text })] }, item.text)));
|
|
53
|
+
if (currentMember && currentMember.id) {
|
|
54
|
+
Actions =
|
|
55
|
+
currentMember.type === AccountType.Individual
|
|
56
|
+
? [
|
|
57
|
+
_jsxs(MenuItem, { onClick: goToProfile, id: seeProfileButtonId, children: [_jsx(ListItemIcon, { children: _jsx(AccountCircleIcon, { fontSize: 'large' }) }), _jsx(Typography, { variant: 'subtitle2', children: seeProfileText })] }, 'seeProfile'),
|
|
58
|
+
]
|
|
59
|
+
: [];
|
|
60
|
+
Actions.push(...MenuItems);
|
|
61
|
+
Actions.push(_jsxs(MenuItem, { onClick: handleSignOut, id: signOutMenuItemId, children: [_jsx(ListItemIcon, { children: _jsx(MeetingRoomIcon, { fontSize: 'large' }) }), _jsx(Typography, { variant: 'subtitle2', children: signOutText })] }, 'signout'));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
Actions = [
|
|
65
|
+
_jsxs(MenuItem, { onClick: handleSignIn, id: signInMenuItemId, children: [_jsx(ListItemIcon, { children: _jsx(AccountCircleIcon, { fontSize: 'large' }) }), _jsx(Typography, { variant: 'subtitle2', children: switchMemberText })] }, 'signin'),
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
return (_jsx(UserSwitch, { ButtonContent: ButtonContent, Actions: Actions,
|
|
69
|
+
// onMemberClick={onMemberClick}
|
|
70
|
+
currentMember: currentMember,
|
|
71
|
+
// members={members}
|
|
72
|
+
signedOutTooltipText: signedOutTooltipText, buttonId: buttonId, buildMemberMenuItemId: buildMemberMenuItemId, avatar: avatar, dataUmamiEvent: dataUmamiEvent }));
|
|
73
|
+
};
|
|
74
|
+
export default UserSwitchWrapper;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { UserFeedback } from './types.js';
|
|
2
|
+
interface ErrorFallbackProps {
|
|
3
|
+
error: unknown;
|
|
4
|
+
componentStack: string;
|
|
5
|
+
eventId: string;
|
|
6
|
+
captureFeedback: (userFeedback: UserFeedback) => void;
|
|
7
|
+
title?: string;
|
|
8
|
+
formTitle?: string;
|
|
9
|
+
nameLabel?: string;
|
|
10
|
+
nameHelper?: string;
|
|
11
|
+
emailLabel?: string;
|
|
12
|
+
emailHelper?: string;
|
|
13
|
+
commentLabel?: string;
|
|
14
|
+
commentHelper?: string;
|
|
15
|
+
thanksMessage?: string;
|
|
16
|
+
sendButtonLabel?: string;
|
|
17
|
+
errorDetailsLabel?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @returns A form to submit user feedback.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
const ErrorBoundary: FC<{ children?: ReactNode }> = ({ children }) => {
|
|
25
|
+
const { t: tFallback } = useTranslation('translations', {
|
|
26
|
+
keyPrefix: 'ERROR_BOUNDARY.FALLBACK',
|
|
27
|
+
});
|
|
28
|
+
return (
|
|
29
|
+
<Sentry.ErrorBoundary
|
|
30
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
31
|
+
fallback={({ error, componentStack, eventId }) => (
|
|
32
|
+
<ErrorFallback
|
|
33
|
+
error={error}
|
|
34
|
+
componentStack={componentStack}
|
|
35
|
+
eventId={eventId}
|
|
36
|
+
captureUserFeedback={Sentry.captureUserFeedback}
|
|
37
|
+
title={tFallback('MESSAGE_TITLE')}
|
|
38
|
+
formTitle={tFallback('MESSAGE_FEEDBACK')}
|
|
39
|
+
nameLabel={tFallback('NAME_LABEL')}
|
|
40
|
+
nameHelper={tFallback('NAME_HELPER')}
|
|
41
|
+
emailLabel={tFallback('EMAIL_LABEL')}
|
|
42
|
+
emailHelper={tFallback('EMAIL_HELPER')}
|
|
43
|
+
commentLabel={tFallback('COMMENT_LABEL')}
|
|
44
|
+
commentHelper={tFallback('COMMENT_HELPER')}
|
|
45
|
+
thanksMessage={tFallback('THANKS_FOR_FEEDBACK')}
|
|
46
|
+
sendButtonLabel={tFallback('SEND')}
|
|
47
|
+
errorDetailsLabel={tFallback('ERROR_DETAILS')}
|
|
48
|
+
/>
|
|
49
|
+
)}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</Sentry.ErrorBoundary>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
*/
|
|
56
|
+
declare const ErrorFallback: ({ error, componentStack, eventId, captureFeedback, title, formTitle, nameLabel, nameHelper, emailLabel, emailHelper, commentLabel, commentHelper, thanksMessage, sendButtonLabel, errorDetailsLabel, }: ErrorFallbackProps) => JSX.Element;
|
|
57
|
+
export default ErrorFallback;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ExpandMore as ExpandMoreIcon, Send as SendIcon, WarningAmber as WarningIcon, } from '@mui/icons-material';
|
|
3
|
+
import { Accordion, AccordionDetails, AccordionSummary, Alert, Box, Button, Container, Paper, Stack, TextField, Typography, useTheme, } from '@mui/material';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
// DEFAULTS
|
|
6
|
+
const TITLE = 'Sorry, something went wrong with this application';
|
|
7
|
+
const FORM_TITLE = 'Our team has been notified. If you would like to help, please, tell us what happened below.';
|
|
8
|
+
const ERROR_DETAILS = 'Details of the error';
|
|
9
|
+
const NAME_LABEL = 'Name';
|
|
10
|
+
const NAME_HELPER = 'Provide your name (optional)';
|
|
11
|
+
const EMAIL_LABEL = 'Email';
|
|
12
|
+
const EMAIL_HELPER = 'Provide your email (optional)';
|
|
13
|
+
const COMMENT_LABEL = 'Comment';
|
|
14
|
+
const COMMENT_HELPER = 'Tell us what happened (optional)';
|
|
15
|
+
const THANKS_FOR_FEEDBACK = 'Thank you for your feedback!';
|
|
16
|
+
const SEND = 'Send your feedback';
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @returns A form to submit user feedback.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
const ErrorBoundary: FC<{ children?: ReactNode }> = ({ children }) => {
|
|
23
|
+
const { t: tFallback } = useTranslation('translations', {
|
|
24
|
+
keyPrefix: 'ERROR_BOUNDARY.FALLBACK',
|
|
25
|
+
});
|
|
26
|
+
return (
|
|
27
|
+
<Sentry.ErrorBoundary
|
|
28
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
29
|
+
fallback={({ error, componentStack, eventId }) => (
|
|
30
|
+
<ErrorFallback
|
|
31
|
+
error={error}
|
|
32
|
+
componentStack={componentStack}
|
|
33
|
+
eventId={eventId}
|
|
34
|
+
captureUserFeedback={Sentry.captureUserFeedback}
|
|
35
|
+
title={tFallback('MESSAGE_TITLE')}
|
|
36
|
+
formTitle={tFallback('MESSAGE_FEEDBACK')}
|
|
37
|
+
nameLabel={tFallback('NAME_LABEL')}
|
|
38
|
+
nameHelper={tFallback('NAME_HELPER')}
|
|
39
|
+
emailLabel={tFallback('EMAIL_LABEL')}
|
|
40
|
+
emailHelper={tFallback('EMAIL_HELPER')}
|
|
41
|
+
commentLabel={tFallback('COMMENT_LABEL')}
|
|
42
|
+
commentHelper={tFallback('COMMENT_HELPER')}
|
|
43
|
+
thanksMessage={tFallback('THANKS_FOR_FEEDBACK')}
|
|
44
|
+
sendButtonLabel={tFallback('SEND')}
|
|
45
|
+
errorDetailsLabel={tFallback('ERROR_DETAILS')}
|
|
46
|
+
/>
|
|
47
|
+
)}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
</Sentry.ErrorBoundary>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
*/
|
|
54
|
+
const ErrorFallback = ({ error, componentStack, eventId, captureFeedback, title = TITLE, formTitle = FORM_TITLE, nameLabel = NAME_LABEL, nameHelper = NAME_HELPER, emailLabel = EMAIL_LABEL, emailHelper = EMAIL_HELPER, commentLabel = COMMENT_LABEL, commentHelper = COMMENT_HELPER, thanksMessage = THANKS_FOR_FEEDBACK, sendButtonLabel = SEND, errorDetailsLabel = ERROR_DETAILS, }) => {
|
|
55
|
+
const [name, setName] = useState('');
|
|
56
|
+
const [email, setEmail] = useState('');
|
|
57
|
+
const [comment, setComment] = useState('');
|
|
58
|
+
const [feedbackGiven, setFeedbackGiven] = useState(false);
|
|
59
|
+
const theme = useTheme();
|
|
60
|
+
const sendUserFeedback = () => {
|
|
61
|
+
const userFeedback = {
|
|
62
|
+
associatedEventId: eventId,
|
|
63
|
+
name,
|
|
64
|
+
email,
|
|
65
|
+
message: comment,
|
|
66
|
+
};
|
|
67
|
+
captureFeedback(userFeedback);
|
|
68
|
+
setFeedbackGiven(true);
|
|
69
|
+
};
|
|
70
|
+
return (_jsx(Container, { maxWidth: 'lg', children: _jsx(Paper, { variant: 'outlined', sx: { p: 4 }, children: _jsxs(Stack, { direction: 'column', spacing: 1, children: [_jsxs(Stack, { direction: 'row', spacing: 2, alignItems: 'center', children: [_jsx(WarningIcon, { sx: { color: theme.palette.error.main } }), _jsx(Typography, { variant: 'h2', color: theme.palette.error.dark, fontSize: '1.8rem', children: title })] }), feedbackGiven ? (_jsx(Alert, { severity: 'success', children: thanksMessage })) : (_jsx(Box, { id: 'user-feedback', children: _jsxs(Stack, { direction: 'column', spacing: 1, children: [_jsx(Typography, { variant: 'body1', children: formTitle }), _jsx(TextField, { value: name, onChange: (e) => setName(e.target.value), label: nameLabel, helperText: nameHelper }), _jsx(TextField, { value: email, onChange: (e) => setEmail(e.target.value), label: emailLabel, helperText: emailHelper }), _jsx(TextField, { multiline: true, rows: 5, value: comment, onChange: (e) => setComment(e.target.value), label: commentLabel, helperText: commentHelper }), _jsx(Box, { children: _jsx(Button, { startIcon: _jsx(SendIcon, {}), onClick: sendUserFeedback, children: sendButtonLabel }) })] }) })), _jsxs(Accordion, { children: [_jsx(AccordionSummary, { expandIcon: _jsx(ExpandMoreIcon, {}), "aria-controls": 'error-details', id: 'error-details', children: errorDetailsLabel }), _jsxs(AccordionDetails, { children: [_jsx(Typography, { variant: 'caption', children: JSON.stringify(error) }), _jsx(Typography, { variant: 'caption', children: componentStack })] })] })] }) }) }));
|
|
71
|
+
};
|
|
72
|
+
export default ErrorFallback;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TypographyProps } from '@mui/material';
|
|
2
|
+
type QuestionLabelProps = {
|
|
3
|
+
typographyProps?: TypographyProps;
|
|
4
|
+
children: JSX.Element | JSX.Element[];
|
|
5
|
+
width?: string;
|
|
6
|
+
dataCy?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const QuestionLabel: ({ typographyProps, children, width, dataCy, }: QuestionLabelProps) => JSX.Element;
|
|
9
|
+
export default QuestionLabel;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
const QuestionLabel = ({ typographyProps, children, width, dataCy, }) => (_jsx(Typography, { ...typographyProps, sx: { ...typographyProps?.sx, mb: 1, width }, variant: 'h6', "data-cy": dataCy, children: children }));
|
|
4
|
+
export default QuestionLabel;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as ErrorFallback } from './ErrorFallback.js';
|
|
2
|
+
export { default as QuestionLabel } from './QuestionLabel.js';
|
|
3
|
+
export { default as RequiredChip } from './statusChips/RequiredChip.js';
|
|
4
|
+
export { default as SubmittedChip } from './statusChips/SubmittedChip.js';
|
|
5
|
+
export { default as SavedChip } from './statusChips/SavedChip.js';
|
|
6
|
+
export type { UserFeedback } from './types.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as ErrorFallback } from './ErrorFallback.js';
|
|
2
|
+
export { default as QuestionLabel } from './QuestionLabel.js';
|
|
3
|
+
export { default as RequiredChip } from './statusChips/RequiredChip.js';
|
|
4
|
+
export { default as SubmittedChip } from './statusChips/SubmittedChip.js';
|
|
5
|
+
export { default as SavedChip } from './statusChips/SavedChip.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { WarningRounded as WarningIcon } from '@mui/icons-material';
|
|
3
|
+
import { Chip, Tooltip } from '@mui/material';
|
|
4
|
+
const RequiredChip = ({ label, tooltip, dataCy, }) => (_jsx(Tooltip, { title: tooltip, children: _jsx(Chip, { color: 'warning', icon: _jsx(WarningIcon, {}), label: label, variant: 'outlined', "data-cy": dataCy }) }));
|
|
5
|
+
export default RequiredChip;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Backup as BackupIcon } from '@mui/icons-material';
|
|
3
|
+
import { Chip, Tooltip } from '@mui/material';
|
|
4
|
+
const SavedChip = ({ label, tooltip, dataCy, }) => (_jsx(Tooltip, { title: tooltip, children: _jsx(Chip, { icon: _jsx(BackupIcon, {}), label: label, variant: 'outlined', "data-cy": dataCy }) }));
|
|
5
|
+
export default SavedChip;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CheckCircleOutline as CheckCircleOutlineIcon } from '@mui/icons-material';
|
|
3
|
+
import { Chip, Tooltip } from '@mui/material';
|
|
4
|
+
const SubmittedChip = ({ label, tooltip, dataCy, }) => (_jsx(Tooltip, { title: tooltip, children: _jsx(Chip, { color: 'info', icon: _jsx(CheckCircleOutlineIcon, {}), label: label, variant: 'outlined', "data-cy": dataCy }) }));
|
|
5
|
+
export default SubmittedChip;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/apps.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ErrorFallback, QuestionLabel, SavedChip, SubmittedChip, RequiredChip, type UserFeedback, } from './appComponents/index.js';
|
package/dist/apps.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ErrorFallback, QuestionLabel, SavedChip, SubmittedChip, RequiredChip, } from './appComponents/index.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvgIconProps, SxProps } from '@mui/material';
|
|
2
|
+
import { MouseEventHandler } from 'react';
|
|
3
|
+
import { ActionButtonVariant, ColorVariantsType } from '../../types.js';
|
|
4
|
+
export type BookmarkButtonProps = {
|
|
5
|
+
sx?: SxProps;
|
|
6
|
+
/**
|
|
7
|
+
* IconButton's color
|
|
8
|
+
*/
|
|
9
|
+
color?: ColorVariantsType;
|
|
10
|
+
handleBookmark: MouseEventHandler;
|
|
11
|
+
handleUnbookmark: MouseEventHandler;
|
|
12
|
+
isFavorite?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* IconButton's size
|
|
16
|
+
*/
|
|
17
|
+
size?: SvgIconProps['fontSize'];
|
|
18
|
+
type?: ActionButtonVariant;
|
|
19
|
+
ariaLabel?: string;
|
|
20
|
+
tooltip?: string;
|
|
21
|
+
text?: string;
|
|
22
|
+
};
|
|
23
|
+
declare const BookmarkButton: ({ ariaLabel, className, color, handleBookmark, handleUnbookmark, isFavorite, size, sx, text, tooltip, type, }: BookmarkButtonProps) => JSX.Element;
|
|
24
|
+
export default BookmarkButton;
|