@activecollab/components 2.0.548 → 2.0.550
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/dist/cjs/components/ComboBox/ComboBox.js +2 -0
- package/dist/cjs/components/ComboBox/ComboBox.js.map +1 -1
- package/dist/cjs/components/ModalRoot/ModalRoot.js +43 -4
- package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/cjs/components/Window/Window.js +22 -1
- package/dist/cjs/components/Window/Window.js.map +1 -1
- package/dist/esm/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/dist/esm/components/ComboBox/ComboBox.js +2 -0
- package/dist/esm/components/ComboBox/ComboBox.js.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts +6 -1
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.js +42 -4
- package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/esm/components/Window/Window.d.ts.map +1 -1
- package/dist/esm/components/Window/Window.js +24 -1
- package/dist/esm/components/Window/Window.js.map +1 -1
- package/dist/index.js +67 -5
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Window.d.ts","sourceRoot":"","sources":["../../../../src/components/Window/Window.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAWf,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mFAAmF;IACnF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAID,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"Window.d.ts","sourceRoot":"","sources":["../../../../src/components/Window/Window.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAWf,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mFAAmF;IACnF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAID,eAAO,MAAM,MAAM,kMAmJlB,CAAC"}
|
|
@@ -61,8 +61,31 @@ export const Window = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
61
61
|
onClose();
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
|
|
65
|
+
// In a native modal dialog the focus can stay on the trigger, in the dialog content. The window in front takes
|
|
66
|
+
// that Escape before the dialog's own handlers do, so it closes and the dialog stays open. On the page an Escape
|
|
67
|
+
// from outside the window still belongs to the page.
|
|
68
|
+
const handleDialogKeyDown = event => {
|
|
69
|
+
const own = innerRef.current;
|
|
70
|
+
const target = event.target;
|
|
71
|
+
if (event.defaultPrevented || event.key !== "Esc" && event.key !== "Escape" || !own || !(target instanceof Element) || own.contains(target) || getTopLayer() !== own) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const dialog = own.closest("dialog[open]");
|
|
75
|
+
|
|
76
|
+
// Stopped as well, as the dialog stops an Escape it takes, so it does not reach an ancestor in the React tree.
|
|
77
|
+
if (dialog && target.closest("dialog[open]") === dialog) {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
event.stopPropagation();
|
|
80
|
+
onClose();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
64
83
|
document.addEventListener("keydown", handleBodyKeyDown);
|
|
65
|
-
|
|
84
|
+
document.addEventListener("keydown", handleDialogKeyDown, true);
|
|
85
|
+
return () => {
|
|
86
|
+
document.removeEventListener("keydown", handleBodyKeyDown);
|
|
87
|
+
document.removeEventListener("keydown", handleDialogKeyDown, true);
|
|
88
|
+
};
|
|
66
89
|
}, [disableCloseOnEsc, onClose]);
|
|
67
90
|
|
|
68
91
|
// A native modal dialog this window is not inside sits above it in the top layer and leaves it inert, such as a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Window.js","names":["React","useCallback","useEffect","useRef","forwardRef","FocusLock","RemoveScroll","classnames","StyledWindow","Portal","useLayerContext","getTopLayer","layers","useForkRef","returnFocus","preventScroll","Window","_ref","ref","children","onClose","className","style","onKeyDown","_ref$disableFocusLock","disableFocusLock","_ref$disableScrollLoc","disableScrollLock","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$disableReturnFoc","disableReturnFocus","_ref$isolateScroll","isolateScroll","onClick","rest","_objectWithoutPropertiesLoose","_excluded","innerRef","handleRef","_useLayerContext","_useLayerContext$zInd","zIndex","skyscraper","handleKeyDown","event","defaultPrevented","key","preventDefault","stopPropagation","undefined","handleBodyKeyDown","isTopWindow","current","target","document","body","addEventListener","removeEventListener","isFocusForLock","node","modalDialog","closest","contains","handleClick","createElement","disabled","whiteList","forwardProps","enabled","noIsolation","_extends","tabIndex","displayName"],"sources":["../../../../src/components/Window/Window.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useRef,\n forwardRef,\n KeyboardEvent,\n} from \"react\";\nimport FocusLock from \"react-focus-lock\";\nimport { RemoveScroll } from \"react-remove-scroll\";\n\nimport classnames from \"classnames\";\n\nimport { StyledWindow } from \"./Style\";\nimport { Portal, useLayerContext } from \"../../helpers\";\nimport { getTopLayer, layers } from \"../../utils\";\nimport useForkRef from \"../../utils/useForkRef\";\n\nexport interface IWindow {\n onClose?: () => void;\n disableFocusLock?: boolean;\n disableScrollLock?: boolean;\n disableCloseOnEsc?: boolean;\n /** Leave the focus where it is when the focus lock turns off */\n disableReturnFocus?: boolean;\n /** With the scroll lock on, also stop the scroll that starts outside the window */\n isolateScroll?: boolean;\n}\n\nconst returnFocus = { preventScroll: true };\n\nexport const Window = forwardRef<\n HTMLDivElement,\n IWindow & Omit<React.ComponentPropsWithoutRef<\"div\">, keyof IWindow>\n>(\n (\n {\n children,\n onClose,\n className,\n style,\n onKeyDown,\n disableFocusLock = false,\n disableScrollLock = false,\n disableCloseOnEsc = false,\n disableReturnFocus = false,\n isolateScroll = false,\n onClick,\n ...rest\n },\n ref\n ) => {\n const innerRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(innerRef, ref);\n const { zIndex = layers.skyscraper } = useLayerContext();\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (\n !event.defaultPrevented &&\n (event.key === \"Esc\" || event.key === \"Escape\") &&\n !disableCloseOnEsc\n ) {\n event.preventDefault();\n event.stopPropagation();\n if (onClose) {\n onClose();\n }\n }\n if (typeof onKeyDown === \"function\") {\n onKeyDown(event);\n }\n },\n [disableCloseOnEsc, onClose, onKeyDown]\n );\n\n // Focus that falls to the body, when the focused node unmounts, sends no key to the window.\n useEffect(() => {\n if (disableCloseOnEsc || !onClose) {\n return undefined;\n }\n\n const handleBodyKeyDown = (event: globalThis.KeyboardEvent) => {\n // A window or a native modal dialog opened above this one takes the Escape.\n const isTopWindow = getTopLayer() === innerRef.current;\n\n if (\n event.target === document.body &&\n !event.defaultPrevented &&\n (event.key === \"Esc\" || event.key === \"Escape\") &&\n isTopWindow\n ) {\n event.preventDefault();\n onClose();\n }\n };\n\n document.addEventListener(\"keydown\", handleBodyKeyDown);\n\n return () => document.removeEventListener(\"keydown\", handleBodyKeyDown);\n }, [disableCloseOnEsc, onClose]);\n\n // A native modal dialog this window is not inside sits above it in the top layer and leaves it inert, such as a\n // confirmation rendered outside the window's React tree. Focus in that dialog is the dialog's, so the lock lets it be.\n const isFocusForLock = useCallback((node: HTMLElement) => {\n const modalDialog = node.closest(\"dialog[open]\");\n\n return !modalDialog || modalDialog.contains(innerRef.current);\n }, []);\n\n const handleClick = useCallback(\n (event) => {\n event?.stopPropagation();\n typeof onClick === \"function\" && onClick(event);\n },\n [onClick]\n );\n\n return (\n <Portal>\n <FocusLock\n returnFocus={disableReturnFocus ? false : returnFocus}\n disabled={disableFocusLock}\n whiteList={isFocusForLock}\n >\n <RemoveScroll\n forwardProps\n ref={handleRef}\n enabled={!disableScrollLock}\n noIsolation={!isolateScroll}\n >\n <StyledWindow\n {...rest}\n style={{ zIndex, ...style }}\n onKeyDown={handleKeyDown}\n tabIndex={0}\n className={classnames(\"c-window\", className)}\n onClick={handleClick}\n >\n {children}\n </StyledWindow>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n );\n }\n);\n\nWindow.displayName = \"Window\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,UAAU,QAEL,OAAO;AACd,OAAOC,SAAS,MAAM,kBAAkB;AACxC,SAASC,YAAY,QAAQ,qBAAqB;AAElD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,YAAY,QAAQ,SAAS;AACtC,SAASC,MAAM,EAAEC,eAAe,QAAQ,eAAe;AACvD,SAASC,WAAW,EAAEC,MAAM,QAAQ,aAAa;AACjD,OAAOC,UAAU,MAAM,wBAAwB;AAa/C,MAAMC,WAAW,GAAG;EAAEC,aAAa,EAAE;AAAK,CAAC;AAE3C,OAAO,MAAMC,MAAM,gBAAGZ,UAAU,CAI9B,CAAAa,IAAA,EAeEC,GAAG,KACA;EAAA,IAdDC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IACPC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IACTC,KAAK,GAAAL,IAAA,CAALK,KAAK;IACLC,SAAS,GAAAN,IAAA,CAATM,SAAS;IAAAC,qBA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,CAAC;EACjD,CAAC,EACD,CAACX,OAAO,CACV,CAAC;EAED,oBACElC,KAAA,CAAAiE,aAAA,CAACxD,MAAM,qBACLT,KAAA,CAAAiE,aAAA,CAAC5D,SAAS;IACRS,WAAW,EAAEiB,kBAAkB,GAAG,KAAK,GAAGjB,WAAY;IACtDoD,QAAQ,EAAEzC,gBAAiB;IAC3B0C,SAAS,EAAER;EAAe,gBAE1B3D,KAAA,CAAAiE,aAAA,CAAC3D,YAAY;IACX8D,YAAY;IACZlD,GAAG,EAAEqB,SAAU;IACf8B,OAAO,EAAE,CAAC1C,iBAAkB;IAC5B2C,WAAW,EAAE,CAACrC;EAAc,gBAE5BjC,KAAA,CAAAiE,aAAA,CAACzD,YAAY,EAAA+D,QAAA,KACPpC,IAAI;IACRb,KAAK,EAAAiD,QAAA;MAAI7B;IAAM,GAAKpB,KAAK,CAAG;IAC5BC,SAAS,EAAEqB,aAAc;IACzB4B,QAAQ,EAAE,CAAE;IACZnD,SAAS,EAAEd,UAAU,CAAC,UAAU,EAAEc,SAAS,CAAE;IAC7Ca,OAAO,EAAE8B;EAAY,IAEpB7C,QACW,CACF,CACL,CACL,CAAC;AAEb,CACF,CAAC;AAEDH,MAAM,CAACyD,WAAW,GAAG,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Window.js","names":["React","useCallback","useEffect","useRef","forwardRef","FocusLock","RemoveScroll","classnames","StyledWindow","Portal","useLayerContext","getTopLayer","layers","useForkRef","returnFocus","preventScroll","Window","_ref","ref","children","onClose","className","style","onKeyDown","_ref$disableFocusLock","disableFocusLock","_ref$disableScrollLoc","disableScrollLock","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$disableReturnFoc","disableReturnFocus","_ref$isolateScroll","isolateScroll","onClick","rest","_objectWithoutPropertiesLoose","_excluded","innerRef","handleRef","_useLayerContext","_useLayerContext$zInd","zIndex","skyscraper","handleKeyDown","event","defaultPrevented","key","preventDefault","stopPropagation","undefined","handleBodyKeyDown","isTopWindow","current","target","document","body","handleDialogKeyDown","own","Element","contains","dialog","closest","addEventListener","removeEventListener","isFocusForLock","node","modalDialog","handleClick","createElement","disabled","whiteList","forwardProps","enabled","noIsolation","_extends","tabIndex","displayName"],"sources":["../../../../src/components/Window/Window.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useRef,\n forwardRef,\n KeyboardEvent,\n} from \"react\";\nimport FocusLock from \"react-focus-lock\";\nimport { RemoveScroll } from \"react-remove-scroll\";\n\nimport classnames from \"classnames\";\n\nimport { StyledWindow } from \"./Style\";\nimport { Portal, useLayerContext } from \"../../helpers\";\nimport { getTopLayer, layers } from \"../../utils\";\nimport useForkRef from \"../../utils/useForkRef\";\n\nexport interface IWindow {\n onClose?: () => void;\n disableFocusLock?: boolean;\n disableScrollLock?: boolean;\n disableCloseOnEsc?: boolean;\n /** Leave the focus where it is when the focus lock turns off */\n disableReturnFocus?: boolean;\n /** With the scroll lock on, also stop the scroll that starts outside the window */\n isolateScroll?: boolean;\n}\n\nconst returnFocus = { preventScroll: true };\n\nexport const Window = forwardRef<\n HTMLDivElement,\n IWindow & Omit<React.ComponentPropsWithoutRef<\"div\">, keyof IWindow>\n>(\n (\n {\n children,\n onClose,\n className,\n style,\n onKeyDown,\n disableFocusLock = false,\n disableScrollLock = false,\n disableCloseOnEsc = false,\n disableReturnFocus = false,\n isolateScroll = false,\n onClick,\n ...rest\n },\n ref\n ) => {\n const innerRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(innerRef, ref);\n const { zIndex = layers.skyscraper } = useLayerContext();\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (\n !event.defaultPrevented &&\n (event.key === \"Esc\" || event.key === \"Escape\") &&\n !disableCloseOnEsc\n ) {\n event.preventDefault();\n event.stopPropagation();\n if (onClose) {\n onClose();\n }\n }\n if (typeof onKeyDown === \"function\") {\n onKeyDown(event);\n }\n },\n [disableCloseOnEsc, onClose, onKeyDown]\n );\n\n // Focus that falls to the body, when the focused node unmounts, sends no key to the window.\n useEffect(() => {\n if (disableCloseOnEsc || !onClose) {\n return undefined;\n }\n\n const handleBodyKeyDown = (event: globalThis.KeyboardEvent) => {\n // A window or a native modal dialog opened above this one takes the Escape.\n const isTopWindow = getTopLayer() === innerRef.current;\n\n if (\n event.target === document.body &&\n !event.defaultPrevented &&\n (event.key === \"Esc\" || event.key === \"Escape\") &&\n isTopWindow\n ) {\n event.preventDefault();\n onClose();\n }\n };\n\n // In a native modal dialog the focus can stay on the trigger, in the dialog content. The window in front takes\n // that Escape before the dialog's own handlers do, so it closes and the dialog stays open. On the page an Escape\n // from outside the window still belongs to the page.\n const handleDialogKeyDown = (event: globalThis.KeyboardEvent) => {\n const own = innerRef.current;\n const target = event.target;\n\n if (\n event.defaultPrevented ||\n (event.key !== \"Esc\" && event.key !== \"Escape\") ||\n !own ||\n !(target instanceof Element) ||\n own.contains(target) ||\n getTopLayer() !== own\n ) {\n return;\n }\n\n const dialog = own.closest(\"dialog[open]\");\n\n // Stopped as well, as the dialog stops an Escape it takes, so it does not reach an ancestor in the React tree.\n if (dialog && target.closest(\"dialog[open]\") === dialog) {\n event.preventDefault();\n event.stopPropagation();\n onClose();\n }\n };\n\n document.addEventListener(\"keydown\", handleBodyKeyDown);\n document.addEventListener(\"keydown\", handleDialogKeyDown, true);\n\n return () => {\n document.removeEventListener(\"keydown\", handleBodyKeyDown);\n document.removeEventListener(\"keydown\", handleDialogKeyDown, true);\n };\n }, [disableCloseOnEsc, onClose]);\n\n // A native modal dialog this window is not inside sits above it in the top layer and leaves it inert, such as a\n // confirmation rendered outside the window's React tree. Focus in that dialog is the dialog's, so the lock lets it be.\n const isFocusForLock = useCallback((node: HTMLElement) => {\n const modalDialog = node.closest(\"dialog[open]\");\n\n return !modalDialog || modalDialog.contains(innerRef.current);\n }, []);\n\n const handleClick = useCallback(\n (event) => {\n event?.stopPropagation();\n typeof onClick === \"function\" && onClick(event);\n },\n [onClick]\n );\n\n return (\n <Portal>\n <FocusLock\n returnFocus={disableReturnFocus ? false : returnFocus}\n disabled={disableFocusLock}\n whiteList={isFocusForLock}\n >\n <RemoveScroll\n forwardProps\n ref={handleRef}\n enabled={!disableScrollLock}\n noIsolation={!isolateScroll}\n >\n <StyledWindow\n {...rest}\n style={{ zIndex, ...style }}\n onKeyDown={handleKeyDown}\n tabIndex={0}\n className={classnames(\"c-window\", className)}\n onClick={handleClick}\n >\n {children}\n </StyledWindow>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n );\n }\n);\n\nWindow.displayName = \"Window\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,UAAU,QAEL,OAAO;AACd,OAAOC,SAAS,MAAM,kBAAkB;AACxC,SAASC,YAAY,QAAQ,qBAAqB;AAElD,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,YAAY,QAAQ,SAAS;AACtC,SAASC,MAAM,EAAEC,eAAe,QAAQ,eAAe;AACvD,SAASC,WAAW,EAAEC,MAAM,QAAQ,aAAa;AACjD,OAAOC,UAAU,MAAM,wBAAwB;AAa/C,MAAMC,WAAW,GAAG;EAAEC,aAAa,EAAE;AAAK,CAAC;AAE3C,OAAO,MAAMC,MAAM,gBAAGZ,UAAU,CAI9B,CAAAa,IAAA,EAeEC,GAAG,KACA;EAAA,IAdDC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IACPC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IACTC,KAAK,GAAAL,IAAA,CAALK,KAAK;IACLC,SAAS,GAAAN,IAAA,CAATM,SAAS;IAAAC,qBAAA,GAAAP,IAAA,CACTQ,gBAAgB;IAAhBA,gBAAgB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAT,IAAA,CACxBU,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA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AAEqB,aAAc;IACzBgC,QAAQ,EAAE,CAAE;IACZvD,SAAS,EAAEd,UAAU,CAAC,UAAU,EAAEc,SAAS,CAAE;IAC7Ca,OAAO,EAAEkC;EAAY,IAEpBjD,QACW,CACF,CACL,CACL,CAAC;AAEb,CACF,CAAC;AAEDH,MAAM,CAAC6D,WAAW,GAAG,QAAQ","ignoreList":[]}
|
package/dist/index.js
CHANGED
|
@@ -17160,9 +17160,30 @@
|
|
|
17160
17160
|
onClose();
|
|
17161
17161
|
}
|
|
17162
17162
|
};
|
|
17163
|
+
|
|
17164
|
+
// In a native modal dialog the focus can stay on the trigger, in the dialog content. The window in front takes
|
|
17165
|
+
// that Escape before the dialog's own handlers do, so it closes and the dialog stays open. On the page an Escape
|
|
17166
|
+
// from outside the window still belongs to the page.
|
|
17167
|
+
var handleDialogKeyDown = function handleDialogKeyDown(event) {
|
|
17168
|
+
var own = innerRef.current;
|
|
17169
|
+
var target = event.target;
|
|
17170
|
+
if (event.defaultPrevented || event.key !== "Esc" && event.key !== "Escape" || !own || !(target instanceof Element) || own.contains(target) || getTopLayer() !== own) {
|
|
17171
|
+
return;
|
|
17172
|
+
}
|
|
17173
|
+
var dialog = own.closest("dialog[open]");
|
|
17174
|
+
|
|
17175
|
+
// Stopped as well, as the dialog stops an Escape it takes, so it does not reach an ancestor in the React tree.
|
|
17176
|
+
if (dialog && target.closest("dialog[open]") === dialog) {
|
|
17177
|
+
event.preventDefault();
|
|
17178
|
+
event.stopPropagation();
|
|
17179
|
+
onClose();
|
|
17180
|
+
}
|
|
17181
|
+
};
|
|
17163
17182
|
document.addEventListener("keydown", handleBodyKeyDown);
|
|
17183
|
+
document.addEventListener("keydown", handleDialogKeyDown, true);
|
|
17164
17184
|
return function () {
|
|
17165
|
-
|
|
17185
|
+
document.removeEventListener("keydown", handleBodyKeyDown);
|
|
17186
|
+
document.removeEventListener("keydown", handleDialogKeyDown, true);
|
|
17166
17187
|
};
|
|
17167
17188
|
}, [disableCloseOnEsc, onClose]);
|
|
17168
17189
|
|
|
@@ -19146,6 +19167,19 @@
|
|
|
19146
19167
|
StyledModalRoot.displayName = "StyledModalRoot";
|
|
19147
19168
|
|
|
19148
19169
|
var _excluded$1P = ["open", "onRequestClose", "onDismissBlocked", "onClose", "disableCloseOnEsc", "disableBackgroundClick", "disableScrollLock", "disableReturnFocus", "belowOpenSheets", "children", "className", "onPointerDown", "onClick", "onKeyDown"];
|
|
19170
|
+
var FOCUSABLE = "button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, iframe, audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), [tabindex]";
|
|
19171
|
+
|
|
19172
|
+
// What showModal does for content that was not there yet: the first node that takes the focus gets it, so a
|
|
19173
|
+
// disabled or hidden one is skipped as the browser skips it.
|
|
19174
|
+
var focusFirstFocusable = function focusFirstFocusable(dialog, overlayRoot) {
|
|
19175
|
+
Array.from(dialog.querySelectorAll(FOCUSABLE)).some(function (candidate) {
|
|
19176
|
+
if (overlayRoot !== null && overlayRoot !== void 0 && overlayRoot.contains(candidate)) {
|
|
19177
|
+
return false;
|
|
19178
|
+
}
|
|
19179
|
+
candidate.focus();
|
|
19180
|
+
return document.activeElement === candidate;
|
|
19181
|
+
});
|
|
19182
|
+
};
|
|
19149
19183
|
var ModalRoot = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
19150
19184
|
var open = _ref.open,
|
|
19151
19185
|
onRequestClose = _ref.onRequestClose,
|
|
@@ -19183,6 +19217,13 @@
|
|
|
19183
19217
|
setDialog(node);
|
|
19184
19218
|
}, []);
|
|
19185
19219
|
var handleRef = useForkRef(setDialogNode, ref);
|
|
19220
|
+
// A closed dialog hides its content, and React focuses an autoFocus field while it mounts, so the content mounts
|
|
19221
|
+
// only once showModal ran on this node.
|
|
19222
|
+
var _useState5 = React.useState(null),
|
|
19223
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
19224
|
+
shownDialog = _useState6[0],
|
|
19225
|
+
setShownDialog = _useState6[1];
|
|
19226
|
+
var contentShown = dialog !== null && shownDialog === dialog;
|
|
19186
19227
|
var hasTransition = typeof children === "function";
|
|
19187
19228
|
var openRef = React.useRef(open);
|
|
19188
19229
|
var pressStartedOnBackdrop = React.useRef(false);
|
|
@@ -19262,6 +19303,7 @@
|
|
|
19262
19303
|
closeDialog(dialogRef.current);
|
|
19263
19304
|
}
|
|
19264
19305
|
setMounted(false);
|
|
19306
|
+
setShownDialog(null);
|
|
19265
19307
|
onClose === null || onClose === void 0 || onClose();
|
|
19266
19308
|
}, [closeDialog, onClose]);
|
|
19267
19309
|
|
|
@@ -19278,8 +19320,22 @@
|
|
|
19278
19320
|
if (stackIdRef.current === undefined) {
|
|
19279
19321
|
stackIdRef.current = pushModalRoot(overlayRootRef.current, suspensionRef.current, belowOpenSheets);
|
|
19280
19322
|
}
|
|
19323
|
+
setShownDialog(dialog);
|
|
19281
19324
|
}, [open, dialog, belowOpenSheets]);
|
|
19282
19325
|
|
|
19326
|
+
// showModal found no content to focus, so the dialog moves the focus in once the content is there, unless an
|
|
19327
|
+
// autoFocus field took it. A dialog that opened suspended stays out of the way of the overlay above it.
|
|
19328
|
+
React.useLayoutEffect(function () {
|
|
19329
|
+
if (!contentShown || !dialog || areModalRootsSuspended()) {
|
|
19330
|
+
return;
|
|
19331
|
+
}
|
|
19332
|
+
var focus = document.activeElement;
|
|
19333
|
+
if (focus !== dialog && dialog.contains(focus)) {
|
|
19334
|
+
return;
|
|
19335
|
+
}
|
|
19336
|
+
focusFirstFocusable(dialog, overlayRootRef.current);
|
|
19337
|
+
}, [contentShown, dialog]);
|
|
19338
|
+
|
|
19283
19339
|
// A layout effect, so the entry leaves the stack before an unmount removes the dialog and its overlay root.
|
|
19284
19340
|
// An owner that unmounts the dialog while it is open, as a form does on submit, gets the focus back on the
|
|
19285
19341
|
// opener: a dialog removed while open would leave it on the body.
|
|
@@ -19425,6 +19481,13 @@
|
|
|
19425
19481
|
if (!mounted) {
|
|
19426
19482
|
return null;
|
|
19427
19483
|
}
|
|
19484
|
+
var content = null;
|
|
19485
|
+
if (contentShown) {
|
|
19486
|
+
content = typeof children === "function" ? children({
|
|
19487
|
+
in: open,
|
|
19488
|
+
onExited: handleExited
|
|
19489
|
+
}) : children;
|
|
19490
|
+
}
|
|
19428
19491
|
return /*#__PURE__*/React__default["default"].createElement(Portal, null, /*#__PURE__*/React__default["default"].createElement(reactRemoveScroll.RemoveScroll, {
|
|
19429
19492
|
forwardProps: true,
|
|
19430
19493
|
ref: handleRef,
|
|
@@ -19438,10 +19501,7 @@
|
|
|
19438
19501
|
onKeyDown: handleKeyDown
|
|
19439
19502
|
}), /*#__PURE__*/React__default["default"].createElement(PortalContainerProvider, {
|
|
19440
19503
|
value: getOverlayRoot
|
|
19441
|
-
},
|
|
19442
|
-
in: open,
|
|
19443
|
-
onExited: handleExited
|
|
19444
|
-
}) : children), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
19504
|
+
}, content), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
19445
19505
|
ref: overlayRootRef,
|
|
19446
19506
|
className: "c-modal-root__overlays"
|
|
19447
19507
|
}))));
|
|
@@ -27130,6 +27190,8 @@
|
|
|
27130
27190
|
setValue(selectedName);
|
|
27131
27191
|
}
|
|
27132
27192
|
onCancel === null || onCancel === void 0 || onCancel(selectedName);
|
|
27193
|
+
// A native dialog around the field would take an Escape that is not prevented as its own close request.
|
|
27194
|
+
e.preventDefault();
|
|
27133
27195
|
e.stopPropagation();
|
|
27134
27196
|
}
|
|
27135
27197
|
if (e.key === "Enter" && type === "multiple") {
|