@availity/mui-dialog 0.1.11 → 0.2.0
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/CHANGELOG.md +22 -0
- package/dist/index.d.mts +16 -6
- package/dist/index.d.ts +16 -6
- package/dist/index.js +40 -4
- package/dist/index.mjs +41 -6
- package/package.json +10 -3
- package/src/lib/Dialog.stories.tsx +240 -1
- package/src/lib/Dialog.test.tsx +25 -1
- package/src/lib/Dialog.tsx +29 -3
- package/src/lib/DialogContentText.stories.tsx +11 -0
- package/src/lib/DialogTitle.stories.tsx +16 -1
- package/src/lib/DialogTitle.test.tsx +14 -0
- package/src/lib/DialogTitle.tsx +24 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.2.0](https://github.com/Availity/element/compare/@availity/mui-dialog@0.1.12...@availity/mui-dialog@0.2.0) (2024-12-09)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-block-ui` updated to version `0.1.12`
|
|
10
|
+
* `mui-form-utils` updated to version `0.1.12`
|
|
11
|
+
* `mui-menu` updated to version `0.1.12`
|
|
12
|
+
* `mui-alert` updated to version `0.1.12`
|
|
13
|
+
* `mui-button` updated to version `0.1.12`
|
|
14
|
+
* `mui-icon` updated to version `0.1.12`
|
|
15
|
+
* `mui-textfield` updated to version `0.1.12`
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **mui-dialog:** add styles, alert icons, and close button ([7efdbdf](https://github.com/Availity/element/commit/7efdbdf41cca4365d196f5bab6797a07824e2c3a))
|
|
20
|
+
|
|
21
|
+
## [0.1.12](https://github.com/Availity/element/compare/@availity/mui-dialog@0.1.11...@availity/mui-dialog@0.1.12) (2024-10-31)
|
|
22
|
+
|
|
23
|
+
### Dependency Updates
|
|
24
|
+
|
|
25
|
+
* `mui-button` updated to version `0.1.11`
|
|
26
|
+
* `mui-layout` updated to version `0.1.11`
|
|
5
27
|
## [0.1.11](https://github.com/Availity/element/compare/@availity/mui-dialog@0.1.10...@availity/mui-dialog@0.1.11) (2024-08-08)
|
|
6
28
|
|
|
7
29
|
### Dependency Updates
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import * as _emotion_styled from '@emotion/styled';
|
|
2
|
+
import * as _mui_system from '@mui/system';
|
|
3
|
+
import * as _mui_material_styles from '@mui/material/styles';
|
|
1
4
|
import { DialogProps as DialogProps$1 } from '@mui/material/Dialog';
|
|
5
|
+
import { IconButtonProps } from '@availity/mui-button';
|
|
2
6
|
import { DialogActionsProps as DialogActionsProps$1 } from '@mui/material/DialogActions';
|
|
3
7
|
import { DialogContentProps as DialogContentProps$1 } from '@mui/material/DialogContent';
|
|
4
8
|
import { DialogContentTextProps as DialogContentTextProps$1 } from '@mui/material/DialogContentText';
|
|
5
9
|
import { DialogTitleProps as DialogTitleProps$1 } from '@mui/material/DialogTitle';
|
|
10
|
+
import { AlertIcons } from '@availity/mui-alert';
|
|
6
11
|
|
|
7
|
-
type DialogProps = Omit<DialogProps$1, 'BackdropComponent' | 'BackdropProps' | 'PaperComponent' | 'PaperProps' | 'TransitionComponent' | 'TransitionProps'> & {
|
|
12
|
+
type DialogProps = Omit<DialogProps$1, 'BackdropComponent' | 'BackdropProps' | 'components' | 'componentsProps' | 'container' | 'disableEnforceFocus' | 'disableEscapeKeyDown' | 'disablePortal' | 'disableRestoreFocus' | 'onBackdropClick' | 'PaperComponent' | 'PaperProps' | 'TransitionComponent' | 'TransitionProps'> & {
|
|
8
13
|
children?: React.ReactNode;
|
|
14
|
+
/** If `true` the Close icon button is shown. */
|
|
15
|
+
closeButton?: boolean;
|
|
9
16
|
};
|
|
10
|
-
declare const
|
|
17
|
+
declare const CloseButtonSlot: _emotion_styled.StyledComponent<Pick<Omit<IconButtonProps, "children" | "title">, "className" | "style" | "classes" | "action" | "disabled" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "tabIndex" | "color" | "content" | "translate" | "size" | "variant" | "ref" | "form" | "slot" | "key" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "component" | "edge"> & _mui_system.MUIStyledCommonProps<_mui_material_styles.Theme>, {}, {}>;
|
|
18
|
+
declare const Dialog: ({ children, closeButton, onClose, ...rest }: DialogProps) => JSX.Element;
|
|
11
19
|
|
|
12
20
|
interface DialogActionsProps extends DialogActionsProps$1 {
|
|
13
21
|
children?: React.ReactNode;
|
|
@@ -24,9 +32,11 @@ interface DialogContentTextProps extends DialogContentTextProps$1 {
|
|
|
24
32
|
}
|
|
25
33
|
declare const DialogContentText: ({ children, ...rest }: DialogContentTextProps) => JSX.Element;
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
type DialogTitleProps = {
|
|
28
36
|
children?: React.ReactNode;
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
/** The corresponding severity for the Alert Icon, if `undefined`/`false` no icon is displayed */
|
|
38
|
+
icon?: keyof typeof AlertIcons;
|
|
39
|
+
} & Omit<DialogTitleProps$1, 'variantMapping'>;
|
|
40
|
+
declare const DialogTitle: ({ children, component, icon, variant, ...rest }: DialogTitleProps) => JSX.Element;
|
|
31
41
|
|
|
32
|
-
export { Dialog, DialogActions, type DialogActionsProps, DialogContent, type DialogContentProps, DialogContentText, type DialogContentTextProps, type DialogProps, DialogTitle, type DialogTitleProps };
|
|
42
|
+
export { CloseButtonSlot, Dialog, DialogActions, type DialogActionsProps, DialogContent, type DialogContentProps, DialogContentText, type DialogContentTextProps, type DialogProps, DialogTitle, type DialogTitleProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import * as _emotion_styled from '@emotion/styled';
|
|
2
|
+
import * as _mui_system from '@mui/system';
|
|
3
|
+
import * as _mui_material_styles from '@mui/material/styles';
|
|
1
4
|
import { DialogProps as DialogProps$1 } from '@mui/material/Dialog';
|
|
5
|
+
import { IconButtonProps } from '@availity/mui-button';
|
|
2
6
|
import { DialogActionsProps as DialogActionsProps$1 } from '@mui/material/DialogActions';
|
|
3
7
|
import { DialogContentProps as DialogContentProps$1 } from '@mui/material/DialogContent';
|
|
4
8
|
import { DialogContentTextProps as DialogContentTextProps$1 } from '@mui/material/DialogContentText';
|
|
5
9
|
import { DialogTitleProps as DialogTitleProps$1 } from '@mui/material/DialogTitle';
|
|
10
|
+
import { AlertIcons } from '@availity/mui-alert';
|
|
6
11
|
|
|
7
|
-
type DialogProps = Omit<DialogProps$1, 'BackdropComponent' | 'BackdropProps' | 'PaperComponent' | 'PaperProps' | 'TransitionComponent' | 'TransitionProps'> & {
|
|
12
|
+
type DialogProps = Omit<DialogProps$1, 'BackdropComponent' | 'BackdropProps' | 'components' | 'componentsProps' | 'container' | 'disableEnforceFocus' | 'disableEscapeKeyDown' | 'disablePortal' | 'disableRestoreFocus' | 'onBackdropClick' | 'PaperComponent' | 'PaperProps' | 'TransitionComponent' | 'TransitionProps'> & {
|
|
8
13
|
children?: React.ReactNode;
|
|
14
|
+
/** If `true` the Close icon button is shown. */
|
|
15
|
+
closeButton?: boolean;
|
|
9
16
|
};
|
|
10
|
-
declare const
|
|
17
|
+
declare const CloseButtonSlot: _emotion_styled.StyledComponent<Pick<Omit<IconButtonProps, "children" | "title">, "className" | "style" | "classes" | "action" | "disabled" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "tabIndex" | "color" | "content" | "translate" | "size" | "variant" | "ref" | "form" | "slot" | "key" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "component" | "edge"> & _mui_system.MUIStyledCommonProps<_mui_material_styles.Theme>, {}, {}>;
|
|
18
|
+
declare const Dialog: ({ children, closeButton, onClose, ...rest }: DialogProps) => JSX.Element;
|
|
11
19
|
|
|
12
20
|
interface DialogActionsProps extends DialogActionsProps$1 {
|
|
13
21
|
children?: React.ReactNode;
|
|
@@ -24,9 +32,11 @@ interface DialogContentTextProps extends DialogContentTextProps$1 {
|
|
|
24
32
|
}
|
|
25
33
|
declare const DialogContentText: ({ children, ...rest }: DialogContentTextProps) => JSX.Element;
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
type DialogTitleProps = {
|
|
28
36
|
children?: React.ReactNode;
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
/** The corresponding severity for the Alert Icon, if `undefined`/`false` no icon is displayed */
|
|
38
|
+
icon?: keyof typeof AlertIcons;
|
|
39
|
+
} & Omit<DialogTitleProps$1, 'variantMapping'>;
|
|
40
|
+
declare const DialogTitle: ({ children, component, icon, variant, ...rest }: DialogTitleProps) => JSX.Element;
|
|
31
41
|
|
|
32
|
-
export { Dialog, DialogActions, type DialogActionsProps, DialogContent, type DialogContentProps, DialogContentText, type DialogContentTextProps, type DialogProps, DialogTitle, type DialogTitleProps };
|
|
42
|
+
export { CloseButtonSlot, Dialog, DialogActions, type DialogActionsProps, DialogContent, type DialogContentProps, DialogContentText, type DialogContentTextProps, type DialogProps, DialogTitle, type DialogTitleProps };
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
59
59
|
// src/index.ts
|
|
60
60
|
var src_exports = {};
|
|
61
61
|
__export(src_exports, {
|
|
62
|
+
CloseButtonSlot: () => CloseButtonSlot,
|
|
62
63
|
Dialog: () => Dialog,
|
|
63
64
|
DialogActions: () => DialogActions,
|
|
64
65
|
DialogContent: () => DialogContent,
|
|
@@ -69,10 +70,29 @@ module.exports = __toCommonJS(src_exports);
|
|
|
69
70
|
|
|
70
71
|
// src/lib/Dialog.tsx
|
|
71
72
|
var import_Dialog = __toESM(require("@mui/material/Dialog"));
|
|
73
|
+
var import_styles = require("@mui/material/styles");
|
|
74
|
+
var import_mui_button = require("@availity/mui-button");
|
|
75
|
+
var import_mui_icon = require("@availity/mui-icon");
|
|
72
76
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
77
|
+
var CloseButton = (args) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_button.IconButton, __spreadProps(__spreadValues({ title: "Close Dialog", color: "secondary" }, args), { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_icon.CloseIcon, { fontSize: "xsmall" }) }));
|
|
78
|
+
var CloseButtonSlot = (0, import_styles.styled)(CloseButton, {
|
|
79
|
+
name: "MuiDialog",
|
|
80
|
+
slot: "AvCloseButton",
|
|
81
|
+
overridesResolver: (props, styles) => styles.avCloseButton
|
|
82
|
+
})({
|
|
83
|
+
position: "absolute",
|
|
84
|
+
top: ".5rem",
|
|
85
|
+
right: ".5rem",
|
|
86
|
+
"~ .MuiDialogTitle-root": {
|
|
87
|
+
marginRight: "3.5rem"
|
|
88
|
+
}
|
|
89
|
+
});
|
|
73
90
|
var Dialog = (_a) => {
|
|
74
|
-
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
75
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
91
|
+
var _b = _a, { children, closeButton = true, onClose } = _b, rest = __objRest(_b, ["children", "closeButton", "onClose"]);
|
|
92
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_Dialog.default, __spreadProps(__spreadValues({ onClose }, rest), { children: [
|
|
93
|
+
closeButton ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CloseButtonSlot, { onClick: onClose }) : null,
|
|
94
|
+
children
|
|
95
|
+
] }));
|
|
76
96
|
};
|
|
77
97
|
|
|
78
98
|
// src/lib/DialogActions.tsx
|
|
@@ -101,13 +121,29 @@ var DialogContentText = (_a) => {
|
|
|
101
121
|
|
|
102
122
|
// src/lib/DialogTitle.tsx
|
|
103
123
|
var import_DialogTitle = __toESM(require("@mui/material/DialogTitle"));
|
|
124
|
+
var import_mui_alert = require("@availity/mui-alert");
|
|
125
|
+
var import_styles2 = require("@mui/material/styles");
|
|
104
126
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
127
|
+
var AlertIcon = (0, import_styles2.styled)("div", {
|
|
128
|
+
name: "MuiDialogTitle",
|
|
129
|
+
slot: "AvIcon",
|
|
130
|
+
overridesResolver: (props, styles) => styles.avIcon
|
|
131
|
+
})({
|
|
132
|
+
display: "inline-flex",
|
|
133
|
+
fontSize: "inherit",
|
|
134
|
+
marginRight: ".5rem",
|
|
135
|
+
verticalAlign: "text-bottom"
|
|
136
|
+
});
|
|
105
137
|
var DialogTitle = (_a) => {
|
|
106
|
-
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
107
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.
|
|
138
|
+
var _b = _a, { children, component = "h2", icon, variant = "h5" } = _b, rest = __objRest(_b, ["children", "component", "icon", "variant"]);
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_DialogTitle.default, __spreadProps(__spreadValues({ component, variant }, rest), { children: [
|
|
140
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AlertIcon, { children: import_mui_alert.AlertIcons[icon] }) : null,
|
|
141
|
+
children
|
|
142
|
+
] }));
|
|
108
143
|
};
|
|
109
144
|
// Annotate the CommonJS export names for ESM import in node:
|
|
110
145
|
0 && (module.exports = {
|
|
146
|
+
CloseButtonSlot,
|
|
111
147
|
Dialog,
|
|
112
148
|
DialogActions,
|
|
113
149
|
DialogContent,
|
package/dist/index.mjs
CHANGED
|
@@ -32,10 +32,29 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
|
|
33
33
|
// src/lib/Dialog.tsx
|
|
34
34
|
import MuiDialog from "@mui/material/Dialog";
|
|
35
|
-
import {
|
|
35
|
+
import { styled } from "@mui/material/styles";
|
|
36
|
+
import { IconButton } from "@availity/mui-button";
|
|
37
|
+
import { CloseIcon } from "@availity/mui-icon";
|
|
38
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
39
|
+
var CloseButton = (args) => /* @__PURE__ */ jsx(IconButton, __spreadProps(__spreadValues({ title: "Close Dialog", color: "secondary" }, args), { children: /* @__PURE__ */ jsx(CloseIcon, { fontSize: "xsmall" }) }));
|
|
40
|
+
var CloseButtonSlot = styled(CloseButton, {
|
|
41
|
+
name: "MuiDialog",
|
|
42
|
+
slot: "AvCloseButton",
|
|
43
|
+
overridesResolver: (props, styles) => styles.avCloseButton
|
|
44
|
+
})({
|
|
45
|
+
position: "absolute",
|
|
46
|
+
top: ".5rem",
|
|
47
|
+
right: ".5rem",
|
|
48
|
+
"~ .MuiDialogTitle-root": {
|
|
49
|
+
marginRight: "3.5rem"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
36
52
|
var Dialog = (_a) => {
|
|
37
|
-
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
38
|
-
return /* @__PURE__ */
|
|
53
|
+
var _b = _a, { children, closeButton = true, onClose } = _b, rest = __objRest(_b, ["children", "closeButton", "onClose"]);
|
|
54
|
+
return /* @__PURE__ */ jsxs(MuiDialog, __spreadProps(__spreadValues({ onClose }, rest), { children: [
|
|
55
|
+
closeButton ? /* @__PURE__ */ jsx(CloseButtonSlot, { onClick: onClose }) : null,
|
|
56
|
+
children
|
|
57
|
+
] }));
|
|
39
58
|
};
|
|
40
59
|
|
|
41
60
|
// src/lib/DialogActions.tsx
|
|
@@ -64,12 +83,28 @@ var DialogContentText = (_a) => {
|
|
|
64
83
|
|
|
65
84
|
// src/lib/DialogTitle.tsx
|
|
66
85
|
import MuiDialogTitle from "@mui/material/DialogTitle";
|
|
67
|
-
import {
|
|
86
|
+
import { AlertIcons } from "@availity/mui-alert";
|
|
87
|
+
import { styled as styled2 } from "@mui/material/styles";
|
|
88
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
89
|
+
var AlertIcon = styled2("div", {
|
|
90
|
+
name: "MuiDialogTitle",
|
|
91
|
+
slot: "AvIcon",
|
|
92
|
+
overridesResolver: (props, styles) => styles.avIcon
|
|
93
|
+
})({
|
|
94
|
+
display: "inline-flex",
|
|
95
|
+
fontSize: "inherit",
|
|
96
|
+
marginRight: ".5rem",
|
|
97
|
+
verticalAlign: "text-bottom"
|
|
98
|
+
});
|
|
68
99
|
var DialogTitle = (_a) => {
|
|
69
|
-
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
70
|
-
return /* @__PURE__ */
|
|
100
|
+
var _b = _a, { children, component = "h2", icon, variant = "h5" } = _b, rest = __objRest(_b, ["children", "component", "icon", "variant"]);
|
|
101
|
+
return /* @__PURE__ */ jsxs2(MuiDialogTitle, __spreadProps(__spreadValues({ component, variant }, rest), { children: [
|
|
102
|
+
icon ? /* @__PURE__ */ jsx5(AlertIcon, { children: AlertIcons[icon] }) : null,
|
|
103
|
+
children
|
|
104
|
+
] }));
|
|
71
105
|
};
|
|
72
106
|
export {
|
|
107
|
+
CloseButtonSlot,
|
|
73
108
|
Dialog,
|
|
74
109
|
DialogActions,
|
|
75
110
|
DialogContent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-dialog",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Availity MUI Dialog Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -31,9 +31,16 @@
|
|
|
31
31
|
"publish": "yarn npm publish --tolerate-republish --access public",
|
|
32
32
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
33
33
|
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@availity/mui-alert": "0.7.0",
|
|
36
|
+
"@availity/mui-button": "0.6.12",
|
|
37
|
+
"@availity/mui-icon": "0.11.1"
|
|
38
|
+
},
|
|
34
39
|
"devDependencies": {
|
|
35
|
-
"@availity/mui-
|
|
36
|
-
"@availity/mui-
|
|
40
|
+
"@availity/mui-block-ui": "0.1.16",
|
|
41
|
+
"@availity/mui-form-utils": "0.15.1",
|
|
42
|
+
"@availity/mui-layout": "0.2.0",
|
|
43
|
+
"@availity/mui-menu": "0.2.12",
|
|
37
44
|
"@mui/material": "^5.15.15",
|
|
38
45
|
"react": "18.2.0",
|
|
39
46
|
"react-dom": "18.2.0",
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
4
|
import { Button } from '@availity/mui-button';
|
|
5
|
+
import { BlockUi } from '@availity/mui-block-ui';
|
|
6
|
+
import { SelectChangeEvent, FormControlLabel, Switch } from '@availity/mui-form-utils';
|
|
7
|
+
import { Box, Grid } from '@availity/mui-layout';
|
|
8
|
+
import { MenuItem } from '@availity/mui-menu';
|
|
9
|
+
import { TextField } from '@availity/mui-textfield';
|
|
5
10
|
|
|
6
11
|
import { Dialog, DialogProps } from './Dialog';
|
|
7
12
|
import { DialogActions } from './DialogActions';
|
|
@@ -17,6 +22,30 @@ const meta: Meta<typeof Dialog> = {
|
|
|
17
22
|
|
|
18
23
|
export default meta;
|
|
19
24
|
|
|
25
|
+
const MockDialogProps = {
|
|
26
|
+
disableAutoFocus: true,
|
|
27
|
+
disableEnforceFocus: true,
|
|
28
|
+
disableEscapeKeyDown: true,
|
|
29
|
+
disablePortal: true,
|
|
30
|
+
disableRestoreFocus: true,
|
|
31
|
+
disableScrollLock: true,
|
|
32
|
+
hideBackdrop: true,
|
|
33
|
+
keepMounted: true,
|
|
34
|
+
onClose: ()=>null,
|
|
35
|
+
open: true,
|
|
36
|
+
sx: {
|
|
37
|
+
position: 'relative',
|
|
38
|
+
'.MuiDialog-container': {
|
|
39
|
+
alignItems: 'normal',
|
|
40
|
+
justifyContent: 'normal'
|
|
41
|
+
},
|
|
42
|
+
'.MuiDialog-paper': {
|
|
43
|
+
margin: 0
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
20
49
|
export const _Dialog: StoryObj<typeof Dialog> = {
|
|
21
50
|
render: (args: DialogProps) => {
|
|
22
51
|
const [open, setOpen] = useState(args.open);
|
|
@@ -37,7 +66,7 @@ export const _Dialog: StoryObj<typeof Dialog> = {
|
|
|
37
66
|
<>
|
|
38
67
|
<Button onClick={handleOpen}>Open Dialog</Button>
|
|
39
68
|
<Dialog {...args} open={open} onClose={handleClose} aria-labelledby="alert-dialog-title">
|
|
40
|
-
<DialogTitle id="alert-dialog-title"
|
|
69
|
+
<DialogTitle id="alert-dialog-title">
|
|
41
70
|
Availity Dialog
|
|
42
71
|
</DialogTitle>
|
|
43
72
|
<DialogContent>
|
|
@@ -60,3 +89,213 @@ export const _Dialog: StoryObj<typeof Dialog> = {
|
|
|
60
89
|
open: false,
|
|
61
90
|
},
|
|
62
91
|
};
|
|
92
|
+
export const _DialogDisplay: StoryObj<typeof Dialog> = {
|
|
93
|
+
render: (args: DialogProps) => (
|
|
94
|
+
<Dialog {...MockDialogProps} {...args}>
|
|
95
|
+
<DialogTitle id="alert-dialog-title">
|
|
96
|
+
Availity Dialog
|
|
97
|
+
</DialogTitle>
|
|
98
|
+
<DialogContent>
|
|
99
|
+
<DialogContentText>Dialog Content Text</DialogContentText>
|
|
100
|
+
</DialogContent>
|
|
101
|
+
<DialogActions>
|
|
102
|
+
<Button onClick={()=>null} color="secondary">
|
|
103
|
+
Disagree
|
|
104
|
+
</Button>
|
|
105
|
+
<Button onClick={()=>null} autoFocus>
|
|
106
|
+
Agree
|
|
107
|
+
</Button>
|
|
108
|
+
</DialogActions>
|
|
109
|
+
</Dialog>
|
|
110
|
+
),
|
|
111
|
+
args: {
|
|
112
|
+
disableAutoFocus: true,
|
|
113
|
+
disableScrollLock: true,
|
|
114
|
+
hideBackdrop: true,
|
|
115
|
+
onClose: ()=>null,
|
|
116
|
+
open: true,
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const _Sizes: StoryObj<typeof Dialog> = {
|
|
121
|
+
render: () => {
|
|
122
|
+
const [open, setOpen] = useState(false);
|
|
123
|
+
const [fullWidth, setFullWidth] = useState(true);
|
|
124
|
+
const [maxWidth, setMaxWidth] = useState<DialogProps['maxWidth']>('sm');
|
|
125
|
+
|
|
126
|
+
const handleClickOpen = () => {
|
|
127
|
+
setOpen(true);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const handleClose = () => {
|
|
131
|
+
setOpen(false);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const handleMaxWidthChange = (event: SelectChangeEvent<typeof maxWidth>) => {
|
|
135
|
+
setMaxWidth(
|
|
136
|
+
// @ts-expect-error autofill of arbitrary value is not handled.
|
|
137
|
+
event.target.value,
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const handleFullWidthChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
142
|
+
setFullWidth(event.target.checked);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<>
|
|
147
|
+
<Button onClick={handleClickOpen}>
|
|
148
|
+
Open max-width dialog
|
|
149
|
+
</Button>
|
|
150
|
+
<Dialog
|
|
151
|
+
fullWidth={fullWidth}
|
|
152
|
+
maxWidth={maxWidth}
|
|
153
|
+
open={open}
|
|
154
|
+
onClose={handleClose}
|
|
155
|
+
>
|
|
156
|
+
<DialogTitle>Optional sizes</DialogTitle>
|
|
157
|
+
<DialogContent>
|
|
158
|
+
<DialogContentText>
|
|
159
|
+
You can set my maximum width and whether to adapt or not.
|
|
160
|
+
</DialogContentText>
|
|
161
|
+
<Box
|
|
162
|
+
component="form"
|
|
163
|
+
sx={{
|
|
164
|
+
display: 'flex',
|
|
165
|
+
flexDirection: 'column',
|
|
166
|
+
m: 'auto',
|
|
167
|
+
width: 'fit-content',
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<FormControlLabel
|
|
171
|
+
sx={{ mt: 1 }}
|
|
172
|
+
control={
|
|
173
|
+
<Switch checked={fullWidth} onChange={handleFullWidthChange} />
|
|
174
|
+
}
|
|
175
|
+
label="Full width"
|
|
176
|
+
/>
|
|
177
|
+
<TextField value={maxWidth} select SelectProps={{ onChange: handleMaxWidthChange }} label="max-width" name="max-width" margin="normal">
|
|
178
|
+
<MenuItem value={false as any}>false</MenuItem>
|
|
179
|
+
<MenuItem value="xs">xs</MenuItem>
|
|
180
|
+
<MenuItem value="sm">sm</MenuItem>
|
|
181
|
+
<MenuItem value="md">md</MenuItem>
|
|
182
|
+
<MenuItem value="lg">lg</MenuItem>
|
|
183
|
+
<MenuItem value="xl">xl</MenuItem>
|
|
184
|
+
</TextField>
|
|
185
|
+
</Box>
|
|
186
|
+
</DialogContent>
|
|
187
|
+
<DialogActions>
|
|
188
|
+
<Button onClick={handleClose}>Close</Button>
|
|
189
|
+
</DialogActions>
|
|
190
|
+
</Dialog>
|
|
191
|
+
</>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/** The loader should only display over the central dialog content */
|
|
197
|
+
export const _Loading: StoryObj<typeof Dialog> = {
|
|
198
|
+
render: () => (
|
|
199
|
+
<Dialog {...MockDialogProps} fullWidth>
|
|
200
|
+
<DialogTitle id="alert-dialog-title">
|
|
201
|
+
Availity Dialog
|
|
202
|
+
</DialogTitle>
|
|
203
|
+
<DialogContent>
|
|
204
|
+
<BlockUi blocking message="Loading">
|
|
205
|
+
<DialogContentText>
|
|
206
|
+
Dialog Content Text
|
|
207
|
+
|
|
208
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sem mauris, sollicitudin sit amet lacus vel, sollicitudin tincidunt mi. Mauris risus nisi, sagittis id augue sit amet, venenatis volutpat dui. Etiam commodo vel lectus eget ornare. Donec laoreet urna eu velit condimentum viverra. Curabitur ut pulvinar ipsum, vitae laoreet nulla. Nam in nisl sit amet leo dignissim tempor. Donec imperdiet est odio, ac aliquam libero eleifend at. Pellentesque tempor semper nulla vel fermentum. Pellentesque viverra, neque vel laoreet sollicitudin, massa lacus ultricies lectus, quis rutrum odio orci vitae turpis. Donec rhoncus dui nec ex porta, vel porta odio suscipit.
|
|
209
|
+
</DialogContentText>
|
|
210
|
+
</BlockUi>
|
|
211
|
+
</DialogContent>
|
|
212
|
+
<DialogActions>
|
|
213
|
+
<Button onClick={()=>null} color="secondary">
|
|
214
|
+
Disagree
|
|
215
|
+
</Button>
|
|
216
|
+
<Button onClick={()=>null} autoFocus>
|
|
217
|
+
Agree
|
|
218
|
+
</Button>
|
|
219
|
+
</DialogActions>
|
|
220
|
+
</Dialog>
|
|
221
|
+
),
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export const _WithAlertIcons: StoryObj<typeof Dialog> = {
|
|
225
|
+
render: () => (
|
|
226
|
+
<Grid container direction="row" spacing={2} flexWrap="wrap">
|
|
227
|
+
<Grid>
|
|
228
|
+
<Dialog {...MockDialogProps}>
|
|
229
|
+
<DialogTitle id="alert-dialog-title" icon="info">
|
|
230
|
+
Info
|
|
231
|
+
</DialogTitle>
|
|
232
|
+
<DialogContent>
|
|
233
|
+
<DialogContentText>Dialog Content Text</DialogContentText>
|
|
234
|
+
</DialogContent>
|
|
235
|
+
<DialogActions>
|
|
236
|
+
<Button onClick={()=>null} color="secondary">
|
|
237
|
+
Disagree
|
|
238
|
+
</Button>
|
|
239
|
+
<Button onClick={()=>null} autoFocus>
|
|
240
|
+
Agree
|
|
241
|
+
</Button>
|
|
242
|
+
</DialogActions>
|
|
243
|
+
</Dialog>
|
|
244
|
+
</Grid>
|
|
245
|
+
<Grid>
|
|
246
|
+
<Dialog {...MockDialogProps}>
|
|
247
|
+
<DialogTitle id="alert-dialog-title" icon="success">
|
|
248
|
+
Success
|
|
249
|
+
</DialogTitle>
|
|
250
|
+
<DialogContent>
|
|
251
|
+
<DialogContentText>Dialog Content Text</DialogContentText>
|
|
252
|
+
</DialogContent>
|
|
253
|
+
<DialogActions>
|
|
254
|
+
<Button onClick={()=>null} color="secondary">
|
|
255
|
+
Disagree
|
|
256
|
+
</Button>
|
|
257
|
+
<Button onClick={()=>null} autoFocus>
|
|
258
|
+
Agree
|
|
259
|
+
</Button>
|
|
260
|
+
</DialogActions>
|
|
261
|
+
</Dialog>
|
|
262
|
+
</Grid>
|
|
263
|
+
<Grid>
|
|
264
|
+
<Dialog {...MockDialogProps}>
|
|
265
|
+
<DialogTitle id="alert-dialog-title" icon="warning">
|
|
266
|
+
Warning
|
|
267
|
+
</DialogTitle>
|
|
268
|
+
<DialogContent>
|
|
269
|
+
<DialogContentText>Dialog Content Text</DialogContentText>
|
|
270
|
+
</DialogContent>
|
|
271
|
+
<DialogActions>
|
|
272
|
+
<Button onClick={()=>null} color="secondary">
|
|
273
|
+
Disagree
|
|
274
|
+
</Button>
|
|
275
|
+
<Button onClick={()=>null} autoFocus>
|
|
276
|
+
Agree
|
|
277
|
+
</Button>
|
|
278
|
+
</DialogActions>
|
|
279
|
+
</Dialog>
|
|
280
|
+
</Grid>
|
|
281
|
+
<Grid>
|
|
282
|
+
<Dialog {...MockDialogProps}>
|
|
283
|
+
<DialogTitle id="alert-dialog-title" icon="error">
|
|
284
|
+
Error
|
|
285
|
+
</DialogTitle>
|
|
286
|
+
<DialogContent>
|
|
287
|
+
<DialogContentText>Dialog Content Text</DialogContentText>
|
|
288
|
+
</DialogContent>
|
|
289
|
+
<DialogActions>
|
|
290
|
+
<Button onClick={()=>null} color="secondary">
|
|
291
|
+
Disagree
|
|
292
|
+
</Button>
|
|
293
|
+
<Button onClick={()=>null} autoFocus>
|
|
294
|
+
Agree
|
|
295
|
+
</Button>
|
|
296
|
+
</DialogActions>
|
|
297
|
+
</Dialog>
|
|
298
|
+
</Grid>
|
|
299
|
+
</Grid>
|
|
300
|
+
),
|
|
301
|
+
};
|
package/src/lib/Dialog.test.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
2
2
|
import { Dialog } from './Dialog';
|
|
3
3
|
|
|
4
4
|
describe('Dialog', () => {
|
|
@@ -6,4 +6,28 @@ describe('Dialog', () => {
|
|
|
6
6
|
const { getByText } = render(<Dialog open>Test</Dialog>);
|
|
7
7
|
expect(getByText('Test')).toBeTruthy();
|
|
8
8
|
});
|
|
9
|
+
|
|
10
|
+
test('should render close button when `closeButton` is true', () => {
|
|
11
|
+
const { getByRole } = render(
|
|
12
|
+
<Dialog open closeButton/>
|
|
13
|
+
);
|
|
14
|
+
expect(getByRole('button')).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('should not render close button when `closeButton` is false', () => {
|
|
18
|
+
const { queryByRole } = render(
|
|
19
|
+
<Dialog open closeButton={false}/>
|
|
20
|
+
);
|
|
21
|
+
expect(queryByRole('button')).toBeNull();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('calls onClose when close button clicked', () => {
|
|
25
|
+
const handleClose = jest.fn();
|
|
26
|
+
const { getByRole } = render(
|
|
27
|
+
<Dialog open onClose={handleClose}/>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
fireEvent.click(getByRole('button'));
|
|
31
|
+
expect(handleClose).toHaveBeenCalled();
|
|
32
|
+
});
|
|
9
33
|
});
|
package/src/lib/Dialog.tsx
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
import MuiDialog, { DialogProps as MuiDialogProps } from '@mui/material/Dialog';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import { IconButton, IconButtonProps } from '@availity/mui-button';
|
|
4
|
+
import { CloseIcon } from '@availity/mui-icon';
|
|
5
|
+
|
|
2
6
|
|
|
3
7
|
export type DialogProps = Omit<
|
|
4
8
|
MuiDialogProps,
|
|
5
|
-
'BackdropComponent' | 'BackdropProps' | 'PaperComponent' | 'PaperProps' | 'TransitionComponent' | 'TransitionProps'
|
|
9
|
+
'BackdropComponent' | 'BackdropProps' | 'components' | 'componentsProps' | 'container' | 'disableEnforceFocus' | 'disableEscapeKeyDown' | 'disablePortal' | 'disableRestoreFocus' | 'onBackdropClick' | 'PaperComponent' | 'PaperProps' | 'TransitionComponent' | 'TransitionProps'
|
|
6
10
|
> & {
|
|
7
11
|
children?: React.ReactNode;
|
|
12
|
+
/** If `true` the Close icon button is shown. */
|
|
13
|
+
closeButton?: boolean;
|
|
8
14
|
};
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
const CloseButton = (args: Omit<IconButtonProps, 'children' | 'title'>) => <IconButton title="Close Dialog" color="secondary" {...args}><CloseIcon fontSize="xsmall"/></IconButton>
|
|
17
|
+
|
|
18
|
+
export const CloseButtonSlot = styled(CloseButton, {
|
|
19
|
+
name: 'MuiDialog',
|
|
20
|
+
slot: 'AvCloseButton',
|
|
21
|
+
overridesResolver: (props, styles) => styles.avCloseButton,
|
|
22
|
+
})({
|
|
23
|
+
position: "absolute",
|
|
24
|
+
top: '.5rem',
|
|
25
|
+
right: '.5rem',
|
|
26
|
+
"~ .MuiDialogTitle-root": {
|
|
27
|
+
marginRight: '3.5rem'
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const Dialog = ({ children, closeButton = true, onClose, ...rest }: DialogProps): JSX.Element => {
|
|
32
|
+
return (
|
|
33
|
+
<MuiDialog onClose={onClose} {...rest}>
|
|
34
|
+
{closeButton ? <CloseButtonSlot onClick={onClose as IconButtonProps['onClick']}/> : null}
|
|
35
|
+
{children}
|
|
36
|
+
</MuiDialog>
|
|
37
|
+
);
|
|
12
38
|
};
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
3
|
+
import { SystemPropsList } from '../../../../data/MuiSystemProperties';
|
|
2
4
|
|
|
3
5
|
import { DialogContentText, DialogContentTextProps } from './DialogContentText';
|
|
4
6
|
|
|
7
|
+
/** > As a CSS utility, the `DialogContextText` component also supports all [system properties](https://mui.com/system/properties/). They are omitted for brevity, but can be used as props directly on the component.
|
|
8
|
+
*/
|
|
5
9
|
const meta: Meta<typeof DialogContentText> = {
|
|
6
10
|
title: 'Components/Dialog/DialogContentText',
|
|
7
11
|
component: DialogContentText,
|
|
8
12
|
tags: ['autodocs'],
|
|
13
|
+
parameters: {
|
|
14
|
+
docs: {
|
|
15
|
+
controls: {
|
|
16
|
+
exclude: SystemPropsList,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
9
20
|
};
|
|
10
21
|
|
|
11
22
|
export default meta;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
2
|
import { DialogTitle, DialogTitleProps } from './DialogTitle';
|
|
3
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
4
|
+
import { SystemPropsList } from '../../../../data/MuiSystemProperties';
|
|
4
5
|
|
|
6
|
+
/** > As a CSS utility, the `DialogTitle` component also supports all [system properties](https://mui.com/system/properties/). They are omitted for brevity, but can be used as props directly on the component.
|
|
7
|
+
*/
|
|
5
8
|
const meta: Meta<typeof DialogTitle> = {
|
|
6
9
|
title: 'Components/Dialog/DialogTitle',
|
|
7
10
|
component: DialogTitle,
|
|
8
11
|
tags: ['autodocs'],
|
|
12
|
+
parameters: {
|
|
13
|
+
docs: {
|
|
14
|
+
controls: {
|
|
15
|
+
exclude: SystemPropsList,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
9
19
|
};
|
|
10
20
|
|
|
11
21
|
export default meta;
|
|
@@ -16,3 +26,8 @@ export const _DialogTitle: StoryObj<typeof DialogTitle> = {
|
|
|
16
26
|
children: 'Modal Title',
|
|
17
27
|
},
|
|
18
28
|
};
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export const _WithIcon: StoryObj<typeof DialogTitle> = {
|
|
32
|
+
render: () => <DialogTitle icon="info">Info</DialogTitle>,
|
|
33
|
+
};
|
|
@@ -6,4 +6,18 @@ describe('DialogTitle', () => {
|
|
|
6
6
|
const { getByText } = render(<DialogTitle>Test</DialogTitle>);
|
|
7
7
|
expect(getByText('Test')).toBeTruthy();
|
|
8
8
|
});
|
|
9
|
+
|
|
10
|
+
test('should render an alert icon when value passed to `icon`', () => {
|
|
11
|
+
const { queryByRole } = render(
|
|
12
|
+
<DialogTitle icon="info"/>
|
|
13
|
+
);
|
|
14
|
+
expect(queryByRole('img', {hidden: true, })).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('should not render an alert icon when no value passed to `icon`', () => {
|
|
18
|
+
const { queryByRole } = render(
|
|
19
|
+
<DialogTitle/>
|
|
20
|
+
);
|
|
21
|
+
expect(queryByRole('img', {hidden: true})).toBeNull();
|
|
22
|
+
});
|
|
9
23
|
});
|
package/src/lib/DialogTitle.tsx
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import MuiDialogTitle, { DialogTitleProps as MuiDialogTitleProps } from '@mui/material/DialogTitle';
|
|
2
|
+
import { AlertIcons } from '@availity/mui-alert';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
const AlertIcon = styled('div', {
|
|
6
|
+
name: 'MuiDialogTitle',
|
|
7
|
+
slot: 'AvIcon',
|
|
8
|
+
overridesResolver: (props, styles) => styles.avIcon,
|
|
9
|
+
})({
|
|
10
|
+
display: 'inline-flex',
|
|
11
|
+
fontSize: 'inherit',
|
|
12
|
+
marginRight: '.5rem',
|
|
13
|
+
verticalAlign: 'text-bottom'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type DialogTitleProps = {
|
|
4
17
|
children?: React.ReactNode;
|
|
5
|
-
|
|
18
|
+
/** The corresponding severity for the Alert Icon, if `undefined`/`false` no icon is displayed */
|
|
19
|
+
icon?: keyof typeof AlertIcons;
|
|
20
|
+
} & Omit<MuiDialogTitleProps, 'variantMapping'>
|
|
6
21
|
|
|
7
|
-
export const DialogTitle = ({ children, ...rest }: DialogTitleProps): JSX.Element => {
|
|
8
|
-
return
|
|
22
|
+
export const DialogTitle = ({ children, component="h2", icon, variant="h5", ...rest }: DialogTitleProps): JSX.Element => {
|
|
23
|
+
return (
|
|
24
|
+
<MuiDialogTitle component={component} variant={variant} {...rest}>
|
|
25
|
+
{icon ? <AlertIcon>{AlertIcons[icon]}</AlertIcon> : null}
|
|
26
|
+
{children}
|
|
27
|
+
</MuiDialogTitle>
|
|
28
|
+
);
|
|
9
29
|
};
|