goobs-frontend 0.7.53

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/package.json +122 -0
  4. package/src/app/_app.tsx +8 -0
  5. package/src/atoms/helperfooter.ts +21 -0
  6. package/src/components/Button/index.tsx +241 -0
  7. package/src/components/ConfirmationCodeInput/index.tsx +108 -0
  8. package/src/components/ConfirmationCodeInput/utils/useCodeConfirmation.tsx +129 -0
  9. package/src/components/Content/Structure/animations.tsx +106 -0
  10. package/src/components/Content/Structure/button/useButton.tsx +80 -0
  11. package/src/components/Content/Structure/confirmationinput/useConfirmationInput.tsx +56 -0
  12. package/src/components/Content/Structure/image/useImage.tsx +62 -0
  13. package/src/components/Content/Structure/link/useLink.tsx +60 -0
  14. package/src/components/Content/Structure/radiogroup/useGridRadioGroup.tsx +62 -0
  15. package/src/components/Content/Structure/styledcomponent/useStyledComponent.tsx +96 -0
  16. package/src/components/Content/Structure/typography/useGridTypography.tsx +53 -0
  17. package/src/components/Content/index.tsx +147 -0
  18. package/src/components/Form/Popup/index.tsx +121 -0
  19. package/src/components/Grid/defaultconfig.tsx +131 -0
  20. package/src/components/Grid/index.tsx +265 -0
  21. package/src/components/Icons/Calendar.tsx +21 -0
  22. package/src/components/Icons/DownArrowFilled.tsx +9 -0
  23. package/src/components/Icons/Drag.tsx +9 -0
  24. package/src/components/Icons/FavoriteIcon.tsx +24 -0
  25. package/src/components/Icons/Info.tsx +12 -0
  26. package/src/components/Icons/Search.tsx +29 -0
  27. package/src/components/Icons/ShowHideEye.tsx +16 -0
  28. package/src/components/RadioGroup/index.tsx +96 -0
  29. package/src/components/StyledComponent/adornments.tsx +118 -0
  30. package/src/components/StyledComponent/helperfooter/useHelperFooter.tsx +411 -0
  31. package/src/components/StyledComponent/hooks/useDropdown.tsx +144 -0
  32. package/src/components/StyledComponent/hooks/usePassword.tsx +23 -0
  33. package/src/components/StyledComponent/hooks/usePhoneNumber.tsx +75 -0
  34. package/src/components/StyledComponent/hooks/useSearchbar.tsx +44 -0
  35. package/src/components/StyledComponent/hooks/useSplitButton.tsx +66 -0
  36. package/src/components/StyledComponent/index.tsx +404 -0
  37. package/src/components/Typography/index.tsx +268 -0
  38. package/src/index.ts +210 -0
  39. package/src/main.tsx +7 -0
  40. package/src/styles/Form/index.ts +7 -0
  41. package/src/styles/StyledComponent/Label/index.ts +76 -0
  42. package/src/styles/palette.ts +143 -0
  43. package/src/styles/typography.ts +184 -0
  44. package/src/types/async-lock.d.ts +35 -0
@@ -0,0 +1,265 @@
1
+ 'use client'
2
+
3
+ import React from 'react'
4
+ import { Grid, Box, GridProps, useMediaQuery, useTheme } from '@mui/material'
5
+
6
+ export type Alignment = 'left' | 'center' | 'right' | 'inherit' | 'justify'
7
+ export type BorderProp = 'none' | 'solid'
8
+
9
+ export interface columnconfig {
10
+ row?: number
11
+ column?: number
12
+ gridname?: string
13
+ alignment?: Alignment
14
+ margintop?: number
15
+ columnwidth?: string
16
+ marginbottom?: number
17
+ marginright?: number
18
+ marginleft?: number
19
+ component?: React.ReactNode
20
+ bordercolor?: string
21
+ cellconfig?: cellconfig
22
+ mobilewidth?: string
23
+ tabletwidth?: string
24
+ computerwidth?: string
25
+ }
26
+
27
+ export interface gridconfig {
28
+ gridname?: string
29
+ alignment?: Alignment
30
+ margintop?: number
31
+ marginbottom?: number
32
+ marginright?: number
33
+ marginleft?: number
34
+ gridwidth?: string
35
+ bordercolor?: string
36
+ }
37
+
38
+ export interface CustomGridProps extends GridProps {
39
+ gridconfig?: gridconfig
40
+ columnconfig?: columnconfig[]
41
+ cellconfig?: cellconfig
42
+ }
43
+
44
+ export interface cellconfig {
45
+ border?: BorderProp
46
+ minHeight?: string
47
+ maxHeight?: string
48
+ width?: string
49
+ mobilewidth?: string
50
+ tabletwidth?: string
51
+ computerwidth?: string
52
+ }
53
+
54
+ /**
55
+ * CustomGrid component renders a customizable grid layout with configurable rows and columns.
56
+ * It supports responsive design by adapting to different screen sizes (mobile, tablet, computer).
57
+ * @param props The props for the CustomGrid component.
58
+ * @returns The rendered CustomGrid component.
59
+ */
60
+ const CustomGrid: React.FC<CustomGridProps> = ({
61
+ gridconfig,
62
+ columnconfig,
63
+ cellconfig,
64
+ ...rest
65
+ }) => {
66
+ const gridConfigValues = Array.isArray(gridconfig)
67
+ ? gridconfig[0]
68
+ : gridconfig
69
+
70
+ const gridJustifyContent =
71
+ gridConfigValues?.alignment === 'left'
72
+ ? 'flex-start'
73
+ : gridConfigValues?.alignment === 'right'
74
+ ? 'flex-end'
75
+ : 'center'
76
+
77
+ const theme = useTheme()
78
+ const isMobile = useMediaQuery(theme.breakpoints.between(0, 767))
79
+ const isTablet = useMediaQuery(theme.breakpoints.between(768, 1023))
80
+ const isComputer = useMediaQuery(theme.breakpoints.up(1024))
81
+
82
+ const minGridWidth = '300px'
83
+
84
+ /**
85
+ * Calculate the number of rows based on the columnconfig.
86
+ */
87
+ const rows = Math.max(...(columnconfig || []).map(c => c.row || 1))
88
+
89
+ return (
90
+ <Box
91
+ width={gridConfigValues?.gridwidth || '100%'}
92
+ display="flex"
93
+ justifyContent={gridJustifyContent}
94
+ minWidth={minGridWidth}
95
+ >
96
+ <Box
97
+ // @ts-ignore
98
+ mt={gridConfigValues?.margintop || 0}
99
+ mb={gridConfigValues?.marginbottom || 0}
100
+ ml={gridConfigValues?.marginleft || 0}
101
+ mr={gridConfigValues?.marginright || 0}
102
+ width="100%"
103
+ height="100%"
104
+ display="flex"
105
+ flexDirection="column"
106
+ alignItems="center"
107
+ {...rest}
108
+ >
109
+ {Array.from({ length: rows }).map((_, rowIndex) => {
110
+ /**
111
+ * Calculate the number of columns in the current row based on the columnconfig.
112
+ */
113
+ const columns = Math.max(
114
+ ...(columnconfig || [])
115
+ .filter(c => c.row === rowIndex + 1)
116
+ .map(c => c.column || 1)
117
+ )
118
+
119
+ return (
120
+ <Grid
121
+ key={`row-${rowIndex}`}
122
+ container
123
+ alignItems="center"
124
+ display="flex"
125
+ justifyContent="center"
126
+ sx={{
127
+ marginTop:
128
+ rowIndex === 0 ? gridConfigValues?.margintop || 0 : 0,
129
+ marginBottom:
130
+ rowIndex === rows - 1
131
+ ? gridConfigValues?.marginbottom || 0
132
+ : 0,
133
+ marginLeft: gridConfigValues?.marginleft || 0,
134
+ marginRight: gridConfigValues?.marginright || 0,
135
+ flexGrow: 1,
136
+ width: '100%',
137
+ }}
138
+ >
139
+ {Array.from({ length: columns }).map((_, columnIndex) => {
140
+ /**
141
+ * Get the current column configuration based on the row and column indices.
142
+ */
143
+ const currentColumnConfig = (columnconfig || []).find(
144
+ c => c.row === rowIndex + 1 && c.column === columnIndex + 1
145
+ )
146
+
147
+ /**
148
+ * Determine the column width based on the screen size and configuration.
149
+ */
150
+ const columnWidth = isMobile
151
+ ? currentColumnConfig?.mobilewidth ||
152
+ currentColumnConfig?.columnwidth ||
153
+ `${100 / columns}%`
154
+ : isTablet
155
+ ? currentColumnConfig?.tabletwidth ||
156
+ currentColumnConfig?.columnwidth ||
157
+ `${100 / columns}%`
158
+ : isComputer
159
+ ? currentColumnConfig?.computerwidth ||
160
+ currentColumnConfig?.columnwidth ||
161
+ `${100 / columns}%`
162
+ : currentColumnConfig?.columnwidth || `${100 / columns}%`
163
+
164
+ /**
165
+ * Determine the justification of the column content based on the alignment configuration.
166
+ */
167
+ const justifyContent =
168
+ currentColumnConfig?.alignment === 'left'
169
+ ? 'flex-start'
170
+ : currentColumnConfig?.alignment === 'right'
171
+ ? 'flex-end'
172
+ : 'center'
173
+
174
+ /**
175
+ * Get the current cell configuration based on the column configuration or the default cell configuration.
176
+ */
177
+ const currentCellConfig =
178
+ currentColumnConfig?.cellconfig || cellconfig
179
+
180
+ /**
181
+ * Determine if the cell has a border based on the cell configuration.
182
+ */
183
+ const hasBorder = currentCellConfig?.border === 'solid'
184
+
185
+ /**
186
+ * Determine the cell width based on the cell configuration.
187
+ */
188
+ const cellWidth = currentCellConfig?.width || '100%'
189
+
190
+ /**
191
+ * Determine the cell widths for different screen sizes based on the cell configuration.
192
+ */
193
+ const mobileWidth = currentCellConfig?.mobilewidth || '100%'
194
+ const tabletWidth = currentCellConfig?.tabletwidth || '100%'
195
+ const computerWidth = currentCellConfig?.computerwidth || '100%'
196
+
197
+ return (
198
+ <Grid
199
+ item
200
+ key={`column-${columnIndex}`}
201
+ sx={{
202
+ display: 'flex',
203
+ justifyContent,
204
+ marginRight: currentColumnConfig?.marginright || 0,
205
+ marginLeft: currentColumnConfig?.marginleft || 0,
206
+ marginTop: currentColumnConfig?.margintop || 0,
207
+ marginBottom: currentColumnConfig?.marginbottom || 0,
208
+ width: columnWidth,
209
+ '--Grid-borderWidth': hasBorder ? '1px' : '0',
210
+ borderTop: hasBorder
211
+ ? 'var(--Grid-borderWidth) solid'
212
+ : 'none',
213
+ borderLeft: hasBorder
214
+ ? 'var(--Grid-borderWidth) solid'
215
+ : 'none',
216
+ borderColor: 'divider',
217
+ }}
218
+ >
219
+ <Box
220
+ sx={{
221
+ borderRight: hasBorder
222
+ ? 'var(--Grid-borderWidth) solid'
223
+ : 'none',
224
+ borderBottom: hasBorder
225
+ ? 'var(--Grid-borderWidth) solid'
226
+ : 'none',
227
+ borderColor: 'divider',
228
+ minHeight: currentCellConfig?.minHeight || 'auto',
229
+ maxHeight: currentCellConfig?.maxHeight || 'none',
230
+ height: currentCellConfig?.maxHeight || 'auto',
231
+ display: 'flex',
232
+ alignItems: 'center',
233
+ justifyContent,
234
+ overflow: 'auto',
235
+ width: cellWidth,
236
+ minWidth: isMobile
237
+ ? mobileWidth
238
+ : isTablet
239
+ ? tabletWidth
240
+ : isComputer
241
+ ? computerWidth
242
+ : '100%',
243
+ maxWidth: isMobile
244
+ ? mobileWidth
245
+ : isTablet
246
+ ? tabletWidth
247
+ : isComputer
248
+ ? computerWidth
249
+ : '100%',
250
+ }}
251
+ >
252
+ {currentColumnConfig?.component || null}
253
+ </Box>
254
+ </Grid>
255
+ )
256
+ })}
257
+ </Grid>
258
+ )
259
+ })}
260
+ </Box>
261
+ </Box>
262
+ )
263
+ }
264
+
265
+ export default CustomGrid
@@ -0,0 +1,21 @@
1
+ // src/components/Icons/Calendar.tsx
2
+ import React from 'react'
3
+ import CalendarTodayIcon from '@mui/icons-material/CalendarToday'
4
+ import { SvgIconProps } from '@mui/material/SvgIcon'
5
+
6
+ const CalendarIcon: React.FC<SvgIconProps> = props => {
7
+ // Set a default size for the icon
8
+ const iconSize = '20px' // You can change this value to any size you want
9
+
10
+ return (
11
+ <CalendarTodayIcon
12
+ {...props}
13
+ style={{
14
+ fontSize: iconSize, // Set the size of the icon
15
+ ...props.style, // Allow for other styles to be applied if necessary
16
+ }}
17
+ />
18
+ )
19
+ }
20
+
21
+ export default CalendarIcon
@@ -0,0 +1,9 @@
1
+ // BlackArrowDropDownIcon.tsx
2
+ import React from 'react'
3
+ import ArrowDropDown from '@mui/icons-material/ArrowDropDown'
4
+
5
+ const BlackArrowDropDownIcon: React.FC = () => {
6
+ return <ArrowDropDown style={{ color: 'black' }} />
7
+ }
8
+
9
+ export default BlackArrowDropDownIcon
@@ -0,0 +1,9 @@
1
+ import React from 'react'
2
+ import DragIndicatorIcon from '@mui/icons-material/DragIndicator'
3
+
4
+ const DragIcon = () => {
5
+ const iconStyle = { color: 'black' }
6
+ return <DragIndicatorIcon style={iconStyle} />
7
+ }
8
+
9
+ export default DragIcon
@@ -0,0 +1,24 @@
1
+ import React, { useState } from 'react'
2
+ import { IconButton } from '@mui/material'
3
+ import FavoriteIcon from '@mui/icons-material/Favorite'
4
+ import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder'
5
+
6
+ const FavoriteIconComponent: React.FC = () => {
7
+ const [isFavorite, setIsFavorite] = useState(false)
8
+
9
+ const handleFavoriteClick = () => {
10
+ setIsFavorite(!isFavorite)
11
+ }
12
+
13
+ return (
14
+ <IconButton onClick={handleFavoriteClick} size="small">
15
+ {isFavorite ? (
16
+ <FavoriteIcon style={{ color: 'red' }} />
17
+ ) : (
18
+ <FavoriteBorderIcon />
19
+ )}
20
+ </IconButton>
21
+ )
22
+ }
23
+
24
+ export default FavoriteIconComponent
@@ -0,0 +1,12 @@
1
+ import { SvgIcon, SvgIconProps } from '@mui/material'
2
+ import React from 'react'
3
+
4
+ const InfoIcon: React.FC<SvgIconProps> = props => {
5
+ return (
6
+ <SvgIcon viewBox="0 0 24 24" {...props}>
7
+ <path d="M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 17C11.45 17 11 16.55 11 16V12C11 11.45 11.45 11 12 11C12.55 11 13 11.45 13 12V16C13 16.55 12.55 17 12 17ZM13 9H11V7H13V9Z" />
8
+ </SvgIcon>
9
+ )
10
+ }
11
+
12
+ export default InfoIcon
@@ -0,0 +1,29 @@
1
+ import React from 'react'
2
+ import Search from '@mui/icons-material/Search'
3
+
4
+ const SearchIcon: React.FC<{
5
+ size?: number | 'small' | 'medium' | 'large'
6
+ color?: string
7
+ }> = ({ size = 'medium', color = 'black' }) => {
8
+ let fontSize = '20px'
9
+
10
+ if (typeof size === 'number') {
11
+ fontSize = `${size}px`
12
+ } else {
13
+ switch (size) {
14
+ case 'small':
15
+ fontSize = '16px'
16
+ break
17
+ case 'medium':
18
+ fontSize = '20px'
19
+ break
20
+ case 'large':
21
+ fontSize = '24px'
22
+ break
23
+ }
24
+ }
25
+
26
+ return <Search style={{ fontSize, color }} />
27
+ }
28
+
29
+ export default SearchIcon
@@ -0,0 +1,16 @@
1
+ // src/components/Icons/ShowHideEyeIcon.tsx
2
+
3
+ import React from 'react'
4
+ import VisibilityIcon from '@mui/icons-material/Visibility'
5
+ import VisibilityOffIcon from '@mui/icons-material/VisibilityOff'
6
+
7
+ const ShowHideEyeIcon = ({ visible }: { visible: boolean }) => {
8
+ const iconStyle = { color: 'black' }
9
+ return visible ? (
10
+ <VisibilityIcon style={iconStyle} />
11
+ ) : (
12
+ <VisibilityOffIcon style={iconStyle} />
13
+ )
14
+ }
15
+
16
+ export default ShowHideEyeIcon
@@ -0,0 +1,96 @@
1
+ import React from 'react'
2
+ import {
3
+ Radio,
4
+ RadioGroup as MuiRadioGroup,
5
+ FormControlLabel,
6
+ FormControl,
7
+ FormLabel,
8
+ } from '@mui/material'
9
+ import { Typography } from './../../components/Typography'
10
+ import { TypographyPropsVariantOverrides } from '@mui/material'
11
+
12
+ export interface RadioOption {
13
+ value: string
14
+ label: string
15
+ fontColor?: string
16
+ fontVariant?: keyof TypographyPropsVariantOverrides
17
+ }
18
+
19
+ export interface RadioGroupProps {
20
+ label?: string
21
+ options: RadioOption[]
22
+ defaultValue?: string
23
+ name: string
24
+ labelFontVariant?: keyof TypographyPropsVariantOverrides
25
+ labelFontColor?: string
26
+ labelText?: string
27
+ onChange?: (value: string) => void
28
+ }
29
+
30
+ /**
31
+ * RadioGroup component renders a group of radio buttons with customizable options.
32
+ * It allows selecting a single value from a list of options.
33
+ * @param props The props for the RadioGroup component.
34
+ * @returns The rendered RadioGroup component.
35
+ */
36
+ const RadioGroup: React.FC<RadioGroupProps> = ({
37
+ label,
38
+ options,
39
+ defaultValue,
40
+ name,
41
+ labelFontVariant,
42
+ labelFontColor,
43
+ labelText,
44
+ onChange,
45
+ }) => {
46
+ /**
47
+ * handleChange function is called when the selected radio button changes.
48
+ * It invokes the onChange callback with the selected value.
49
+ * @param event The change event triggered by the radio button.
50
+ */
51
+ const handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
52
+ const selectedValue = event.target.value
53
+ if (onChange) {
54
+ onChange(selectedValue)
55
+ }
56
+ }
57
+
58
+ return (
59
+ <FormControl>
60
+ <FormLabel id={`${name}-label`} sx={{ marginBottom: '8px' }}>
61
+ <Typography
62
+ text={labelText || label}
63
+ fontcolor={labelFontColor}
64
+ fontvariant={
65
+ labelFontVariant as keyof TypographyPropsVariantOverrides
66
+ }
67
+ />
68
+ </FormLabel>
69
+ <MuiRadioGroup
70
+ aria-labelledby={`${name}-label`}
71
+ defaultValue={defaultValue}
72
+ name={name}
73
+ onChange={handleChange}
74
+ >
75
+ {options.map(option => (
76
+ <FormControlLabel
77
+ key={option.value}
78
+ value={option.value}
79
+ control={<Radio />}
80
+ label={
81
+ <Typography
82
+ text={option.label}
83
+ fontcolor={option.fontColor}
84
+ fontvariant={
85
+ option.fontVariant as keyof TypographyPropsVariantOverrides
86
+ }
87
+ />
88
+ }
89
+ />
90
+ ))}
91
+ </MuiRadioGroup>
92
+ </FormControl>
93
+ )
94
+ }
95
+
96
+ export default RadioGroup
@@ -0,0 +1,118 @@
1
+ import React from 'react'
2
+ import { InputAdornment, Button, Box } from '@mui/material'
3
+ import SearchIcon from '../../components/Icons/Search'
4
+ import ShowHideEyeIcon from '../../components/Icons/ShowHideEye'
5
+ import DownArrowFilledIcon from '../../components/Icons/DownArrowFilled'
6
+ import { AdornmentProps } from './index'
7
+
8
+ /**
9
+ * StartAdornment component renders the start adornment for the input component.
10
+ * @param props The props for the StartAdornment component.
11
+ * @returns The start adornment component or null.
12
+ */
13
+ const StartAdornment: React.FC<AdornmentProps> = props => {
14
+ const { componentvariant, iconcolor } = props
15
+
16
+ // Render the search icon for the search bar variant
17
+ if (componentvariant === 'searchbar') {
18
+ return (
19
+ <InputAdornment position="start">
20
+ <SearchIcon color={iconcolor} />
21
+ </InputAdornment>
22
+ )
23
+ }
24
+
25
+ return null
26
+ }
27
+
28
+ /**
29
+ * EndAdornment component renders the end adornment for the input component.
30
+ * @param props The props for the EndAdornment component.
31
+ * @returns The end adornment component or null.
32
+ */
33
+ const EndAdornment: React.FC<AdornmentProps> = props => {
34
+ const {
35
+ componentvariant,
36
+ passwordVisible,
37
+ togglePasswordVisibility,
38
+ handleIncrement,
39
+ handleDecrement,
40
+ } = props
41
+
42
+ const adornmentStyle = {
43
+ cursor: 'pointer',
44
+ }
45
+
46
+ // Render the show/hide eye icon for the password variant
47
+ if (componentvariant === 'password' && togglePasswordVisibility) {
48
+ return (
49
+ <InputAdornment
50
+ position="end"
51
+ onClick={togglePasswordVisibility}
52
+ style={adornmentStyle}
53
+ >
54
+ <ShowHideEyeIcon visible={passwordVisible || false} />
55
+ </InputAdornment>
56
+ )
57
+ }
58
+ // Render the down arrow icon for the dropdown variant
59
+ else if (componentvariant === 'dropdown') {
60
+ return (
61
+ <InputAdornment position="end" style={adornmentStyle}>
62
+ <DownArrowFilledIcon />
63
+ </InputAdornment>
64
+ )
65
+ }
66
+ // Render the increment/decrement buttons for the splitbutton variant
67
+ else if (componentvariant === 'splitbutton') {
68
+ return (
69
+ <InputAdornment position="end">
70
+ <Button
71
+ sx={{
72
+ minWidth: '20px',
73
+ padding: 0,
74
+ height: '100%',
75
+ borderLeft: '1px solid #c4c4c4',
76
+ borderRadius: '0 4px 4px 0',
77
+ backgroundColor: '#f0f0f0',
78
+ color: 'black',
79
+ '&:hover': {
80
+ backgroundColor: '#e0e0e0',
81
+ },
82
+ }}
83
+ >
84
+ <Box
85
+ sx={{
86
+ display: 'flex',
87
+ flexDirection: 'column',
88
+ alignItems: 'center',
89
+ }}
90
+ >
91
+ <Box
92
+ sx={{ fontSize: '10px', lineHeight: 1, cursor: 'pointer' }}
93
+ onClick={handleIncrement}
94
+ >
95
+
96
+ </Box>
97
+ <Box
98
+ sx={{ fontSize: '10px', lineHeight: 1, cursor: 'pointer' }}
99
+ onClick={handleDecrement}
100
+ >
101
+
102
+ </Box>
103
+ </Box>
104
+ </Button>
105
+ </InputAdornment>
106
+ )
107
+ }
108
+ // Render an empty end adornment for the search bar variant
109
+ else if (componentvariant === 'searchbar') {
110
+ return (
111
+ <InputAdornment position="end" style={adornmentStyle}></InputAdornment>
112
+ )
113
+ }
114
+
115
+ return null
116
+ }
117
+
118
+ export { StartAdornment, EndAdornment }