@smartbooks-ai/layout 0.0.4 → 0.0.5
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/PageHeader/PageHeader.d.ts +6 -0
- package/dist/components/PageHeader/PageHeader.d.ts.map +1 -0
- package/dist/components/PageHeader/PageHeader.js +4 -0
- package/dist/components/PageHeader/index.d.ts +2 -0
- package/dist/components/PageHeader/index.d.ts.map +1 -0
- package/dist/components/PageHeader/index.js +1 -0
- package/dist/components/PageHeader/styles.d.ts +9 -0
- package/dist/components/PageHeader/styles.d.ts.map +1 -0
- package/dist/components/PageHeader/styles.js +28 -0
- package/dist/components/PageWithMenuLayout/AppSelect/index.d.ts +12 -0
- package/dist/components/PageWithMenuLayout/AppSelect/index.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/AppSelect/index.js +27 -0
- package/dist/components/PageWithMenuLayout/AppSelect/styles.d.ts +10 -0
- package/dist/components/PageWithMenuLayout/AppSelect/styles.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/AppSelect/styles.js +27 -0
- package/dist/components/PageWithMenuLayout/LogoHeaderImage.d.ts +4 -0
- package/dist/components/PageWithMenuLayout/LogoHeaderImage.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/LogoHeaderImage.js +3 -0
- package/dist/components/PageWithMenuLayout/LogoHeaderText.d.ts +4 -0
- package/dist/components/PageWithMenuLayout/LogoHeaderText.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/LogoHeaderText.js +3 -0
- package/dist/components/PageWithMenuLayout/MenuItemWithChildren/MenuItemWithChildren.d.ts +13 -0
- package/dist/components/PageWithMenuLayout/MenuItemWithChildren/MenuItemWithChildren.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/MenuItemWithChildren/MenuItemWithChildren.js +49 -0
- package/dist/components/PageWithMenuLayout/MenuItemWithChildren/styles.d.ts +53 -0
- package/dist/components/PageWithMenuLayout/MenuItemWithChildren/styles.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/MenuItemWithChildren/styles.js +127 -0
- package/dist/components/PageWithMenuLayout/MenuSelect/index.d.ts +12 -0
- package/dist/components/PageWithMenuLayout/MenuSelect/index.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/MenuSelect/index.js +24 -0
- package/dist/components/PageWithMenuLayout/MenuSelect/styles.d.ts +22 -0
- package/dist/components/PageWithMenuLayout/MenuSelect/styles.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/MenuSelect/styles.js +84 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/ConsolidationIcon.d.ts +3 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/ConsolidationIcon.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/ConsolidationIcon.js +3 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/MultiSubscriptionsMenuItems.d.ts +10 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/MultiSubscriptionsMenuItems.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/MultiSubscriptionsMenuItems.js +40 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/index.d.ts +2 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/index.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/index.js +1 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/styles.d.ts +5 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/styles.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/styles.js +9 -0
- package/dist/components/PageWithMenuLayout/PageWithMenuLayout.d.ts +15 -0
- package/dist/components/PageWithMenuLayout/PageWithMenuLayout.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/PageWithMenuLayout.js +15 -0
- package/dist/components/PageWithMenuLayout/UserProfileSelect/index.d.ts +9 -0
- package/dist/components/PageWithMenuLayout/UserProfileSelect/index.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/UserProfileSelect/index.js +16 -0
- package/dist/components/PageWithMenuLayout/UserProfileSelect/styles.d.ts +4 -0
- package/dist/components/PageWithMenuLayout/UserProfileSelect/styles.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/UserProfileSelect/styles.js +7 -0
- package/dist/components/PageWithMenuLayout/index.d.ts +9 -0
- package/dist/components/PageWithMenuLayout/index.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/index.js +8 -0
- package/dist/components/PageWithMenuLayout/styles.d.ts +33 -0
- package/dist/components/PageWithMenuLayout/styles.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/styles.js +91 -0
- package/dist/components/PageWithMenuLayout/types.d.ts +13 -0
- package/dist/components/PageWithMenuLayout/types.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/types.js +1 -0
- package/dist/components/PageWithMenuLayout/useMenuToggle.d.ts +6 -0
- package/dist/components/PageWithMenuLayout/useMenuToggle.d.ts.map +1 -0
- package/dist/components/PageWithMenuLayout/useMenuToggle.js +13 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useIsAuthorized.d.ts +13 -0
- package/dist/hooks/useIsAuthorized.d.ts.map +1 -0
- package/dist/hooks/useIsAuthorized.js +15 -0
- package/dist/hooks/useToggle.d.ts +10 -0
- package/dist/hooks/useToggle.d.ts.map +1 -0
- package/dist/hooks/useToggle.js +17 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/package-isolation.test.d.ts +2 -0
- package/dist/package-isolation.test.d.ts.map +1 -0
- package/dist/package-isolation.test.js +47 -0
- package/dist/security/AuthorizedContent/index.d.ts +18 -0
- package/dist/security/AuthorizedContent/index.d.ts.map +1 -0
- package/dist/security/AuthorizedContent/index.js +41 -0
- package/dist/security/AuthorizedContent/state.d.ts +9 -0
- package/dist/security/AuthorizedContent/state.d.ts.map +1 -0
- package/dist/security/AuthorizedContent/state.js +9 -0
- package/dist/security/AuthorizedContent/useAuthorizationState.d.ts +12 -0
- package/dist/security/AuthorizedContent/useAuthorizationState.d.ts.map +1 -0
- package/dist/security/AuthorizedContent/useAuthorizationState.js +22 -0
- package/dist/security/ProfileContext/ProfileContext.d.ts +22 -0
- package/dist/security/ProfileContext/ProfileContext.d.ts.map +1 -0
- package/dist/security/ProfileContext/ProfileContext.js +11 -0
- package/dist/security/ProfileContext/index.d.ts +5 -0
- package/dist/security/ProfileContext/index.d.ts.map +1 -0
- package/dist/security/ProfileContext/index.js +4 -0
- package/dist/security/ProfileContext/types.d.ts +8 -0
- package/dist/security/ProfileContext/types.d.ts.map +1 -0
- package/dist/security/ProfileContext/types.js +8 -0
- package/dist/security/ProfileContext/useProfile.d.ts +2 -0
- package/dist/security/ProfileContext/useProfile.d.ts.map +1 -0
- package/dist/security/ProfileContext/useProfile.js +5 -0
- package/dist/security/UserProfile.d.ts +12 -0
- package/dist/security/UserProfile.d.ts.map +1 -0
- package/dist/security/UserProfile.js +25 -0
- package/dist/security/index.d.ts +3 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +2 -0
- package/dist/theme/colorPrimitives.d.ts +3 -0
- package/dist/theme/colorPrimitives.d.ts.map +1 -0
- package/dist/theme/colorPrimitives.js +105 -0
- package/dist/theme/colors.d.ts +3 -0
- package/dist/theme/colors.d.ts.map +1 -0
- package/dist/theme/colors.js +75 -0
- package/dist/theme/font.d.ts +4 -0
- package/dist/theme/font.d.ts.map +1 -0
- package/dist/theme/font.js +24 -0
- package/dist/theme/globalStyles.d.ts +2 -0
- package/dist/theme/globalStyles.d.ts.map +1 -0
- package/dist/theme/globalStyles.js +50 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +197 -0
- package/dist/theme/radius.d.ts +3 -0
- package/dist/theme/radius.d.ts.map +1 -0
- package/dist/theme/radius.js +10 -0
- package/dist/theme/spacing.d.ts +3 -0
- package/dist/theme/spacing.d.ts.map +1 -0
- package/dist/theme/spacing.js +10 -0
- package/dist/theme/typography.d.ts +4 -0
- package/dist/theme/typography.d.ts.map +1 -0
- package/dist/theme/typography.js +32 -0
- package/dist/utils/assertNever.d.ts +15 -0
- package/dist/utils/assertNever.d.ts.map +1 -0
- package/dist/utils/assertNever.js +14 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/shouldNotForwardPropsWithKeys.d.ts +3 -0
- package/dist/utils/shouldNotForwardPropsWithKeys.d.ts.map +1 -0
- package/dist/utils/shouldNotForwardPropsWithKeys.js +3 -0
- package/package.json +10 -8
- package/src/components/PageWithMenuLayout/PageWithMenuLayout.tsx +3 -6
- package/src/components/PageWithMenuLayout/useMenuToggle.ts +19 -0
- package/tsconfig.layout.tsbuildinfo +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import MuiUnfoldMoreIcon from '@mui/icons-material/UnfoldMoreRounded';
|
|
4
|
+
import Button, { buttonClasses } from '@mui/material/Button';
|
|
5
|
+
import MuiMenu, { menuClasses } from '@mui/material/Menu';
|
|
6
|
+
import { shouldNotForwardPropsWithKeys } from '../../../utils/shouldNotForwardPropsWithKeys';
|
|
7
|
+
export const SelectorButton = styled(Button, shouldNotForwardPropsWithKeys(['isMenuExpanded']))(({ theme, isMenuExpanded, disabled }) => css `
|
|
8
|
+
display: ${disabled && 'none'};
|
|
9
|
+
|
|
10
|
+
justify-content: flex-start;
|
|
11
|
+
|
|
12
|
+
min-width: 0;
|
|
13
|
+
height: 2.375rem;
|
|
14
|
+
|
|
15
|
+
padding-right: calc(${theme.my.spacing.xxxs} - 0.0625rem);
|
|
16
|
+
padding-left: calc(${theme.my.spacing.xxxs} - 0.0625rem);
|
|
17
|
+
|
|
18
|
+
text-overflow: ellipsis;
|
|
19
|
+
|
|
20
|
+
color: ${theme.my.colors.primitives.common.white};
|
|
21
|
+
|
|
22
|
+
white-space: nowrap;
|
|
23
|
+
|
|
24
|
+
border-radius: ${theme.my.radius.md};
|
|
25
|
+
|
|
26
|
+
transition:
|
|
27
|
+
height 0.3s,
|
|
28
|
+
padding 0.3s;
|
|
29
|
+
|
|
30
|
+
:hover {
|
|
31
|
+
&.${buttonClasses.outlined} {
|
|
32
|
+
border-color: ${theme.my.colors.primitives.common.white};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
${isMenuExpanded &&
|
|
37
|
+
css `
|
|
38
|
+
height: 3rem;
|
|
39
|
+
|
|
40
|
+
padding-right: ${theme.my.spacing.xxs};
|
|
41
|
+
padding-left: ${theme.my.spacing.xxs};
|
|
42
|
+
`}
|
|
43
|
+
|
|
44
|
+
.${buttonClasses.startIcon} {
|
|
45
|
+
width: 1.75rem;
|
|
46
|
+
height: 1.75rem;
|
|
47
|
+
|
|
48
|
+
margin-right: 0;
|
|
49
|
+
margin-left: 0;
|
|
50
|
+
|
|
51
|
+
transition: 0.3s;
|
|
52
|
+
|
|
53
|
+
${isMenuExpanded &&
|
|
54
|
+
css `
|
|
55
|
+
width: 2rem;
|
|
56
|
+
height: 2rem;
|
|
57
|
+
`}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.${buttonClasses.endIcon} {
|
|
61
|
+
margin-right: ${theme.my.spacing.xxxs};
|
|
62
|
+
}
|
|
63
|
+
`);
|
|
64
|
+
export const SelectedOptionText = styled.span `
|
|
65
|
+
flex: 1;
|
|
66
|
+
|
|
67
|
+
padding-left: ${({ theme }) => theme.my.spacing.xxs};
|
|
68
|
+
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
text-overflow: ellipsis;
|
|
71
|
+
|
|
72
|
+
font: ${({ theme }) => theme.my.font.highlight3};
|
|
73
|
+
|
|
74
|
+
text-align: left;
|
|
75
|
+
`;
|
|
76
|
+
export const Menu = styled(MuiMenu) `
|
|
77
|
+
.${menuClasses.root} {
|
|
78
|
+
padding: 0;
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
export const UnfoldMoreIcon = styled(MuiUnfoldMoreIcon) `
|
|
82
|
+
width: 1rem;
|
|
83
|
+
height: 1rem;
|
|
84
|
+
`;
|
package/dist/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/ConsolidationIcon.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsolidationIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/ConsolidationIcon.tsx"],"names":[],"mappings":"AAAA,QAAA,MAAM,iBAAiB,GAAI,OAAO,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,qDAI9D,CAAC;AACF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
const ConsolidationIcon = (props) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 36 36", ...props, children: _jsx("path", { d: "M9.8 18.8h16.4v3.08h1.6V17.2h-9V14h-1.6v3.2h-9v4.68h1.6zM14 23H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6a2 2 0 0 0-2-2M4 31v-6h10v6ZM32 23H22a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6a2 2 0 0 0-2-2m-10 8v-6h10v6ZM13 13h10a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H13a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2m0-8h10v6H13Z" }) }));
|
|
3
|
+
export default ConsolidationIcon;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AvailableCompany, AvailableTenant } from '@smartbooks-ai/api-client';
|
|
2
|
+
type Props = {
|
|
3
|
+
selectedTenant?: AvailableTenant;
|
|
4
|
+
tenants: AvailableTenant[];
|
|
5
|
+
onCompanySelected: (company: AvailableCompany) => void;
|
|
6
|
+
selectedCompanyCode: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const MultiSubscriptionsMenuItems: React.FC<Props>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=MultiSubscriptionsMenuItems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSubscriptionsMenuItems.d.ts","sourceRoot":"","sources":["../../../../src/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/MultiSubscriptionsMenuItems.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAO9E,KAAK,KAAK,GAAG;IACX,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,iBAAiB,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACvD,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiGvD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment, useEffect, useState } from 'react';
|
|
3
|
+
import { Business as BusinessIcon, ExpandLess as ExpandLessIcon, ExpandMore as ExpandMoreIcon, } from '@mui/icons-material';
|
|
4
|
+
import { Collapse, Divider, List, ListItemIcon, MenuItem, Tooltip } from '@mui/material';
|
|
5
|
+
import ConsolidationIcon from './ConsolidationIcon';
|
|
6
|
+
import * as Styled from './styles';
|
|
7
|
+
import { assertNever } from '../../../utils/assertNever';
|
|
8
|
+
export const MultiSubscriptionsMenuItems = ({ selectedTenant, tenants, onCompanySelected, selectedCompanyCode, }) => {
|
|
9
|
+
const [openTenants, setOpenTenants] = useState([]);
|
|
10
|
+
const toggleTenant = (tenantCode) => {
|
|
11
|
+
if (openTenants.includes(tenantCode)) {
|
|
12
|
+
setOpenTenants(openTenants.filter((a) => a !== tenantCode));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
setOpenTenants([...openTenants, tenantCode]);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (selectedTenant) {
|
|
20
|
+
setOpenTenants([selectedTenant.code]);
|
|
21
|
+
}
|
|
22
|
+
}, [selectedTenant]);
|
|
23
|
+
const sortedTenants = tenants.toSorted((a, b) => (a.description || '').localeCompare(b.description || ''));
|
|
24
|
+
const [highlightedCompanyMenuItem, setHighlightedCompanyMenuItem] = useState(null);
|
|
25
|
+
return (_jsx(_Fragment, { children: sortedTenants.map((tenant) => {
|
|
26
|
+
const sortedCompanies = tenant.companies.toSorted((a, b) => a.companyType === 'consolidation' && b.companyType !== 'consolidation'
|
|
27
|
+
? -1
|
|
28
|
+
: a.companyType !== 'consolidation' && b.companyType === 'consolidation'
|
|
29
|
+
? 1
|
|
30
|
+
: (a.description || '').localeCompare(b.description || ''));
|
|
31
|
+
const isOpen = tenants.length === 1 || openTenants.includes(tenant.code);
|
|
32
|
+
return (_jsxs(Fragment, { children: [tenants.length > 1 && (_jsxs(MenuItem, { onClick: () => toggleTenant(tenant.code), children: [tenant.description, _jsx(ListItemIcon, { sx: { marginLeft: '1em' }, children: isOpen ? _jsx(ExpandLessIcon, { fontSize: "small" }) : _jsx(ExpandMoreIcon, { fontSize: "small" }) })] })), _jsx(Collapse, { in: isOpen, timeout: "auto", unmountOnExit: true, onEntered: () => {
|
|
33
|
+
if (tenant.code === selectedTenant?.code)
|
|
34
|
+
highlightedCompanyMenuItem?.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
35
|
+
}, children: _jsxs(List, { component: "div", disablePadding: true, children: [_jsx(Divider, {}), sortedCompanies.map((company) => (_jsxs(MenuItem, { onClick: () => onCompanySelected(company), selected: company.code === selectedCompanyCode, autoFocus: company.code === selectedCompanyCode, ref: (el) => {
|
|
36
|
+
if (company.code === selectedCompanyCode)
|
|
37
|
+
setHighlightedCompanyMenuItem(el);
|
|
38
|
+
}, children: [_jsx(ListItemIcon, { children: company.companyType === 'consolidation' ? (_jsx(Tooltip, { title: "Consolidation", disableInteractive: true, children: _jsx(Styled.IconContainer, { children: _jsx(ConsolidationIcon, { fontSize: "inherit" }) }) })) : company.companyType === 'regular' ? (_jsx(Styled.IconContainer, { children: _jsx(BusinessIcon, { fontSize: "inherit" }) })) : (assertNever(company.companyType)) }), company.description] }, company.code)))] }) })] }, tenant.code));
|
|
39
|
+
}) }));
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MultiSubscriptionsMenuItems } from './MultiSubscriptionsMenuItems';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const IconContainer: import("@emotion/styled").StyledComponent<{
|
|
2
|
+
theme?: import("@emotion/react").Theme;
|
|
3
|
+
as?: React.ElementType;
|
|
4
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
5
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;yGAOzB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AvailableCompany } from '@smartbooks-ai/api-client';
|
|
2
|
+
import { MenuStructure } from './types';
|
|
3
|
+
import { UserProfile } from '../../security/UserProfile';
|
|
4
|
+
export type PageWithMenuLayoutProps = {
|
|
5
|
+
resolvedCompanyCode?: string;
|
|
6
|
+
topMenu?: MenuStructure;
|
|
7
|
+
bottomMenu: MenuStructure;
|
|
8
|
+
profile: UserProfile | null;
|
|
9
|
+
tenantCode?: string;
|
|
10
|
+
switchToCompany: (company: AvailableCompany) => Promise<void>;
|
|
11
|
+
logout: () => void;
|
|
12
|
+
additionalOutletContent?: React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
export declare const PageWithMenuLayout: React.FC<PageWithMenuLayoutProps>;
|
|
15
|
+
//# sourceMappingURL=PageWithMenuLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageWithMenuLayout.d.ts","sourceRoot":"","sources":["../../../src/components/PageWithMenuLayout/PageWithMenuLayout.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAQ7D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,MAAM,uBAAuB,GAAG;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,aAAa,CAAC;IAC1B,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,uBAAuB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA2EhE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import KeyboardArrowLeftIcon from '@mui/icons-material/KeyboardArrowLeft';
|
|
3
|
+
import Fade from '@mui/material/Fade';
|
|
4
|
+
import MenuList from '@mui/material/MenuList';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
import { NavLink, Outlet } from 'react-router';
|
|
7
|
+
import LogoHeaderImage from './LogoHeaderImage';
|
|
8
|
+
import LogoHeaderText from './LogoHeaderText';
|
|
9
|
+
import { AppSelect, MenuItemWithChildren, UserProfileSelect } from './index';
|
|
10
|
+
import * as Styled from './styles';
|
|
11
|
+
import { useMenuToggle } from './useMenuToggle';
|
|
12
|
+
export const PageWithMenuLayout = ({ resolvedCompanyCode, topMenu, bottomMenu, profile, tenantCode, switchToCompany, logout, additionalOutletContent, }) => {
|
|
13
|
+
const { isExpanded, openMenu, toggleIsExpanded } = useMenuToggle();
|
|
14
|
+
return (_jsxs(_Fragment, { children: [_jsx(Styled.LockMenuButton, { onClick: toggleIsExpanded, isExpanded: isExpanded, children: _jsx(KeyboardArrowLeftIcon, { fontSize: "inherit" }) }), createPortal(_jsxs(Styled.Drawer, { open: isExpanded, variant: "permanent", children: [_jsxs(Styled.Header, { children: [_jsx(Styled.LogoContainer, { children: _jsx(NavLink, { to: "/", children: _jsx(LogoHeaderImage, { height: 24 }) }) }), _jsx(Fade, { in: isExpanded, children: _jsx(NavLink, { to: "/", children: _jsx(LogoHeaderText, { height: 12 }) }) })] }), _jsx(AppSelect, { tenantCode: tenantCode, companyCode: resolvedCompanyCode, isExpanded: isExpanded, profile: profile, onCompanyClicked: switchToCompany }), _jsx(Styled.TopMenuList, { children: topMenu?.map((firstLevelItem) => (_jsx(MenuItemWithChildren, { menuItem: firstLevelItem, isMenuOpen: isExpanded, openMenu: openMenu }, firstLevelItem.title))) }), _jsx(MenuList, { disablePadding: true, children: bottomMenu?.map((firstLevelItem) => (_jsx(MenuItemWithChildren, { menuItem: firstLevelItem, isMenuOpen: isExpanded, openMenu: openMenu }, firstLevelItem.title))) }), _jsx(UserProfileSelect, { isTextVisible: isExpanded, profile: profile, logout: logout })] }), document.body), _jsxs(Styled.Main, { isLocked: isExpanded, children: [_jsx(Outlet, {}), additionalOutletContent] })] }));
|
|
15
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UserProfile } from '../../../security/ProfileContext';
|
|
2
|
+
type Props = {
|
|
3
|
+
isTextVisible: boolean;
|
|
4
|
+
profile: UserProfile | null;
|
|
5
|
+
logout: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const UserProfileSelect: React.FC<Props>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PageWithMenuLayout/UserProfileSelect/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAG/D,KAAK,KAAK,GAAG;IACX,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2C7C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import AccountCircleRoundedIcon from '@mui/icons-material/AccountCircleRounded';
|
|
4
|
+
import { Fade } from '@mui/material';
|
|
5
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
6
|
+
import { GlobalRole } from '@smartbooks-ai/api-client';
|
|
7
|
+
import * as Styled from './styles';
|
|
8
|
+
import { useIsAuthorized } from '../../../hooks/useIsAuthorized';
|
|
9
|
+
import { useToggle } from '../../../hooks/useToggle';
|
|
10
|
+
import * as MenuItemWithChildrenStyled from '../MenuItemWithChildren/styles';
|
|
11
|
+
export const UserProfileSelect = ({ isTextVisible, profile, logout }) => {
|
|
12
|
+
const { value: isMenuOpen, switchOn: openMenu, switchOff: closeMenu } = useToggle();
|
|
13
|
+
const getIsAuthorized = useIsAuthorized();
|
|
14
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsxs(MenuItemWithChildrenStyled.MenuItem, { isTitle: false, isMenuOpen: isTextVisible, ref: setAnchorEl, isHighlighted: false, onClick: openMenu, children: [_jsx(MenuItemWithChildrenStyled.ListItemIcon, { children: _jsx(AccountCircleRoundedIcon, { fontSize: "small" }) }), _jsx(Fade, { in: isTextVisible, children: _jsx(MenuItemWithChildrenStyled.ListItemText, { elevation: 0, isHighlighted: false, isTitle: false, children: profile?.displayName ?? 'My account' }) }), _jsx(MenuItemWithChildrenStyled.ArrowDownIcon, { isExpanded: isMenuOpen, isVisible: isTextVisible })] }), _jsxs(Styled.Menu, { anchorOrigin: { horizontal: 'left', vertical: 'top' }, transformOrigin: { horizontal: 'left', vertical: 'bottom' }, anchorEl: anchorEl, open: isMenuOpen, onClose: closeMenu, children: [_jsx(MenuItem, { disabled: true, children: profile?.email }), getIsAuthorized({ globalRole: GlobalRole.GlobalAdmin }) && (_jsx(MenuItem, { onClick: () => window.open('/ac/ga', '_blank'), children: "System admin" })), _jsx(MenuItem, { onClick: logout, children: "Logout" })] })] }));
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/PageWithMenuLayout/UserProfileSelect/styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;;UAIhB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { AppSelect } from './AppSelect';
|
|
2
|
+
export { MenuSelect } from './MenuSelect';
|
|
3
|
+
export { MultiSubscriptionsMenuItems } from './MultiSubscriptionsMenuItems';
|
|
4
|
+
export { MenuItemWithChildren } from './MenuItemWithChildren/MenuItemWithChildren';
|
|
5
|
+
export { UserProfileSelect } from './UserProfileSelect';
|
|
6
|
+
export { PageWithMenuLayout } from './PageWithMenuLayout';
|
|
7
|
+
export { default as LogoHeaderImage } from './LogoHeaderImage';
|
|
8
|
+
export { default as LogoHeaderText } from './LogoHeaderText';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PageWithMenuLayout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AppSelect } from './AppSelect';
|
|
2
|
+
export { MenuSelect } from './MenuSelect';
|
|
3
|
+
export { MultiSubscriptionsMenuItems } from './MultiSubscriptionsMenuItems';
|
|
4
|
+
export { MenuItemWithChildren } from './MenuItemWithChildren/MenuItemWithChildren';
|
|
5
|
+
export { UserProfileSelect } from './UserProfileSelect';
|
|
6
|
+
export { PageWithMenuLayout } from './PageWithMenuLayout';
|
|
7
|
+
export { default as LogoHeaderImage } from './LogoHeaderImage';
|
|
8
|
+
export { default as LogoHeaderText } from './LogoHeaderText';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const Drawer: import("@emotion/styled").StyledComponent<import("@mui/material").DrawerProps & {
|
|
2
|
+
theme?: import("@emotion/react").Theme;
|
|
3
|
+
}, {}, {}>;
|
|
4
|
+
export declare const Header: import("@emotion/styled").StyledComponent<{
|
|
5
|
+
theme?: import("@emotion/react").Theme;
|
|
6
|
+
as?: React.ElementType;
|
|
7
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
8
|
+
export declare const LogoContainer: import("@emotion/styled").StyledComponent<{
|
|
9
|
+
theme?: import("@emotion/react").Theme;
|
|
10
|
+
as?: React.ElementType;
|
|
11
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
12
|
+
type LockMenuButtonProps = {
|
|
13
|
+
isExpanded: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const LockMenuButton: import("@emotion/styled").StyledComponent<import("@mui/material").IconButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
16
|
+
ref?: ((instance: HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
17
|
+
}, "style" | "className" | "classes" | "tabIndex" | "color" | "children" | "sx" | "disabled" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "loading" | "loadingIndicator" | "size" | "edge"> & {
|
|
18
|
+
theme?: import("@emotion/react").Theme;
|
|
19
|
+
} & LockMenuButtonProps, {}, {}>;
|
|
20
|
+
export declare const TopMenuList: import("@emotion/styled").StyledComponent<import("@mui/material").MenuListOwnProps & import("@mui/material").ListOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & {
|
|
21
|
+
ref?: ((instance: HTMLUListElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLUListElement> | null | undefined;
|
|
22
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "autoFocus" | "children" | "sx" | "variant" | "dense" | "disablePadding" | "subheader" | "autoFocusItem" | "disabledItemsFocusable" | "disableListWrap"> & {
|
|
23
|
+
theme?: import("@emotion/react").Theme;
|
|
24
|
+
}, {}, {}>;
|
|
25
|
+
type MainProps = {
|
|
26
|
+
isLocked: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare const Main: import("@emotion/styled").StyledComponent<{
|
|
29
|
+
theme?: import("@emotion/react").Theme;
|
|
30
|
+
as?: React.ElementType;
|
|
31
|
+
} & MainProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/PageWithMenuLayout/styles.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,MAAM;;UAgBlB,CAAC;AAEF,eAAO,MAAM,MAAM;;;yGAYlB,CAAC;AAEF,eAAO,MAAM,aAAa;;;yGAQzB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AACF,eAAO,MAAM,cAAc;;;;gCA2B1B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;UASvB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AACF,eAAO,MAAM,IAAI;;;qHAUhB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import MuiDrawer, { drawerClasses } from '@mui/material/Drawer';
|
|
4
|
+
import MuiIconButton from '@mui/material/IconButton';
|
|
5
|
+
import MenuList from '@mui/material/MenuList';
|
|
6
|
+
import { shouldNotForwardPropsWithKeys } from '../../utils/shouldNotForwardPropsWithKeys';
|
|
7
|
+
const drawerOpenWidthRem = 15.625;
|
|
8
|
+
const drawerClosedWidthRem = 3.75;
|
|
9
|
+
export const Drawer = styled(MuiDrawer) `
|
|
10
|
+
flex-shrink: 0;
|
|
11
|
+
|
|
12
|
+
overflow-x: hidden;
|
|
13
|
+
.${drawerClasses.paper} {
|
|
14
|
+
width: ${({ open }) => (open ? drawerOpenWidthRem : drawerClosedWidthRem)}rem;
|
|
15
|
+
|
|
16
|
+
padding: ${({ theme }) => theme.my.spacing.xs};
|
|
17
|
+
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
|
|
20
|
+
background-color: ${({ theme }) => theme.my.colors.primary.main};
|
|
21
|
+
border: unset;
|
|
22
|
+
|
|
23
|
+
transition: width 0.3s;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
export const Header = styled.div `
|
|
27
|
+
display: flex;
|
|
28
|
+
|
|
29
|
+
column-gap: ${({ theme }) => theme.my.spacing.xxs};
|
|
30
|
+
align-items: center;
|
|
31
|
+
|
|
32
|
+
width: max-content;
|
|
33
|
+
min-width: 100%;
|
|
34
|
+
|
|
35
|
+
padding-bottom: ${({ theme }) => theme.my.spacing.xs};
|
|
36
|
+
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
`;
|
|
39
|
+
export const LogoContainer = styled.div `
|
|
40
|
+
display: flex;
|
|
41
|
+
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
|
|
45
|
+
width: 2.25rem;
|
|
46
|
+
height: 2.25rem;
|
|
47
|
+
`;
|
|
48
|
+
export const LockMenuButton = styled(MuiIconButton, shouldNotForwardPropsWithKeys(['isExpanded']))(({ theme, isExpanded }) => css `
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: ${theme.my.spacing.sm};
|
|
51
|
+
left: ${isExpanded ? drawerOpenWidthRem : drawerClosedWidthRem}rem;
|
|
52
|
+
z-index: ${(theme.zIndex?.drawer ?? 0) + 1};
|
|
53
|
+
|
|
54
|
+
padding: ${theme.my.spacing.xxxs};
|
|
55
|
+
|
|
56
|
+
font-size: 1rem;
|
|
57
|
+
|
|
58
|
+
color: ${theme.my.colors.text.white};
|
|
59
|
+
|
|
60
|
+
background-color: ${theme.my.colors.primitives.darkNavy[700]};
|
|
61
|
+
border-radius: ${theme.my.radius.xxl};
|
|
62
|
+
|
|
63
|
+
transform: translateX(-50%) rotate(${isExpanded ? 0 : 180}deg);
|
|
64
|
+
|
|
65
|
+
transition: 0.3s;
|
|
66
|
+
|
|
67
|
+
&:hover {
|
|
68
|
+
background-color: ${theme.my.colors.primitives.darkNavy[600]};
|
|
69
|
+
}
|
|
70
|
+
`);
|
|
71
|
+
export const TopMenuList = styled(MenuList) `
|
|
72
|
+
display: flex;
|
|
73
|
+
|
|
74
|
+
flex: 1;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
|
|
77
|
+
gap: ${({ theme }) => theme.my.spacing.xxxs};
|
|
78
|
+
|
|
79
|
+
overflow: hidden auto;
|
|
80
|
+
`;
|
|
81
|
+
export const Main = styled('div', shouldNotForwardPropsWithKeys(['isLocked'])) `
|
|
82
|
+
position: relative;
|
|
83
|
+
|
|
84
|
+
flex-grow: 1;
|
|
85
|
+
|
|
86
|
+
margin-left: ${({ isLocked }) => (isLocked ? drawerOpenWidthRem : drawerClosedWidthRem)}rem;
|
|
87
|
+
|
|
88
|
+
overflow: auto;
|
|
89
|
+
|
|
90
|
+
transition: margin 0.3s;
|
|
91
|
+
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type MenuItem = {
|
|
2
|
+
title: string;
|
|
3
|
+
icon?: React.ReactNode;
|
|
4
|
+
skipHeader?: boolean;
|
|
5
|
+
} & ({
|
|
6
|
+
children: MenuItem[];
|
|
7
|
+
} | {
|
|
8
|
+
href: string;
|
|
9
|
+
} | {
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
});
|
|
12
|
+
export type MenuStructure = MenuItem[];
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/PageWithMenuLayout/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,CAAC;IAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC,CAAC;AAE5E,MAAM,MAAM,aAAa,GAAG,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMenuToggle.d.ts","sourceRoot":"","sources":["../../../src/components/PageWithMenuLayout/useMenuToggle.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa;;;;CAczB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { useProfile, useToggle } from '@smartbooks-ai/layout';
|
|
3
|
+
export const useMenuToggle = () => {
|
|
4
|
+
const { value: isExpanded, toggle: toggleIsExpanded, switchOn: openMenu, switchOff: closeMenu } = useToggle(true);
|
|
5
|
+
const { profile } = useProfile();
|
|
6
|
+
const tenants = profile?.allowedTenants;
|
|
7
|
+
const tenantsWithCompanies = useMemo(() => tenants?.filter(({ companies }) => companies.length > 0) ?? [], [tenants]);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (tenants && !tenantsWithCompanies.length)
|
|
10
|
+
closeMenu();
|
|
11
|
+
}, [closeMenu, tenants, tenantsWithCompanies.length]);
|
|
12
|
+
return { isExpanded, toggleIsExpanded, openMenu };
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CompanyRole, GlobalRole, ResourceType, TenantRole } from '@smartbooks-ai/api-client';
|
|
2
|
+
type AuthorizationParams = {
|
|
3
|
+
companyRole?: CompanyRole;
|
|
4
|
+
tenantCode?: string;
|
|
5
|
+
companyCode?: string;
|
|
6
|
+
tenantRole?: TenantRole;
|
|
7
|
+
globalRole?: GlobalRole;
|
|
8
|
+
resourceType?: ResourceType;
|
|
9
|
+
};
|
|
10
|
+
type Output = (params: AuthorizationParams) => boolean | null;
|
|
11
|
+
export declare const useIsAuthorized: () => Output;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=useIsAuthorized.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsAuthorized.d.ts","sourceRoot":"","sources":["../../src/hooks/useIsAuthorized.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI9F,KAAK,mBAAmB,GAAG;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,KAAK,MAAM,GAAG,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,GAAG,IAAI,CAAC;AAE9D,eAAO,MAAM,eAAe,QAAO,MAiBlC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useProfile } from '../security/ProfileContext';
|
|
3
|
+
export const useIsAuthorized = () => {
|
|
4
|
+
const { profile } = useProfile();
|
|
5
|
+
return useCallback(({ companyCode, companyRole, globalRole, tenantCode, tenantRole, resourceType }) => profile &&
|
|
6
|
+
(globalRole === undefined || profile.globalRoles.includes(globalRole)) &&
|
|
7
|
+
(tenantRole === undefined ||
|
|
8
|
+
!!profile.allowedTenants.find(({ code }) => code === tenantCode)?.roles.includes(tenantRole)) &&
|
|
9
|
+
(companyRole === undefined ||
|
|
10
|
+
!!profile.allowedCompanies.find(({ code }) => code === companyCode)?.roles.includes(companyRole)) &&
|
|
11
|
+
(resourceType === undefined ||
|
|
12
|
+
!profile.allowedCompanies
|
|
13
|
+
.find(({ code }) => code === companyCode)
|
|
14
|
+
?.resources?.find(({ resource }) => resource === resourceType)?.isRestricted), [profile]);
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Output = {
|
|
2
|
+
value: boolean;
|
|
3
|
+
switchOn: () => void;
|
|
4
|
+
switchOff: () => void;
|
|
5
|
+
toggle: () => void;
|
|
6
|
+
set: (value: boolean) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const useToggle: (defaultValue?: boolean) => Output;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=useToggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToggle.d.ts","sourceRoot":"","sources":["../../src/hooks/useToggle.ts"],"names":[],"mappings":"AAEA,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,sBAAoB,KAAG,MAgBhD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
export const useToggle = (defaultValue = false) => {
|
|
3
|
+
const [value, setValue] = useState(defaultValue);
|
|
4
|
+
return {
|
|
5
|
+
value,
|
|
6
|
+
switchOn: useCallback(() => {
|
|
7
|
+
setValue(true);
|
|
8
|
+
}, []),
|
|
9
|
+
switchOff: useCallback(() => {
|
|
10
|
+
setValue(false);
|
|
11
|
+
}, []),
|
|
12
|
+
toggle: useCallback(() => {
|
|
13
|
+
setValue((previous) => !previous);
|
|
14
|
+
}, []),
|
|
15
|
+
set: setValue,
|
|
16
|
+
};
|
|
17
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-isolation.test.d.ts","sourceRoot":"","sources":["../src/package-isolation.test.ts"],"names":[],"mappings":""}
|