@dashadmin/dash-admin 1.3.72 → 1.3.74-srcfree.1
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/components/tenant/TenancyPlan.js +307 -0
- package/dist/systemResources.js +18 -2
- package/package.json +25 -22
- package/src/AppAsyncWrapper.tsx +0 -42
- package/src/AppWrapper.tsx +0 -45
- package/src/DASHAdmin.tsx +0 -502
- package/src/DASHAdmin.tsx.old +0 -456
- package/src/RoutingWrapper.tsx +0 -143
- package/src/classes/DASHStorageClass.tsx +0 -8
- package/src/components/Input/RichTextField.tsx +0 -27
- package/src/components/Redirect.tsx +0 -46
- package/src/components/avatar/Avatar.tsx +0 -71
- package/src/components/avatar/SingleImageUploader.tsx +0 -107
- package/src/components/currency/Format.tsx +0 -79
- package/src/components/custom/Redirect.tsx +0 -23
- package/src/components/error/Error.tsx +0 -168
- package/src/components/geocoding/GeocodingField.tsx +0 -167
- package/src/components/i18n/BridgedLocalesMenuButton.tsx +0 -160
- package/src/components/i18n/LangSwitcher.tsx +0 -204
- package/src/components/loader/GlobalLoader.tsx +0 -49
- package/src/components/logs/LogFile.tsx +0 -88
- package/src/components/logs/LogFileById.tsx +0 -68
- package/src/components/logs/LogViewer.tsx +0 -43
- package/src/components/menu/AppMenu.tsx +0 -22
- package/src/components/menu/CustomMenuItemLink.tsx +0 -61
- package/src/components/menu/DarkToggleMode.tsx +0 -65
- package/src/components/menu/LanguageToggleMode.tsx +0 -120
- package/src/components/misc/CustomImageInput.tsx +0 -62
- package/src/components/misc/DASHGlobalErrorHandler.tsx +0 -194
- package/src/components/misc/DarkModeSwitcher.tsx +0 -112
- package/src/components/misc/HorizontalScroller.tsx +0 -225
- package/src/components/misc/LanguageSwitcher.tsx +0 -199
- package/src/components/misc/MUIHtmlToolTip.tsx +0 -15
- package/src/components/misc/MuiSimpleJsonTable.tsx +0 -279
- package/src/components/misc/MultiLevelTable.tsx +0 -229
- package/src/components/misc/NoResults.tsx +0 -28
- package/src/components/misc/PDFViewer.tsx +0 -85
- package/src/components/navigation/Breadcrumbs.tsx +0 -220
- package/src/components/navigation/BreadcrumbsManager.tsx +0 -310
- package/src/components/navigation/index.tsx +0 -5
- package/src/components/panel/Error.tsx +0 -168
- package/src/components/permission/AvailablePermissionsContext.tsx +0 -173
- package/src/components/permission/PermissionsSelector.tsx +0 -834
- package/src/components/permission/PermissionsSelectorList.tsx +0 -473
- package/src/components/permission/tsx +0 -0
- package/src/components/racustombuttons/CustomRAButton.tsx +0 -87
- package/src/components/racustombuttons/QuickButton.tsx +0 -117
- package/src/components/racustombuttons/QuickEditButton.tsx +0 -115
- package/src/components/racustombuttons/QuickIconButton.tsx +0 -122
- package/src/components/scrollbar/Scrollbar.tsx +0 -31
- package/src/components/selects/MultiSelect.tsx +0 -53
- package/src/components/selects/RASearchableSelect.tsx +0 -282
- package/src/components/selects/RASearchableSelectChips.tsx +0 -308
- package/src/components/selects/SearchableSelect.tsx +0 -139
- package/src/components/serviceAccount/ApiKeyRevealDialog.tsx +0 -129
- package/src/components/serviceAccount/ServiceAccountStatusSwitch.tsx +0 -99
- package/src/components/subscription/BillingCycleSelectInput.tsx +0 -68
- package/src/components/subscription/PlanAddonsSettings.tsx +0 -563
- package/src/components/subscription/PlanAuditLog.tsx +0 -453
- package/src/components/subscription/PlanFeaturesSettings.tsx +0 -243
- package/src/components/subscription/PlanLimitsSettings.tsx +0 -230
- package/src/components/subscription/PlanMetadataSettings.tsx +0 -306
- package/src/components/subscription/PlanPricesSettings.tsx +0 -307
- package/src/components/subscription/index.ts +0 -7
- package/src/components/svgelements/SvgLoading.tsx +0 -229
- package/src/components/svgelements/SvgLogo.tsx +0 -53
- package/src/components/svgelements/SvgLogoMin.tsx +0 -64
- package/src/components/svgelements/SvgShipping.tsx +0 -673
- package/src/components/tenancy/GlobalTenantWrapper.tsx +0 -84
- package/src/components/tenancy/TenantSwitcher.tsx +0 -514
- package/src/components/tenant/AvailablePermissionsContext.tsx +0 -0
- package/src/components/tenant/SettingsSections.tsx +0 -151
- package/src/components/tenant/TenancySettings.tsx +0 -122
- package/src/components/tenant/TenantAttributes.tsx +0 -153
- package/src/components/tenant/TenantAttributesContext.tsx +0 -163
- package/src/components/tenant/TenantSelector.tsx +0 -142
- package/src/components/tenant/TenantSettings.tsx +0 -184
- package/src/components/tenant/TenantSettingsContext.tsx +0 -165
- package/src/components/tenant/TenantTheme.tsx +0 -172
- package/src/components/user/AvatarComponent.tsx +0 -317
- package/src/components/user/TenantAvatarComponent.tsx +0 -99
- package/src/components/user/UserPreferences.tsx +0 -677
- package/src/config/ACTIONS.tsx +0 -26
- package/src/config/ConstantsService.tsx +0 -44
- package/src/config/DASHAdminSystemConstants.tsx +0 -183
- package/src/config/PARSERS.tsx +0 -9
- package/src/contexts/DashQueryClientContext.tsx +0 -113
- package/src/contexts/DashResourceContext.tsx +0 -34
- package/src/contexts/I18nBridgeContext.tsx +0 -156
- package/src/contexts/I18nBridgeSetter.tsx +0 -39
- package/src/contexts/I18nReduxSync.tsx +0 -27
- package/src/contexts/SubscriptionPlanFormatsProvider.tsx +0 -217
- package/src/contexts/SystemRequestsCache.tsx +0 -215
- package/src/contexts/auth/AuthContext.tsx +0 -567
- package/src/contexts/auth/AuthContextLocalStorage.tsx +0 -140
- package/src/contexts/auth/DASHAuthenticationService.tsx +0 -915
- package/src/contexts/auth/WindowContext.tsx +0 -15
- package/src/contexts/auth/index.tsx +0 -3
- package/src/contexts/com/FCMContext.tsx +0 -415
- package/src/contexts/com/LaravelEchoContext.tsx +0 -41
- package/src/contexts/com/LaravelEchoMgr.tsx +0 -155
- package/src/contexts/com/components/DefaultNotificationComponent.tsx +0 -20
- package/src/contexts/com/components/EchoNotificationsCenter.tsx +0 -65
- package/src/contexts/com/components/NotificationAttributesTable.tsx +0 -54
- package/src/contexts/com/components/NotificationRenderer.tsx +0 -42
- package/src/contexts/com/components/NotificationsWidget.tsx +0 -182
- package/src/contexts/com/components/notificationFormats.tsx +0 -50
- package/src/contexts/com/useLaravelEcho.tsx +0 -432
- package/src/contexts/dictionary/DictionaryContext.tsx +0 -94
- package/src/declarations.d.ts +0 -17
- package/src/default-theme/DASHAppProviders.tsx +0 -117
- package/src/default-theme/DashThemeContext.tsx +0 -209
- package/src/default-theme/DashThemeContext.tsx.fast +0 -143
- package/src/default-theme/DashThemeContext.tsx.old +0 -306
- package/src/default-theme/DashThemeHelperProvider.tsx +0 -98
- package/src/default-theme/DomainAppLayout.tsx +0 -166
- package/src/default-theme/DomainHeader.tsx +0 -162
- package/src/default-theme/DomainTheme.tsx +0 -59
- package/src/default-theme/FullLayoutMarkup.tsx +0 -231
- package/src/default-theme/StaticLayout.tsx +0 -47
- package/src/default-theme/index.tsx +0 -11
- package/src/default-theme/menu/AppDashboardGrid.tsx +0 -279
- package/src/default-theme/menu/AppMaterialMenu.tsx +0 -546
- package/src/default-theme/menu/AppMenuComponents/SubmenuPortal.tsx +0 -61
- package/src/default-theme/menu/AppMenuComponents/collapsed/CollapsedSidebarItem.tsx +0 -264
- package/src/default-theme/menu/AppMenuComponents/collapsed/CollapsedSidebarItems.tsx +0 -31
- package/src/default-theme/menu/AppMenuComponents/expanded/CollapsableSidebarMenu.tsx +0 -293
- package/src/default-theme/menu/AppMenuComponents/expanded/SidebarItem.tsx +0 -92
- package/src/default-theme/menu/AppMenuComponents/getItem.tsx +0 -17
- package/src/default-theme/menu/AppMenuComponents/interfaces.tsx +0 -41
- package/src/default-theme/menu/AppMenuComponents/submenuConstants.ts +0 -90
- package/src/default-theme/menu/AppSidebarMaterial.tsx +0 -339
- package/src/default-theme/menu/SidebarActions.tsx +0 -84
- package/src/default-theme/updateDomCssVariables.tsx +0 -176
- package/src/helpers/checkRole.tsx +0 -66
- package/src/helpers/parseAxiosError.tsx +0 -41
- package/src/hooks/audio/useAudio.tsx +0 -39
- package/src/hooks/axios.tsx +0 -165
- package/src/hooks/data/useDashboardStats.tsx +0 -65
- package/src/hooks/data/usePackageByClientsStats.tsx +0 -44
- package/src/hooks/data/usePackageByCommunesStats.tsx +0 -44
- package/src/hooks/data/usePackageStats.tsx +0 -69
- package/src/hooks/data/usePackageWithdrawDetails.tsx +0 -61
- package/src/hooks/data/useStats.tsx +0 -86
- package/src/hooks/isCurrentPath.tsx +0 -22
- package/src/hooks/notifications/WSMessagesManager.tsx +0 -152
- package/src/hooks/notifications/WSPusherManager.tsx +0 -92
- package/src/hooks/useBreadcrumbs.tsx +0 -329
- package/src/hooks/useClickOutside.tsx +0 -57
- package/src/hooks/useFormPersistance.tsx +0 -150
- package/src/hooks/useGlobalErrorMediator.tsx +0 -43
- package/src/hooks/useGlobalLoaderMgr.tsx +0 -21
- package/src/hooks/useHash.tsx +0 -27
- package/src/hooks/useLocalStorage.tsx +0 -196
- package/src/hooks/usePolyglotTranslation.tsx +0 -62
- package/src/hooks/usePrevious.tsx +0 -9
- package/src/hooks/usePrintSelected.tsx +0 -37
- package/src/hooks/useVirtualHash.tsx +0 -33
- package/src/hooks/window/useWindowSize.tsx +0 -36
- package/src/index.tsx +0 -134
- package/src/interfaces/IAppResourceConfig.tsx +0 -20
- package/src/interfaces/Log.tsx +0 -16
- package/src/interfaces/Tenant.tsx +0 -25
- package/src/interfaces/communication/IActions.tsx +0 -5
- package/src/interfaces/communication/INotification.tsx +0 -21
- package/src/interfaces/communication/IPayload.tsx +0 -3
- package/src/interfaces/communication/IRequestAction.tsx +0 -10
- package/src/interfaces/communication/IRequestPayload.tsx +0 -7
- package/src/interfaces/communication/IResponseAction.tsx +0 -7
- package/src/interfaces/misc/IAny.tsx +0 -3
- package/src/interfaces/misc/IFlashMessage.tsx +0 -10
- package/src/interfaces/navigation/IAppMenu.ts +0 -14
- package/src/interfaces/navigation/ICollapsableSidebarMenu.ts +0 -12
- package/src/interfaces/navigation/IMenuItem.ts +0 -16
- package/src/interfaces/notifications/IModel.tsx +0 -6
- package/src/interfaces/notifications/IModelField.tsx +0 -8
- package/src/interfaces/notifications/IUserNotification.tsx +0 -12
- package/src/interfaces/notifications/IUserNotificationData.tsx +0 -13
- package/src/interfaces/notifications/IUserNotificationPayload.tsx +0 -8
- package/src/interfaces/user/IGetAuth.tsx +0 -92
- package/src/interfaces/user/ITenantSettings.tsx +0 -3
- package/src/interfaces/user/IUser.tsx +0 -60
- package/src/interfaces/user/IUserSettings.tsx +0 -43
- package/src/interfaces.tsx +0 -6
- package/src/layout/AppLayout.tsx +0 -112
- package/src/layout/ApplicationLayout.tsx +0 -197
- package/src/layout/MotionWrapper.original.tsx +0 -236
- package/src/layout/MotionWrapper.tsx +0 -236
- package/src/layout/ResourceMenu.tsx +0 -164
- package/src/layout/ResoureLayout.tsx +0 -105
- package/src/layout/TransitionWrapper.tsx +0 -125
- package/src/pages/ChangePassword.tsx +0 -179
- package/src/pages/DASHLanding.tsx +0 -22
- package/src/pages/DASHLightWeightLogin.tsx +0 -611
- package/src/pages/DASHSimpleLogin.tsx +0 -260
- package/src/pages/Login.tsx +0 -111
- package/src/pages/Profile.tsx +0 -357
- package/src/pages/RecoverPassword.tsx +0 -175
- package/src/pages/SingleImageUploader.tsx +0 -55
- package/src/pages/VerifyAccount.tsx +0 -128
- package/src/providers/authProvider.tsx +0 -217
- package/src/providers/dataProvider.tsx +0 -672
- package/src/providers/i18n/en.ts +0 -646
- package/src/providers/i18n/es.ts +0 -652
- package/src/providers/i18n/languages.tsx +0 -8
- package/src/providers/i18n/mergeTranslations.ts +0 -53
- package/src/providers/i18nProvider.tsx +0 -23
- package/src/react-admin-dash/RADashComponent.tsx +0 -240
- package/src/react-admin-dash/Resource.tsx +0 -77
- package/src/resources/Brand/BrandResource.tsx +0 -130
- package/src/resources/DASHResourceLoader.ts +0 -180
- package/src/resources/Log/LogResource.tsx +0 -73
- package/src/resources/Tenant/ImpersonateTenantResource.tsx +0 -113
- package/src/resources/Trash/TrashTemplate.tsx +0 -180
- package/src/resources/User/components/AvatarUploadField.tsx +0 -57
- package/src/resources/User/components/PasswordFields.tsx +0 -73
- package/src/resources/User/getProfileMenu.ts +0 -57
- package/src/resources/User/profileResource.tsx +0 -51
- package/src/resources/User/userLayout.tsx +0 -62
- package/src/resources/User/userResource.tsx +0 -111
- package/src/resources/User/userSchema.tsx +0 -213
- package/src/resources/User/usersFilters.tsx +0 -21
- package/src/resources.tsx +0 -280
- package/src/schemas/log.tsx +0 -45
- package/src/schemas/notification.tsx +0 -42
- package/src/schemas/permissions.tsx +0 -44
- package/src/schemas/roles.tsx +0 -48
- package/src/schemas/rolesDataGrid.tsx +0 -48
- package/src/schemas/subscription/components/SubscriptionActions.tsx +0 -153
- package/src/schemas/subscription/components/SubscriptionPaymentHistory.tsx +0 -127
- package/src/schemas/subscription/components/SubscriptionPlanFeatures.tsx +0 -162
- package/src/schemas/subscription/components/SubscriptionPlanPreview.tsx +0 -141
- package/src/schemas/subscription/components/SubscriptionPlanStats.tsx +0 -318
- package/src/schemas/subscription/components/SubscriptionStatusIndicator.tsx +0 -72
- package/src/schemas/subscription/subscriptionPlanSchema.tsx +0 -185
- package/src/schemas/subscription/subscriptionSchema.tsx +0 -152
- package/src/schemas/subscriptionPlan.ts +0 -422
- package/src/schemas/tenant.tsx +0 -129
- package/src/schemas/tenantUser.tsx +0 -96
- package/src/schemas/tenant_superadmin.tsx +0 -119
- package/src/schemas/user.tsx +0 -26
- package/src/systemResources.old.tsx +0 -928
- package/src/systemResources.tsx +0 -1369
- package/src/templates/ResourceTemplate.tsx +0 -240
- package/src/templates/ResourceTemplate.tsx.memoized_experiment +0 -350
- package/src/templates/ResourceTemplate.tsx.original +0 -396
- package/src/templates/ResourceTemplateCreate.tsx +0 -182
- package/src/templates/ResourceTemplateEdit.tsx +0 -176
- package/src/templates/ResourceTemplateFull.tsx +0 -581
- package/src/templates/ResourceTemplateList.tsx +0 -340
- package/src/templates/ResourceTemplateOld.tsx.bkup +0 -567
- package/src/templates/ResourceTemplateShow.tsx +0 -88
- package/src/templates/TrashTemplate.tsx +0 -179
- package/src/tenantResources.tsx +0 -223
- package/src/test_portal_bubbles.tsx +0 -40
- package/src/theme/AppHeader.tsx +0 -52
- package/src/theme/AppLayoutSetting.tsx +0 -33
- package/src/theme/AppLogo.tsx +0 -13
- package/src/theme/AppSidebar.tsx +0 -12
- package/src/theme/AppSidebarContent.tsx +0 -105
- package/src/theme/AppSidebarLogo.tsx +0 -48
- package/src/theme/components/PageTitle.tsx +0 -37
- package/src/utils/cache/CacheInvalidatorContext.tsx +0 -125
- package/src/utils/cache/CacheInvalidatorListenerComponent.tsx +0 -10
- package/src/utils/cache/useCacheInvalidatorListener.tsx +0 -27
- package/src/utils/convertFileToBase64.tsx +0 -9
- package/src/utils/convertToFile.tsx +0 -14
- package/src/utils/cookies.tsx +0 -33
- package/src/utils/dashDefaultQueryClient.tsx +0 -34
- package/src/utils/dataUrlToBlob.tsx +0 -30
- package/src/utils/deepReplace.tsx +0 -19
- package/src/utils/getProfileMenu.tsx +0 -41
- package/src/utils/getTenantSettings.tsx +0 -9
- package/src/utils/getType.tsx +0 -8
- package/src/utils/getUserSettings.tsx +0 -8
- package/src/utils/hasCode.tsx +0 -14
- package/src/utils/index.ts +0 -19
- package/src/utils/injectTenantStyles.ts +0 -28
- package/src/utils/isComponent.tsx +0 -45
- package/src/utils/navEvents.tsx +0 -91
- package/src/utils/prototypes.tsx +0 -5
- package/src/utils/regexp.tsx +0 -4
- package/src/utils/resolveObjectPath.tsx +0 -4
- package/src/utils/setNativeValue.tsx +0 -24
- package/src/utils/slugify.tsx +0 -11
- package/src/utils/validators/emailValidator.tsx +0 -6
- package/src/utils/validators/requiredValidator.tsx +0 -5
- package/src/utils/validators/rutValidator.tsx +0 -31
- package/src/utils/validators.tsx +0 -96
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { FC, PropsWithChildren, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { IMenuItem } from '../interfaces';
|
|
3
|
-
import {
|
|
4
|
-
ListItemButton,
|
|
5
|
-
ListItemButtonProps,
|
|
6
|
-
ListItemIcon,
|
|
7
|
-
ListItemText,
|
|
8
|
-
} from '@mui/material';
|
|
9
|
-
import { useLocation, useNavigate } from 'react-router';
|
|
10
|
-
import { IPageState, DASH_REDUX_ACTIONS } from 'dash-admin-state';
|
|
11
|
-
import { useDispatch } from 'react-redux';
|
|
12
|
-
import isCurrentPath from '../../../../hooks/isCurrentPath';
|
|
13
|
-
import { NavEventManager } from '../../../../utils/navEvents';
|
|
14
|
-
import useClickOutside from '../../../../hooks/useClickOutside';
|
|
15
|
-
import { SidebarPosition } from '../../AppSidebarMaterial';
|
|
16
|
-
import { FORCE_CLICK_OPEN, SUBMENU_SCROLL_THRESHOLD } from '../submenuConstants';
|
|
17
|
-
import SubmenuPortal from '../SubmenuPortal';
|
|
18
|
-
|
|
19
|
-
export interface ICollapsedSidebarItem {
|
|
20
|
-
item: IMenuItem;
|
|
21
|
-
navSize: 'large' | 'small';
|
|
22
|
-
navExpanded: boolean;
|
|
23
|
-
level: number;
|
|
24
|
-
sidebarPosition?: SidebarPosition;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface ISidebarItem extends ListItemButtonProps, PropsWithChildren {
|
|
28
|
-
item: IMenuItem;
|
|
29
|
-
showIcon?: boolean;
|
|
30
|
-
showText?: boolean;
|
|
31
|
-
navExpanded?: boolean;
|
|
32
|
-
navSize: 'large' | 'small';
|
|
33
|
-
level: number,
|
|
34
|
-
hasChildren?: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const SidebarItem: FC<ISidebarItem> = (props) => {
|
|
38
|
-
const {
|
|
39
|
-
item,
|
|
40
|
-
showIcon = true,
|
|
41
|
-
showText = true,
|
|
42
|
-
children,
|
|
43
|
-
navExpanded,
|
|
44
|
-
navSize,
|
|
45
|
-
level,
|
|
46
|
-
hasChildren = false,
|
|
47
|
-
onClick,
|
|
48
|
-
...rest
|
|
49
|
-
} = props;
|
|
50
|
-
|
|
51
|
-
const loc = useLocation();
|
|
52
|
-
|
|
53
|
-
const [isCurrent, setCurrent] = useState(isCurrentPath(loc.pathname, item));
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
setCurrent(isCurrentPath(loc.pathname, item));
|
|
57
|
-
}, [loc]);
|
|
58
|
-
|
|
59
|
-
const navigate = useNavigate();
|
|
60
|
-
|
|
61
|
-
const dispatch = useDispatch();
|
|
62
|
-
|
|
63
|
-
const updatePageState = () => {
|
|
64
|
-
const newPageState: IPageState = {
|
|
65
|
-
title: item?.label,
|
|
66
|
-
icon: item?.icon,
|
|
67
|
-
subTitle: item?.group,
|
|
68
|
-
};
|
|
69
|
-
dispatch(DASH_REDUX_ACTIONS.updatePage(newPageState));
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<ListItemButton
|
|
74
|
-
{...rest}
|
|
75
|
-
selected={isCurrent}
|
|
76
|
-
onClick={(e) => {
|
|
77
|
-
|
|
78
|
-
if(onClick) {
|
|
79
|
-
|
|
80
|
-
onClick(e);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
//e.preventDefault();
|
|
84
|
-
e.stopPropagation();
|
|
85
|
-
//if ((e.target as any)?.localName === 'svg') return;
|
|
86
|
-
|
|
87
|
-
if (!hasChildren) {
|
|
88
|
-
if (!isCurrentPath(loc.pathname, item)) {
|
|
89
|
-
updatePageState();
|
|
90
|
-
navigate(item.to);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
98
|
-
{showIcon && <ListItemIcon>{item.icon && item.icon}</ListItemIcon>}
|
|
99
|
-
{(showText && level > 0) && (
|
|
100
|
-
<ListItemText>{item.label}</ListItemText>
|
|
101
|
-
)}
|
|
102
|
-
{children}
|
|
103
|
-
</ListItemButton>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const CollapsedSidebarItem = ({
|
|
108
|
-
item,
|
|
109
|
-
navSize,
|
|
110
|
-
navExpanded,
|
|
111
|
-
level,
|
|
112
|
-
sidebarPosition = "left"
|
|
113
|
-
}: ICollapsedSidebarItem) => {
|
|
114
|
-
const hovering = useRef<boolean>(false);
|
|
115
|
-
const timeoutDuration = 20;
|
|
116
|
-
let timeout;
|
|
117
|
-
const [webView, setWebView] = useState<boolean>(false);
|
|
118
|
-
const [open, setOpen] = useState(false);
|
|
119
|
-
const itemRef = useRef<HTMLDivElement>(null);
|
|
120
|
-
const menuRef = useRef<HTMLDivElement>(null);
|
|
121
|
-
|
|
122
|
-
// Unique key for this submenu to identify it in accordion behavior
|
|
123
|
-
const submenuKey = `collapsed-${item.key || item.label}`;
|
|
124
|
-
|
|
125
|
-
// Close on click/tap outside the trigger AND the portal-rendered flyout
|
|
126
|
-
// (the flyout isn't a DOM descendant of itemRef since it's portaled to
|
|
127
|
-
// document.body — see SubmenuPortal). Hover mode already self-closes via
|
|
128
|
-
// onMouseLeave, but that never fires in webview/FORCE_CLICK_OPEN click
|
|
129
|
-
// mode, which previously had no way to dismiss an open flyout other than
|
|
130
|
-
// clicking the trigger again or opening a different submenu.
|
|
131
|
-
useClickOutside([itemRef, menuRef], () => setOpen(false), open);
|
|
132
|
-
|
|
133
|
-
const openMenuOnHover = (event) => {
|
|
134
|
-
// Notify other submenus to close (accordion behavior)
|
|
135
|
-
NavEventManager.notifySubmenuOpened(submenuKey);
|
|
136
|
-
setOpen(true);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const openMenuOnClick = (event) => {
|
|
140
|
-
if (!open) {
|
|
141
|
-
// Notify other submenus to close (accordion behavior)
|
|
142
|
-
NavEventManager.notifySubmenuOpened(submenuKey);
|
|
143
|
-
}
|
|
144
|
-
setOpen(prevOpen => !prevOpen);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const closeMenu = (event) => {
|
|
148
|
-
if (!webView) {
|
|
149
|
-
setOpen(false);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
if (document.body.classList.contains('webview')) {
|
|
155
|
-
setWebView(true)
|
|
156
|
-
} else {
|
|
157
|
-
setWebView(false)
|
|
158
|
-
}
|
|
159
|
-
}, []);
|
|
160
|
-
|
|
161
|
-
// Listen for other submenus opening and close this one (accordion behavior)
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
const unsubscribeSubmenuOpened = NavEventManager.onSubmenuOpened((openedKey) => {
|
|
164
|
-
// Close this submenu if a different one was opened
|
|
165
|
-
if (openedKey !== submenuKey && open) {
|
|
166
|
-
setOpen(false);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const unsubscribeCloseAll = NavEventManager.onCloseAllSubmenus(() => {
|
|
171
|
-
setOpen(false);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
return () => {
|
|
175
|
-
unsubscribeSubmenuOpened();
|
|
176
|
-
unsubscribeCloseAll();
|
|
177
|
-
};
|
|
178
|
-
}, [submenuKey, open]);
|
|
179
|
-
|
|
180
|
-
const hasChildren = item.children && item.children.length > 0;
|
|
181
|
-
|
|
182
|
-
// Helper to close submenu after item click - navigation is handled by SidebarItem
|
|
183
|
-
const handleSubmenuItemClick = (e, childItem) => {
|
|
184
|
-
// Close the dropdown menu after a short delay to allow navigation to complete
|
|
185
|
-
setTimeout(() => {
|
|
186
|
-
setOpen(false);
|
|
187
|
-
// Close the drawer on mobile
|
|
188
|
-
NavEventManager.closeDrawer();
|
|
189
|
-
}, 100);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
return hasChildren ? (
|
|
193
|
-
<>
|
|
194
|
-
<div ref={itemRef}>
|
|
195
|
-
<SidebarItem
|
|
196
|
-
aria-owns={open ? 'menu-' + item.key : undefined}
|
|
197
|
-
aria-haspopup='true'
|
|
198
|
-
onMouseEnter={!webView && !FORCE_CLICK_OPEN ? openMenuOnHover : null}
|
|
199
|
-
onMouseLeave={!FORCE_CLICK_OPEN ? closeMenu : null}
|
|
200
|
-
onClick={webView || FORCE_CLICK_OPEN ? openMenuOnClick : null}
|
|
201
|
-
item={item}
|
|
202
|
-
showText={false}
|
|
203
|
-
navSize={navSize}
|
|
204
|
-
navExpanded={navExpanded}
|
|
205
|
-
level={level}
|
|
206
|
-
hasChildren={hasChildren}
|
|
207
|
-
>
|
|
208
|
-
<SubmenuPortal
|
|
209
|
-
open={open}
|
|
210
|
-
itemRef={itemRef}
|
|
211
|
-
contentRef={menuRef}
|
|
212
|
-
sidebarPosition={sidebarPosition}
|
|
213
|
-
childrenCount={item.children?.length || 0}
|
|
214
|
-
className="sidebar-collapsed-menu"
|
|
215
|
-
>
|
|
216
|
-
<ul
|
|
217
|
-
id={'menu-' + item.key}
|
|
218
|
-
key={'menu-' + item.key}
|
|
219
|
-
className={`dropdown ${open ? 'show' : ''}`}
|
|
220
|
-
style={{
|
|
221
|
-
margin: 0,
|
|
222
|
-
padding: 0,
|
|
223
|
-
listStyle: 'none',
|
|
224
|
-
}}
|
|
225
|
-
>
|
|
226
|
-
{item.children?.map((item, index) => {
|
|
227
|
-
return (
|
|
228
|
-
<SidebarItem
|
|
229
|
-
navSize={navSize}
|
|
230
|
-
navExpanded={navExpanded}
|
|
231
|
-
level={level + 1}
|
|
232
|
-
item={item}
|
|
233
|
-
key={index}
|
|
234
|
-
hasChildren={item.children && item.children.length > 0}
|
|
235
|
-
onClick={(e) => handleSubmenuItemClick(e, item)}
|
|
236
|
-
onTouchStart={(e) => e.stopPropagation()}
|
|
237
|
-
/>
|
|
238
|
-
);
|
|
239
|
-
})}
|
|
240
|
-
</ul>
|
|
241
|
-
</SubmenuPortal>
|
|
242
|
-
</SidebarItem>
|
|
243
|
-
</div>
|
|
244
|
-
</>
|
|
245
|
-
) : (
|
|
246
|
-
<SidebarItem
|
|
247
|
-
item={item}
|
|
248
|
-
navSize={navSize}
|
|
249
|
-
navExpanded={navExpanded}
|
|
250
|
-
level={level}
|
|
251
|
-
hasChildren={false}
|
|
252
|
-
onClick={() => {
|
|
253
|
-
// Close all other submenus first
|
|
254
|
-
NavEventManager.closeAllSubmenus();
|
|
255
|
-
// Close drawer when clicking primary level item without children
|
|
256
|
-
setTimeout(() => {
|
|
257
|
-
NavEventManager.closeDrawer();
|
|
258
|
-
}, 100);
|
|
259
|
-
}}
|
|
260
|
-
/>
|
|
261
|
-
);
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
export default CollapsedSidebarItem;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { List } from '@mui/material';
|
|
2
|
-
import { IMenuItem } from '../interfaces';
|
|
3
|
-
import CollapsedSidebarItem from './CollapsedSidebarItem';
|
|
4
|
-
import { SidebarPosition } from '../../AppSidebarMaterial';
|
|
5
|
-
|
|
6
|
-
export interface ICollapsedSidebarItems {
|
|
7
|
-
items: IMenuItem[];
|
|
8
|
-
navSize: 'large' | 'small';
|
|
9
|
-
navExpanded: boolean;
|
|
10
|
-
level: number;
|
|
11
|
-
sidebarPosition?: SidebarPosition;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const CollapsedSidebarItems: React.FC<ICollapsedSidebarItems> = ({ items, navSize, navExpanded, level, sidebarPosition = "left" }) => {
|
|
15
|
-
return (
|
|
16
|
-
<List className={'sidebar-list sidebar-collapsed-menu'} component='nav'>
|
|
17
|
-
{items.map((item, index) => {
|
|
18
|
-
return <CollapsedSidebarItem
|
|
19
|
-
level={level}
|
|
20
|
-
item={item}
|
|
21
|
-
key={index}
|
|
22
|
-
navSize={navSize}
|
|
23
|
-
navExpanded={navExpanded}
|
|
24
|
-
sidebarPosition={sidebarPosition}
|
|
25
|
-
/>
|
|
26
|
-
})}
|
|
27
|
-
</List>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export default CollapsedSidebarItems;
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import { ICollapsableSidebarMenu } from '../interfaces';
|
|
2
|
-
import { useDispatch } from 'react-redux';
|
|
3
|
-
import { memo, useEffect, useState, useRef } from 'react';
|
|
4
|
-
import isCurrentPath from '../../../../hooks/isCurrentPath';
|
|
5
|
-
import { useLocation, useNavigate } from 'react-router';
|
|
6
|
-
import {
|
|
7
|
-
Collapse,
|
|
8
|
-
List,
|
|
9
|
-
ListItemButton,
|
|
10
|
-
ListItemIcon,
|
|
11
|
-
ListItemText,
|
|
12
|
-
Typography,
|
|
13
|
-
} from '@mui/material';
|
|
14
|
-
import ExpandLessOutlinedIcon from '@mui/icons-material/ExpandLessOutlined';
|
|
15
|
-
import ExpandMoreOutlinedIcon from '@mui/icons-material/ExpandMoreOutlined';
|
|
16
|
-
import SidebarItem from './SidebarItem';
|
|
17
|
-
|
|
18
|
-
/** @ts-ignore */
|
|
19
|
-
//import clickSound from '@app/assets/sounds/click2.mp3?string';
|
|
20
|
-
import { IPageState, DASH_REDUX_ACTIONS } from 'dash-admin-state';
|
|
21
|
-
import {DASHAppConstants} from 'dash-constants';
|
|
22
|
-
import { NavEventManager } from '../../../../utils/navEvents';
|
|
23
|
-
import { FORCE_CLICK_OPEN } from '../submenuConstants';
|
|
24
|
-
import SubmenuPortal from '../SubmenuPortal';
|
|
25
|
-
import useClickOutside from '../../../../hooks/useClickOutside';
|
|
26
|
-
|
|
27
|
-
const CollapsableSidebarMenu = ({
|
|
28
|
-
item,
|
|
29
|
-
navExpanded,
|
|
30
|
-
navSize,
|
|
31
|
-
level,
|
|
32
|
-
sidebarPosition = "left"
|
|
33
|
-
}: ICollapsableSidebarMenu) => {
|
|
34
|
-
const loc = useLocation();
|
|
35
|
-
const dispatch = useDispatch();
|
|
36
|
-
const itemRef = useRef<HTMLDivElement>(null);
|
|
37
|
-
const menuRef = useRef<HTMLDivElement>(null);
|
|
38
|
-
const isHorizontal = sidebarPosition === "top" || sidebarPosition === "bottom";
|
|
39
|
-
|
|
40
|
-
// Detect if running in mobile webview or android
|
|
41
|
-
const [webView, setWebView] = useState<boolean>(false);
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (document.body.classList.contains('webview') || document.body.classList.contains('android')) {
|
|
45
|
-
setWebView(true);
|
|
46
|
-
} else {
|
|
47
|
-
setWebView(false);
|
|
48
|
-
}
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
const [isCurrent, setCurrent] = useState(isCurrentPath(loc.pathname, item));
|
|
52
|
-
|
|
53
|
-
const [localOpen, setLocalOpen] = useState<boolean>(
|
|
54
|
-
isCurrentPath(loc.pathname, item),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
// Generate a unique key for this submenu
|
|
58
|
-
const submenuKey = `${item.group}-${item.key}`;
|
|
59
|
-
|
|
60
|
-
/* This hook is to open the menu on load only, memo state will not rerender this twice */
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
setLocalOpen(isCurrentPath(loc.pathname, item));
|
|
63
|
-
}, []);
|
|
64
|
-
|
|
65
|
-
// Listen for other submenus opening (accordion behavior)
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
const unsubscribe = NavEventManager.onSubmenuOpened((openedKey: string) => {
|
|
68
|
-
// If another submenu opened (not this one), close this one
|
|
69
|
-
if (openedKey !== submenuKey) {
|
|
70
|
-
setLocalOpen(false);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Also listen for close all submenus event
|
|
75
|
-
const unsubscribeCloseAll = NavEventManager.onCloseAllSubmenus(() => {
|
|
76
|
-
setLocalOpen(false);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return () => {
|
|
80
|
-
unsubscribe();
|
|
81
|
-
unsubscribeCloseAll();
|
|
82
|
-
};
|
|
83
|
-
}, [submenuKey, navSize]);
|
|
84
|
-
|
|
85
|
-
// Close on click/tap outside the trigger AND the portal-rendered dropdown
|
|
86
|
-
// (only relevant to the horizontal top/bottom layout, which portals its
|
|
87
|
-
// dropdown to document.body via SubmenuPortal — see contentRef below; the
|
|
88
|
-
// dropdown is not a DOM descendant of itemRef). The vertical Collapse
|
|
89
|
-
// variant is rendered inline in the sidebar tree, so it doesn't need this.
|
|
90
|
-
// Desktop hover already self-closes via handleMouseLeave, but that's
|
|
91
|
-
// disabled in webview/FORCE_CLICK_OPEN click mode, which previously had
|
|
92
|
-
// no way to dismiss an open dropdown other than the accordion behavior.
|
|
93
|
-
useClickOutside([itemRef, menuRef], () => setLocalOpen(false), isHorizontal && localOpen);
|
|
94
|
-
|
|
95
|
-
const navigate = useNavigate();
|
|
96
|
-
|
|
97
|
-
const playClick = () => {
|
|
98
|
-
if (!!DASHAppConstants.system.UI_SOUNDS) {
|
|
99
|
-
// const audio = new Audio(clickSound);
|
|
100
|
-
// audio.load();
|
|
101
|
-
// audio.play();
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const updatePageState = () => {
|
|
106
|
-
const newPageState: IPageState = {
|
|
107
|
-
title: item?.label,
|
|
108
|
-
icon: item?.icon,
|
|
109
|
-
subTitle: item?.group,
|
|
110
|
-
};
|
|
111
|
-
dispatch(DASH_REDUX_ACTIONS.updatePage(newPageState));
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// Handle expand/collapse icon click
|
|
115
|
-
const handleExpandClick = (e: React.MouseEvent) => {
|
|
116
|
-
e.stopPropagation();
|
|
117
|
-
playClick();
|
|
118
|
-
const newState = !localOpen;
|
|
119
|
-
setLocalOpen(newState);
|
|
120
|
-
|
|
121
|
-
// Notify other submenus to close (accordion behavior)
|
|
122
|
-
if (newState) {
|
|
123
|
-
NavEventManager.notifySubmenuOpened(submenuKey);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
// Handle opening submenu - notify others to close (for click mode)
|
|
128
|
-
const handleOpenSubmenu = () => {
|
|
129
|
-
const newState = !localOpen;
|
|
130
|
-
setLocalOpen(newState);
|
|
131
|
-
|
|
132
|
-
// Notify other submenus to close (accordion behavior)
|
|
133
|
-
if (newState) {
|
|
134
|
-
NavEventManager.notifySubmenuOpened(submenuKey);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
// Hover handlers for horizontal mode (desktop only)
|
|
139
|
-
const handleMouseEnter = () => {
|
|
140
|
-
if (isHorizontal && !webView && !FORCE_CLICK_OPEN) {
|
|
141
|
-
NavEventManager.notifySubmenuOpened(submenuKey);
|
|
142
|
-
setLocalOpen(true);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const handleMouseLeave = () => {
|
|
147
|
-
if (isHorizontal && !webView && !FORCE_CLICK_OPEN) {
|
|
148
|
-
setLocalOpen(false);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
// Calculate dropdown position based on sidebar position
|
|
153
|
-
const getDropdownPosition = () => {
|
|
154
|
-
if (!itemRef.current) return {};
|
|
155
|
-
const rect = itemRef.current.getBoundingClientRect();
|
|
156
|
-
|
|
157
|
-
switch (sidebarPosition) {
|
|
158
|
-
case "top":
|
|
159
|
-
return { top: rect.bottom + 10, left: rect.left };
|
|
160
|
-
case "bottom":
|
|
161
|
-
return { bottom: window.innerHeight - rect.top + 4, left: rect.left };
|
|
162
|
-
case "right":
|
|
163
|
-
// For right sidebar, submenu opens to the left of the menu item
|
|
164
|
-
return { top: rect.top, right: window.innerWidth - rect.left + 4 };
|
|
165
|
-
case "left":
|
|
166
|
-
default:
|
|
167
|
-
// For left sidebar, submenu opens to the right of the menu item
|
|
168
|
-
return { top: rect.top, left: rect.right + 4 };
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// Submenu content - shared between portal and inline rendering
|
|
173
|
-
const submenuContent = (
|
|
174
|
-
<List className={'sidebar-list-sub'} disablePadding>
|
|
175
|
-
{item.children?.map((childItem, index) =>
|
|
176
|
-
childItem ? (
|
|
177
|
-
childItem.children ? (
|
|
178
|
-
<CollapsableSidebarMenu
|
|
179
|
-
navExpanded={navExpanded}
|
|
180
|
-
navSize={navSize}
|
|
181
|
-
item={childItem}
|
|
182
|
-
key={index}
|
|
183
|
-
level={level + 1}
|
|
184
|
-
sidebarPosition={sidebarPosition}
|
|
185
|
-
/>
|
|
186
|
-
) : (
|
|
187
|
-
<SidebarItem
|
|
188
|
-
level={level}
|
|
189
|
-
navExpanded={navExpanded}
|
|
190
|
-
navSize={navSize}
|
|
191
|
-
showIcon={false}
|
|
192
|
-
item={childItem}
|
|
193
|
-
key={index}
|
|
194
|
-
/>
|
|
195
|
-
)
|
|
196
|
-
) : null,
|
|
197
|
-
)}
|
|
198
|
-
</List>
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
return (
|
|
202
|
-
<>
|
|
203
|
-
<div
|
|
204
|
-
ref={itemRef}
|
|
205
|
-
style={{ display: isHorizontal ? 'inline-flex' : 'block' }}
|
|
206
|
-
onMouseEnter={handleMouseEnter}
|
|
207
|
-
onMouseLeave={handleMouseLeave}
|
|
208
|
-
>
|
|
209
|
-
<ListItemButton
|
|
210
|
-
selected={localOpen}
|
|
211
|
-
className={'sidebar-list-menu-item'}
|
|
212
|
-
sx={isHorizontal ? {
|
|
213
|
-
flexShrink: 0,
|
|
214
|
-
whiteSpace: 'nowrap',
|
|
215
|
-
paddingX: 2,
|
|
216
|
-
} : undefined}
|
|
217
|
-
onClick={(e) => {
|
|
218
|
-
// Only handle click if it's not on the expand icon
|
|
219
|
-
if (!(e.target as HTMLElement).closest('.expand-icon')) {
|
|
220
|
-
playClick();
|
|
221
|
-
// For horizontal mode, only handle click on mobile/webview/FORCE_CLICK_OPEN (desktop uses hover)
|
|
222
|
-
if (!isHorizontal || webView || FORCE_CLICK_OPEN) {
|
|
223
|
-
handleOpenSubmenu();
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (!isCurrentPath(loc.pathname, item)) {
|
|
227
|
-
updatePageState();
|
|
228
|
-
navigate(item.to || item.model);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}}
|
|
232
|
-
>
|
|
233
|
-
<ListItemIcon>{item.icon && item.icon}</ListItemIcon>
|
|
234
|
-
{/* Este es el submenu con la barra lateral expandida */}
|
|
235
|
-
{navExpanded && (
|
|
236
|
-
<ListItemText
|
|
237
|
-
disableTypography
|
|
238
|
-
primary={<Typography>{item.label}</Typography>}
|
|
239
|
-
/>
|
|
240
|
-
)}
|
|
241
|
-
{navExpanded && (
|
|
242
|
-
// "expand-icon" is ALSO on the wrapper (not just the inner svg): the row's
|
|
243
|
-
// onClick above does closest('.expand-icon') to tell "clicked the arrow"
|
|
244
|
-
// from "clicked the row" — if only the svg had it, clicking the circle's
|
|
245
|
-
// padding (outside the svg's own box) would miss the check and navigate.
|
|
246
|
-
(<div className="expand-icon expand-icon-wrapper" onClick={handleExpandClick}>
|
|
247
|
-
{/* For bottom position, invert icons since submenu opens upward */}
|
|
248
|
-
{sidebarPosition === "bottom" ? (
|
|
249
|
-
localOpen ?
|
|
250
|
-
<ExpandMoreOutlinedIcon className='expand-icon more' /> :
|
|
251
|
-
<ExpandLessOutlinedIcon className='expand-icon less' />
|
|
252
|
-
) : (
|
|
253
|
-
localOpen ?
|
|
254
|
-
<ExpandLessOutlinedIcon className='expand-icon less' /> :
|
|
255
|
-
<ExpandMoreOutlinedIcon className='expand-icon more' />
|
|
256
|
-
)}
|
|
257
|
-
</div>)
|
|
258
|
-
)}
|
|
259
|
-
</ListItemButton>
|
|
260
|
-
</div>
|
|
261
|
-
|
|
262
|
-
{/* Portal submenu for all positions */}
|
|
263
|
-
{/* Vertical mode (Left/Right) - Inline Expansion using Collapse */}
|
|
264
|
-
{!isHorizontal && (
|
|
265
|
-
<Collapse in={localOpen} timeout="auto" unmountOnExit>
|
|
266
|
-
{submenuContent}
|
|
267
|
-
</Collapse>
|
|
268
|
-
)}
|
|
269
|
-
|
|
270
|
-
{/* Horizontal mode (Top/Bottom) - Portal Dropdown */}
|
|
271
|
-
{isHorizontal && (
|
|
272
|
-
<SubmenuPortal
|
|
273
|
-
open={navExpanded && localOpen}
|
|
274
|
-
itemRef={itemRef}
|
|
275
|
-
contentRef={menuRef}
|
|
276
|
-
sidebarPosition={sidebarPosition}
|
|
277
|
-
childrenCount={item.children?.length || 0}
|
|
278
|
-
className="sidebar-submenu-portal"
|
|
279
|
-
onMouseEnter={() => !webView && !FORCE_CLICK_OPEN && setLocalOpen(true)}
|
|
280
|
-
onMouseLeave={() => !webView && !FORCE_CLICK_OPEN && setLocalOpen(false)}
|
|
281
|
-
>
|
|
282
|
-
{submenuContent}
|
|
283
|
-
</SubmenuPortal>
|
|
284
|
-
)}
|
|
285
|
-
</>
|
|
286
|
-
);
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
const MemoizedCollapsableSidebarMenu = memo(CollapsableSidebarMenu, (prev, next) => {
|
|
290
|
-
return prev === next;
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
export default MemoizedCollapsableSidebarMenu as typeof CollapsableSidebarMenu;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { ICollapsableSidebarMenu } from '../interfaces';
|
|
2
|
-
import { ListItemButton, ListItemIcon, ListItemText } from '@mui/material';
|
|
3
|
-
import Circle from '@mui/icons-material/Circle';
|
|
4
|
-
import { useLocation, useNavigate } from 'react-router';
|
|
5
|
-
|
|
6
|
-
import { useDispatch } from 'react-redux';
|
|
7
|
-
|
|
8
|
-
import { useEffect, useState } from 'react';
|
|
9
|
-
|
|
10
|
-
/** @ts-ignore */
|
|
11
|
-
//import clickSound from '@app/assets/sounds/click2.mp3?string';
|
|
12
|
-
/** @ts-ignore */
|
|
13
|
-
//import bubbleSound from '@app/assets/sounds/bubble.mp3?string';
|
|
14
|
-
import { IPageState, DASH_REDUX_ACTIONS } from 'dash-admin-state';
|
|
15
|
-
import {DASHAppConstants} from 'dash-constants';
|
|
16
|
-
import isCurrentPath from '../../../../hooks/isCurrentPath';
|
|
17
|
-
import { NavEventManager } from '../../../../utils/navEvents';
|
|
18
|
-
|
|
19
|
-
const SidebarItem = ({
|
|
20
|
-
item,
|
|
21
|
-
navExpanded,
|
|
22
|
-
navSize,
|
|
23
|
-
level,
|
|
24
|
-
className,
|
|
25
|
-
showIcon = true,
|
|
26
|
-
}: ICollapsableSidebarMenu) => {
|
|
27
|
-
const navigate = useNavigate();
|
|
28
|
-
const DefaultIcon = <Circle />;
|
|
29
|
-
|
|
30
|
-
const loc = useLocation();
|
|
31
|
-
|
|
32
|
-
const [isCurrent, setCurrent] = useState(isCurrentPath(loc.pathname, item));
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
setCurrent(isCurrentPath(loc.pathname, item));
|
|
36
|
-
}, [loc]);
|
|
37
|
-
|
|
38
|
-
const playClick = () => {
|
|
39
|
-
|
|
40
|
-
if (!!DASHAppConstants.system.UI_SOUNDS) {
|
|
41
|
-
const audio = new Audio(clickSound);
|
|
42
|
-
audio.load();
|
|
43
|
-
audio.play();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const dispatch = useDispatch();
|
|
49
|
-
const updatePageState = () => {
|
|
50
|
-
const newPageState: IPageState = {
|
|
51
|
-
title: item?.label,
|
|
52
|
-
icon: item?.icon,
|
|
53
|
-
subTitle: item?.group,
|
|
54
|
-
};
|
|
55
|
-
dispatch(DASH_REDUX_ACTIONS.updatePage(newPageState));
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (isCurrent === true) {
|
|
60
|
-
updatePageState();
|
|
61
|
-
}
|
|
62
|
-
}, [isCurrent]);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<ListItemButton
|
|
66
|
-
className={className}
|
|
67
|
-
selected={isCurrent}
|
|
68
|
-
onClick={(e) => {
|
|
69
|
-
|
|
70
|
-
playClick();
|
|
71
|
-
updatePageState();
|
|
72
|
-
|
|
73
|
-
//if ((e.target as any)?.localName === "svg") return;
|
|
74
|
-
|
|
75
|
-
if (item?.to) {
|
|
76
|
-
|
|
77
|
-
navigate(item.to.replace(/\/+/g, '/'));
|
|
78
|
-
|
|
79
|
-
// Close drawer on mobile after navigation (for second-level items)
|
|
80
|
-
if (navSize === 'small') {
|
|
81
|
-
NavEventManager.closeDrawer();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}}
|
|
85
|
-
>
|
|
86
|
-
<ListItemIcon>{item?.icon || DefaultIcon}</ListItemIcon>
|
|
87
|
-
{navSize !== "small" && <ListItemText>{item.label}</ListItemText>}
|
|
88
|
-
</ListItemButton>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export default SidebarItem;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { IMenuItem } from './interfaces';
|
|
2
|
-
|
|
3
|
-
const getItem = (item: IMenuItem): IMenuItem => {
|
|
4
|
-
/*return {
|
|
5
|
-
key: item.key,
|
|
6
|
-
icon: item.icon,
|
|
7
|
-
children: item.children,
|
|
8
|
-
label: item.label,
|
|
9
|
-
type: item.type,
|
|
10
|
-
group: item.group,
|
|
11
|
-
model: item.model,
|
|
12
|
-
txtLabel: item.txtLabel
|
|
13
|
-
};*/
|
|
14
|
-
return item;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default getItem;
|