@turnit-ou/shared 2.18.0 → 2.18.1

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.
@@ -2,6 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { useCallback, useRef } from 'react';
3
3
  import { makeStyles, useTheme } from '@mui/styles';
4
4
  import Paper from '@mui/material/Paper';
5
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
5
6
  import { Icon } from "../mui/Icon";
6
7
  import classNames from 'classnames';
7
8
  import { alpha } from '@mui/material/styles';
@@ -67,6 +68,10 @@ export function DrawerForm(inProps) {
67
68
  const handleClickClose = useCallback((event) => {
68
69
  onClose?.(event, 'close');
69
70
  }, [onClose]);
71
+ const handleClickAway = useCallback((event) => {
72
+ if (open)
73
+ onClose?.(event, 'backdropClick');
74
+ }, [open, onClose]);
70
75
  const classes = useStyles({ width, ...props });
71
76
  // The drawer is a modal: MUI moves focus into it on open, keeps it there
72
77
  // while it is open and puts it back on close. The page behind it is hidden
@@ -74,11 +79,11 @@ export function DrawerForm(inProps) {
74
79
  // why MUI's own aria-hidden is not enough here).
75
80
  const drawerRef = useRef(null);
76
81
  useInertBackground(Boolean(open), drawerRef);
77
- return (_jsx(Drawer, { ref: drawerRef, anchor: "right", open: open, onClose: onClose, className: classNames(classes.modal, className), disablePortal: true, hideBackdrop: true, PaperProps: {
78
- className: classes.paper,
79
- elevation: 4,
80
- square: true,
81
- // Focus target for MUI's focus trap when the drawer opens.
82
- tabIndex: -1,
83
- }, SlideProps: { timeout: transitionDuration }, ...props, children: _jsxs(_Fragment, { children: [arrow && (_jsx("button", { type: "button", className: classNames(classes.arrow, 'drawer-button'), "aria-label": t('button.collapse', 'Collapse'), onClick: handleClickClose, children: _jsx(Icon, { name: "chevron-right" }) })), _jsx(Paper, { className: classes.content, ...(arrow && { variant: 'surface' }), children: _jsx(DrawerFormContextProvider, { value: { handleClose: handleClickClose }, children: children }) })] }) }));
82
+ return (_jsx(ClickAwayListener, { onClickAway: handleClickAway, children: _jsx(Drawer, { ref: drawerRef, anchor: "right", open: open, onClose: onClose, className: classNames(classes.modal, className), disablePortal: true, hideBackdrop: true, PaperProps: {
83
+ className: classes.paper,
84
+ elevation: 4,
85
+ square: true,
86
+ // Focus target for MUI's focus trap when the drawer opens.
87
+ tabIndex: -1,
88
+ }, SlideProps: { timeout: transitionDuration }, ...props, children: _jsxs(_Fragment, { children: [arrow && (_jsx("button", { type: "button", className: classNames(classes.arrow, 'drawer-button'), "aria-label": t('button.collapse', 'Collapse'), onClick: handleClickClose, children: _jsx(Icon, { name: "chevron-right" }) })), _jsx(Paper, { className: classes.content, ...(arrow && { variant: 'surface' }), children: _jsx(DrawerFormContextProvider, { value: { handleClose: handleClickClose }, children: children }) })] }) }) }));
84
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turnit-ou/shared",
3
- "version": "2.18.0",
3
+ "version": "2.18.1",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "start": "vite --force",