@smartbooks-ai/layout 0.0.3
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/package/tsconfig.layout.tsbuildinfo +1 -0
- package/package.json +48 -0
- package/src/components/PageHeader/PageHeader.tsx +15 -0
- package/src/components/PageHeader/index.ts +1 -0
- package/src/components/PageHeader/styles.ts +34 -0
- package/src/components/PageWithMenuLayout/AppSelect/index.tsx +66 -0
- package/src/components/PageWithMenuLayout/AppSelect/styles.ts +33 -0
- package/src/components/PageWithMenuLayout/LogoHeaderImage.tsx +44 -0
- package/src/components/PageWithMenuLayout/LogoHeaderText.tsx +48 -0
- package/src/components/PageWithMenuLayout/MenuItemWithChildren/MenuItemWithChildren.tsx +149 -0
- package/src/components/PageWithMenuLayout/MenuItemWithChildren/styles.ts +179 -0
- package/src/components/PageWithMenuLayout/MenuSelect/index.tsx +78 -0
- package/src/components/PageWithMenuLayout/MenuSelect/styles.ts +97 -0
- package/src/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/ConsolidationIcon.tsx +6 -0
- package/src/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/MultiSubscriptionsMenuItems.tsx +120 -0
- package/src/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/consolidation.svg +8 -0
- package/src/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/index.ts +1 -0
- package/src/components/PageWithMenuLayout/MultiSubscriptionsMenuItems/styles.ts +10 -0
- package/src/components/PageWithMenuLayout/PageWithMenuLayout.tsx +106 -0
- package/src/components/PageWithMenuLayout/UserProfileSelect/index.tsx +64 -0
- package/src/components/PageWithMenuLayout/UserProfileSelect/styles.ts +8 -0
- package/src/components/PageWithMenuLayout/index.ts +8 -0
- package/src/components/PageWithMenuLayout/styles.ts +110 -0
- package/src/components/PageWithMenuLayout/types.ts +7 -0
- package/src/components/index.ts +3 -0
- package/src/emotion.d.ts +76 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useIsAuthorized.ts +35 -0
- package/src/hooks/useToggle.ts +27 -0
- package/src/index.ts +7 -0
- package/src/package-isolation.test.ts +60 -0
- package/src/security/AuthorizedContent/index.tsx +77 -0
- package/src/security/AuthorizedContent/state.ts +8 -0
- package/src/security/AuthorizedContent/useAuthorizationState.ts +42 -0
- package/src/security/ProfileContext/ProfileContext.tsx +37 -0
- package/src/security/ProfileContext/index.ts +4 -0
- package/src/security/ProfileContext/types.ts +7 -0
- package/src/security/ProfileContext/useProfile.tsx +7 -0
- package/src/security/UserProfile.ts +48 -0
- package/src/security/index.ts +2 -0
- package/src/theme/colorPrimitives.ts +107 -0
- package/src/theme/colors.ts +78 -0
- package/src/theme/font.ts +27 -0
- package/src/theme/globalStyles.tsx +55 -0
- package/src/theme/index.tsx +228 -0
- package/src/theme/radius.ts +12 -0
- package/src/theme/spacing.ts +12 -0
- package/src/theme/typography.ts +40 -0
- package/src/utils/assertNever.ts +14 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/shouldNotForwardPropsWithKeys.ts +7 -0
- package/tsconfig.json +34 -0
- package/tsconfig.layout.tsbuildinfo +1 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { GlobalStyles as MUIGlobalStyles } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
export default function GlobalStyles() {
|
|
4
|
+
const inputGlobalStyles = (
|
|
5
|
+
<MUIGlobalStyles
|
|
6
|
+
styles={{
|
|
7
|
+
'@keyframes mui-auto-fill': { from: { display: 'block' } },
|
|
8
|
+
'@keyframes mui-auto-fill-cancel': { from: { display: 'block' } },
|
|
9
|
+
'*': {
|
|
10
|
+
boxSizing: 'border-box',
|
|
11
|
+
},
|
|
12
|
+
html: {
|
|
13
|
+
margin: 0,
|
|
14
|
+
padding: 0,
|
|
15
|
+
width: '100%',
|
|
16
|
+
height: '100%',
|
|
17
|
+
WebkitOverflowScrolling: 'touch',
|
|
18
|
+
},
|
|
19
|
+
body: {
|
|
20
|
+
margin: 0,
|
|
21
|
+
padding: 0,
|
|
22
|
+
width: '100%',
|
|
23
|
+
height: '100%',
|
|
24
|
+
},
|
|
25
|
+
'#root': {
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
},
|
|
29
|
+
input: {
|
|
30
|
+
'&[type=number]': {
|
|
31
|
+
MozAppearance: 'textfield',
|
|
32
|
+
'&::-webkit-outer-spin-button': {
|
|
33
|
+
margin: 0,
|
|
34
|
+
WebkitAppearance: 'none',
|
|
35
|
+
},
|
|
36
|
+
'&::-webkit-inner-spin-button': {
|
|
37
|
+
margin: 0,
|
|
38
|
+
WebkitAppearance: 'none',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
img: {
|
|
43
|
+
display: 'block',
|
|
44
|
+
maxWidth: '100%',
|
|
45
|
+
},
|
|
46
|
+
ul: {
|
|
47
|
+
margin: 0,
|
|
48
|
+
padding: 0,
|
|
49
|
+
},
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return inputGlobalStyles;
|
|
55
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider as EmotionThemeProvider, css } from '@emotion/react';
|
|
4
|
+
import ExpandedMoreRoundedIcon from '@mui/icons-material/ExpandMoreRounded';
|
|
5
|
+
import { listItemTextClasses } from '@mui/material';
|
|
6
|
+
import { buttonClasses } from '@mui/material/Button';
|
|
7
|
+
import CssBaseline from '@mui/material/CssBaseline';
|
|
8
|
+
import { LinkProps } from '@mui/material/Link';
|
|
9
|
+
import {
|
|
10
|
+
ThemeProvider as MUIThemeProvider,
|
|
11
|
+
ThemeOptions as MuiThemeOptions,
|
|
12
|
+
StyledEngineProvider,
|
|
13
|
+
createTheme,
|
|
14
|
+
} from '@mui/material/styles';
|
|
15
|
+
import type {} from '@mui/x-date-pickers/themeAugmentation';
|
|
16
|
+
import { rem } from 'polished';
|
|
17
|
+
import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router';
|
|
18
|
+
|
|
19
|
+
import { colorPrimitives } from './colorPrimitives';
|
|
20
|
+
import { colors } from './colors';
|
|
21
|
+
import { font } from './font';
|
|
22
|
+
import GlobalStyles from './globalStyles';
|
|
23
|
+
import { radius } from './radius';
|
|
24
|
+
import { spacing } from './spacing';
|
|
25
|
+
import typography from './typography';
|
|
26
|
+
|
|
27
|
+
import { ThemeOptions } from '../emotion';
|
|
28
|
+
|
|
29
|
+
const LinkBehavior = forwardRef<HTMLAnchorElement, Omit<RouterLinkProps, 'to'> & { href: RouterLinkProps['to'] }>(
|
|
30
|
+
({ href, ...other }, ref) => <RouterLink ref={ref} to={href} {...other} />,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const muiTextField = {
|
|
34
|
+
defaultProps: {
|
|
35
|
+
variant: 'outlined',
|
|
36
|
+
margin: 'normal',
|
|
37
|
+
size: 'small',
|
|
38
|
+
InputLabelProps: { shrink: true },
|
|
39
|
+
SelectProps: { displayEmpty: true },
|
|
40
|
+
},
|
|
41
|
+
} as const;
|
|
42
|
+
|
|
43
|
+
const muiOutlinedInput = {
|
|
44
|
+
styleOverrides: {
|
|
45
|
+
notchedOutline: css`
|
|
46
|
+
border-color: ${colorPrimitives.darkNavy[100]};
|
|
47
|
+
`,
|
|
48
|
+
},
|
|
49
|
+
} as const;
|
|
50
|
+
|
|
51
|
+
const muiTheme: MuiThemeOptions = {
|
|
52
|
+
shape: { borderRadius: 6 },
|
|
53
|
+
typography,
|
|
54
|
+
components: {
|
|
55
|
+
MuiCssBaseline: {
|
|
56
|
+
styleOverrides: {
|
|
57
|
+
a: css`
|
|
58
|
+
color: '#000000';
|
|
59
|
+
|
|
60
|
+
text-decoration: none;
|
|
61
|
+
`,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
MuiAccordionDetails: {
|
|
65
|
+
styleOverrides: {
|
|
66
|
+
root: css`
|
|
67
|
+
display: flex;
|
|
68
|
+
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
|
|
71
|
+
row-gap: ${spacing.xxs};
|
|
72
|
+
`,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
MuiDialogContent: {
|
|
76
|
+
styleOverrides: {
|
|
77
|
+
root: css`
|
|
78
|
+
display: flex;
|
|
79
|
+
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
|
|
82
|
+
row-gap: ${spacing.sm};
|
|
83
|
+
|
|
84
|
+
min-width: 30rem;
|
|
85
|
+
`,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
MuiCheckbox: {
|
|
89
|
+
defaultProps: {
|
|
90
|
+
size: 'small',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
MuiFormControlLabel: {
|
|
94
|
+
styleOverrides: {
|
|
95
|
+
label: css`
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
text-overflow: ellipsis;
|
|
98
|
+
|
|
99
|
+
font: ${font.body2};
|
|
100
|
+
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
`,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
MuiInputBase: {
|
|
106
|
+
defaultProps: {
|
|
107
|
+
disableInjectingGlobalStyles: true,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
MuiTextField: muiTextField,
|
|
111
|
+
MuiPickersTextField: muiTextField,
|
|
112
|
+
MuiAccordion: {
|
|
113
|
+
defaultProps: {
|
|
114
|
+
elevation: 3,
|
|
115
|
+
slotProps: { transition: { unmountOnExit: true } },
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
MuiAccordionSummary: {
|
|
119
|
+
defaultProps: {
|
|
120
|
+
expandIcon: <ExpandedMoreRoundedIcon />,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
MuiLink: {
|
|
124
|
+
defaultProps: {
|
|
125
|
+
component: LinkBehavior,
|
|
126
|
+
} as LinkProps,
|
|
127
|
+
styleOverrides: {
|
|
128
|
+
root: ({ theme }) => css`
|
|
129
|
+
color: ${theme.palette.primary.main};
|
|
130
|
+
|
|
131
|
+
text-decoration-color: inherit;
|
|
132
|
+
text-underline-offset: 0.25rem;
|
|
133
|
+
|
|
134
|
+
&:hover {
|
|
135
|
+
color: ${theme.palette.primary.dark};
|
|
136
|
+
}
|
|
137
|
+
`,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
MuiOutlinedInput: muiOutlinedInput,
|
|
141
|
+
MuiPickersOutlinedInput: muiOutlinedInput,
|
|
142
|
+
MuiButtonGroup: {
|
|
143
|
+
defaultProps: {
|
|
144
|
+
disableRipple: true,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
MuiMenuItem: {
|
|
148
|
+
styleOverrides: {
|
|
149
|
+
root: css`
|
|
150
|
+
font: ${font.body3};
|
|
151
|
+
`,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
MuiButtonBase: {
|
|
155
|
+
styleOverrides: {
|
|
156
|
+
root: css`
|
|
157
|
+
&.${buttonClasses.outlined} {
|
|
158
|
+
border: 0.0625rem solid ${colorPrimitives.darkNavy[100]};
|
|
159
|
+
|
|
160
|
+
&:hover {
|
|
161
|
+
/* For button groups - we should bring the border of hovered button in front of the other ones */
|
|
162
|
+
z-index: 1;
|
|
163
|
+
|
|
164
|
+
background: none;
|
|
165
|
+
border: 0.0625rem solid ${colorPrimitives.darkNavy[800]};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
`,
|
|
169
|
+
},
|
|
170
|
+
defaultProps: {
|
|
171
|
+
disableRipple: true,
|
|
172
|
+
LinkComponent: LinkBehavior,
|
|
173
|
+
type: 'button',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
MuiTooltip: {
|
|
177
|
+
styleOverrides: {
|
|
178
|
+
tooltip: css`
|
|
179
|
+
font: ${font.body3};
|
|
180
|
+
|
|
181
|
+
line-height: 1.5;
|
|
182
|
+
|
|
183
|
+
letter-spacing: 0.05rem;
|
|
184
|
+
|
|
185
|
+
background-color: ${colorPrimitives.darkNavy[900]};
|
|
186
|
+
`,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
MuiSelect: {
|
|
190
|
+
styleOverrides: {
|
|
191
|
+
select: css`
|
|
192
|
+
.${listItemTextClasses.root} {
|
|
193
|
+
margin-top: ${rem(2)};
|
|
194
|
+
margin-bottom: ${rem(2)};
|
|
195
|
+
}
|
|
196
|
+
`,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const themeValue: ThemeOptions = {
|
|
203
|
+
...muiTheme,
|
|
204
|
+
my: {
|
|
205
|
+
font,
|
|
206
|
+
radius,
|
|
207
|
+
spacing,
|
|
208
|
+
colors,
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const theme = createTheme(themeValue);
|
|
213
|
+
|
|
214
|
+
export function ThemeProvider(props: React.PropsWithChildren) {
|
|
215
|
+
return (
|
|
216
|
+
<StyledEngineProvider injectFirst={true}>
|
|
217
|
+
<MUIThemeProvider theme={theme}>
|
|
218
|
+
<EmotionThemeProvider theme={theme}>
|
|
219
|
+
<CssBaseline />
|
|
220
|
+
|
|
221
|
+
<GlobalStyles />
|
|
222
|
+
|
|
223
|
+
{props.children}
|
|
224
|
+
</EmotionThemeProvider>
|
|
225
|
+
</MUIThemeProvider>
|
|
226
|
+
</StyledEngineProvider>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TypographyStyle, TypographyVariantsOptions } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
import { FONT_FAMILY, font } from './font';
|
|
4
|
+
|
|
5
|
+
import { FontStyleName } from '../emotion';
|
|
6
|
+
|
|
7
|
+
const stylesForFont = (fontName: FontStyleName): TypographyStyle => ({
|
|
8
|
+
font: font[fontName],
|
|
9
|
+
|
|
10
|
+
// This is needed to prevent overrides
|
|
11
|
+
fontFamily: undefined,
|
|
12
|
+
fontWeight: undefined,
|
|
13
|
+
fontSize: undefined,
|
|
14
|
+
lineHeight: undefined,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const typography: TypographyVariantsOptions = {
|
|
18
|
+
fontFamily: FONT_FAMILY,
|
|
19
|
+
fontWeightRegular: 400,
|
|
20
|
+
fontWeightMedium: 600,
|
|
21
|
+
fontWeightBold: 700,
|
|
22
|
+
h1: stylesForFont('h1'),
|
|
23
|
+
h2: stylesForFont('h2'),
|
|
24
|
+
h3: stylesForFont('h3'),
|
|
25
|
+
h4: stylesForFont('h4'),
|
|
26
|
+
h5: stylesForFont('h5'),
|
|
27
|
+
h6: stylesForFont('h6'),
|
|
28
|
+
subtitle1: stylesForFont('subtitle1'),
|
|
29
|
+
subtitle2: stylesForFont('subtitle2'),
|
|
30
|
+
body1: stylesForFont('body1'),
|
|
31
|
+
body2: stylesForFont('body2'),
|
|
32
|
+
caption: stylesForFont('caption'),
|
|
33
|
+
overline: stylesForFont('overline'),
|
|
34
|
+
button: {
|
|
35
|
+
...stylesForFont('button1'),
|
|
36
|
+
textTransform: 'inherit',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default typography;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* const a: 'one' | 'two' = 'one';
|
|
4
|
+
*
|
|
5
|
+
* switch(a) {
|
|
6
|
+
* case 'one':
|
|
7
|
+
* return 1;
|
|
8
|
+
* case 'two':
|
|
9
|
+
* return 2;
|
|
10
|
+
* default:
|
|
11
|
+
* return assertNever(a); // Works fine, but if we change the type of `a` to `'one' | 'two' | 'three'` then we get an error here
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
export const assertNever = (input: never): never => input;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StyledOptions } from '@emotion/styled';
|
|
2
|
+
|
|
3
|
+
export const shouldNotForwardPropsWithKeys = <TCustomProps extends object>(
|
|
4
|
+
keys: (keyof TCustomProps)[],
|
|
5
|
+
): StyledOptions<TCustomProps> => ({
|
|
6
|
+
shouldForwardProp: (propName: PropertyKey) => !keys.map((key) => key.toString()).includes(propName.toString()),
|
|
7
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tsconfig/vite-react/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2023",
|
|
5
|
+
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ES2022",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"allowImportingTsExtensions": false,
|
|
10
|
+
"verbatimModuleSyntax": false,
|
|
11
|
+
"moduleDetection": "force",
|
|
12
|
+
"noEmit": false,
|
|
13
|
+
"emitDeclarationOnly": false,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
"jsxImportSource": "@emotion/react",
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": false,
|
|
20
|
+
"noUnusedParameters": false,
|
|
21
|
+
"erasableSyntaxOnly": false,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noUncheckedSideEffectImports": true,
|
|
24
|
+
"outDir": "./dist",
|
|
25
|
+
"rootDir": "./src",
|
|
26
|
+
"incremental": true,
|
|
27
|
+
"composite": true,
|
|
28
|
+
"tsBuildInfoFile": "./tsconfig.layout.tsbuildinfo",
|
|
29
|
+
"baseUrl": ".",
|
|
30
|
+
"paths": {}
|
|
31
|
+
},
|
|
32
|
+
"include": ["src/**/*", "src/emotion.d.ts"],
|
|
33
|
+
"exclude": ["dist", "node_modules"]
|
|
34
|
+
}
|