MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / PaperComponent

Function PaperComponent

web/pgadmin/static/js/helpers/ModalProvider.jsx:210–261  ·  view source on GitHub ↗
({minHeight, minWidth, ...props})

Source from the content-addressed store, hash-verified

208}
209
210function PaperComponent({minHeight, minWidth, ...props}) {
211 let [dialogPosition, setDialogPosition] = useState(null);
212 let resizeable = checkIsResizable(props);
213 const nodeRef = useRef(null);
214
215 const setConditionalPosition = () => {
216 return props.isfullscreen == 'true' ? { x: 0, y: 0 } : dialogPosition && { x: dialogPosition.x, y: dialogPosition.y };
217 };
218
219 const y_position = window.innerHeight*0.02; // 2% of total height
220 const x_position = props.width ? (window.innerWidth/2) - (props.width/2) : (window.innerWidth/2) - (MIN_WIDTH/2);
221
222 return (
223 props.isresizeable == 'true' ?
224 <StyledRnd
225 size={props.isfullscreen == 'true' && { width: '100%', height: '100%' }}
226 className={'Dialog-content ' + ( props.isfullscreen == 'true' ? 'Dialog-fullScreen' : '')}
227 default={{
228 x: x_position,
229 y: y_position,
230 ...(props.width && { width: props.width }),
231 ...(props.height && { height: props.height }),
232 }}
233 minWidth = { minWidth || MIN_WIDTH }
234 minHeight = { minHeight || MIN_HEIGHT }
235 // {...(props.width && { minWidth: MIN_WIDTH })}
236 // {...(props.height && { minHeight: MIN_HEIGHT })}
237 bounds="window"
238 enableResizing={setEnableResizing(props, resizeable)}
239 position={setConditionalPosition()}
240 onDragStop={(e, position) => {
241 if (props.isfullscreen !== 'true') {
242 setDialogPosition({
243 ...position,
244 });
245 }
246 }}
247 onResize={(e, direction, ref, delta, position) => {
248 setDialogPosition({
249 ...position,
250 });
251 }}
252 dragHandleClassName="modal-drag-area"
253 >
254 <Paper {...props} style={{ width: '100%', height: '100%', maxHeight: '100%', maxWidth: '100%' }} />
255 </StyledRnd>
256 :
257 <Draggable nodeRef={nodeRef} cancel={'[class*="MuiDialogContent-root"]'}>
258 <Paper {...props} ref={nodeRef} style={{ minWidth: '600px' }} />
259 </Draggable>
260 );
261}
262
263PaperComponent.propTypes = {
264 isfullscreen: PropTypes.string,

Callers

nothing calls this directly

Calls 3

checkIsResizableFunction · 0.85
setEnableResizingFunction · 0.85
setConditionalPositionFunction · 0.85

Tested by

no test coverage detected