goobs-frontend 0.7.65 → 0.7.66
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 +1 -1
- package/src/components/Form/Popup/index.tsx +108 -145
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goobs-frontend",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.66",
|
|
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",
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import React, {
|
|
4
|
-
forwardRef,
|
|
5
|
-
useImperativeHandle,
|
|
6
|
-
useRef,
|
|
7
|
-
useMemo,
|
|
8
|
-
useCallback,
|
|
9
|
-
} from 'react'
|
|
3
|
+
import React, { useMemo } from 'react'
|
|
10
4
|
import { Close } from '@mui/icons-material'
|
|
11
5
|
import { Dialog, IconButton, Box, DialogProps } from '@mui/material'
|
|
12
6
|
import ContentSection, { ContentSectionProps } from '../../Content'
|
|
@@ -24,8 +18,6 @@ export interface PopupFormProps {
|
|
|
24
18
|
description?: string
|
|
25
19
|
/** The grid configuration for the form content */
|
|
26
20
|
grids?: ContentSectionProps['grids']
|
|
27
|
-
/** Callback function to handle form submission */
|
|
28
|
-
onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void
|
|
29
21
|
/** Custom content to render inside the form */
|
|
30
22
|
content?: React.ReactNode
|
|
31
23
|
/** The type of popup to render ('dialog' or 'modal') */
|
|
@@ -52,160 +44,131 @@ export interface PopupFormProps {
|
|
|
52
44
|
* popupType="dialog"
|
|
53
45
|
* open={isOpen}
|
|
54
46
|
* onClose={handleClose}
|
|
55
|
-
* onSubmit={handleSubmit}
|
|
56
47
|
* content={<LoginForm />}
|
|
57
48
|
* width={400}
|
|
58
49
|
* />
|
|
59
50
|
*/
|
|
60
|
-
const PopupForm
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
51
|
+
const PopupForm: React.FC<PopupFormProps> = ({
|
|
52
|
+
title,
|
|
53
|
+
description,
|
|
54
|
+
grids,
|
|
55
|
+
content,
|
|
56
|
+
popupType,
|
|
57
|
+
open,
|
|
58
|
+
onClose,
|
|
59
|
+
width = 450,
|
|
60
|
+
}) => {
|
|
61
|
+
/**
|
|
62
|
+
* Memoized header grid configuration
|
|
63
|
+
*/
|
|
64
|
+
const headerGrid: ContentSectionProps['grids'][0] = useMemo(
|
|
65
|
+
() => ({
|
|
66
|
+
grid: {
|
|
67
|
+
gridconfig: {
|
|
68
|
+
gridname: 'formHeader',
|
|
69
|
+
marginbottom: 1,
|
|
70
|
+
gridwidth: '100%',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
typography: [
|
|
74
|
+
{
|
|
75
|
+
text: title,
|
|
76
|
+
fontvariant: 'merrih5',
|
|
77
|
+
fontcolor: 'black',
|
|
78
|
+
columnconfig: {
|
|
79
|
+
row: 1,
|
|
80
|
+
column: 1,
|
|
87
81
|
gridname: 'formHeader',
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
columnwidth: '100%',
|
|
83
|
+
alignment: 'left',
|
|
84
|
+
marginbottom: 1.5,
|
|
90
85
|
},
|
|
91
86
|
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
alignment: 'left',
|
|
103
|
-
marginbottom: 1.5,
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
text: description,
|
|
108
|
-
fontvariant: 'merriparagraph',
|
|
109
|
-
fontcolor: 'black',
|
|
110
|
-
columnconfig: {
|
|
111
|
-
row: 2,
|
|
112
|
-
column: 1,
|
|
113
|
-
alignment: 'left',
|
|
114
|
-
gridname: 'formHeader',
|
|
115
|
-
columnwidth: '100%',
|
|
116
|
-
},
|
|
87
|
+
{
|
|
88
|
+
text: description,
|
|
89
|
+
fontvariant: 'merriparagraph',
|
|
90
|
+
fontcolor: 'black',
|
|
91
|
+
columnconfig: {
|
|
92
|
+
row: 2,
|
|
93
|
+
column: 1,
|
|
94
|
+
alignment: 'left',
|
|
95
|
+
gridname: 'formHeader',
|
|
96
|
+
columnwidth: '100%',
|
|
117
97
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Handle form submission
|
|
125
|
-
* @param {React.FormEvent<HTMLFormElement>} event - The form submission event
|
|
126
|
-
*/
|
|
127
|
-
const handleSubmit = useCallback(
|
|
128
|
-
(event: React.FormEvent<HTMLFormElement>) => {
|
|
129
|
-
event.preventDefault()
|
|
130
|
-
if (onSubmit) {
|
|
131
|
-
onSubmit(event)
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
[onSubmit]
|
|
135
|
-
)
|
|
98
|
+
},
|
|
99
|
+
] as ExtendedTypographyProps[],
|
|
100
|
+
}),
|
|
101
|
+
[title, description]
|
|
102
|
+
)
|
|
136
103
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Memoized header render function
|
|
106
|
+
*/
|
|
107
|
+
const renderHeader = useMemo(
|
|
108
|
+
() => <ContentSection grids={[headerGrid]} />,
|
|
109
|
+
[headerGrid]
|
|
110
|
+
)
|
|
144
111
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
)
|
|
112
|
+
/**
|
|
113
|
+
* Memoized content render function
|
|
114
|
+
*/
|
|
115
|
+
const renderContent = useMemo(
|
|
116
|
+
() => (
|
|
117
|
+
<Box
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
sx={formContainerStyle}
|
|
120
|
+
>
|
|
121
|
+
<Box mb={0}>{renderHeader}</Box>
|
|
122
|
+
{React.isValidElement(content)
|
|
123
|
+
? React.cloneElement(content as React.ReactElement, {
|
|
124
|
+
onClose: onClose,
|
|
125
|
+
open: open,
|
|
126
|
+
})
|
|
127
|
+
: content || (grids && <ContentSection grids={grids} />)}
|
|
128
|
+
</Box>
|
|
129
|
+
),
|
|
130
|
+
[renderHeader, content, grids, onClose, open]
|
|
131
|
+
)
|
|
166
132
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
},
|
|
133
|
+
const dialogProps: DialogProps = {
|
|
134
|
+
open: popupType === 'modal' ? true : open || false,
|
|
135
|
+
onClose: popupType === 'modal' ? undefined : onClose,
|
|
136
|
+
fullWidth: true,
|
|
137
|
+
maxWidth: false,
|
|
138
|
+
PaperProps: {
|
|
139
|
+
style: {
|
|
140
|
+
width: `${width}px`,
|
|
176
141
|
},
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (popupType === 'modal') {
|
|
180
|
-
return (
|
|
181
|
-
<Dialog {...dialogProps} disableEscapeKeyDown hideBackdrop>
|
|
182
|
-
{renderContent}
|
|
183
|
-
</Dialog>
|
|
184
|
-
)
|
|
185
|
-
}
|
|
142
|
+
},
|
|
143
|
+
}
|
|
186
144
|
|
|
145
|
+
if (popupType === 'modal') {
|
|
187
146
|
return (
|
|
188
|
-
<Dialog {...dialogProps}>
|
|
189
|
-
{onClose && (
|
|
190
|
-
<IconButton
|
|
191
|
-
size="small"
|
|
192
|
-
onClick={onClose}
|
|
193
|
-
sx={{
|
|
194
|
-
position: 'absolute',
|
|
195
|
-
right: 8,
|
|
196
|
-
top: 8,
|
|
197
|
-
color: theme => theme.palette.grey[500],
|
|
198
|
-
}}
|
|
199
|
-
>
|
|
200
|
-
<Close />
|
|
201
|
-
</IconButton>
|
|
202
|
-
)}
|
|
147
|
+
<Dialog {...dialogProps} disableEscapeKeyDown hideBackdrop>
|
|
203
148
|
{renderContent}
|
|
204
149
|
</Dialog>
|
|
205
150
|
)
|
|
206
151
|
}
|
|
207
|
-
)
|
|
208
152
|
|
|
209
|
-
|
|
153
|
+
return (
|
|
154
|
+
<Dialog {...dialogProps}>
|
|
155
|
+
{onClose && (
|
|
156
|
+
<IconButton
|
|
157
|
+
size="small"
|
|
158
|
+
onClick={onClose}
|
|
159
|
+
sx={{
|
|
160
|
+
position: 'absolute',
|
|
161
|
+
right: 8,
|
|
162
|
+
top: 8,
|
|
163
|
+
color: theme => theme.palette.grey[500],
|
|
164
|
+
}}
|
|
165
|
+
>
|
|
166
|
+
<Close />
|
|
167
|
+
</IconButton>
|
|
168
|
+
)}
|
|
169
|
+
{renderContent}
|
|
170
|
+
</Dialog>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
210
173
|
|
|
211
174
|
export default PopupForm
|