@conveyorhq/arrow-ds 1.94.0 → 1.95.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.
- package/package.json +1 -1
- package/public/components/Modal/Modal.d.ts +45 -1
- package/public/components/Modal/Modal.js +104 -30
- package/public/components/Modal/context.d.ts +2 -0
- package/public/css/styles.css +45 -2
- package/public/css/styles.min.css +1 -1
- package/public/css/styles.min.css.map +1 -1
- package/src/components/Button/index.css +4 -0
- package/src/components/Modal/Modal.story.mdx +57 -2
- package/src/components/Modal/Modal.tsx +270 -72
- package/src/components/Modal/context.ts +2 -0
- package/src/components/Modal/index.css +22 -5
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React, { HTMLAttributes, ReactNode } from "react";
|
|
1
2
|
import { BoxProps } from "../Box";
|
|
2
3
|
import { CloseButtonProps } from "../CloseButton";
|
|
3
4
|
import { StackProps } from "../Stack";
|
|
@@ -13,6 +14,7 @@ export interface ModalProps extends BoxProps {
|
|
|
13
14
|
isOpen?: boolean;
|
|
14
15
|
onClose?: () => void;
|
|
15
16
|
autoFocus?: boolean;
|
|
17
|
+
lockScroll?: boolean;
|
|
16
18
|
disableOutsideClick?: boolean;
|
|
17
19
|
disableEscClose?: boolean;
|
|
18
20
|
hideCloseButton?: boolean;
|
|
@@ -35,12 +37,54 @@ export declare const ModalTabs: (props: StackProps) => JSX.Element;
|
|
|
35
37
|
export declare const ModalFooter: (props: BoxProps) => JSX.Element;
|
|
36
38
|
export declare const ModalFooterMultiStep: ({ steps, currentStep, leftButtonLabel, rightButtonLabel, children, className, ...rest }: ModalFooterMultiStepProps) => JSX.Element;
|
|
37
39
|
export declare const ModalCloseButton: ({ className, ...rest }: CloseButtonProps) => JSX.Element;
|
|
40
|
+
interface ModalCloseProps {
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
asChild?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare const ModalClose: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & ModalCloseProps & React.RefAttributes<HTMLElement>>;
|
|
45
|
+
export interface ModalRootProps {
|
|
46
|
+
children: ReactNode;
|
|
47
|
+
isOpen?: boolean;
|
|
48
|
+
onClose?: () => void;
|
|
49
|
+
disableOutsideClick?: boolean;
|
|
50
|
+
disableEscClose?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare const ModalRoot: ({ children, isOpen, onClose, disableOutsideClick, disableEscClose, }: ModalRootProps) => JSX.Element;
|
|
53
|
+
export interface ModalPortalProps {
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
}
|
|
56
|
+
export declare const ModalPortal: ({ children }: ModalPortalProps) => JSX.Element;
|
|
57
|
+
export interface ModalOverlayProps {
|
|
58
|
+
children: ReactNode;
|
|
59
|
+
className?: string;
|
|
60
|
+
lockScroll?: boolean;
|
|
61
|
+
autoFocus?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export declare const ModalOverlay: ({ children, className, lockScroll, autoFocus, }: ModalOverlayProps) => JSX.Element;
|
|
64
|
+
export interface ModalContainerProps extends BoxProps {
|
|
65
|
+
children: ReactNode;
|
|
66
|
+
className?: string;
|
|
67
|
+
}
|
|
68
|
+
export declare const ModalContainer: ({ children, className, ...rest }: ModalContainerProps) => JSX.Element;
|
|
69
|
+
export interface ModalContentProps extends BoxProps {
|
|
70
|
+
children: ReactNode;
|
|
71
|
+
}
|
|
72
|
+
export declare const ModalContent: React.ForwardRefExoticComponent<Pick<ModalContentProps, "as" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "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-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "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" | "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" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLDivElement>>;
|
|
73
|
+
export declare const ModalScreen: ({ className, style, ...rest }: HTMLAttributes<HTMLDivElement>) => JSX.Element;
|
|
38
74
|
export declare const Modal: {
|
|
39
|
-
(props: ModalProps): JSX.Element
|
|
75
|
+
(props: ModalProps): JSX.Element;
|
|
76
|
+
Root: ({ children, isOpen, onClose, disableOutsideClick, disableEscClose, }: ModalRootProps) => JSX.Element;
|
|
77
|
+
Portal: ({ children }: ModalPortalProps) => JSX.Element;
|
|
78
|
+
Overlay: ({ children, className, lockScroll, autoFocus, }: ModalOverlayProps) => JSX.Element;
|
|
79
|
+
Container: ({ children, className, ...rest }: ModalContainerProps) => JSX.Element;
|
|
80
|
+
Content: React.ForwardRefExoticComponent<Pick<ModalContentProps, "as" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "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-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "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" | "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" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLDivElement>>;
|
|
81
|
+
Screen: ({ className, style, ...rest }: HTMLAttributes<HTMLDivElement>) => JSX.Element;
|
|
40
82
|
Tabs: (props: StackProps) => JSX.Element;
|
|
41
83
|
Header: (props: BoxProps) => JSX.Element;
|
|
42
84
|
Body: (props: ModalBodyProps) => JSX.Element;
|
|
43
85
|
Footer: (props: BoxProps) => JSX.Element;
|
|
44
86
|
FooterMultiStep: ({ steps, currentStep, leftButtonLabel, rightButtonLabel, children, className, ...rest }: ModalFooterMultiStepProps) => JSX.Element;
|
|
45
87
|
CloseButton: ({ className, ...rest }: CloseButtonProps) => JSX.Element;
|
|
88
|
+
Close: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & ModalCloseProps & React.RefAttributes<HTMLElement>>;
|
|
46
89
|
};
|
|
90
|
+
export {};
|
|
@@ -22,11 +22,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.Modal = exports.ModalCloseButton = exports.ModalFooterMultiStep = exports.ModalFooter = exports.ModalTabs = exports.ModalBody = exports.ModalHeader = exports.MODAL_SIZE = void 0;
|
|
25
|
+
exports.Modal = exports.ModalScreen = exports.ModalContent = exports.ModalContainer = exports.ModalOverlay = exports.ModalPortal = exports.ModalRoot = exports.ModalClose = exports.ModalCloseButton = exports.ModalFooterMultiStep = exports.ModalFooter = exports.ModalTabs = exports.ModalBody = exports.ModalHeader = exports.MODAL_SIZE = void 0;
|
|
26
26
|
const react_1 = __importStar(require("react"));
|
|
27
27
|
const classnames_1 = __importDefault(require("classnames"));
|
|
28
28
|
const react_focus_lock_1 = __importDefault(require("react-focus-lock"));
|
|
29
29
|
const react_remove_scroll_1 = require("react-remove-scroll");
|
|
30
|
+
const react_merge_refs_1 = __importDefault(require("react-merge-refs"));
|
|
30
31
|
const Box_1 = require("../Box");
|
|
31
32
|
const Flex_1 = require("../Flex");
|
|
32
33
|
const Portal_1 = require("../Portal");
|
|
@@ -90,25 +91,60 @@ const ModalCloseButton = ({ className, ...rest }) => {
|
|
|
90
91
|
return (react_1.default.createElement(CloseButton_1.CloseButton, Object.assign({ className: classnames_1.default(bem_1.bem(cn, { e: "close" }), className), onClick: onClose }, rest)));
|
|
91
92
|
};
|
|
92
93
|
exports.ModalCloseButton = ModalCloseButton;
|
|
93
|
-
|
|
94
|
-
const {
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
94
|
+
exports.ModalClose = react_1.forwardRef(function ModalClose({ children, onClick, asChild = false, ...rest }, forwardedRef) {
|
|
95
|
+
const { onClose } = context_1.useModalContext();
|
|
96
|
+
const childrenRef = children.ref;
|
|
97
|
+
const ref = react_1.useMemo(() => react_merge_refs_1.default([forwardedRef, childrenRef]), [
|
|
98
|
+
forwardedRef,
|
|
99
|
+
childrenRef,
|
|
100
|
+
]);
|
|
101
|
+
const mergedOnClick = (event) => {
|
|
102
|
+
if (onClose) {
|
|
103
|
+
onClose();
|
|
104
|
+
}
|
|
105
|
+
if (onClick) {
|
|
106
|
+
onClick(event);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
if (asChild && react_1.isValidElement(children)) {
|
|
110
|
+
return react_1.cloneElement(children, {
|
|
111
|
+
ref,
|
|
112
|
+
...rest,
|
|
113
|
+
...children.props,
|
|
114
|
+
onClick: mergedOnClick,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return (react_1.default.createElement("button", Object.assign({ ref: ref, type: "button", onClick: mergedOnClick }, rest), children));
|
|
118
|
+
});
|
|
119
|
+
const ModalRoot = ({ children, isOpen, onClose, disableOutsideClick = true, disableEscClose = false, }) => {
|
|
98
120
|
const [isSelectOpen, setIsSelectOpen] = react_1.useState(false);
|
|
121
|
+
const [esc, setEsc] = react_1.useState(disableEscClose);
|
|
99
122
|
react_1.useEffect(() => {
|
|
100
123
|
setEsc(disableEscClose);
|
|
101
124
|
}, [disableEscClose]);
|
|
102
125
|
hooks_1.useKeyPress(types_1.KEY_CODE.ESC, () => {
|
|
103
|
-
if (!esc && onClose) {
|
|
104
|
-
onClose();
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
hooks_1.useOutsideClick(modalElement, () => {
|
|
108
|
-
if (!disableOutsideClick && onClose) {
|
|
126
|
+
if (!esc && onClose && isOpen) {
|
|
109
127
|
onClose();
|
|
110
128
|
}
|
|
111
129
|
});
|
|
130
|
+
const context = react_1.useMemo(() => {
|
|
131
|
+
return {
|
|
132
|
+
isOpen,
|
|
133
|
+
onClose,
|
|
134
|
+
isSelectOpen,
|
|
135
|
+
setIsSelectOpen,
|
|
136
|
+
disableOutsideClick,
|
|
137
|
+
};
|
|
138
|
+
}, [isOpen, onClose, isSelectOpen, disableOutsideClick]);
|
|
139
|
+
return (react_1.default.createElement(context_1.ModalContext.Provider, { value: context }, children));
|
|
140
|
+
};
|
|
141
|
+
exports.ModalRoot = ModalRoot;
|
|
142
|
+
const ModalPortal = ({ children }) => {
|
|
143
|
+
return react_1.default.createElement(Portal_1.Portal, null, children);
|
|
144
|
+
};
|
|
145
|
+
exports.ModalPortal = ModalPortal;
|
|
146
|
+
const ModalOverlay = ({ children, className, lockScroll = true, autoFocus = false, }) => {
|
|
147
|
+
const { isOpen } = context_1.useModalContext();
|
|
112
148
|
react_1.useEffect(() => {
|
|
113
149
|
if (isOpen) {
|
|
114
150
|
document.body.classList.add("modal-open");
|
|
@@ -118,29 +154,67 @@ const Modal = (props) => {
|
|
|
118
154
|
}
|
|
119
155
|
return () => document.body.classList.remove("modal-open");
|
|
120
156
|
}, [isOpen]);
|
|
121
|
-
return isOpen
|
|
122
|
-
react_1.default.createElement(
|
|
123
|
-
react_1.default.createElement(
|
|
124
|
-
react_1.default.createElement(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
157
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, isOpen && (react_1.default.createElement(Box_1.Box, { className: classnames_1.default(bem_1.bem(cn, { e: "overlay" }), className) },
|
|
158
|
+
react_1.default.createElement(react_focus_lock_1.default, { autoFocus: autoFocus, returnFocus: true },
|
|
159
|
+
react_1.default.createElement(react_remove_scroll_1.RemoveScroll, { enabled: lockScroll },
|
|
160
|
+
react_1.default.createElement(react_1.default.Fragment, null, children)))))));
|
|
161
|
+
};
|
|
162
|
+
exports.ModalOverlay = ModalOverlay;
|
|
163
|
+
const ModalContainer = ({ children, className, ...rest }) => {
|
|
164
|
+
return (react_1.default.createElement(Box_1.Box, Object.assign({ className: classnames_1.default(bem_1.bem(`${cn}Container`), className) }, rest), children));
|
|
165
|
+
};
|
|
166
|
+
exports.ModalContainer = ModalContainer;
|
|
167
|
+
exports.ModalContent = react_1.forwardRef(function ModalContent({ children, className, ...rest }, forwardedRef) {
|
|
168
|
+
const { onClose, disableOutsideClick } = context_1.useModalContext();
|
|
169
|
+
const modalElement = react_1.useRef(null);
|
|
170
|
+
hooks_1.useOutsideClick(modalElement, () => {
|
|
171
|
+
if (!disableOutsideClick && onClose) {
|
|
172
|
+
onClose();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
const ref = react_1.useMemo(() => react_merge_refs_1.default([modalElement, forwardedRef]), [
|
|
176
|
+
modalElement,
|
|
177
|
+
forwardedRef,
|
|
178
|
+
]);
|
|
179
|
+
return (react_1.default.createElement(Box_1.Box, Object.assign({ ref: ref, className: classnames_1.default(bem_1.bem(cn, { e: "content" }), className) }, rest), children));
|
|
180
|
+
});
|
|
181
|
+
const ModalScreen = ({ className, style, ...rest }) => {
|
|
182
|
+
return (react_1.default.createElement(Box_1.Box, Object.assign({ className: classnames_1.default(bem_1.bem(cn, { e: "screen" }), className) }, rest)));
|
|
183
|
+
};
|
|
184
|
+
exports.ModalScreen = ModalScreen;
|
|
185
|
+
const Modal = (props) => {
|
|
186
|
+
const { title, secondaryTitle, description, children, isOpen, onClose, autoFocus = false, lockScroll = true, disableOutsideClick = true, disableEscClose = false, hideCloseButton = false, size = MODAL_SIZE.DEFAULT, center = false, noHeader = false, className, ...rest } = props;
|
|
187
|
+
const showHeader = title || secondaryTitle || !hideCloseButton;
|
|
188
|
+
return (react_1.default.createElement(exports.ModalRoot, { isOpen: isOpen, onClose: onClose, disableOutsideClick: disableOutsideClick, disableEscClose: disableEscClose },
|
|
189
|
+
react_1.default.createElement(exports.ModalPortal, null,
|
|
190
|
+
react_1.default.createElement(exports.ModalOverlay, { autoFocus: autoFocus, lockScroll: lockScroll },
|
|
191
|
+
react_1.default.createElement(exports.ModalContainer, null,
|
|
192
|
+
react_1.default.createElement(exports.ModalContent, Object.assign({ className: classnames_1.default([
|
|
193
|
+
bem_1.bem(cn),
|
|
194
|
+
bem_1.bem(cn, { m: size }),
|
|
195
|
+
center && bem_1.bem(cn, { m: "center" }),
|
|
196
|
+
className,
|
|
197
|
+
]) }, rest),
|
|
198
|
+
!noHeader && showHeader && (react_1.default.createElement(exports.ModalHeader, null,
|
|
199
|
+
title && react_1.default.createElement(Heading_1.Heading.H2, null, title),
|
|
200
|
+
react_1.default.createElement(Stack_1.Stack, { className: "flex-shrink-0", spacing: 5 },
|
|
201
|
+
secondaryTitle && (react_1.default.createElement(Heading_1.Heading.H5, { className: "text-gray-600" }, secondaryTitle)),
|
|
202
|
+
!hideCloseButton && react_1.default.createElement(exports.ModalCloseButton, null)))),
|
|
203
|
+
description && (react_1.default.createElement(Description_1.Description, { className: bem_1.bem(cn, { e: "description" }) }, description)),
|
|
204
|
+
children)),
|
|
205
|
+
react_1.default.createElement(exports.ModalScreen, null)))));
|
|
139
206
|
};
|
|
140
207
|
exports.Modal = Modal;
|
|
208
|
+
exports.Modal.Root = exports.ModalRoot;
|
|
209
|
+
exports.Modal.Portal = exports.ModalPortal;
|
|
210
|
+
exports.Modal.Overlay = exports.ModalOverlay;
|
|
211
|
+
exports.Modal.Container = exports.ModalContainer;
|
|
212
|
+
exports.Modal.Content = exports.ModalContent;
|
|
213
|
+
exports.Modal.Screen = exports.ModalScreen;
|
|
141
214
|
exports.Modal.Tabs = exports.ModalTabs;
|
|
142
215
|
exports.Modal.Header = exports.ModalHeader;
|
|
143
216
|
exports.Modal.Body = exports.ModalBody;
|
|
144
217
|
exports.Modal.Footer = exports.ModalFooter;
|
|
145
218
|
exports.Modal.FooterMultiStep = exports.ModalFooterMultiStep;
|
|
146
219
|
exports.Modal.CloseButton = exports.ModalCloseButton;
|
|
220
|
+
exports.Modal.Close = exports.ModalClose;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from "react";
|
|
2
2
|
export declare type ModalContextProps = {
|
|
3
|
+
isOpen?: boolean;
|
|
3
4
|
onClose?(): void;
|
|
4
5
|
isSelectOpen?: boolean;
|
|
5
6
|
setIsSelectOpen?: Dispatch<SetStateAction<boolean>>;
|
|
7
|
+
disableOutsideClick?: boolean;
|
|
6
8
|
};
|
|
7
9
|
export declare const ModalContext: import("react").Context<ModalContextProps | undefined>;
|
|
8
10
|
export declare function useModalContext(): ModalContextProps;
|
package/public/css/styles.css
CHANGED
|
@@ -2028,6 +2028,10 @@ override built-in Image component classes */
|
|
|
2028
2028
|
border-right-width: 0;
|
|
2029
2029
|
}
|
|
2030
2030
|
|
|
2031
|
+
.ads-ButtonGroup-button {
|
|
2032
|
+
display: contents;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2031
2035
|
.ads-ButtonGroup--isFullWidth .ads-Button {
|
|
2032
2036
|
flex: 1 1 auto;
|
|
2033
2037
|
}
|
|
@@ -4651,9 +4655,34 @@ override built-in Image component classes */
|
|
|
4651
4655
|
--modal-max-width: calc(100vw - 88px);
|
|
4652
4656
|
}
|
|
4653
4657
|
|
|
4654
|
-
.ads-
|
|
4658
|
+
.ads-Modal-overlay {
|
|
4655
4659
|
position: fixed;
|
|
4656
4660
|
top: 0;
|
|
4661
|
+
right: 0;
|
|
4662
|
+
bottom: 0;
|
|
4663
|
+
left: 0;
|
|
4664
|
+
z-index: 700;
|
|
4665
|
+
overflow: auto;
|
|
4666
|
+
}
|
|
4667
|
+
|
|
4668
|
+
.ads-Modal-screen {
|
|
4669
|
+
position: absolute;
|
|
4670
|
+
top: 0;
|
|
4671
|
+
right: 0;
|
|
4672
|
+
bottom: 0;
|
|
4673
|
+
left: 0;
|
|
4674
|
+
background-color: rgba(0, 0, 0, 0.25);
|
|
4675
|
+
|
|
4676
|
+
-webkit-backdrop-filter: blur(4px);
|
|
4677
|
+
|
|
4678
|
+
backdrop-filter: blur(4px);
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4681
|
+
.ads-ModalContainer {
|
|
4682
|
+
position: absolute;
|
|
4683
|
+
top: 0;
|
|
4684
|
+
right: 0;
|
|
4685
|
+
bottom: 0;
|
|
4657
4686
|
left: 0;
|
|
4658
4687
|
z-index: 900;
|
|
4659
4688
|
display: flex;
|
|
@@ -4661,7 +4690,10 @@ override built-in Image component classes */
|
|
|
4661
4690
|
width: 100vw;
|
|
4662
4691
|
align-items: center;
|
|
4663
4692
|
justify-content: center;
|
|
4664
|
-
|
|
4693
|
+
}
|
|
4694
|
+
|
|
4695
|
+
.ads-Modal-content {
|
|
4696
|
+
z-index: 1;
|
|
4665
4697
|
}
|
|
4666
4698
|
|
|
4667
4699
|
.ads-Modal {
|
|
@@ -7987,6 +8019,13 @@ override built-in Image component classes */
|
|
|
7987
8019
|
position: sticky;
|
|
7988
8020
|
}
|
|
7989
8021
|
|
|
8022
|
+
.inset-0 {
|
|
8023
|
+
top: 0;
|
|
8024
|
+
right: 0;
|
|
8025
|
+
bottom: 0;
|
|
8026
|
+
left: 0;
|
|
8027
|
+
}
|
|
8028
|
+
|
|
7990
8029
|
.top-0 {
|
|
7991
8030
|
top: 0;
|
|
7992
8031
|
}
|
|
@@ -8315,6 +8354,10 @@ override built-in Image component classes */
|
|
|
8315
8354
|
width: 48px;
|
|
8316
8355
|
}
|
|
8317
8356
|
|
|
8357
|
+
.w-2\/5 {
|
|
8358
|
+
width: 40%;
|
|
8359
|
+
}
|
|
8360
|
+
|
|
8318
8361
|
.w-40 {
|
|
8319
8362
|
width: 160px;
|
|
8320
8363
|
}
|