goobs-frontend 0.8.6 → 0.8.8

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.
@@ -1,45 +1,6 @@
1
1
  'use client'
2
- import React, { useState, useCallback } from 'react'
3
- import { TextField, TextFieldProps } from '@mui/material'
4
- import { styled } from '@mui/material/styles'
5
-
6
- export interface PhoneNumberFieldProps
7
- extends Omit<TextFieldProps, 'onChange'> {
8
- initialValue?: string
9
- onChange?: () => void
10
- backgroundcolor?: string
11
- outlinecolor?: string
12
- fontcolor?: string
13
- label?: string
14
- }
15
-
16
- const StyledTextField = styled(TextField)<{
17
- backgroundcolor?: string
18
- outlinecolor?: string
19
- fontcolor?: string
20
- }>(({ theme, backgroundcolor, outlinecolor, fontcolor }) => ({
21
- '& .MuiOutlinedInput-root': {
22
- backgroundColor: backgroundcolor || theme.palette.background.paper,
23
- '& fieldset': {
24
- borderColor: outlinecolor || theme.palette.primary.main,
25
- },
26
- '&:hover fieldset': {
27
- borderColor: outlinecolor || theme.palette.primary.main,
28
- },
29
- '&.Mui-focused fieldset': {
30
- borderColor: outlinecolor || theme.palette.primary.main,
31
- },
32
- },
33
- '& .MuiInputLabel-root': {
34
- color: fontcolor || theme.palette.text.primary,
35
- '&.Mui-focused': {
36
- color: fontcolor || theme.palette.primary.main,
37
- },
38
- },
39
- '& .MuiInputBase-input': {
40
- color: fontcolor || theme.palette.text.primary,
41
- },
42
- }))
2
+ import React, { useCallback, useMemo, useState } from 'react'
3
+ import { Box, TextField as MuiTextField, TextFieldProps } from '@mui/material'
43
4
 
44
5
  const formatPhoneNumber = (value: string): string => {
45
6
  const digits = value.replace(/\D/g, '')
@@ -57,47 +18,110 @@ const formatPhoneNumber = (value: string): string => {
57
18
  return formattedNumber.trim()
58
19
  }
59
20
 
60
- const PhoneNumberField: React.FC<PhoneNumberFieldProps> = ({
61
- initialValue = '',
62
- onChange,
63
- backgroundcolor,
64
- outlinecolor,
65
- fontcolor,
66
- label = 'Phone Number',
67
- ...rest
68
- }) => {
21
+ const PhoneNumberField: React.FC<TextFieldProps> = React.memo(props => {
22
+ const {
23
+ name,
24
+ label = 'Phone Number',
25
+ placeholder,
26
+ onChange,
27
+ onFocus,
28
+ onBlur,
29
+ value = '',
30
+ error,
31
+ ...restProps
32
+ } = props
33
+
69
34
  const [phoneNumber, setPhoneNumber] = useState(
70
- formatPhoneNumber(initialValue)
35
+ formatPhoneNumber(value as string)
71
36
  )
72
37
 
73
- const handlePhoneNumberChange = useCallback(
74
- (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
38
+ const handleChange = useCallback(
39
+ (e: React.ChangeEvent<HTMLInputElement>) => {
75
40
  const input = e.target.value
76
41
  let strippedInput = input.replace(/^\+1\s?/, '').replace(/\D/g, '')
77
42
  strippedInput = strippedInput.slice(0, 10)
78
43
  const formattedValue =
79
44
  strippedInput.length > 0 ? formatPhoneNumber(strippedInput) : '+1 '
80
45
  setPhoneNumber(formattedValue)
81
- onChange?.()
46
+ if (onChange) {
47
+ onChange(e)
48
+ }
82
49
  },
83
50
  [onChange]
84
51
  )
85
52
 
53
+ const handleFocus = useCallback(
54
+ (e: React.FocusEvent<HTMLInputElement>) => {
55
+ if (onFocus) {
56
+ onFocus(e)
57
+ }
58
+ },
59
+ [onFocus]
60
+ )
61
+
62
+ const handleBlur = useCallback(
63
+ (e: React.FocusEvent<HTMLInputElement>) => {
64
+ if (onBlur) {
65
+ onBlur(e)
66
+ }
67
+ },
68
+ [onBlur]
69
+ )
70
+
71
+ const handleClick = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
72
+ e.preventDefault()
73
+ }, [])
74
+
75
+ const inputProps = useMemo(
76
+ () => ({
77
+ style: {
78
+ height: '40px',
79
+ padding: '8px 14px',
80
+ },
81
+ }),
82
+ []
83
+ )
84
+
85
+ const InputProps = useMemo(
86
+ () => ({
87
+ style: {
88
+ height: '45px',
89
+ },
90
+ }),
91
+ []
92
+ )
93
+
86
94
  return (
87
- <StyledTextField
88
- label={label}
89
- value={phoneNumber}
90
- onChange={handlePhoneNumberChange}
91
- backgroundcolor={backgroundcolor}
92
- outlinecolor={outlinecolor}
93
- fontcolor={fontcolor}
94
- fullWidth
95
- inputProps={{
96
- maxLength: 16,
95
+ <Box
96
+ sx={{
97
+ display: 'flex',
98
+ flexDirection: 'column',
99
+ justifyContent: 'center',
100
+ width: '100%',
101
+ marginTop: '5px',
102
+ height: '70px',
97
103
  }}
98
- {...rest}
99
- />
104
+ onClick={handleClick}
105
+ >
106
+ <MuiTextField
107
+ name={name}
108
+ label={label}
109
+ placeholder={placeholder}
110
+ onChange={handleChange}
111
+ onFocus={handleFocus}
112
+ onBlur={handleBlur}
113
+ value={phoneNumber}
114
+ error={error}
115
+ fullWidth
116
+ variant="outlined"
117
+ inputProps={inputProps}
118
+ InputProps={InputProps}
119
+ {...restProps}
120
+ />
121
+ </Box>
100
122
  )
101
- }
123
+ })
124
+
125
+ PhoneNumberField.displayName = 'PhoneNumberField'
102
126
 
103
127
  export default PhoneNumberField
@@ -1,6 +1,14 @@
1
- import React from 'react'
2
- import { TextField, InputAdornment, styled } from '@mui/material'
1
+ 'use client'
2
+ import React, { useState } from 'react'
3
+ import {
4
+ OutlinedInput,
5
+ styled,
6
+ FormControl,
7
+ InputLabel,
8
+ InputAdornment,
9
+ } from '@mui/material'
3
10
  import SearchIcon from '@mui/icons-material/Search'
11
+ import * as palette from '../../styles/palette'
4
12
 
5
13
  export interface SearchbarProps {
6
14
  label?: string
@@ -13,31 +21,65 @@ export interface SearchbarProps {
13
21
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
14
22
  }
15
23
 
16
- const StyledTextField = styled(TextField)<{
24
+ const StyledFormControl = styled(FormControl)({
25
+ width: '100%',
26
+ position: 'relative',
27
+ height: '45px',
28
+ display: 'flex',
29
+ justifyContent: 'flex-end',
30
+ })
31
+
32
+ const StyledOutlinedInput = styled(OutlinedInput)<{
17
33
  backgroundcolor?: string
18
34
  outlinecolor?: string
19
- $fontcolor?: string
20
- }>(({ theme, backgroundcolor, outlinecolor, $fontcolor }) => ({
21
- '& .MuiOutlinedInput-root': {
22
- backgroundColor: backgroundcolor || theme.palette.background.paper,
23
- '& fieldset': {
24
- borderColor: outlinecolor || theme.palette.primary.main,
25
- },
26
- '&:hover fieldset': {
27
- borderColor: outlinecolor || theme.palette.primary.main,
28
- },
29
- '&.Mui-focused fieldset': {
30
- borderColor: outlinecolor || theme.palette.primary.main,
31
- },
35
+ fontcolor?: string
36
+ }>(({ backgroundcolor, outlinecolor, fontcolor }) => ({
37
+ height: '40px',
38
+ backgroundColor: backgroundcolor || palette.white.main,
39
+ '& .MuiOutlinedInput-notchedOutline': {
40
+ border:
41
+ outlinecolor === 'none'
42
+ ? 'none'
43
+ : `1px solid ${outlinecolor || palette.black.main}`,
44
+ },
45
+ '&:hover .MuiOutlinedInput-notchedOutline': {
46
+ border:
47
+ outlinecolor === 'none'
48
+ ? 'none'
49
+ : `1px solid ${outlinecolor || palette.black.main}`,
50
+ },
51
+ '&.Mui-focused .MuiOutlinedInput-notchedOutline': {
52
+ border:
53
+ outlinecolor === 'none'
54
+ ? 'none'
55
+ : `1px solid ${outlinecolor || palette.black.main}`,
56
+ borderWidth: outlinecolor === 'none' ? '0' : '1px',
32
57
  },
33
- '& .MuiInputLabel-root': {
34
- color: $fontcolor || theme.palette.text.primary,
35
- '&.Mui-focused': {
36
- color: $fontcolor || theme.palette.primary.main,
58
+ '& input': {
59
+ color: fontcolor || palette.black.main,
60
+ padding: '0 12px',
61
+ paddingLeft: '7px',
62
+ height: '100%',
63
+ '&::placeholder': {
64
+ color: fontcolor || palette.black.main,
65
+ opacity: 0.7,
37
66
  },
38
67
  },
39
- '& .MuiInputBase-input': {
40
- color: $fontcolor || theme.palette.text.primary,
68
+ }))
69
+
70
+ const StyledInputLabel = styled(InputLabel)<{
71
+ fontcolor?: string
72
+ }>(({ fontcolor }) => ({
73
+ color: fontcolor || palette.black.main,
74
+ transform: 'translate(44px, 20px) scale(1)',
75
+ position: 'absolute',
76
+ top: '-5px',
77
+ '&.Mui-focused': {
78
+ color: fontcolor || palette.black.main,
79
+ },
80
+ '&.MuiInputLabel-shrink': {
81
+ transform: 'translate(14px, 3px) scale(0.75)',
82
+ color: fontcolor || palette.black.main,
41
83
  },
42
84
  }))
43
85
 
@@ -51,27 +93,41 @@ const Searchbar: React.FC<SearchbarProps> = ({
51
93
  value,
52
94
  onChange,
53
95
  }) => {
96
+ const [focused, setFocused] = useState(false)
97
+ const isLabelShrunken = focused || Boolean(value)
98
+
99
+ const handleFocus = () => setFocused(true)
100
+ const handleBlur = () => setFocused(false)
101
+
54
102
  return (
55
- <StyledTextField
56
- label={label}
57
- variant="outlined"
58
- fullWidth
59
- placeholder={placeholder}
60
- backgroundcolor={backgroundcolor}
61
- outlinecolor={outlinecolor}
62
- $fontcolor={fontcolor}
63
- value={value}
64
- onChange={onChange}
65
- slotProps={{
66
- input: {
67
- startAdornment: (
68
- <InputAdornment position="start">
69
- <SearchIcon style={{ color: iconcolor }} />
70
- </InputAdornment>
71
- ),
72
- },
73
- }}
74
- />
103
+ <StyledFormControl variant="outlined">
104
+ <StyledInputLabel
105
+ variant="outlined"
106
+ htmlFor="search-input"
107
+ shrink={isLabelShrunken}
108
+ fontcolor={fontcolor}
109
+ >
110
+ {label}
111
+ </StyledInputLabel>
112
+ <StyledOutlinedInput
113
+ id="search-input"
114
+ label={label}
115
+ notched={isLabelShrunken}
116
+ placeholder={isLabelShrunken ? placeholder : ''}
117
+ value={value}
118
+ onChange={onChange}
119
+ onFocus={handleFocus}
120
+ onBlur={handleBlur}
121
+ backgroundcolor={backgroundcolor}
122
+ outlinecolor={outlinecolor}
123
+ fontcolor={fontcolor}
124
+ startAdornment={
125
+ <InputAdornment position="start">
126
+ <SearchIcon sx={{ color: iconcolor || palette.black.main }} />
127
+ </InputAdornment>
128
+ }
129
+ />
130
+ </StyledFormControl>
75
131
  )
76
132
  }
77
133
 
@@ -1,11 +1,8 @@
1
+ 'use client'
1
2
  import React, { useCallback, useMemo } from 'react'
2
3
  import { Box, TextField as MuiTextField, TextFieldProps } from '@mui/material'
3
4
 
4
- export interface CustomTextFieldProps extends Omit<TextFieldProps, 'name'> {
5
- name: string
6
- }
7
-
8
- const TextField: React.FC<CustomTextFieldProps> = React.memo(props => {
5
+ const TextField: React.FC<TextFieldProps> = React.memo(props => {
9
6
  const {
10
7
  name,
11
8
  label,
@@ -16,7 +13,6 @@ const TextField: React.FC<CustomTextFieldProps> = React.memo(props => {
16
13
  value,
17
14
  error,
18
15
  sx,
19
- InputProps,
20
16
  ...restProps
21
17
  } = props
22
18
 
@@ -59,36 +55,31 @@ const TextField: React.FC<CustomTextFieldProps> = React.memo(props => {
59
55
  cursor: 'text',
60
56
  boxSizing: 'border-box',
61
57
  borderRadius: 5,
62
- paddingRight: 6,
63
58
  }),
64
59
  []
65
60
  )
66
61
 
67
- const mergedInputProps = useMemo(
62
+ const slotProps = useMemo(
68
63
  () => ({
69
- ...InputProps,
70
- style: {
71
- ...inputStyle,
72
- ...InputProps?.style,
64
+ input: {
65
+ style: inputStyle,
73
66
  },
74
- }),
75
- [InputProps, inputStyle]
76
- )
77
-
78
- const labelStyle = useMemo(
79
- () => ({
80
- '&.MuiInputLabel-shrink': {
81
- top: '0px',
82
- left: '0px',
83
- },
84
- '&:not(.MuiInputLabel-shrink)': {
85
- transform: 'scale(1)',
86
- transformOrigin: 'top left',
87
- top: '9px',
88
- left: '12px',
67
+ inputLabel: {
68
+ sx: {
69
+ '&.MuiInputLabel-shrink': {
70
+ top: '0px',
71
+ left: '0px',
72
+ },
73
+ '&:not(.MuiInputLabel-shrink)': {
74
+ transform: 'scale(1)',
75
+ transformOrigin: 'top left',
76
+ top: '9px',
77
+ left: '12px',
78
+ },
79
+ },
89
80
  },
90
81
  }),
91
- []
82
+ [inputStyle]
92
83
  )
93
84
 
94
85
  return (
@@ -99,7 +90,7 @@ const TextField: React.FC<CustomTextFieldProps> = React.memo(props => {
99
90
  justifyContent: 'center',
100
91
  width: '100%',
101
92
  marginTop: '5px',
102
- height: '62px',
93
+ height: '70px',
103
94
  ...sx,
104
95
  }}
105
96
  onClick={handleClick}
@@ -113,10 +104,7 @@ const TextField: React.FC<CustomTextFieldProps> = React.memo(props => {
113
104
  onBlur={handleBlur}
114
105
  value={value}
115
106
  error={error}
116
- InputProps={mergedInputProps}
117
- InputLabelProps={{
118
- sx: labelStyle,
119
- }}
107
+ slotProps={slotProps}
120
108
  fullWidth
121
109
  variant="outlined"
122
110
  {...restProps}
@@ -6,33 +6,20 @@ import Searchbar, { SearchbarProps } from '../Searchbar'
6
6
  import Dropdown, { DropdownProps } from '../Dropdown'
7
7
  import { white, black, semiTransparentWhite } from '../../styles/palette'
8
8
 
9
- /**
10
- * Styled component for a vertical divider
11
- */
12
9
  const VerticalDivider = styled(Box)({
13
10
  borderLeft: '2px solid black',
14
11
  height: '20px',
15
12
  })
16
13
 
17
- /**
18
- * Interface for the CustomToolbar component props
19
- */
20
14
  export interface ToolbarProps {
21
15
  buttons?: CustomButtonProps[]
22
16
  dropdowns?: DropdownProps[]
23
17
  searchbarProps?: Partial<SearchbarProps>
24
18
  }
25
19
 
26
- /**
27
- * CustomToolbar component that renders a toolbar with buttons, dropdowns, and a search bar
28
- * @param {ToolbarProps} props - The props for the CustomToolbar component
29
- * @returns {JSX.Element} The rendered CustomToolbar component
30
- */
31
20
  function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
32
- // State for checkbox width (set to 45px as default)
33
21
  const [checkboxWidth] = useState(45)
34
- // Explicitly set toolbar height to 56px
35
- const toolbarHeight = 56
22
+ const toolbarHeight = 45
36
23
 
37
24
  return (
38
25
  <Box
@@ -41,12 +28,13 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
41
28
  pl: `${checkboxWidth}px`,
42
29
  display: 'flex',
43
30
  flexDirection: 'row',
44
- justifyContent: 'space-between',
31
+ justifyContent: 'flex-start',
45
32
  alignItems: 'stretch',
46
33
  height: `${toolbarHeight}px`,
34
+ width: '100%',
47
35
  }}
48
36
  >
49
- {/* Left section of the toolbar */}
37
+ {/* Left section with buttons and divider */}
50
38
  <Box
51
39
  sx={{
52
40
  display: 'flex',
@@ -70,7 +58,8 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
70
58
  <Box
71
59
  sx={{
72
60
  display: 'flex',
73
- alignItems: 'center',
61
+ alignItems: 'flex-end', // Changed from center to flex-end
62
+ paddingBottom: '13px', // Added padding to align with other elements
74
63
  gap: '10px',
75
64
  height: '100%',
76
65
  padding: '0 15px',
@@ -90,6 +79,7 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
90
79
  ))}
91
80
  </Box>
92
81
  </Box>
82
+
93
83
  {/* Search bar section */}
94
84
  <Box
95
85
  sx={{
@@ -99,10 +89,12 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
99
89
  width: '300px',
100
90
  minWidth: '200px',
101
91
  height: '100%',
92
+ padding: '0 15px',
102
93
  }}
103
94
  >
104
95
  <Searchbar
105
96
  backgroundcolor={semiTransparentWhite.main}
97
+ outlinecolor="none"
106
98
  label="Search the DataGrid"
107
99
  fontcolor={black.main}
108
100
  iconcolor={black.main}
@@ -111,15 +103,21 @@ function CustomToolbar({ buttons, dropdowns, searchbarProps }: ToolbarProps) {
111
103
  {...searchbarProps}
112
104
  />
113
105
  </Box>
106
+
107
+ {/* Spacer to push dropdowns to the right */}
108
+ <Box sx={{ flexGrow: 1 }} />
109
+
114
110
  {/* Dropdowns section */}
115
111
  {dropdowns && dropdowns.length > 0 && (
116
112
  <Box
117
113
  sx={{
118
114
  display: 'flex',
119
- alignItems: 'center',
115
+ alignItems: 'flex-end', // Changed from center to flex-end
116
+ paddingBottom: '13px', // Added padding to align with other elements
120
117
  height: '100%',
121
118
  padding: '0 15px',
122
119
  gap: '10px',
120
+ marginLeft: 'auto',
123
121
  }}
124
122
  >
125
123
  {dropdowns.map((dropdown, index) => (
package/src/index.ts CHANGED
@@ -47,7 +47,9 @@ import PasswordField from './components/PasswordField'
47
47
  import PhoneNumberField from './components/PhoneNumberField'
48
48
  import Searchbar from './components/Searchbar'
49
49
  import TextField from './components/TextField'
50
-
50
+ // Add FormDataGrid import
51
+ import FormDataGrid from './components/Form/DataGrid'
52
+ import type { FormDataGridProps } from './components/Form/DataGrid'
51
53
  // Animations
52
54
  import { Animation } from './components/Content/Structure/animations'
53
55
 
@@ -71,7 +73,10 @@ import { ExtendedImageProps } from './components/Content/Structure/image/useImag
71
73
  import { ExtendedConfirmationCodeInputsProps } from './components/Content/Structure/confirmationinput/useConfirmationInput'
72
74
  import { ExtendedRadioGroupProps } from './components/Content/Structure/radiogroup/useRadioGroup'
73
75
  import { ExtendedPhoneNumberFieldProps } from './components/Content/Structure/phoneNumber/usePhoneNumber'
74
- import { CustomTextFieldProps } from './components/TextField'
76
+ import { DatagridProps } from './components/DataGrid'
77
+ import type { ColumnDef, RowData } from './components/DataGrid/Table'
78
+ import type { CellParams, HeaderParams } from './components/DataGrid/Table'
79
+
75
80
  // Colors
76
81
  import {
77
82
  moss,
@@ -213,6 +218,15 @@ export { PhoneNumberField }
213
218
  export { Searchbar }
214
219
  export { TextField }
215
220
 
221
+ // Add FormDataGrid to named exports
222
+ export { FormDataGrid }
223
+
224
+ // Add FormDataGrid type to type exports
225
+ export type { FormDataGridProps }
226
+ export type { DatagridProps }
227
+ export type { ColumnDef, RowData }
228
+ export type { CellParams, HeaderParams }
229
+
216
230
  // Exporting ExtendedButtonProps
217
231
  export type { ExtendedButtonProps }
218
232
  export type { ExtendedTypographyProps }
@@ -268,7 +282,6 @@ export type { CustomToolbarComponentProps }
268
282
  export type { TransferListComponentProps }
269
283
  export type { StyledTooltipComponentProps }
270
284
  export type { DropdownOption }
271
- export type { CustomTextFieldProps }
272
285
 
273
286
  // New type exports
274
287
  export type { DateFieldProps }