goobs-frontend 0.7.59 → 0.7.61

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.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goobs-frontend",
3
- "version": "0.7.59",
3
+ "version": "0.7.61",
4
4
  "description": "A comprehensive React-based UI library built on Material-UI, offering a wide range of customizable components including grids, typography, buttons, cards, forms, navigation, pricing tables, steppers, tooltips, accordions, and more. Designed for building responsive and consistent user interfaces with advanced features like form validation, theming, and code syntax highlighting.",
5
5
  "license": "MIT",
6
6
  "main": "./src/index.ts",
@@ -28,7 +28,7 @@
28
28
  "@mui/icons-material": "^5.16.0",
29
29
  "@mui/material": "^5.16.0",
30
30
  "@types/lodash": "^4.17.6",
31
- "goobs-cache": "^1.3.1",
31
+ "goobs-cache": "^1.3.2",
32
32
  "highlight.js": "^11.10.0",
33
33
  "lodash": "^4.17.21",
34
34
  "next": "14.2.5"
@@ -82,7 +82,7 @@ const ConfirmationCodeInputs: React.FC<ConfirmationCodeInputsProps> = ({
82
82
  'verificationCode',
83
83
  combinedCode,
84
84
  new Date(Date.now() + 3600000),
85
- 'memory'
85
+ 'client'
86
86
  )
87
87
  }
88
88
  }, [combinedCode, isValid])
@@ -55,11 +55,12 @@ const useLink = (grid: {
55
55
  ...cellconfig,
56
56
  },
57
57
  component: (
58
- <Link key={`link-${index}`} href={link} passHref {...restProps}>
58
+ <Link key={`link-${index}`} href={link} passHref>
59
59
  <Typography
60
60
  text={text}
61
61
  fontvariant={fontvariant}
62
62
  fontcolor={fontcolor}
63
+ {...restProps}
63
64
  />
64
65
  </Link>
65
66
  ),
@@ -1,89 +1,42 @@
1
1
  'use client'
2
2
  import React, { useState, useEffect } from 'react'
3
- import { Box, Tabs, styled, Tab } from '@mui/material'
3
+ import { Box, Tabs, Tab } from '@mui/material'
4
4
  import { get, set, JSONValue } from 'goobs-cache'
5
5
  import { NavProps, SubNav, View } from '../index'
6
6
 
7
- // Define the possible alignment values for the navigation
7
+ /**
8
+ * Represents the possible alignment options for the horizontal navigation.
9
+ */
8
10
  type Alignment = 'left' | 'center' | 'right' | 'inherit' | 'justify'
9
11
 
10
12
  /**
11
- * Interface representing the active tab value
13
+ * Represents the structure of an active tab value.
12
14
  */
13
15
  export interface ActiveTabValue {
16
+ /** The unique identifier of the active tab. */
14
17
  tabId: string
15
18
  }
16
19
 
17
20
  /**
18
- * Interface for the props of the HorizontalVariant component
21
+ * Props for the HorizontalVariant component.
19
22
  */
20
23
  export interface HorizontalVariantProps {
21
- items: (NavProps | SubNav | View)[] // Array of navigation items
22
- height?: string // Optional height of the navigation
23
- alignment?: Alignment // Optional alignment of the navigation
24
- navname?: string // Optional name for the navigation
25
- }
26
-
27
- /**
28
- * Styled component for the Tab, extending MUI's Tab with custom props
29
- */
30
- const StyledTab = styled(Tab, {
31
- shouldForwardProp: prop =>
32
- prop !== 'height' && prop !== 'hasleftborder' && prop !== 'hasrightborder',
33
- })<NavProps & { height?: string }>(
34
- ({ height = '80px', hasleftborder = 'false', hasrightborder = 'false' }) => ({
35
- minHeight: 0,
36
- textTransform: 'none',
37
- border: 'none',
38
- boxSizing: 'border-box',
39
- backgroundColor: 'black',
40
- color: '#fff',
41
- fontWeight: 500,
42
- fontFamily: 'Merriweather',
43
- fontSize: 16,
44
- height: height,
45
- '&:hover': {
46
- backgroundColor: 'rgba(255, 255, 255, 0.1)',
47
- },
48
- '& .MuiTouchRipple-root': {
49
- color: '#fff',
50
- },
51
- '&.Mui-selected': {
52
- color: '#fff',
53
- backgroundColor: 'rgba(255, 255, 255, 0.2)',
54
- },
55
- '& .MuiSvgIcon-root': {
56
- color: '#fff',
57
- },
58
- ...(hasleftborder === 'true' && {
59
- borderLeft: '1px solid white',
60
- }),
61
- ...(hasrightborder === 'true' && {
62
- borderRight: '1px solid white',
63
- }),
64
- })
65
- )
66
-
67
- /**
68
- * Styled component for the horizontal navigation container
69
- */
70
- const HorizontalNavContainer = styled(Box)<{
24
+ /** An array of navigation items, sub-navigation items, or views. */
25
+ items: (NavProps | SubNav | View)[]
26
+ /** The height of the navigation bar. Defaults to '80px'. */
71
27
  height?: string
28
+ /** The alignment of the navigation items. Defaults to 'left'. */
72
29
  alignment?: Alignment
73
- }>(({ height = '80px', alignment = 'left' }) => ({
74
- flexGrow: 1,
75
- bgcolor: 'black',
76
- display: 'flex',
77
- height: height,
78
- justifyContent: alignment,
79
- paddingLeft: '5px',
80
- paddingRight: '5px',
81
- }))
30
+ /** A unique name for this navigation component. Used for state management. */
31
+ navname?: string
32
+ }
82
33
 
83
34
  /**
84
- * HorizontalVariant component for rendering a horizontal navigation bar
85
- * @param {HorizontalVariantProps} props - The props for the component
86
- * @returns {JSX.Element} The rendered HorizontalVariant component
35
+ * HorizontalVariant component that renders a horizontal navigation bar.
36
+ * It supports dynamic tab management, routing, and custom click handlers.
37
+ *
38
+ * @param {HorizontalVariantProps} props - The props for the HorizontalVariant component.
39
+ * @returns {JSX.Element} The rendered HorizontalVariant component.
87
40
  */
88
41
  function HorizontalVariant({
89
42
  items,
@@ -91,13 +44,20 @@ function HorizontalVariant({
91
44
  alignment = 'left',
92
45
  navname,
93
46
  }: HorizontalVariantProps) {
94
- // State to store active tab values
47
+ /**
48
+ * State to keep track of active tab values for different navigation components.
49
+ */
95
50
  const [activeTabValues, setActiveTabValues] = useState<
96
51
  Record<string, ActiveTabValue | null>
97
52
  >({})
98
53
 
99
- // Effect to fetch active tab values from cache on component mount
54
+ /**
55
+ * Effect hook to fetch and set the active tab values when the component mounts.
56
+ */
100
57
  useEffect(() => {
58
+ /**
59
+ * Asynchronously fetches the active tab values from the cache.
60
+ */
101
61
  const fetchActiveTabValues = async () => {
102
62
  const result = await get('activeTabValues', 'client')
103
63
  if (result && typeof result === 'object' && 'value' in result) {
@@ -111,9 +71,11 @@ function HorizontalVariant({
111
71
  }, [])
112
72
 
113
73
  /**
114
- * Handle tab change event
115
- * @param {React.SyntheticEvent} event - The event object
116
- * @param {string} newValue - The new value of the selected tab
74
+ * Handles tab change events.
75
+ * Updates the active tab values in the state and cache.
76
+ *
77
+ * @param {React.SyntheticEvent} event - The event object.
78
+ * @param {string} newValue - The new value of the selected tab.
117
79
  */
118
80
  const handleTabChange = async (
119
81
  event: React.SyntheticEvent,
@@ -124,7 +86,6 @@ function HorizontalVariant({
124
86
  [navname ?? '']: { tabId: newValue },
125
87
  }
126
88
  setActiveTabValues(updatedActiveTabValues)
127
- // Store updated values in cache with 30 minutes expiration
128
89
  await set(
129
90
  'activeTabValues',
130
91
  { type: 'json', value: updatedActiveTabValues } as JSONValue,
@@ -134,8 +95,10 @@ function HorizontalVariant({
134
95
  }
135
96
 
136
97
  /**
137
- * Handle tab click event based on the tab's trigger type
138
- * @param {NavProps} tab - The tab object that was clicked
98
+ * Handles click events on individual tabs.
99
+ * Supports different trigger types: route, onClick, and routeonhorizontal.
100
+ *
101
+ * @param {NavProps} tab - The tab object that was clicked.
139
102
  */
140
103
  const handleTabClick = (tab: NavProps) => {
141
104
  if (tab.trigger === 'route') {
@@ -154,9 +117,19 @@ function HorizontalVariant({
154
117
  }
155
118
 
156
119
  return (
157
- <HorizontalNavContainer height={height} alignment={alignment}>
120
+ <Box
121
+ sx={{
122
+ flexGrow: 1,
123
+ bgcolor: 'black',
124
+ display: 'flex',
125
+ height: height,
126
+ justifyContent: alignment,
127
+ paddingLeft: '5px',
128
+ paddingRight: '5px',
129
+ }}
130
+ >
158
131
  <Tabs
159
- value={activeTabValues[navname ?? '']?.tabId || false}
132
+ value={activeTabValues?.[navname ?? '']?.tabId || false}
160
133
  onChange={handleTabChange}
161
134
  aria-label="nav tabs"
162
135
  sx={{
@@ -171,35 +144,56 @@ function HorizontalVariant({
171
144
  }}
172
145
  >
173
146
  {items.map((item: NavProps | SubNav | View) => {
174
- // Only render NavProps items as tabs
175
147
  if ('orientation' in item) {
176
148
  const tab = item as NavProps
177
149
  return (
178
- <StyledTab
150
+ <Tab
179
151
  key={tab.title}
180
152
  value={tab.title}
181
153
  label={tab.title}
182
- hasleftborder={tab.hasleftborder}
183
- hasrightborder={tab.hasrightborder}
184
- height={height}
185
- orientation={tab.orientation}
154
+ onClick={() => handleTabClick(tab)}
186
155
  sx={{
156
+ minHeight: 0,
157
+ textTransform: 'none',
158
+ border: 'none',
159
+ boxSizing: 'border-box',
160
+ backgroundColor: 'black',
161
+ color: '#fff',
162
+ fontWeight: 500,
163
+ fontFamily: 'Merriweather',
164
+ fontSize: 16,
165
+ height: height,
166
+ '&:hover': {
167
+ backgroundColor: 'rgba(255, 255, 255, 0.1)',
168
+ },
169
+ '& .MuiTouchRipple-root': {
170
+ color: '#fff',
171
+ },
172
+ '&.Mui-selected': {
173
+ color: '#fff',
174
+ backgroundColor: 'rgba(255, 255, 255, 0.2)',
175
+ },
176
+ '& .MuiSvgIcon-root': {
177
+ color: '#fff',
178
+ },
179
+ ...(tab.hasleftborder === 'true' && {
180
+ borderLeft: '1px solid white',
181
+ }),
182
+ ...(tab.hasrightborder === 'true' && {
183
+ borderRight: '1px solid white',
184
+ }),
187
185
  width: 'auto',
188
186
  justifyContent: 'center',
189
187
  alignItems: 'center',
190
188
  px: 4,
191
189
  }}
192
- onClick={() => handleTabClick(tab)}
193
- title={tab.title}
194
- route={tab.route}
195
- navname={tab.navname}
196
190
  />
197
191
  )
198
192
  }
199
193
  return null
200
194
  })}
201
195
  </Tabs>
202
- </HorizontalNavContainer>
196
+ </Box>
203
197
  )
204
198
  }
205
199
 
@@ -4,7 +4,6 @@ import React from 'react'
4
4
  import {
5
5
  Drawer,
6
6
  Box,
7
- Typography,
8
7
  Stack,
9
8
  Divider,
10
9
  MenuItem,
@@ -24,32 +23,48 @@ import {
24
23
  ocean,
25
24
  semiTransparentWhite,
26
25
  } from '../../../styles/palette'
26
+ import { Typography } from './../../Typography'
27
27
 
28
28
  /**
29
- * Interface for the props of the VerticalVariant component
29
+ * Props for the VerticalVariant component.
30
30
  */
31
31
  export interface VerticalVariantProps {
32
- items: (NavProps | SubNav | View)[] // Array of navigation items
33
- showSearchbar: boolean // Flag to show/hide search bar
34
- showDropdown: boolean // Flag to show/hide dropdown
35
- showTitle: boolean // Flag to show/hide title
36
- showLine: boolean // Flag to show/hide divider line
37
- verticalNavTitle: string // Title for the vertical navigation
38
- dropdownLabel: string // Label for the dropdown
39
- searchbarLabel: string // Label for the search bar
40
- anchor: 'left' | 'right' // Position of the drawer
41
- expandedNavs: string[] // Array of expanded navigation items
42
- setExpandedNavs: React.Dispatch<React.SetStateAction<string[]>> // Function to set expanded navs
43
- expandedSubnavs: string[] // Array of expanded subnavigation items
44
- setExpandedSubnavs: React.Dispatch<React.SetStateAction<string[]>> // Function to set expanded subnavs
45
- verticalNavWidth: string // Width of the vertical navigation
46
- selectedNav?: string // Currently selected navigation item
32
+ /** An array of navigation items, sub-navigation items, or views. */
33
+ items: (NavProps | SubNav | View)[]
34
+ /** Determines whether to show the search bar. */
35
+ showSearchbar: boolean
36
+ /** Determines whether to show the dropdown. */
37
+ showDropdown: boolean
38
+ /** Determines whether to show the title. */
39
+ showTitle: boolean
40
+ /** Determines whether to show a divider line. */
41
+ showLine: boolean
42
+ /** The title of the vertical navigation. */
43
+ verticalNavTitle: string
44
+ /** The label for the dropdown. */
45
+ dropdownLabel: string
46
+ /** The label for the search bar. */
47
+ searchbarLabel: string
48
+ /** The anchor position of the drawer ('left' or 'right'). */
49
+ anchor: 'left' | 'right'
50
+ /** An array of expanded navigation items. */
51
+ expandedNavs: string[]
52
+ /** Function to set the expanded navigation items. */
53
+ setExpandedNavs: React.Dispatch<React.SetStateAction<string[]>>
54
+ /** An array of expanded sub-navigation items. */
55
+ expandedSubnavs: string[]
56
+ /** Function to set the expanded sub-navigation items. */
57
+ setExpandedSubnavs: React.Dispatch<React.SetStateAction<string[]>>
58
+ /** The width of the vertical navigation drawer. */
59
+ verticalNavWidth: string
47
60
  }
48
61
 
49
62
  /**
50
- * VerticalVariant component for rendering a vertical navigation drawer
51
- * @param {VerticalVariantProps} props - The props for the component
52
- * @returns {JSX.Element} The rendered VerticalVariant component
63
+ * VerticalVariant component that renders a vertical navigation drawer.
64
+ * It supports nested navigation items, sub-navigation items, and views.
65
+ *
66
+ * @param {VerticalVariantProps} props - The props for the VerticalVariant component.
67
+ * @returns {JSX.Element} The rendered VerticalVariant component.
53
68
  */
54
69
  function VerticalVariant({
55
70
  items,
@@ -66,29 +81,21 @@ function VerticalVariant({
66
81
  expandedSubnavs,
67
82
  setExpandedSubnavs,
68
83
  verticalNavWidth,
69
- selectedNav,
70
84
  }: VerticalVariantProps) {
71
85
  const router = useRouter()
72
86
 
73
- // Filter and map navigation options for the dropdown
87
+ /**
88
+ * Extracts navigation options from the items array.
89
+ */
74
90
  const navOptions = items
75
91
  .filter((item): item is NavProps => 'title' in item && 'subnavs' in item)
76
92
  .map(nav => nav.title ?? '')
77
93
 
78
94
  /**
79
- * Handle dropdown change event
80
- * @param {React.ChangeEvent<{ value: unknown }>} event - The change event
81
- */
82
- const handleDropdownChange = (
83
- event: React.ChangeEvent<{ value: unknown }>
84
- ) => {
85
- const selectedOption = event.target.value as string
86
- console.log('handleDropdownChange - selectedOption:', selectedOption)
87
- }
88
-
89
- /**
90
- * Handle navigation item click event
91
- * @param {NavProps} nav - The clicked navigation item
95
+ * Handles click events on navigation items.
96
+ * Supports different trigger types: route and onClick.
97
+ *
98
+ * @param {NavProps} nav - The navigation item that was clicked.
92
99
  */
93
100
  const handleNavClick = (nav: NavProps) => {
94
101
  console.log('Clicked Nav:', nav.title)
@@ -104,11 +111,12 @@ function VerticalVariant({
104
111
  }
105
112
 
106
113
  /**
107
- * Render a navigation item (NavProps, SubNav, or View)
108
- * @param {NavProps | SubNav | View} item - The item to render
109
- * @param {number} level - The nesting level of the item
110
- * @param {string} activeAndHoverColor - The color for active and hover states
111
- * @returns {JSX.Element | null} The rendered item
114
+ * Recursively renders navigation items, sub-navigation items, and views.
115
+ *
116
+ * @param {NavProps | SubNav | View} item - The item to render.
117
+ * @param {number} level - The nesting level of the item.
118
+ * @param {string} [activeAndHoverColor] - The color to use for active and hover states.
119
+ * @returns {JSX.Element | null} The rendered item or null if the item type is not recognized.
112
120
  */
113
121
  const renderItem = (
114
122
  item: NavProps | SubNav | View,
@@ -116,7 +124,6 @@ function VerticalVariant({
116
124
  activeAndHoverColor = semiTransparentWhite.main
117
125
  ) => {
118
126
  if ('title' in item && 'subnavs' in item) {
119
- // Render NavProps item
120
127
  const nav = item as NavProps
121
128
  const isExpanded = expandedNavs.includes(nav.title ?? '')
122
129
  return (
@@ -180,15 +187,12 @@ function VerticalVariant({
180
187
  }}
181
188
  onClick={() => handleNavClick(nav)}
182
189
  >
183
- {nav.trigger === 'route' || nav.trigger === 'onClick' ? (
184
- <Typography variant="merrih5" color={white.main} pl={4 * level}>
185
- {nav.title}
186
- </Typography>
187
- ) : (
188
- <Typography variant="merrih5" color={white.main} pl={4 * level}>
189
- {nav.title}
190
- </Typography>
191
- )}
190
+ <Typography
191
+ fontvariant="merrih5"
192
+ fontcolor={white.main}
193
+ text={nav.title ?? ''}
194
+ marginLeft={4 * level}
195
+ />
192
196
  </AccordionSummary>
193
197
  <AccordionDetails sx={{ border: 'none', p: 0 }}>
194
198
  <List sx={{ py: 0 }}>
@@ -200,7 +204,6 @@ function VerticalVariant({
200
204
  </MuiAccordion>
201
205
  )
202
206
  } else if ('title' in item && 'views' in item) {
203
- // Render SubNav item
204
207
  const subnav = item as SubNav
205
208
  const isExpanded = expandedSubnavs.includes(subnav.title ?? '')
206
209
  if (subnav.views?.length === 0) {
@@ -225,7 +228,11 @@ function VerticalVariant({
225
228
  },
226
229
  }}
227
230
  >
228
- <Typography variant="merrih6">{subnav.title}</Typography>
231
+ <Typography
232
+ fontvariant="merrih6"
233
+ text={subnav.title ?? ''}
234
+ fontcolor={white.main}
235
+ />
229
236
  </MenuItem>
230
237
  </Link>
231
238
  )
@@ -290,9 +297,12 @@ function VerticalVariant({
290
297
  },
291
298
  }}
292
299
  >
293
- <Typography variant="merrih6" color={white.main} pl={4}>
294
- {subnav.title}
295
- </Typography>
300
+ <Typography
301
+ fontvariant="merrih6"
302
+ fontcolor={white.main}
303
+ text={subnav.title ?? ''}
304
+ marginLeft={4}
305
+ />
296
306
  </AccordionSummary>
297
307
  <AccordionDetails sx={{ border: 'none', p: 0 }}>
298
308
  <List sx={{ py: 0 }}>
@@ -305,7 +315,6 @@ function VerticalVariant({
305
315
  )
306
316
  }
307
317
  } else if ('title' in item && 'route' in item) {
308
- // Render View item
309
318
  const view = item as View
310
319
  return (
311
320
  <Link
@@ -328,7 +337,11 @@ function VerticalVariant({
328
337
  },
329
338
  }}
330
339
  >
331
- <Typography variant="merriparagraph">{view.title}</Typography>
340
+ <Typography
341
+ fontvariant="merriparagraph"
342
+ text={view.title ?? ''}
343
+ fontcolor={white.main}
344
+ />
332
345
  </MenuItem>
333
346
  </Link>
334
347
  )
@@ -359,7 +372,6 @@ function VerticalVariant({
359
372
  // @ts-ignore
360
373
  px={`15px`}
361
374
  >
362
- {/* Render title if showTitle is true */}
363
375
  {showTitle && (
364
376
  <Box pt="0px" pb="0px">
365
377
  <Link
@@ -367,13 +379,14 @@ function VerticalVariant({
367
379
  passHref
368
380
  style={{ textDecoration: 'none' }}
369
381
  >
370
- <Typography variant="merrih4" color={white.main}>
371
- {verticalNavTitle}
372
- </Typography>
382
+ <Typography
383
+ fontvariant="merrih4"
384
+ fontcolor={white.main}
385
+ text={verticalNavTitle}
386
+ />
373
387
  </Link>
374
388
  </Box>
375
389
  )}
376
- {/* Render dropdown and searchbar if either showDropdown or showSearchbar is true */}
377
390
  {(showDropdown || showSearchbar) && (
378
391
  <Stack mt={1} spacing={1}>
379
392
  {showDropdown && (
@@ -382,8 +395,6 @@ function VerticalVariant({
382
395
  componentvariant="dropdown"
383
396
  outlinecolor="none"
384
397
  options={navOptions}
385
- value={selectedNav || navOptions[0]}
386
- onChange={handleDropdownChange}
387
398
  backgroundcolor={white.main}
388
399
  shrunklabellocation="above"
389
400
  shrunkfontcolor={white.main}
@@ -404,7 +415,6 @@ function VerticalVariant({
404
415
  </Stack>
405
416
  )}
406
417
  </Box>
407
- {/* Render divider line if showLine is true */}
408
418
  {showLine && (
409
419
  <Divider
410
420
  sx={{
@@ -414,7 +424,6 @@ function VerticalVariant({
414
424
  }}
415
425
  />
416
426
  )}
417
- {/* Render navigation items */}
418
427
  {items.map(item => renderItem(item, 0))}
419
428
  </Drawer>
420
429
  )