goobs-frontend 0.7.54 → 0.7.55

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.54",
3
+ "version": "0.7.55",
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,6 @@
28
28
  "@mui/icons-material": "^5.15.20",
29
29
  "@mui/material": "^5.15.20",
30
30
  "@types/lodash": "^4.17.5",
31
- "async-lock": "^1.4.1",
32
31
  "goobs-cache": "^1.2.1",
33
32
  "highlight.js": "^11.9.0",
34
33
  "lodash": "^4.17.21",
@@ -36,7 +35,6 @@
36
35
  },
37
36
  "devDependencies": {
38
37
  "@next/eslint-plugin-next": "^14.2.4",
39
- "@types/async-lock": "^1.4.2",
40
38
  "@types/node": "^20.14.9",
41
39
  "@types/react": "18.3.0",
42
40
  "@types/react-dom": "^18.3.0",
@@ -44,44 +44,35 @@ import useCodeCopy, {
44
44
  * Includes configuration for various content elements.
45
45
  */
46
46
  export interface ContentSectionProps {
47
- /** Grid configuration */
48
- gridconfig?: gridconfig
49
- /** Configuration for confirmation code input */
50
- confirmationcodeinput?:
51
- | ExtendedConfirmationCodeInputsProps
52
- | ExtendedConfirmationCodeInputsProps[]
53
- /** Typography configuration */
54
- typography?: TypographyProps | TypographyProps[]
55
- /** Styled component configuration */
56
- styledcomponent?:
57
- | ExtendedStyledComponentProps
58
- | ExtendedStyledComponentProps[]
59
- /** Radio group configuration */
60
- radiogroup?: ExtendedRadioGroupProps | ExtendedRadioGroupProps[]
61
- /** Link configuration */
62
- link?: LinkProps | LinkProps[]
63
- /** Button configuration */
64
- button?: ExtendedButtonProps | ExtendedButtonProps[]
65
- /** Image configuration */
66
- image?: ExtendedImageProps | ExtendedImageProps[]
67
- /** Pricing configuration */
68
- pricing?: ExtendedPricingProps
69
- /** Stepper configuration */
70
- stepper?: ExtendedStepperProps | ExtendedStepperProps[]
71
- /** Transfer list configuration */
72
- transferlist?: ExtendedTransferListProps | ExtendedTransferListProps[]
73
- /** Card configuration */
74
- card?: ExtendedCardProps | ExtendedCardProps[]
75
- /** Code copy configuration */
76
- codecopy?: ExtendedCodeCopyProps | ExtendedCodeCopyProps[]
47
+ grids: Array<{
48
+ grid: {
49
+ gridconfig?: gridconfig
50
+ }
51
+ confirmationcodeinput?:
52
+ | ExtendedConfirmationCodeInputsProps
53
+ | ExtendedConfirmationCodeInputsProps[]
54
+ typography?: TypographyProps | TypographyProps[]
55
+ styledcomponent?:
56
+ | ExtendedStyledComponentProps
57
+ | ExtendedStyledComponentProps[]
58
+ radiogroup?: ExtendedRadioGroupProps | ExtendedRadioGroupProps[]
59
+ link?: LinkProps | LinkProps[]
60
+ button?: ExtendedButtonProps | ExtendedButtonProps[]
61
+ image?: ExtendedImageProps | ExtendedImageProps[]
62
+ pricing?: ExtendedPricingProps
63
+ stepper?: ExtendedStepperProps | ExtendedStepperProps[]
64
+ transferlist?: ExtendedTransferListProps | ExtendedTransferListProps[]
65
+ card?: ExtendedCardProps | ExtendedCardProps[]
66
+ codecopy?: ExtendedCodeCopyProps | ExtendedCodeCopyProps[]
67
+ }>
77
68
  }
78
69
 
79
70
  /**
80
71
  * RenderContent component handles the rendering of various content elements
81
72
  * based on the provided configuration.
82
73
  */
83
- const RenderContent: React.FC<ContentSectionProps> = ({
84
- gridconfig,
74
+ const RenderContent: React.FC<ContentSectionProps['grids'][0]> = ({
75
+ grid,
85
76
  ...props
86
77
  }) => {
87
78
  let columnConfigs: columnconfig[] = []
@@ -113,22 +104,20 @@ const RenderContent: React.FC<ContentSectionProps> = ({
113
104
  addToColumnConfigs(useCard(props))
114
105
  addToColumnConfigs(useCodeCopy(props))
115
106
 
116
- return <CustomGrid gridconfig={gridconfig} columnconfig={columnConfigs} />
107
+ return (
108
+ <CustomGrid gridconfig={grid.gridconfig} columnconfig={columnConfigs} />
109
+ )
117
110
  }
118
111
 
119
112
  /**
120
113
  * ContentSection component renders multiple grids based on the provided configuration.
121
114
  * @param grids An array of ContentSectionProps, each representing a grid to be rendered.
122
115
  */
123
- export default function ContentSection({
124
- grids,
125
- }: {
126
- grids: ContentSectionProps[]
127
- }) {
116
+ export default function ContentSection({ grids }: ContentSectionProps) {
128
117
  return (
129
118
  <>
130
- {grids.map((grid, index) => (
131
- <RenderContent key={index} {...grid} />
119
+ {grids.map((gridProps, index) => (
120
+ <RenderContent key={index} {...gridProps} />
132
121
  ))}
133
122
  </>
134
123
  )
@@ -1,11 +1,11 @@
1
1
  'use client'
2
-
3
- import React from 'react'
2
+ import React, { forwardRef, useImperativeHandle, useRef } from 'react'
4
3
  import { Close } from '@mui/icons-material'
5
4
  import { Dialog, IconButton, Box } from '@mui/material'
6
5
  import ContentSection, { ContentSectionProps } from '../../Content'
7
6
  import { formContainerStyle } from './../../../styles/Form'
8
7
  import { ExtendedTypographyProps } from '../../Content/Structure/typography/useGridTypography'
8
+ import Typography from '../../Typography'
9
9
 
10
10
  /**
11
11
  * Props for the PopupForm component.
@@ -19,103 +19,137 @@ export interface PopupFormProps {
19
19
  open: boolean
20
20
  /** Function to call when closing the dialog */
21
21
  onClose: () => void
22
- /** Array of ContentSectionProps to render the form content */
23
- grids: ContentSectionProps[]
22
+ /** ContentSectionProps to render the form content */
23
+ grids: ContentSectionProps['grids']
24
+ /** Optional function to handle form submission */
25
+ onSubmit?: () => void
24
26
  }
25
27
 
26
28
  /**
27
29
  * PopupForm component renders a popup form with a title, description, and content sections.
28
30
  * It uses the ContentSection component to render the form content within a Material-UI Dialog.
31
+ * Handles form submission and displays submitted data internally.
29
32
  *
30
33
  * @param props The props for the PopupForm component.
34
+ * @param ref Ref forwarded to the form element.
31
35
  * @returns The rendered popup form.
32
36
  */
33
- function PopupForm({
34
- title,
35
- description,
36
- open,
37
- onClose,
38
- grids,
39
- }: PopupFormProps) {
40
- /**
41
- * headerGrid contains the grid configuration for the form header.
42
- * It includes the title and description as typography items.
43
- */
44
- const headerGrid: ContentSectionProps = {
45
- gridconfig: {
46
- gridname: 'formHeader',
47
- margintop: 0,
48
- marginbottom: 1,
49
- marginleft: 0,
50
- marginright: 0,
51
- gridwidth: '100%',
52
- },
53
- typography: [
54
- {
55
- text: title,
56
- fontvariant: 'merrih5',
57
- fontcolor: 'black',
58
- columnconfig: {
59
- row: 1,
60
- column: 1,
37
+ const PopupForm = forwardRef<HTMLFormElement, PopupFormProps>(
38
+ ({ title, description, open, onClose, grids, onSubmit }, ref) => {
39
+ const [submittedData, setSubmittedData] = React.useState<
40
+ Record<string, string>
41
+ >({})
42
+ const internalFormRef = useRef<HTMLFormElement>(null)
43
+
44
+ useImperativeHandle(ref, () => internalFormRef.current as HTMLFormElement)
45
+
46
+ /**
47
+ * headerGrid contains the grid configuration for the form header.
48
+ * It includes the title and description as typography items.
49
+ */
50
+ const headerGrid: ContentSectionProps['grids'][0] = {
51
+ grid: {
52
+ gridconfig: {
61
53
  gridname: 'formHeader',
62
- columnwidth: '100%',
63
- alignment: 'left',
64
- marginbottom: 0.5,
65
- },
66
- cellconfig: {
67
- border: 'none',
54
+ marginbottom: 1,
55
+ gridwidth: '100%',
68
56
  },
69
57
  },
70
- {
71
- text: description,
72
- fontvariant: 'merriparagraph',
73
- fontcolor: 'black',
74
- columnconfig: {
75
- row: 2,
76
- column: 1,
77
- gridname: 'formHeader',
78
- columnwidth: '100%',
79
- marginbottom: 0,
58
+ typography: [
59
+ {
60
+ text: title,
61
+ fontvariant: 'merrih5',
62
+ fontcolor: 'black',
63
+ columnconfig: {
64
+ column: 1,
65
+ gridname: 'formHeader',
66
+ columnwidth: '100%',
67
+ alignment: 'left',
68
+ marginbottom: 0.5,
69
+ },
80
70
  },
81
- cellconfig: {
82
- border: 'none',
71
+ {
72
+ text: description,
73
+ fontvariant: 'merriparagraph',
74
+ fontcolor: 'black',
75
+ columnconfig: {
76
+ column: 1,
77
+ gridname: 'formHeader',
78
+ columnwidth: '100%',
79
+ },
83
80
  },
84
- },
85
- ] as ExtendedTypographyProps[],
86
- }
81
+ ] as ExtendedTypographyProps[],
82
+ }
87
83
 
88
- /** Combine the header grid with the provided content grids */
89
- const contentSectionGrids: ContentSectionProps[] = [headerGrid, ...grids]
84
+ /** Combine the header grid with the provided content grids */
85
+ const contentSectionGrids: ContentSectionProps['grids'] = [
86
+ headerGrid,
87
+ ...grids,
88
+ ]
90
89
 
91
- return (
92
- <Dialog open={open} onClose={onClose} fullWidth maxWidth="sm">
93
- {/* Close button */}
94
- <IconButton
95
- size="small"
96
- onClick={onClose}
97
- sx={{
98
- position: 'absolute',
99
- right: 8,
100
- top: 8,
101
- color: theme => theme.palette.grey[500],
102
- }}
103
- >
104
- <Close />
105
- </IconButton>
90
+ /**
91
+ * Handles form submission and processes form data internally.
92
+ * @param event - The form submission event
93
+ */
94
+ const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
95
+ event.preventDefault()
96
+ const formData = new FormData(event.currentTarget)
97
+ const data: Record<string, string> = {}
106
98
 
107
- {/* Form container */}
108
- <Box
109
- // @ts-ignore
110
- sx={formContainerStyle}
111
- >
112
- <form>
113
- {/* Render the form content using ContentSection */}
114
- <ContentSection grids={contentSectionGrids} />
115
- </form>
116
- </Box>
117
- </Dialog>
118
- )
119
- }
99
+ formData.forEach((value, key) => {
100
+ data[key] = value.toString()
101
+ })
102
+
103
+ setSubmittedData(data)
104
+
105
+ if (onSubmit) {
106
+ onSubmit()
107
+ }
108
+ }
109
+
110
+ return (
111
+ <Dialog open={open} onClose={onClose} fullWidth maxWidth="sm">
112
+ {/* Close button */}
113
+ <IconButton
114
+ size="small"
115
+ onClick={onClose}
116
+ sx={{
117
+ position: 'absolute',
118
+ right: 8,
119
+ top: 8,
120
+ color: theme => theme.palette.grey[500],
121
+ }}
122
+ >
123
+ <Close />
124
+ </IconButton>
125
+ {/* Form container */}
126
+ <Box
127
+ // @ts-ignore
128
+ sx={formContainerStyle}
129
+ >
130
+ <form onSubmit={handleSubmit} ref={internalFormRef}>
131
+ {/* Render the form content using ContentSection */}
132
+ <ContentSection grids={contentSectionGrids} />
133
+ </form>
134
+ {/* Display submitted data */}
135
+ {Object.keys(submittedData).length > 0 && (
136
+ <Box mt={2}>
137
+ <Typography fontvariant="merrih6" text="Submitted Data:" />
138
+ {Object.entries(submittedData).map(([key, value]) => (
139
+ <Typography
140
+ key={key}
141
+ fontvariant="merriparagraph"
142
+ text={`${key}: ${value}`}
143
+ />
144
+ ))}
145
+ </Box>
146
+ )}
147
+ </Box>
148
+ </Dialog>
149
+ )
150
+ }
151
+ )
152
+
153
+ PopupForm.displayName = 'PopupForm'
120
154
 
121
155
  export default PopupForm
@@ -13,8 +13,8 @@ export type BorderProp = 'none' | 'solid'
13
13
  * Configuration for individual columns within the grid
14
14
  */
15
15
  export interface columnconfig {
16
- row?: number
17
- column?: number
16
+ row: number
17
+ column: number
18
18
  gridname?: string
19
19
  alignment?: Alignment
20
20
  margintop?: number
package/src/index.ts CHANGED
@@ -38,6 +38,7 @@ import PricingTable, { PricingProps } from './components/PricingTable'
38
38
  import { CustomStepper, CustomStepperProps } from './components/Stepper'
39
39
  import CustomToolbar, { ToolbarProps } from './components/Toolbar'
40
40
  import TransferList, { TransferListProps } from './components/TransferList'
41
+ import StyledTooltip, { CustomTooltipProps } from './components/Tooltip'
41
42
  import React from 'react'
42
43
 
43
44
  // Animations
@@ -139,6 +140,9 @@ declare type CustomToolbarComponentProps = React.ComponentProps<
139
140
  declare type TransferListComponentProps = React.ComponentProps<
140
141
  typeof TransferList
141
142
  >
143
+ declare type StyledTooltipComponentProps = React.ComponentProps<
144
+ typeof StyledTooltip
145
+ >
142
146
 
143
147
  // Named exports
144
148
  export { CustomButton }
@@ -157,6 +161,7 @@ export { PricingTable }
157
161
  export { CustomStepper }
158
162
  export { CustomToolbar }
159
163
  export { TransferList }
164
+ export { StyledTooltip }
160
165
  export { formContainerStyle }
161
166
 
162
167
  // Exporting ExtendedButtonProps
@@ -185,6 +190,7 @@ export type { PricingProps }
185
190
  export type { CustomStepperProps }
186
191
  export type { ToolbarProps }
187
192
  export type { TransferListProps }
193
+ export type { CustomTooltipProps }
188
194
 
189
195
  // Additional type exports for the newly declared types
190
196
  export type { TypographyComponentProps }
@@ -200,6 +206,7 @@ export type { PricingTableComponentProps }
200
206
  export type { CustomStepperComponentProps }
201
207
  export type { CustomToolbarComponentProps }
202
208
  export type { TransferListComponentProps }
209
+ export type { StyledTooltipComponentProps }
203
210
 
204
211
  // Animation type export
205
212
  export type { Animation }