@elliemae/ds-dialog 3.1.4 → 3.1.5-rc.10
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/parts/DSDialogPortal.js +1 -2
- package/dist/cjs/parts/DSDialogPortal.js.map +2 -2
- package/dist/cjs/parts/dialogContent/DSDialogContent.js +8 -1
- package/dist/cjs/parts/dialogContent/DSDialogContent.js.map +2 -2
- package/dist/cjs/parts/dialogContent/useDialogContent.js +1 -17
- package/dist/cjs/parts/dialogContent/useDialogContent.js.map +2 -2
- package/dist/esm/parts/DSDialogPortal.js +1 -2
- package/dist/esm/parts/DSDialogPortal.js.map +2 -2
- package/dist/esm/parts/dialogContent/DSDialogContent.js +9 -2
- package/dist/esm/parts/dialogContent/DSDialogContent.js.map +2 -2
- package/dist/esm/parts/dialogContent/useDialogContent.js +2 -18
- package/dist/esm/parts/dialogContent/useDialogContent.js.map +2 -2
- package/package.json +5 -5
|
@@ -26,14 +26,13 @@ module.exports = __toCommonJS(DSDialogPortal_exports);
|
|
|
26
26
|
var React = __toESM(require("react"));
|
|
27
27
|
var import_react = __toESM(require("react"));
|
|
28
28
|
var import_react_dom = __toESM(require("react-dom"));
|
|
29
|
-
var import_react2 = require("react");
|
|
30
29
|
var import_DSDialogCTX = require("../DSDialogCTX");
|
|
31
30
|
var import_DSDialogContent = require("./dialogContent/DSDialogContent");
|
|
32
31
|
const DSDialogPortal = () => {
|
|
33
32
|
const {
|
|
34
33
|
props: { isOpen },
|
|
35
34
|
actualPortalRef
|
|
36
|
-
} = (0,
|
|
35
|
+
} = (0, import_react.useContext)(import_DSDialogCTX.DSDialogContext);
|
|
37
36
|
if (isOpen && actualPortalRef.current) {
|
|
38
37
|
return import_react_dom.default.createPortal(/* @__PURE__ */ import_react.default.createElement(import_DSDialogContent.DSDialogContent, null), actualPortalRef.current);
|
|
39
38
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/parts/DSDialogPortal.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,
|
|
4
|
+
"sourcesContent": ["import React, { useContext } from 'react';\nimport ReactDOM from 'react-dom';\nimport { DSDialogContext } from '../DSDialogCTX';\nimport { DSDialogContent } from './dialogContent/DSDialogContent';\n\nexport const DSDialogPortal = (): JSX.Element | null => {\n const {\n props: { isOpen },\n actualPortalRef,\n } = useContext(DSDialogContext);\n\n if (isOpen && actualPortalRef.current) {\n return ReactDOM.createPortal(<DSDialogContent />, actualPortalRef.current);\n }\n\n return null;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkC;AAClC,uBAAqB;AACrB,yBAAgC;AAChC,6BAAgC;AAEzB,MAAM,iBAAiB,MAA0B;AACtD,QAAM;AAAA,IACJ,OAAO,EAAE;AAAA,IACT;AAAA,MACE,6BAAW,kCAAe;AAE9B,MAAI,UAAU,gBAAgB,SAAS;AACrC,WAAO,yBAAS,aAAa,mDAAC,4CAAgB,GAAI,gBAAgB,OAAO;AAAA,EAC3E;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -68,6 +68,13 @@ const DSDialogContent = () => {
|
|
|
68
68
|
onClick: handleOutsideClick,
|
|
69
69
|
onKeyDown: handleOnKeyDown
|
|
70
70
|
}), { className } = _b, restOfGlobalAttributes = __objRest(_b, ["className"]);
|
|
71
|
+
const refCallback = (0, import_react.useCallback)((_ref) => {
|
|
72
|
+
if (_ref) {
|
|
73
|
+
containerRef.current = _ref;
|
|
74
|
+
if (!removeAutoFocus)
|
|
75
|
+
_ref.focus();
|
|
76
|
+
}
|
|
77
|
+
}, [containerRef, removeAutoFocus]);
|
|
71
78
|
return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledDialogBackground, {
|
|
72
79
|
className,
|
|
73
80
|
onClick: handleOutsideClick,
|
|
@@ -80,7 +87,7 @@ const DSDialogContent = () => {
|
|
|
80
87
|
}), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledDialogContainer, __spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
81
88
|
role: "dialog",
|
|
82
89
|
"aria-modal": true,
|
|
83
|
-
ref:
|
|
90
|
+
ref: refCallback,
|
|
84
91
|
tabIndex: !removeAutoFocus ? 0 : void 0,
|
|
85
92
|
onKeyDown: handleOnKeyDown
|
|
86
93
|
}, (0, import_utils.getSpaceProps)(rest)), {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/dialogContent/DSDialogContent.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext } from 'react';\nimport { useGetGlobalAttributes } from '@elliemae/ds-utilities';\nimport { PortalStyles, StyledDialogBackground, StyledDialogContainer } from '../../styles';\nimport { getSpaceProps } from '../../utils';\nimport { DSDialogDatatestid } from '../../DSDialogDatatestid';\nimport { DSDialogContext } from '../../DSDialogCTX';\nimport { useDialogContent } from './useDialogContent';\n\nexport const DSDialogContent = () => {\n const { handleOutsideClick, handleOnKeyDown } = useDialogContent();\n const { props, containerRef, portalInfo, portalClassName } = useContext(DSDialogContext);\n\n const { removeAutoFocus, zIndex, centered, size, children, ...rest } = props;\n\n const { className, ...restOfGlobalAttributes } = useGetGlobalAttributes(props, {\n onClick: handleOutsideClick,\n onKeyDown: handleOnKeyDown,\n });\n\n return (\n <StyledDialogBackground\n className={className}\n onClick={handleOutsideClick}\n data-portalbg\n data-testid={DSDialogDatatestid.BACKGROUND}\n zIndex={zIndex}\n >\n <PortalStyles portalInfo={portalInfo} portalClassName={portalClassName} />\n <StyledDialogContainer\n role=\"dialog\"\n aria-modal\n ref={
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,
|
|
4
|
+
"sourcesContent": ["import React, { useCallback, useContext } from 'react';\nimport { useGetGlobalAttributes } from '@elliemae/ds-utilities';\nimport { PortalStyles, StyledDialogBackground, StyledDialogContainer } from '../../styles';\nimport { getSpaceProps } from '../../utils';\nimport { DSDialogDatatestid } from '../../DSDialogDatatestid';\nimport { DSDialogContext } from '../../DSDialogCTX';\nimport { useDialogContent } from './useDialogContent';\n\nexport const DSDialogContent = () => {\n const { handleOutsideClick, handleOnKeyDown } = useDialogContent();\n const { props, containerRef, portalInfo, portalClassName } = useContext(DSDialogContext);\n\n const { removeAutoFocus, zIndex, centered, size, children, ...rest } = props;\n\n const { className, ...restOfGlobalAttributes } = useGetGlobalAttributes(props, {\n onClick: handleOutsideClick,\n onKeyDown: handleOnKeyDown,\n });\n\n const refCallback = useCallback(\n (_ref: HTMLDivElement | null) => {\n if (_ref) {\n containerRef.current = _ref;\n if (!removeAutoFocus) _ref.focus();\n }\n },\n [containerRef, removeAutoFocus],\n );\n\n return (\n <StyledDialogBackground\n className={className}\n onClick={handleOutsideClick}\n data-portalbg\n data-testid={DSDialogDatatestid.BACKGROUND}\n zIndex={zIndex}\n >\n <PortalStyles portalInfo={portalInfo} portalClassName={portalClassName} />\n <StyledDialogContainer\n role=\"dialog\"\n aria-modal\n ref={refCallback}\n tabIndex={!removeAutoFocus ? 0 : undefined}\n onKeyDown={handleOnKeyDown}\n {...getSpaceProps(rest as unknown as Record<string, unknown>)}\n centered={centered}\n data-testid={DSDialogDatatestid.CONTAINER}\n {...restOfGlobalAttributes}\n size={size}\n >\n {children}\n </StyledDialogContainer>\n </StyledDialogBackground>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA+C;AAC/C,0BAAuC;AACvC,oBAA4E;AAC5E,mBAA8B;AAC9B,gCAAmC;AACnC,yBAAgC;AAChC,8BAAiC;AAE1B,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,oBAAoB,oBAAoB,8CAAiB;AACjE,QAAM,EAAE,OAAO,cAAc,YAAY,oBAAoB,6BAAW,kCAAe;AAEvF,QAAuE,YAA/D,mBAAiB,QAAQ,UAAU,MAAM,aAAsB,IAAT,iBAAS,IAAT,CAAtD,mBAAiB,UAAQ,YAAU,QAAM;AAEjD,QAAiD,qDAAuB,OAAO;AAAA,IAC7E,SAAS;AAAA,IACT,WAAW;AAAA,EACb,CAAC,GAHO,gBAAyC,IAA3B,mCAA2B,IAA3B,CAAd;AAKR,QAAM,cAAc,8BAClB,CAAC,SAAgC;AAC/B,QAAI,MAAM;AACR,mBAAa,UAAU;AACvB,UAAI,CAAC;AAAiB,aAAK,MAAM;AAAA,IACnC;AAAA,EACF,GACA,CAAC,cAAc,eAAe,CAChC;AAEA,SACE,mDAAC;AAAA,IACC;AAAA,IACA,SAAS;AAAA,IACT,iBAAa;AAAA,IACb,eAAa,6CAAmB;AAAA,IAChC;AAAA,KAEA,mDAAC;AAAA,IAAa;AAAA,IAAwB;AAAA,GAAkC,GACxE,mDAAC;AAAA,IACC,MAAK;AAAA,IACL,cAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU,CAAC,kBAAkB,IAAI;AAAA,IACjC,WAAW;AAAA,KACP,gCAAc,IAA0C,IAN7D;AAAA,IAOC;AAAA,IACA,eAAa,6CAAmB;AAAA,MAC5B,yBATL;AAAA,IAUC;AAAA,MAEC,QACH,CACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -28,8 +28,7 @@ var import_react = require("react");
|
|
|
28
28
|
var import_DSDialogCTX = require("../../DSDialogCTX");
|
|
29
29
|
const useDialogContent = () => {
|
|
30
30
|
const {
|
|
31
|
-
props: { onClickOutside, onClose
|
|
32
|
-
containerRef
|
|
31
|
+
props: { onClickOutside, onClose }
|
|
33
32
|
} = (0, import_react.useContext)(import_DSDialogCTX.DSDialogContext);
|
|
34
33
|
const handleOutsideClick = (0, import_react.useCallback)((e) => {
|
|
35
34
|
if (e.target.dataset.portalbg)
|
|
@@ -39,21 +38,6 @@ const useDialogContent = () => {
|
|
|
39
38
|
if (e.key === "Escape")
|
|
40
39
|
onClose();
|
|
41
40
|
}, [onClose]);
|
|
42
|
-
(0, import_react.useEffect)(() => {
|
|
43
|
-
if (!removeAutoFocus)
|
|
44
|
-
containerRef?.current?.focus();
|
|
45
|
-
}, [containerRef, removeAutoFocus]);
|
|
46
|
-
const focusContainer = (0, import_react.useCallback)(() => {
|
|
47
|
-
setTimeout(() => {
|
|
48
|
-
const isContainerOrChildFocused = containerRef.current?.contains(document.activeElement);
|
|
49
|
-
if (!isContainerOrChildFocused)
|
|
50
|
-
containerRef.current?.focus?.();
|
|
51
|
-
});
|
|
52
|
-
}, [containerRef]);
|
|
53
|
-
(0, import_react.useEffect)(() => {
|
|
54
|
-
document.addEventListener("focusin", focusContainer);
|
|
55
|
-
return () => document.removeEventListener("focusin", focusContainer);
|
|
56
|
-
}, [focusContainer]);
|
|
57
41
|
return {
|
|
58
42
|
handleOutsideClick,
|
|
59
43
|
handleOnKeyDown
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/dialogContent/useDialogContent.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useCallback,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,
|
|
4
|
+
"sourcesContent": ["import React, { useCallback, useContext } from 'react';\nimport { DSDialogContext } from '../../DSDialogCTX';\n\nexport const useDialogContent = () => {\n const {\n props: { onClickOutside, onClose },\n } = useContext(DSDialogContext);\n\n const handleOutsideClick = useCallback(\n (e: React.MouseEvent) => {\n if ((e.target as HTMLDivElement).dataset.portalbg) onClickOutside();\n },\n [onClickOutside],\n );\n\n const handleOnKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') onClose();\n },\n [onClose],\n );\n\n return {\n handleOutsideClick,\n handleOnKeyDown,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA+C;AAC/C,yBAAgC;AAEzB,MAAM,mBAAmB,MAAM;AACpC,QAAM;AAAA,IACJ,OAAO,EAAE,gBAAgB;AAAA,MACvB,6BAAW,kCAAe;AAE9B,QAAM,qBAAqB,8BACzB,CAAC,MAAwB;AACvB,QAAK,EAAE,OAA0B,QAAQ;AAAU,qBAAe;AAAA,EACpE,GACA,CAAC,cAAc,CACjB;AAEA,QAAM,kBAAkB,8BACtB,CAAC,MAA2B;AAC1B,QAAI,EAAE,QAAQ;AAAU,cAAQ;AAAA,EAClC,GACA,CAAC,OAAO,CACV;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import React2 from "react";
|
|
2
|
+
import React2, { useContext } from "react";
|
|
3
3
|
import ReactDOM from "react-dom";
|
|
4
|
-
import { useContext } from "react";
|
|
5
4
|
import { DSDialogContext } from "../DSDialogCTX";
|
|
6
5
|
import { DSDialogContent } from "./dialogContent/DSDialogContent";
|
|
7
6
|
const DSDialogPortal = () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/DSDialogPortal.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport {
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport ReactDOM from 'react-dom';\nimport { DSDialogContext } from '../DSDialogCTX';\nimport { DSDialogContent } from './dialogContent/DSDialogContent';\n\nexport const DSDialogPortal = (): JSX.Element | null => {\n const {\n props: { isOpen },\n actualPortalRef,\n } = useContext(DSDialogContext);\n\n if (isOpen && actualPortalRef.current) {\n return ReactDOM.createPortal(<DSDialogContent />, actualPortalRef.current);\n }\n\n return null;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEO,MAAM,iBAAiB,MAA0B;AACtD,QAAM;AAAA,IACJ,OAAO,EAAE;AAAA,IACT;AAAA,MACE,WAAW,eAAe;AAE9B,MAAI,UAAU,gBAAgB,SAAS;AACrC,WAAO,SAAS,aAAa,qCAAC,qBAAgB,GAAI,gBAAgB,OAAO;AAAA,EAC3E;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,7 +30,7 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
import * as React from "react";
|
|
33
|
-
import React2, { useContext } from "react";
|
|
33
|
+
import React2, { useCallback, useContext } from "react";
|
|
34
34
|
import { useGetGlobalAttributes } from "@elliemae/ds-utilities";
|
|
35
35
|
import { PortalStyles, StyledDialogBackground, StyledDialogContainer } from "../../styles";
|
|
36
36
|
import { getSpaceProps } from "../../utils";
|
|
@@ -45,6 +45,13 @@ const DSDialogContent = () => {
|
|
|
45
45
|
onClick: handleOutsideClick,
|
|
46
46
|
onKeyDown: handleOnKeyDown
|
|
47
47
|
}), { className } = _b, restOfGlobalAttributes = __objRest(_b, ["className"]);
|
|
48
|
+
const refCallback = useCallback((_ref) => {
|
|
49
|
+
if (_ref) {
|
|
50
|
+
containerRef.current = _ref;
|
|
51
|
+
if (!removeAutoFocus)
|
|
52
|
+
_ref.focus();
|
|
53
|
+
}
|
|
54
|
+
}, [containerRef, removeAutoFocus]);
|
|
48
55
|
return /* @__PURE__ */ React2.createElement(StyledDialogBackground, {
|
|
49
56
|
className,
|
|
50
57
|
onClick: handleOutsideClick,
|
|
@@ -57,7 +64,7 @@ const DSDialogContent = () => {
|
|
|
57
64
|
}), /* @__PURE__ */ React2.createElement(StyledDialogContainer, __spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
58
65
|
role: "dialog",
|
|
59
66
|
"aria-modal": true,
|
|
60
|
-
ref:
|
|
67
|
+
ref: refCallback,
|
|
61
68
|
tabIndex: !removeAutoFocus ? 0 : void 0,
|
|
62
69
|
onKeyDown: handleOnKeyDown
|
|
63
70
|
}, getSpaceProps(rest)), {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/dialogContent/DSDialogContent.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { useGetGlobalAttributes } from '@elliemae/ds-utilities';\nimport { PortalStyles, StyledDialogBackground, StyledDialogContainer } from '../../styles';\nimport { getSpaceProps } from '../../utils';\nimport { DSDialogDatatestid } from '../../DSDialogDatatestid';\nimport { DSDialogContext } from '../../DSDialogCTX';\nimport { useDialogContent } from './useDialogContent';\n\nexport const DSDialogContent = () => {\n const { handleOutsideClick, handleOnKeyDown } = useDialogContent();\n const { props, containerRef, portalInfo, portalClassName } = useContext(DSDialogContext);\n\n const { removeAutoFocus, zIndex, centered, size, children, ...rest } = props;\n\n const { className, ...restOfGlobalAttributes } = useGetGlobalAttributes(props, {\n onClick: handleOutsideClick,\n onKeyDown: handleOnKeyDown,\n });\n\n return (\n <StyledDialogBackground\n className={className}\n onClick={handleOutsideClick}\n data-portalbg\n data-testid={DSDialogDatatestid.BACKGROUND}\n zIndex={zIndex}\n >\n <PortalStyles portalInfo={portalInfo} portalClassName={portalClassName} />\n <StyledDialogContainer\n role=\"dialog\"\n aria-modal\n ref={
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,oBAAoB,oBAAoB,iBAAiB;AACjE,QAAM,EAAE,OAAO,cAAc,YAAY,oBAAoB,WAAW,eAAe;AAEvF,QAAuE,YAA/D,mBAAiB,QAAQ,UAAU,MAAM,aAAsB,IAAT,iBAAS,IAAT,CAAtD,mBAAiB,UAAQ,YAAU,QAAM;AAEjD,QAAiD,4BAAuB,OAAO;AAAA,IAC7E,SAAS;AAAA,IACT,WAAW;AAAA,EACb,CAAC,GAHO,gBAAyC,IAA3B,mCAA2B,IAA3B,CAAd;AAKR,SACE,qCAAC;AAAA,IACC;AAAA,IACA,SAAS;AAAA,IACT,iBAAa;AAAA,IACb,eAAa,mBAAmB;AAAA,IAChC;AAAA,KAEA,qCAAC;AAAA,IAAa;AAAA,IAAwB;AAAA,GAAkC,GACxE,qCAAC;AAAA,IACC,MAAK;AAAA,IACL,cAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU,CAAC,kBAAkB,IAAI;AAAA,IACjC,WAAW;AAAA,KACP,cAAc,IAA0C,IAN7D;AAAA,IAOC;AAAA,IACA,eAAa,mBAAmB;AAAA,MAC5B,yBATL;AAAA,IAUC;AAAA,MAEC,QACH,CACF;AAEJ;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useContext } from 'react';\nimport { useGetGlobalAttributes } from '@elliemae/ds-utilities';\nimport { PortalStyles, StyledDialogBackground, StyledDialogContainer } from '../../styles';\nimport { getSpaceProps } from '../../utils';\nimport { DSDialogDatatestid } from '../../DSDialogDatatestid';\nimport { DSDialogContext } from '../../DSDialogCTX';\nimport { useDialogContent } from './useDialogContent';\n\nexport const DSDialogContent = () => {\n const { handleOutsideClick, handleOnKeyDown } = useDialogContent();\n const { props, containerRef, portalInfo, portalClassName } = useContext(DSDialogContext);\n\n const { removeAutoFocus, zIndex, centered, size, children, ...rest } = props;\n\n const { className, ...restOfGlobalAttributes } = useGetGlobalAttributes(props, {\n onClick: handleOutsideClick,\n onKeyDown: handleOnKeyDown,\n });\n\n const refCallback = useCallback(\n (_ref: HTMLDivElement | null) => {\n if (_ref) {\n containerRef.current = _ref;\n if (!removeAutoFocus) _ref.focus();\n }\n },\n [containerRef, removeAutoFocus],\n );\n\n return (\n <StyledDialogBackground\n className={className}\n onClick={handleOutsideClick}\n data-portalbg\n data-testid={DSDialogDatatestid.BACKGROUND}\n zIndex={zIndex}\n >\n <PortalStyles portalInfo={portalInfo} portalClassName={portalClassName} />\n <StyledDialogContainer\n role=\"dialog\"\n aria-modal\n ref={refCallback}\n tabIndex={!removeAutoFocus ? 0 : undefined}\n onKeyDown={handleOnKeyDown}\n {...getSpaceProps(rest as unknown as Record<string, unknown>)}\n centered={centered}\n data-testid={DSDialogDatatestid.CONTAINER}\n {...restOfGlobalAttributes}\n size={size}\n >\n {children}\n </StyledDialogContainer>\n </StyledDialogBackground>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAM,kBAAkB,MAAM;AACnC,QAAM,EAAE,oBAAoB,oBAAoB,iBAAiB;AACjE,QAAM,EAAE,OAAO,cAAc,YAAY,oBAAoB,WAAW,eAAe;AAEvF,QAAuE,YAA/D,mBAAiB,QAAQ,UAAU,MAAM,aAAsB,IAAT,iBAAS,IAAT,CAAtD,mBAAiB,UAAQ,YAAU,QAAM;AAEjD,QAAiD,4BAAuB,OAAO;AAAA,IAC7E,SAAS;AAAA,IACT,WAAW;AAAA,EACb,CAAC,GAHO,gBAAyC,IAA3B,mCAA2B,IAA3B,CAAd;AAKR,QAAM,cAAc,YAClB,CAAC,SAAgC;AAC/B,QAAI,MAAM;AACR,mBAAa,UAAU;AACvB,UAAI,CAAC;AAAiB,aAAK,MAAM;AAAA,IACnC;AAAA,EACF,GACA,CAAC,cAAc,eAAe,CAChC;AAEA,SACE,qCAAC;AAAA,IACC;AAAA,IACA,SAAS;AAAA,IACT,iBAAa;AAAA,IACb,eAAa,mBAAmB;AAAA,IAChC;AAAA,KAEA,qCAAC;AAAA,IAAa;AAAA,IAAwB;AAAA,GAAkC,GACxE,qCAAC;AAAA,IACC,MAAK;AAAA,IACL,cAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU,CAAC,kBAAkB,IAAI;AAAA,IACjC,WAAW;AAAA,KACP,cAAc,IAA0C,IAN7D;AAAA,IAOC;AAAA,IACA,eAAa,mBAAmB;AAAA,MAC5B,yBATL;AAAA,IAUC;AAAA,MAEC,QACH,CACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useCallback,
|
|
2
|
+
import { useCallback, useContext } from "react";
|
|
3
3
|
import { DSDialogContext } from "../../DSDialogCTX";
|
|
4
4
|
const useDialogContent = () => {
|
|
5
5
|
const {
|
|
6
|
-
props: { onClickOutside, onClose
|
|
7
|
-
containerRef
|
|
6
|
+
props: { onClickOutside, onClose }
|
|
8
7
|
} = useContext(DSDialogContext);
|
|
9
8
|
const handleOutsideClick = useCallback((e) => {
|
|
10
9
|
if (e.target.dataset.portalbg)
|
|
@@ -14,21 +13,6 @@ const useDialogContent = () => {
|
|
|
14
13
|
if (e.key === "Escape")
|
|
15
14
|
onClose();
|
|
16
15
|
}, [onClose]);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (!removeAutoFocus)
|
|
19
|
-
containerRef?.current?.focus();
|
|
20
|
-
}, [containerRef, removeAutoFocus]);
|
|
21
|
-
const focusContainer = useCallback(() => {
|
|
22
|
-
setTimeout(() => {
|
|
23
|
-
const isContainerOrChildFocused = containerRef.current?.contains(document.activeElement);
|
|
24
|
-
if (!isContainerOrChildFocused)
|
|
25
|
-
containerRef.current?.focus?.();
|
|
26
|
-
});
|
|
27
|
-
}, [containerRef]);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
document.addEventListener("focusin", focusContainer);
|
|
30
|
-
return () => document.removeEventListener("focusin", focusContainer);
|
|
31
|
-
}, [focusContainer]);
|
|
32
16
|
return {
|
|
33
17
|
handleOutsideClick,
|
|
34
18
|
handleOnKeyDown
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/dialogContent/useDialogContent.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback,
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AAEO,MAAM,mBAAmB,MAAM;AACpC,QAAM;AAAA,IACJ,OAAO,EAAE,gBAAgB
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useContext } from 'react';\nimport { DSDialogContext } from '../../DSDialogCTX';\n\nexport const useDialogContent = () => {\n const {\n props: { onClickOutside, onClose },\n } = useContext(DSDialogContext);\n\n const handleOutsideClick = useCallback(\n (e: React.MouseEvent) => {\n if ((e.target as HTMLDivElement).dataset.portalbg) onClickOutside();\n },\n [onClickOutside],\n );\n\n const handleOnKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') onClose();\n },\n [onClose],\n );\n\n return {\n handleOutsideClick,\n handleOnKeyDown,\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEO,MAAM,mBAAmB,MAAM;AACpC,QAAM;AAAA,IACJ,OAAO,EAAE,gBAAgB;AAAA,MACvB,WAAW,eAAe;AAE9B,QAAM,qBAAqB,YACzB,CAAC,MAAwB;AACvB,QAAK,EAAE,OAA0B,QAAQ;AAAU,qBAAe;AAAA,EACpE,GACA,CAAC,cAAc,CACjB;AAEA,QAAM,kBAAkB,YACtB,CAAC,MAA2B;AAC1B,QAAI,EAAE,QAAQ;AAAU,cAAQ;AAAA,EAClC,GACA,CAAC,OAAO,CACV;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-dialog",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5-rc.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Dialog",
|
|
6
6
|
"files": [
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"indent": 4
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@elliemae/ds-button": "3.1.
|
|
71
|
-
"@elliemae/ds-icons": "3.1.
|
|
72
|
-
"@elliemae/ds-system": "3.1.
|
|
73
|
-
"@elliemae/ds-utilities": "3.1.
|
|
70
|
+
"@elliemae/ds-button": "3.1.5-rc.10",
|
|
71
|
+
"@elliemae/ds-icons": "3.1.5-rc.10",
|
|
72
|
+
"@elliemae/ds-system": "3.1.5-rc.10",
|
|
73
|
+
"@elliemae/ds-utilities": "3.1.5-rc.10",
|
|
74
74
|
"@xstyled/styled-components": "~3.6.0",
|
|
75
75
|
"lodash": "~4.17.21",
|
|
76
76
|
"uid": "~2.0.0"
|