pge-front-common 14.1.28 → 14.1.29
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/lib/components/modal/Modal.d.ts +1 -1
- package/lib/components/modal/index.type.d.ts +1 -0
- package/lib/components/modal/modal.stories.d.ts +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.esm.js +5 -3
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +5 -3
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ModalProps } from "./index.type";
|
|
3
|
-
export default function Modal({ isOpen, onClose, children, className, }: ModalProps): React.JSX.Element | null;
|
|
3
|
+
export default function Modal({ isOpen, onClose, children, className, closeOnClickOutside, }: ModalProps): React.JSX.Element | null;
|
package/lib/index.d.ts
CHANGED
|
@@ -714,6 +714,7 @@ type ModalProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
714
714
|
onClose: () => void;
|
|
715
715
|
children: ReactNode;
|
|
716
716
|
className?: string;
|
|
717
|
+
closeOnClickOutside?: boolean;
|
|
717
718
|
};
|
|
718
719
|
type ModalHeaderProps = HTMLAttributes<HTMLDivElement> & {
|
|
719
720
|
children: ReactNode;
|
|
@@ -729,7 +730,7 @@ type ModalFooterProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
729
730
|
className?: string;
|
|
730
731
|
};
|
|
731
732
|
|
|
732
|
-
declare function Modal({ isOpen, onClose, children, className, }: ModalProps): React__default.JSX.Element | null;
|
|
733
|
+
declare function Modal({ isOpen, onClose, children, className, closeOnClickOutside, }: ModalProps): React__default.JSX.Element | null;
|
|
733
734
|
|
|
734
735
|
declare const ModalFooter: ({ children, className }: ModalFooterProps) => React__default.JSX.Element;
|
|
735
736
|
|
package/lib/index.esm.js
CHANGED
|
@@ -23850,7 +23850,7 @@ styleInject(css_248z$7);
|
|
|
23850
23850
|
|
|
23851
23851
|
var ELEMENTOS_COM_FOCO = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex="0"]';
|
|
23852
23852
|
function Modal(_a) {
|
|
23853
|
-
var isOpen = _a.isOpen, onClose = _a.onClose, children = _a.children, _b = _a.className, className = _b === void 0 ? "" : _b;
|
|
23853
|
+
var isOpen = _a.isOpen, onClose = _a.onClose, children = _a.children, _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.closeOnClickOutside, closeOnClickOutside = _c === void 0 ? true : _c;
|
|
23854
23854
|
var contentRef = useRef(null);
|
|
23855
23855
|
var openerRef = useRef(null);
|
|
23856
23856
|
useEffect(function () {
|
|
@@ -23873,11 +23873,13 @@ function Modal(_a) {
|
|
|
23873
23873
|
var els = contentRef.current.querySelectorAll(ELEMENTOS_COM_FOCO);
|
|
23874
23874
|
els.length && els[els.length - 1].focus();
|
|
23875
23875
|
};
|
|
23876
|
-
return (React__default.createElement("div", { className: style.modalOverlay, onClick: onClose, role: "presentation" },
|
|
23876
|
+
return (React__default.createElement("div", { className: style.modalOverlay, onClick: closeOnClickOutside ? onClose : undefined, role: "presentation" },
|
|
23877
23877
|
React__default.createElement("div", { tabIndex: 0, onFocus: moveToLast, "aria-hidden": "true" }),
|
|
23878
23878
|
React__default.createElement("div", { ref: contentRef, className: "".concat(style.modal, " ").concat(className), role: "dialog", "aria-modal": "true", tabIndex: -1, onClick: function (e) { return e.stopPropagation(); }, onKeyDown: function (e) {
|
|
23879
|
-
if (e.key === "Escape")
|
|
23879
|
+
if (e.key === "Escape" && closeOnClickOutside)
|
|
23880
23880
|
onClose();
|
|
23881
|
+
if (e.key === "Escape" && !closeOnClickOutside)
|
|
23882
|
+
e.preventDefault();
|
|
23881
23883
|
} }, children),
|
|
23882
23884
|
React__default.createElement("div", { tabIndex: 0, onFocus: moveToFirst, "aria-hidden": "true" })));
|
|
23883
23885
|
}
|