goobs-frontend 0.8.8 → 0.8.9

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.
@@ -4,15 +4,10 @@ import React from 'react'
4
4
  import Grid2, { Grid2Props } from '@mui/material/Grid2'
5
5
  import { Box, useMediaQuery, useTheme } from '@mui/material'
6
6
 
7
- /** Defines the possible alignment options for grid content */
8
7
  export type Alignment = 'left' | 'center' | 'right' | 'inherit' | 'justify'
9
-
10
- /** Defines the possible border styles for grid cells */
11
8
  export type BorderProp = 'none' | 'solid'
9
+ export type WrapProp = 'nowrap' | 'wrap'
12
10
 
13
- /**
14
- * Configuration for individual columns within the grid
15
- */
16
11
  export interface columnconfig {
17
12
  row: number
18
13
  column: number
@@ -31,9 +26,6 @@ export interface columnconfig {
31
26
  computerwidth?: string
32
27
  }
33
28
 
34
- /**
35
- * Configuration for the overall grid
36
- */
37
29
  export interface gridconfig {
38
30
  gridname?: string
39
31
  alignment?: Alignment
@@ -45,18 +37,12 @@ export interface gridconfig {
45
37
  bordercolor?: string
46
38
  }
47
39
 
48
- /**
49
- * Props for the CustomGrid component
50
- */
51
40
  export interface CustomGridProps extends Grid2Props {
52
41
  gridconfig?: gridconfig
53
42
  columnconfig?: columnconfig[]
54
43
  cellconfig?: cellconfig
55
44
  }
56
45
 
57
- /**
58
- * Configuration for individual cells within the grid
59
- */
60
46
  export interface cellconfig {
61
47
  border?: BorderProp
62
48
  minHeight?: string
@@ -65,27 +51,22 @@ export interface cellconfig {
65
51
  mobilewidth?: string
66
52
  tabletwidth?: string
67
53
  computerwidth?: string
54
+ borderColor?: string
55
+ backgroundColor?: string
56
+ onClick?: () => void
57
+ wrap?: WrapProp
68
58
  }
69
59
 
70
- /**
71
- * CustomGrid component renders a customizable grid layout with configurable rows and columns.
72
- * It supports responsive design by adapting to different screen sizes (mobile, tablet, computer).
73
- *
74
- * @param props The props for the CustomGrid component.
75
- * @returns The rendered CustomGrid component.
76
- */
77
60
  const CustomGrid: React.FC<CustomGridProps> = ({
78
61
  gridconfig,
79
62
  columnconfig,
80
63
  cellconfig,
81
64
  ...rest
82
65
  }) => {
83
- // Extract grid configuration values
84
66
  const gridConfigValues = Array.isArray(gridconfig)
85
67
  ? gridconfig[0]
86
68
  : gridconfig
87
69
 
88
- // Determine grid justification based on alignment
89
70
  const gridJustifyContent =
90
71
  gridConfigValues?.alignment === 'left'
91
72
  ? 'flex-start'
@@ -93,7 +74,6 @@ const CustomGrid: React.FC<CustomGridProps> = ({
93
74
  ? 'flex-end'
94
75
  : 'center'
95
76
 
96
- // Set up responsive breakpoints
97
77
  const theme = useTheme()
98
78
  const isMobile = useMediaQuery(theme.breakpoints.between(0, 767))
99
79
  const isTablet = useMediaQuery(theme.breakpoints.between(768, 1023))
@@ -101,7 +81,6 @@ const CustomGrid: React.FC<CustomGridProps> = ({
101
81
 
102
82
  const minGridWidth = '300px'
103
83
 
104
- // Calculate the number of rows based on the columnconfig
105
84
  const rows = Math.max(...(columnconfig || []).map(c => c.row || 1))
106
85
 
107
86
  return (
@@ -110,21 +89,35 @@ const CustomGrid: React.FC<CustomGridProps> = ({
110
89
  display="flex"
111
90
  justifyContent={gridJustifyContent}
112
91
  minWidth={minGridWidth}
92
+ sx={{
93
+ borderSpacing: 0,
94
+ borderCollapse: 'collapse',
95
+ padding: 0,
96
+ margin: 0,
97
+ '& > *': {
98
+ border: 'none !important',
99
+ padding: 0,
100
+ margin: 0,
101
+ },
102
+ }}
113
103
  >
114
104
  <Box
115
- mt={gridConfigValues?.margintop || 0}
116
- mb={gridConfigValues?.marginbottom || 0}
117
- ml={gridConfigValues?.marginleft || 0}
118
- mr={gridConfigValues?.marginright || 0}
119
105
  width="100%"
120
106
  height="100%"
121
107
  display="flex"
122
108
  flexDirection="column"
123
- alignItems="center"
109
+ sx={{
110
+ padding: 0,
111
+ margin: 0,
112
+ '& > *': {
113
+ border: 'none !important',
114
+ padding: 0,
115
+ margin: 0,
116
+ },
117
+ }}
124
118
  {...rest}
125
119
  >
126
120
  {Array.from({ length: rows }).map((_, rowIndex) => {
127
- // Calculate the number of columns in the current row
128
121
  const columns = Math.max(
129
122
  ...(columnconfig || [])
130
123
  .filter(c => c.row === rowIndex + 1)
@@ -137,42 +130,50 @@ const CustomGrid: React.FC<CustomGridProps> = ({
137
130
  container
138
131
  alignItems="center"
139
132
  display="flex"
140
- justifyContent="center"
133
+ justifyContent="flex-start"
134
+ spacing={0}
141
135
  sx={{
142
- marginTop:
143
- rowIndex === 0 ? gridConfigValues?.margintop || 0 : 0,
144
- marginBottom:
145
- rowIndex === rows - 1
146
- ? gridConfigValues?.marginbottom || 0
147
- : 0,
148
- marginLeft: gridConfigValues?.marginleft || 0,
149
- marginRight: gridConfigValues?.marginright || 0,
150
136
  flexGrow: 1,
151
137
  width: '100%',
138
+ gap: 0,
139
+ padding: 0,
140
+ margin: 0,
141
+ border: 'none',
142
+ '& > *': {
143
+ border: 'none !important',
144
+ padding: 0,
145
+ margin: 0,
146
+ },
152
147
  }}
153
148
  >
154
149
  {Array.from({ length: columns }).map((_, columnIndex) => {
155
- // Get the current column configuration
156
150
  const currentColumnConfig = (columnconfig || []).find(
157
151
  c => c.row === rowIndex + 1 && c.column === columnIndex + 1
158
152
  )
159
153
 
160
- // Determine the column width based on screen size
161
- const columnWidth = isMobile
162
- ? currentColumnConfig?.mobilewidth ||
163
- currentColumnConfig?.columnwidth ||
164
- `${100 / columns}%`
165
- : isTablet
166
- ? currentColumnConfig?.tabletwidth ||
154
+ const currentCellConfig =
155
+ currentColumnConfig?.cellconfig || cellconfig
156
+
157
+ const shouldWrap = currentCellConfig?.wrap !== 'nowrap'
158
+
159
+ const hasFixedWidth = currentCellConfig?.width !== undefined
160
+ const columnWidth = hasFixedWidth
161
+ ? currentCellConfig.width
162
+ : isMobile
163
+ ? currentColumnConfig?.mobilewidth ||
167
164
  currentColumnConfig?.columnwidth ||
168
165
  `${100 / columns}%`
169
- : isComputer
170
- ? currentColumnConfig?.computerwidth ||
166
+ : isTablet
167
+ ? currentColumnConfig?.tabletwidth ||
171
168
  currentColumnConfig?.columnwidth ||
172
169
  `${100 / columns}%`
173
- : currentColumnConfig?.columnwidth || `${100 / columns}%`
170
+ : isComputer
171
+ ? currentColumnConfig?.computerwidth ||
172
+ currentColumnConfig?.columnwidth ||
173
+ `${100 / columns}%`
174
+ : currentColumnConfig?.columnwidth ||
175
+ `${100 / columns}%`
174
176
 
175
- // Determine justification of column content
176
177
  const justifyContent =
177
178
  currentColumnConfig?.alignment === 'left'
178
179
  ? 'flex-start'
@@ -180,71 +181,52 @@ const CustomGrid: React.FC<CustomGridProps> = ({
180
181
  ? 'flex-end'
181
182
  : 'center'
182
183
 
183
- // Get current cell configuration
184
- const currentCellConfig =
185
- currentColumnConfig?.cellconfig || cellconfig
186
-
187
- // Determine if cell has a border
188
- const hasBorder = currentCellConfig?.border === 'solid'
189
-
190
- // Determine cell width and responsive widths
191
- const cellWidth = currentCellConfig?.width || '100%'
192
- const mobileWidth = currentCellConfig?.mobilewidth || '100%'
193
- const tabletWidth = currentCellConfig?.tabletwidth || '100%'
194
- const computerWidth = currentCellConfig?.computerwidth || '100%'
195
-
196
184
  return (
197
185
  <Grid2
198
186
  key={`column-${columnIndex}`}
199
187
  sx={{
200
188
  display: 'flex',
201
189
  justifyContent,
202
- marginRight: currentColumnConfig?.marginright || 0,
203
- marginLeft: currentColumnConfig?.marginleft || 0,
204
- marginTop: currentColumnConfig?.margintop || 0,
205
- marginBottom: currentColumnConfig?.marginbottom || 0,
206
190
  width: columnWidth,
207
- '--Grid-borderWidth': hasBorder ? '1px' : '0',
208
- borderTop: hasBorder
209
- ? 'var(--Grid-borderWidth) solid'
210
- : 'none',
211
- borderLeft: hasBorder
212
- ? 'var(--Grid-borderWidth) solid'
213
- : 'none',
214
- borderColor: 'divider',
191
+ position: 'relative',
192
+ flexGrow: hasFixedWidth ? 0 : 1,
193
+ flexShrink: hasFixedWidth ? 0 : 1,
194
+ flexBasis: hasFixedWidth ? columnWidth : 'auto',
195
+ padding: 0,
196
+ margin: 0,
197
+ border: 'none',
198
+ '& > *': {
199
+ border: 'none !important',
200
+ padding: 0,
201
+ margin: 0,
202
+ },
215
203
  }}
216
204
  >
217
205
  <Box
206
+ onClick={currentCellConfig?.onClick}
218
207
  sx={{
219
- borderRight: hasBorder
220
- ? 'var(--Grid-borderWidth) solid'
221
- : 'none',
222
- borderBottom: hasBorder
223
- ? 'var(--Grid-borderWidth) solid'
224
- : 'none',
225
- borderColor: 'divider',
208
+ backgroundColor: currentCellConfig?.backgroundColor,
226
209
  minHeight: currentCellConfig?.minHeight || 'auto',
227
210
  maxHeight: currentCellConfig?.maxHeight || 'none',
228
211
  height: currentCellConfig?.maxHeight || 'auto',
229
212
  display: 'flex',
230
213
  alignItems: 'center',
231
214
  justifyContent,
232
- overflow: 'auto',
233
- width: cellWidth,
234
- minWidth: isMobile
235
- ? mobileWidth
236
- : isTablet
237
- ? tabletWidth
238
- : isComputer
239
- ? computerWidth
240
- : '100%',
241
- maxWidth: isMobile
242
- ? mobileWidth
243
- : isTablet
244
- ? tabletWidth
245
- : isComputer
246
- ? computerWidth
247
- : '100%',
215
+ overflow: 'hidden',
216
+ width: '100%',
217
+ position: 'relative',
218
+ zIndex: currentCellConfig?.backgroundColor ? 1 : 0,
219
+ flexGrow: 1,
220
+ padding: 0,
221
+ margin: 0,
222
+ boxSizing: 'border-box',
223
+ whiteSpace: shouldWrap ? 'normal' : 'nowrap',
224
+ textOverflow: shouldWrap ? 'clip' : 'ellipsis',
225
+ border: 'none',
226
+ outline: 'none',
227
+ '&::before, &::after': {
228
+ display: 'none',
229
+ },
248
230
  }}
249
231
  >
250
232
  {React.isValidElement(currentColumnConfig?.component)
@@ -380,17 +380,21 @@ function VerticalVariant({
380
380
  </Box>
381
381
  )}
382
382
  {(showDropdown || showSearchbar) && (
383
- <Stack mt={1} spacing={1}>
383
+ <Stack mt={2} spacing={1}>
384
384
  {showDropdown && (
385
- <Dropdown
386
- label={dropdownLabel}
387
- options={navOptions}
388
- backgroundcolor={white.main}
389
- outlinecolor="none"
390
- fontcolor={black.main}
391
- shrunkfontcolor={white.main}
392
- onChange={handleDropdownChange}
393
- />
385
+ <Box mt="2px">
386
+ <Dropdown
387
+ label={dropdownLabel}
388
+ options={navOptions}
389
+ backgroundcolor={white.main}
390
+ outlinecolor="none"
391
+ fontcolor={black.main}
392
+ shrunkfontcolor={white.main}
393
+ unshrunkfontcolor={black.main}
394
+ shrunklabelposition="aboveNotch"
395
+ onChange={handleDropdownChange}
396
+ />
397
+ </Box>
394
398
  )}
395
399
  {showSearchbar && (
396
400
  <Searchbar
@@ -15,11 +15,18 @@ export interface ToolbarProps {
15
15
  buttons?: CustomButtonProps[]
16
16
  dropdowns?: DropdownProps[]
17
17
  searchbarProps?: Partial<SearchbarProps>
18
+ middleComponent?: React.ReactNode
18
19
  }
19
20
 
20
- function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
21
+ function CustomToolbar({
22
+ buttons,
23
+ dropdowns,
24
+ searchbarProps,
25
+ middleComponent,
26
+ }: ToolbarProps) {
21
27
  const [checkboxWidth] = useState(45)
22
- const toolbarHeight = 45
28
+ const toolbarHeight = 60
29
+ const buttonHeight = '45px'
23
30
 
24
31
  return (
25
32
  <Box
@@ -29,7 +36,7 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
29
36
  display: 'flex',
30
37
  flexDirection: 'row',
31
38
  justifyContent: 'flex-start',
32
- alignItems: 'stretch',
39
+ alignItems: 'center',
33
40
  height: `${toolbarHeight}px`,
34
41
  width: '100%',
35
42
  }}
@@ -39,7 +46,7 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
39
46
  sx={{
40
47
  display: 'flex',
41
48
  flexDirection: 'row',
42
- alignItems: 'stretch',
49
+ alignItems: 'center',
43
50
  height: '100%',
44
51
  }}
45
52
  >
@@ -58,8 +65,7 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
58
65
  <Box
59
66
  sx={{
60
67
  display: 'flex',
61
- alignItems: 'flex-end', // Changed from center to flex-end
62
- paddingBottom: '13px', // Added padding to align with other elements
68
+ alignItems: 'center',
63
69
  gap: '10px',
64
70
  height: '100%',
65
71
  padding: '0 15px',
@@ -75,6 +81,7 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
75
81
  fontvariant="merriparagraph"
76
82
  variant="contained"
77
83
  onClick={button.onClick}
84
+ height={buttonHeight}
78
85
  />
79
86
  ))}
80
87
  </Box>
@@ -104,6 +111,20 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
104
111
  />
105
112
  </Box>
106
113
 
114
+ {/* Middle component section */}
115
+ {middleComponent && (
116
+ <Box
117
+ sx={{
118
+ display: 'flex',
119
+ alignItems: 'center',
120
+ height: '100%',
121
+ padding: '0 15px',
122
+ }}
123
+ >
124
+ {middleComponent}
125
+ </Box>
126
+ )}
127
+
107
128
  {/* Spacer to push dropdowns to the right */}
108
129
  <Box sx={{ flexGrow: 1 }} />
109
130
 
@@ -112,8 +133,7 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
112
133
  <Box
113
134
  sx={{
114
135
  display: 'flex',
115
- alignItems: 'flex-end', // Changed from center to flex-end
116
- paddingBottom: '13px', // Added padding to align with other elements
136
+ alignItems: 'center',
117
137
  height: '100%',
118
138
  padding: '0 15px',
119
139
  gap: '10px',
@@ -4,7 +4,7 @@ import {
4
4
  Typography as MuiTypography,
5
5
  TypographyProps as MuiTypographyProps,
6
6
  } from '@mui/material'
7
- import React from 'react'
7
+ import React, { JSX } from 'react'
8
8
 
9
9
  export type FontFamily = 'arapey' | 'inter' | 'merri'
10
10
 
@@ -26,6 +26,7 @@ export interface TypographyProps extends Omit<MuiTypographyProps, 'variant'> {
26
26
  fontvariant?: CustomTypographyVariant
27
27
  fontcolor?: string
28
28
  variant?: CustomTypographyVariant | MuiTypographyProps['variant']
29
+ children?: React.ReactNode
29
30
  }
30
31
 
31
32
  const arapeyStyles: Record<TypographyVariant, React.CSSProperties> = {
@@ -199,13 +200,14 @@ const merriStyles: Record<TypographyVariant, React.CSSProperties> = {
199
200
  },
200
201
  }
201
202
 
202
- export const Typography: React.FC<TypographyProps> = ({
203
+ const Typography = ({
203
204
  text,
204
205
  fontcolor,
205
206
  fontvariant,
206
207
  variant,
208
+ children,
207
209
  ...rest
208
- }) => {
210
+ }: TypographyProps): JSX.Element => {
209
211
  let variantStyle: React.CSSProperties = {}
210
212
  const actualVariant = fontvariant || variant
211
213
 
@@ -238,6 +240,7 @@ export const Typography: React.FC<TypographyProps> = ({
238
240
 
239
241
  return (
240
242
  <MuiTypography
243
+ component="span"
241
244
  style={{
242
245
  color: fontcolor,
243
246
  ...variantStyle,
@@ -245,9 +248,10 @@ export const Typography: React.FC<TypographyProps> = ({
245
248
  variant={actualVariant as MuiTypographyProps['variant']}
246
249
  {...rest}
247
250
  >
248
- {text}
251
+ {text || children}
249
252
  </MuiTypography>
250
253
  )
251
254
  }
252
255
 
256
+ export { Typography }
253
257
  export default Typography