@elliemae/ds-dialog 3.0.0-next.6 → 3.0.0-next.62
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/DSDialog.js +18 -133
- package/dist/cjs/DSDialog.js.map +2 -2
- package/dist/cjs/DSDialogCTX.js +30 -0
- package/dist/cjs/DSDialogCTX.js.map +7 -0
- package/dist/cjs/DSDialogDatatestid.js +9 -16
- package/dist/cjs/DSDialogDatatestid.js.map +1 -1
- package/dist/cjs/config/useDialog.js +110 -0
- package/dist/cjs/config/useDialog.js.map +7 -0
- package/dist/cjs/defaultProps.js +12 -17
- package/dist/cjs/defaultProps.js.map +2 -2
- package/dist/cjs/index.js +31 -37
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/parts/DSDialogPortal.js +42 -0
- package/dist/cjs/parts/DSDialogPortal.js.map +7 -0
- package/dist/cjs/parts/dialogContent/DSDialogContent.js +93 -0
- package/dist/cjs/parts/dialogContent/DSDialogContent.js.map +7 -0
- package/dist/cjs/parts/dialogContent/useDialogContent.js +62 -0
- package/dist/cjs/parts/dialogContent/useDialogContent.js.map +7 -0
- package/dist/cjs/propTypes.js +18 -25
- package/dist/cjs/propTypes.js.map +2 -2
- package/dist/cjs/sharedTypes.js +9 -16
- package/dist/cjs/sharedTypes.js.map +2 -2
- package/dist/cjs/styles.js +14 -21
- package/dist/cjs/styles.js.map +2 -2
- package/dist/cjs/utils.js +13 -16
- package/dist/cjs/utils.js.map +2 -2
- package/dist/esm/DSDialog.js +9 -124
- package/dist/esm/DSDialog.js.map +2 -2
- package/dist/esm/DSDialogCTX.js +8 -0
- package/dist/esm/DSDialogCTX.js.map +7 -0
- package/dist/esm/DSDialogDatatestid.js.map +1 -1
- package/dist/esm/config/useDialog.js +90 -0
- package/dist/esm/config/useDialog.js.map +7 -0
- package/dist/esm/defaultProps.js +3 -1
- package/dist/esm/defaultProps.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/parts/DSDialogPortal.js +20 -0
- package/dist/esm/parts/DSDialogPortal.js.map +7 -0
- package/dist/esm/parts/dialogContent/DSDialogContent.js +73 -0
- package/dist/esm/parts/dialogContent/DSDialogContent.js.map +7 -0
- package/dist/esm/parts/dialogContent/useDialogContent.js +40 -0
- package/dist/esm/parts/dialogContent/useDialogContent.js.map +7 -0
- package/dist/esm/propTypes.js +1 -1
- package/dist/esm/propTypes.js.map +2 -2
- package/dist/esm/styles.js +5 -5
- package/dist/esm/styles.js.map +2 -2
- package/dist/esm/utils.js +4 -0
- package/dist/esm/utils.js.map +2 -2
- package/package.json +12 -12
package/dist/esm/DSDialog.js
CHANGED
|
@@ -1,130 +1,15 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
1
|
import * as React from "react";
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import { debounce } from "lodash";
|
|
36
|
-
import {
|
|
37
|
-
useMemoMergePropsWithDefault,
|
|
38
|
-
useGetGlobalAttributes,
|
|
39
|
-
useValidateTypescriptPropTypes,
|
|
40
|
-
describe
|
|
41
|
-
} from "@elliemae/ds-props-helpers";
|
|
42
|
-
import { FixedBody, StyledDialogBackground, StyledDialogContainer } from "./styles";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { describe } from "@elliemae/ds-utilities";
|
|
43
4
|
import { propTypes } from "./propTypes";
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
5
|
+
import { useDialog } from "./config/useDialog";
|
|
6
|
+
import { DSDialogPortal } from "./parts/DSDialogPortal";
|
|
7
|
+
import { DSDialogContext } from "./DSDialogCTX";
|
|
47
8
|
const DSDialog = (props) => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
scrollbarWidth: "0px"
|
|
53
|
-
});
|
|
54
|
-
useValidateTypescriptPropTypes(propsWithDefault, propTypes);
|
|
55
|
-
const _a = propsWithDefault, { children, isOpen, onClickOutside, onClose, centered, size, removeAutoFocus, zIndex } = _a, rest = __objRest(_a, ["children", "isOpen", "onClickOutside", "onClose", "centered", "size", "removeAutoFocus", "zIndex"]);
|
|
56
|
-
const containerRef = useRef(null);
|
|
57
|
-
const focusContainer = useCallback(() => {
|
|
58
|
-
const isContainerOrChildFocused = containerRef.current?.contains(document.activeElement);
|
|
59
|
-
if (!isContainerOrChildFocused)
|
|
60
|
-
containerRef.current?.focus?.();
|
|
61
|
-
}, []);
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
document.addEventListener("focusin", focusContainer);
|
|
64
|
-
return () => document.removeEventListener("focusin", focusContainer);
|
|
65
|
-
}, [focusContainer]);
|
|
66
|
-
const handleOutsideClick = useCallback((e) => {
|
|
67
|
-
if (e.target.dataset.portalbg)
|
|
68
|
-
onClickOutside();
|
|
69
|
-
}, [onClickOutside]);
|
|
70
|
-
const handleOnKeyDown = useCallback((e) => {
|
|
71
|
-
if (e.key === "Escape")
|
|
72
|
-
onClose();
|
|
73
|
-
}, [onClose]);
|
|
74
|
-
const _b = useGetGlobalAttributes(propsWithDefault, {
|
|
75
|
-
onClick: handleOutsideClick,
|
|
76
|
-
onKeyDown: handleOnKeyDown
|
|
77
|
-
}), { className } = _b, restOfGlobalAttributes = __objRest(_b, ["className"]);
|
|
78
|
-
const calculateScrollbar = useCallback(() => {
|
|
79
|
-
const body = document.getElementsByTagName("body")[0];
|
|
80
|
-
const { clientWidth } = body;
|
|
81
|
-
setBodyInfo((prev) => __spreadProps(__spreadValues({}, prev), { scrollbarWidth: `${window.innerWidth - clientWidth}px` }));
|
|
82
|
-
}, []);
|
|
83
|
-
const debouncedCalculateScrollbar = useMemo(() => debounce(calculateScrollbar, 300), [calculateScrollbar]);
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
calculateScrollbar();
|
|
86
|
-
}, [calculateScrollbar]);
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
window.addEventListener("resize", debouncedCalculateScrollbar);
|
|
89
|
-
return () => {
|
|
90
|
-
window.removeEventListener("resize", debouncedCalculateScrollbar);
|
|
91
|
-
};
|
|
92
|
-
}, [calculateScrollbar, debouncedCalculateScrollbar]);
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (isOpen) {
|
|
95
|
-
const body = document.getElementsByTagName("body")[0];
|
|
96
|
-
const { clientHeight, scrollHeight } = body;
|
|
97
|
-
const paddingRight = window.getComputedStyle(body, null)?.getPropertyValue("padding-right");
|
|
98
|
-
setBodyInfo((prev) => __spreadProps(__spreadValues({}, prev), { overflow: scrollHeight > clientHeight, paddingRight }));
|
|
99
|
-
} else
|
|
100
|
-
setBodyInfo((prev) => __spreadProps(__spreadValues({}, prev), { overflow: false, paddingRight: "0px" }));
|
|
101
|
-
}, [isOpen]);
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
if (isOpen && !removeAutoFocus)
|
|
104
|
-
containerRef?.current?.focus();
|
|
105
|
-
}, [isOpen, removeAutoFocus]);
|
|
106
|
-
if (isOpen) {
|
|
107
|
-
return ReactDOM.createPortal(/* @__PURE__ */ React2.createElement(StyledDialogBackground, {
|
|
108
|
-
className,
|
|
109
|
-
onClick: handleOutsideClick,
|
|
110
|
-
"data-portalbg": true,
|
|
111
|
-
"data-testid": DSDialogDatatestid.BACKGROUND,
|
|
112
|
-
zIndex
|
|
113
|
-
}, /* @__PURE__ */ React2.createElement(FixedBody, {
|
|
114
|
-
bodyInfo
|
|
115
|
-
}), /* @__PURE__ */ React2.createElement(StyledDialogContainer, __spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
116
|
-
role: "dialog",
|
|
117
|
-
"aria-modal": true,
|
|
118
|
-
ref: containerRef,
|
|
119
|
-
tabIndex: !removeAutoFocus ? 0 : void 0
|
|
120
|
-
}, getSpaceProps(rest)), {
|
|
121
|
-
centered,
|
|
122
|
-
"data-testid": DSDialogDatatestid.CONTAINER
|
|
123
|
-
}), restOfGlobalAttributes), {
|
|
124
|
-
size
|
|
125
|
-
}), children)), document.getElementsByTagName("body")[0]);
|
|
126
|
-
}
|
|
127
|
-
return null;
|
|
9
|
+
const ctx = useDialog(props);
|
|
10
|
+
return /* @__PURE__ */ React2.createElement(DSDialogContext.Provider, {
|
|
11
|
+
value: ctx
|
|
12
|
+
}, /* @__PURE__ */ React2.createElement(DSDialogPortal, null));
|
|
128
13
|
};
|
|
129
14
|
const DSDialogWithSchema = describe(DSDialog);
|
|
130
15
|
DSDialogWithSchema.propTypes = propTypes;
|
package/dist/esm/DSDialog.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSDialog.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { WeakValidationMap } from 'react';\nimport { describe } from '@elliemae/ds-utilities';\nimport { propTypes } from './propTypes';\nimport { useDialog } from './config/useDialog';\nimport { DSDialogPortal } from './parts/DSDialogPortal';\nimport { DSDialogContext } from './DSDialogCTX';\nimport type { DSDialogT } from './propTypes';\n\nconst DSDialog = (props: DSDialogT.Props): JSX.Element => {\n const ctx = useDialog(props);\n\n return (\n <DSDialogContext.Provider value={ctx}>\n <DSDialogPortal />\n </DSDialogContext.Provider>\n );\n};\n\nconst DSDialogWithSchema = describe(DSDialog);\nDSDialogWithSchema.propTypes = propTypes as WeakValidationMap<unknown>;\n\nexport { DSDialog, DSDialogWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAM,WAAW,CAAC,UAAwC;AACxD,QAAM,MAAM,UAAU,KAAK;AAE3B,SACE,qCAAC,gBAAgB,UAAhB;AAAA,IAAyB,OAAO;AAAA,KAC/B,qCAAC,oBAAe,CAClB;AAEJ;AAEA,MAAM,qBAAqB,SAAS,QAAQ;AAC5C,mBAAmB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSDialogCTX.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext } from 'react';\nimport type { DSDialogInternalsT } from './sharedTypes';\n\nconst defaultContext = {} as DSDialogInternalsT.DSDialogContext;\n\nexport const DSDialogContext = createContext<DSDialogInternalsT.DSDialogContext>(defaultContext);\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAGA,MAAM,iBAAiB,CAAC;AAEjB,MAAM,kBAAkB,cAAkD,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSDialogDatatestid.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSDialogDatatestid = {\n CONTAINER: 'ds-dialog-container',\n BACKGROUND: 'ds-dialog-background',\n};\n"],
|
|
5
|
-
"mappings": "AAAA;ACAO,MAAM,qBAAqB;AAAA,EAChC,WAAW;AAAA,EACX,YAAY;
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,qBAAqB;AAAA,EAChC,WAAW;AAAA,EACX,YAAY;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import { useEffect, useMemo, useState, useCallback, useRef, useLayoutEffect } from "react";
|
|
22
|
+
import { debounce } from "lodash";
|
|
23
|
+
import { uid } from "uid";
|
|
24
|
+
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from "@elliemae/ds-utilities";
|
|
25
|
+
import { defaultProps } from "../defaultProps";
|
|
26
|
+
import { propTypes } from "../propTypes";
|
|
27
|
+
import { getScrollbarWidth, getCurrentRightPadding } from "../utils";
|
|
28
|
+
const useDialog = (props) => {
|
|
29
|
+
useValidateTypescriptPropTypes(props, propTypes);
|
|
30
|
+
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
31
|
+
const { portalRef, isOpen } = propsWithDefault;
|
|
32
|
+
const actualPortalRef = useRef(null);
|
|
33
|
+
const containerRef = useRef(null);
|
|
34
|
+
const [portalInfo, setPortalInfo] = useState({
|
|
35
|
+
paddingRight: "0px",
|
|
36
|
+
scrollbarWidth: "0px"
|
|
37
|
+
});
|
|
38
|
+
const portalClassName = useMemo(() => `ds-dialog-${uid(8)}`, []);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (portalRef)
|
|
41
|
+
actualPortalRef.current = portalRef.current;
|
|
42
|
+
else
|
|
43
|
+
actualPortalRef.current = document.getElementsByTagName("body")["0"];
|
|
44
|
+
}, [portalRef]);
|
|
45
|
+
useLayoutEffect(() => {
|
|
46
|
+
if (actualPortalRef.current) {
|
|
47
|
+
if (isOpen) {
|
|
48
|
+
actualPortalRef.current.classList.add(portalClassName);
|
|
49
|
+
} else {
|
|
50
|
+
actualPortalRef.current.classList.remove(portalClassName);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, [actualPortalRef, isOpen, portalClassName]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (actualPortalRef.current) {
|
|
56
|
+
setPortalInfo((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
57
|
+
paddingRight: getCurrentRightPadding(actualPortalRef.current)
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
}, []);
|
|
61
|
+
const calculateScrollbar = useCallback(() => {
|
|
62
|
+
if (actualPortalRef.current && !isOpen) {
|
|
63
|
+
setPortalInfo((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
64
|
+
scrollbarWidth: getScrollbarWidth(actualPortalRef.current)
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
}, [isOpen]);
|
|
68
|
+
const debouncedCalculateScrollbar = useMemo(() => debounce(calculateScrollbar, 300), [calculateScrollbar]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
window.addEventListener("resize", debouncedCalculateScrollbar);
|
|
71
|
+
return () => {
|
|
72
|
+
window.removeEventListener("resize", debouncedCalculateScrollbar);
|
|
73
|
+
};
|
|
74
|
+
}, [calculateScrollbar, debouncedCalculateScrollbar]);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
calculateScrollbar();
|
|
77
|
+
}, [calculateScrollbar, isOpen]);
|
|
78
|
+
const ctx = useMemo(() => ({
|
|
79
|
+
props: propsWithDefault,
|
|
80
|
+
actualPortalRef,
|
|
81
|
+
containerRef,
|
|
82
|
+
portalInfo,
|
|
83
|
+
portalClassName
|
|
84
|
+
}), [portalClassName, portalInfo, propsWithDefault]);
|
|
85
|
+
return ctx;
|
|
86
|
+
};
|
|
87
|
+
export {
|
|
88
|
+
useDialog
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=useDialog.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useDialog.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useEffect, useMemo, useState, useCallback, useRef, useLayoutEffect } from 'react';\nimport { debounce } from 'lodash';\nimport { uid } from 'uid';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-utilities';\nimport { defaultProps } from '../defaultProps';\nimport { propTypes } from '../propTypes';\nimport { getScrollbarWidth, getCurrentRightPadding } from '../utils';\nimport type { DSDialogT } from '../propTypes';\nimport type { DSDialogInternalsT } from '../sharedTypes';\n\nexport const useDialog = (props: DSDialogT.Props): DSDialogInternalsT.DSDialogContext => {\n useValidateTypescriptPropTypes<DSDialogT.Props>(props, propTypes);\n const propsWithDefault = useMemoMergePropsWithDefault<DSDialogT.InternalProps>(props, defaultProps);\n const { portalRef, isOpen } = propsWithDefault;\n\n const actualPortalRef = useRef<HTMLElement | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n const [portalInfo, setPortalInfo] = useState<DSDialogInternalsT.PortalInfo>({\n paddingRight: '0px',\n scrollbarWidth: '0px',\n });\n\n const portalClassName = useMemo(() => `ds-dialog-${uid(8)}`, []);\n\n useEffect(() => {\n if (portalRef) actualPortalRef.current = portalRef.current;\n else actualPortalRef.current = document.getElementsByTagName('body')['0'];\n }, [portalRef]);\n\n useLayoutEffect(() => {\n if (actualPortalRef.current) {\n if (isOpen) {\n actualPortalRef.current.classList.add(portalClassName);\n } else {\n actualPortalRef.current.classList.remove(portalClassName);\n }\n }\n }, [actualPortalRef, isOpen, portalClassName]);\n\n useEffect(() => {\n if (actualPortalRef.current) {\n setPortalInfo((prev) => ({\n ...prev,\n paddingRight: getCurrentRightPadding(actualPortalRef.current as HTMLElement),\n }));\n }\n }, []);\n\n const calculateScrollbar = useCallback(() => {\n if (actualPortalRef.current && !isOpen) {\n setPortalInfo((prev) => ({\n ...prev,\n scrollbarWidth: getScrollbarWidth(actualPortalRef.current as HTMLElement),\n }));\n }\n }, [isOpen]);\n\n const debouncedCalculateScrollbar = useMemo(() => debounce(calculateScrollbar, 300), [calculateScrollbar]);\n\n useEffect(() => {\n window.addEventListener('resize', debouncedCalculateScrollbar);\n return () => {\n window.removeEventListener('resize', debouncedCalculateScrollbar);\n };\n }, [calculateScrollbar, debouncedCalculateScrollbar]);\n\n useEffect(() => {\n calculateScrollbar();\n }, [calculateScrollbar, isOpen]);\n\n const ctx = useMemo(\n () => ({\n props: propsWithDefault,\n actualPortalRef,\n containerRef,\n portalInfo,\n portalClassName,\n }),\n [portalClassName, portalInfo, propsWithDefault],\n );\n\n return ctx;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AAIO,MAAM,YAAY,CAAC,UAA+D;AACvF,iCAAgD,OAAO,SAAS;AAChE,QAAM,mBAAmB,6BAAsD,OAAO,YAAY;AAClG,QAAM,EAAE,WAAW,WAAW;AAE9B,QAAM,kBAAkB,OAA2B,IAAI;AACvD,QAAM,eAAe,OAA8B,IAAI;AAEvD,QAAM,CAAC,YAAY,iBAAiB,SAAwC;AAAA,IAC1E,cAAc;AAAA,IACd,gBAAgB;AAAA,EAClB,CAAC;AAED,QAAM,kBAAkB,QAAQ,MAAM,aAAa,IAAI,CAAC,KAAK,CAAC,CAAC;AAE/D,YAAU,MAAM;AACd,QAAI;AAAW,sBAAgB,UAAU,UAAU;AAAA;AAC9C,sBAAgB,UAAU,SAAS,qBAAqB,MAAM,EAAE;AAAA,EACvE,GAAG,CAAC,SAAS,CAAC;AAEd,kBAAgB,MAAM;AACpB,QAAI,gBAAgB,SAAS;AAC3B,UAAI,QAAQ;AACV,wBAAgB,QAAQ,UAAU,IAAI,eAAe;AAAA,MACvD,OAAO;AACL,wBAAgB,QAAQ,UAAU,OAAO,eAAe;AAAA,MAC1D;AAAA,IACF;AAAA,EACF,GAAG,CAAC,iBAAiB,QAAQ,eAAe,CAAC;AAE7C,YAAU,MAAM;AACd,QAAI,gBAAgB,SAAS;AAC3B,oBAAc,CAAC,SAAU,iCACpB,OADoB;AAAA,QAEvB,cAAc,uBAAuB,gBAAgB,OAAsB;AAAA,MAC7E,EAAE;AAAA,IACJ;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,qBAAqB,YAAY,MAAM;AAC3C,QAAI,gBAAgB,WAAW,CAAC,QAAQ;AACtC,oBAAc,CAAC,SAAU,iCACpB,OADoB;AAAA,QAEvB,gBAAgB,kBAAkB,gBAAgB,OAAsB;AAAA,MAC1E,EAAE;AAAA,IACJ;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AAEX,QAAM,8BAA8B,QAAQ,MAAM,SAAS,oBAAoB,GAAG,GAAG,CAAC,kBAAkB,CAAC;AAEzG,YAAU,MAAM;AACd,WAAO,iBAAiB,UAAU,2BAA2B;AAC7D,WAAO,MAAM;AACX,aAAO,oBAAoB,UAAU,2BAA2B;AAAA,IAClE;AAAA,EACF,GAAG,CAAC,oBAAoB,2BAA2B,CAAC;AAEpD,YAAU,MAAM;AACd,uBAAmB;AAAA,EACrB,GAAG,CAAC,oBAAoB,MAAM,CAAC;AAE/B,QAAM,MAAM,QACV,MAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IACA,CAAC,iBAAiB,YAAY,gBAAgB,CAChD;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/defaultProps.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/defaultProps.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { DSDialogSizes } from './utils';\nimport type { DSDialogT } from './propTypes';\n\nconst noop = () => {};\n\nexport const defaultProps: DSDialogT.DefaultProps = {\n isOpen: false,\n centered: false,\n size: DSDialogSizes.DEFAULT,\n removeAutoFocus: false,\n onClickOutside: noop,\n onClose: noop,\n zIndex: 10,\n};\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AAGA,MAAM,OAAO,MAAM;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { DSDialogSizes } from './utils';\nimport type { DSDialogT } from './propTypes';\n\nconst noop = () => {};\n\nexport const defaultProps: DSDialogT.DefaultProps = {\n isOpen: false,\n centered: false,\n size: DSDialogSizes.DEFAULT,\n removeAutoFocus: false,\n onClickOutside: noop,\n onClose: noop,\n zIndex: 10,\n portalRef: null,\n children: [],\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAGA,MAAM,OAAO,MAAM;AAAC;AAEb,MAAM,eAAuC;AAAA,EAClD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM,cAAc;AAAA,EACpB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU,CAAC;AACb;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { describe } from 'react-desc';\nimport { globalAttributesPropTypes } from '@elliemae/ds-
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,aAAa,YAAY;AACzB,eAAe,YAAY;AAC3B,eAAe,YAAY;AAC3B,kBAAkB,YAAY;AAC9B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,sBAAsB,YAAY;AAClC,uBAAuB,YAAY;AACnC,yBAAyB,YAAY;AAErC,aAAa,cAAc;AAC3B,eAAe,cAAc;AAC7B,eAAe,cAAc;AAC7B,kBAAkB,cAAc;AAChC,cAAc,cAAc;AAC5B,cAAc,cAAc;AAC5B,sBAAsB,cAAc;AACpC,uBAAuB,cAAc;AACrC,yBAAyB,cAAc;AAEvC,MAAM,yBAAyB,SAAS;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { describe } from 'react-desc';\nimport { globalAttributesPropTypes } from '@elliemae/ds-utilities';\nimport {\n DSDialogBody,\n DSDialogHeader,\n DSDialogFooter,\n DSDialogSeparator,\n DSDialogTitle,\n DSDialogAddon,\n DSDialogDefaultLayout,\n DSDialogPrimaryMessage,\n DSDialogSecondaryMessage,\n} from './styles';\n\nDSDialogBody.propTypes = globalAttributesPropTypes;\nDSDialogHeader.propTypes = globalAttributesPropTypes;\nDSDialogFooter.propTypes = globalAttributesPropTypes;\nDSDialogSeparator.propTypes = globalAttributesPropTypes;\nDSDialogTitle.propTypes = globalAttributesPropTypes;\nDSDialogAddon.propTypes = globalAttributesPropTypes;\nDSDialogDefaultLayout.propTypes = globalAttributesPropTypes;\nDSDialogPrimaryMessage.propTypes = globalAttributesPropTypes;\nDSDialogSecondaryMessage.propTypes = globalAttributesPropTypes;\n\nDSDialogBody.displayName = 'DSDialogBody';\nDSDialogHeader.displayName = 'DSDialogHeader';\nDSDialogFooter.displayName = 'DSDialogFooter';\nDSDialogSeparator.displayName = 'DSDialogSeparator';\nDSDialogTitle.displayName = 'DSDialogTitle';\nDSDialogAddon.displayName = 'DSDialogAddon';\nDSDialogDefaultLayout.displayName = 'DSDialogDefaultLayout';\nDSDialogPrimaryMessage.displayName = 'DSDialogPrimaryMessage';\nDSDialogSecondaryMessage.displayName = 'DSDialogSecondaryMessage';\n\nconst DSDialogBodyWithSchema = describe(DSDialogBody);\nconst DSDialogHeaderWithSchema = describe(DSDialogHeader);\nconst DSDialogFooterWithSchema = describe(DSDialogFooter);\nconst DSDialogSeparatorWithSchema = describe(DSDialogSeparator);\nconst DSDialogTitleWithSchema = describe(DSDialogTitle);\nconst DSDialogAddonWithSchema = describe(DSDialogAddon);\nconst DSDialogDefaultLayoutWithSchema = describe(DSDialogDefaultLayout);\nconst DSDialogPrimaryMessageWithSchema = describe(DSDialogPrimaryMessage);\nconst DSDialogSecondaryMessageWithSchema = describe(DSDialogSecondaryMessage);\n\nDSDialogBodyWithSchema.propTypes = globalAttributesPropTypes;\nDSDialogHeaderWithSchema.propTypes = globalAttributesPropTypes;\nDSDialogFooterWithSchema.propTypes = globalAttributesPropTypes;\nDSDialogSeparatorWithSchema.propTypes = globalAttributesPropTypes;\nDSDialogTitleWithSchema.propTypes = globalAttributesPropTypes;\nDSDialogAddonWithSchema.propTypes = globalAttributesPropTypes;\nDSDialogDefaultLayoutWithSchema.propTypes = globalAttributesPropTypes;\nDSDialogPrimaryMessageWithSchema.propTypes = globalAttributesPropTypes;\nDSDialogSecondaryMessageWithSchema.propTypes = globalAttributesPropTypes;\n\nexport * from './DSDialog';\nexport * from './DSDialogDatatestid';\nexport { DSDialogSizes } from './utils';\nexport {\n DSDialogBody,\n DSDialogHeader,\n DSDialogFooter,\n DSDialogSeparator,\n DSDialogTitle,\n DSDialogAddon,\n DSDialogDefaultLayout,\n DSDialogPrimaryMessage,\n DSDialogSecondaryMessage,\n DSDialogBodyWithSchema,\n DSDialogHeaderWithSchema,\n DSDialogFooterWithSchema,\n DSDialogSeparatorWithSchema,\n DSDialogTitleWithSchema,\n DSDialogAddonWithSchema,\n DSDialogDefaultLayoutWithSchema,\n DSDialogPrimaryMessageWithSchema,\n DSDialogSecondaryMessageWithSchema,\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,aAAa,YAAY;AACzB,eAAe,YAAY;AAC3B,eAAe,YAAY;AAC3B,kBAAkB,YAAY;AAC9B,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,sBAAsB,YAAY;AAClC,uBAAuB,YAAY;AACnC,yBAAyB,YAAY;AAErC,aAAa,cAAc;AAC3B,eAAe,cAAc;AAC7B,eAAe,cAAc;AAC7B,kBAAkB,cAAc;AAChC,cAAc,cAAc;AAC5B,cAAc,cAAc;AAC5B,sBAAsB,cAAc;AACpC,uBAAuB,cAAc;AACrC,yBAAyB,cAAc;AAEvC,MAAM,yBAAyB,SAAS,YAAY;AACpD,MAAM,2BAA2B,SAAS,cAAc;AACxD,MAAM,2BAA2B,SAAS,cAAc;AACxD,MAAM,8BAA8B,SAAS,iBAAiB;AAC9D,MAAM,0BAA0B,SAAS,aAAa;AACtD,MAAM,0BAA0B,SAAS,aAAa;AACtD,MAAM,kCAAkC,SAAS,qBAAqB;AACtE,MAAM,mCAAmC,SAAS,sBAAsB;AACxE,MAAM,qCAAqC,SAAS,wBAAwB;AAE5E,uBAAuB,YAAY;AACnC,yBAAyB,YAAY;AACrC,yBAAyB,YAAY;AACrC,4BAA4B,YAAY;AACxC,wBAAwB,YAAY;AACpC,wBAAwB,YAAY;AACpC,gCAAgC,YAAY;AAC5C,iCAAiC,YAAY;AAC7C,mCAAmC,YAAY;AAE/C;AACA;AACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import { useContext } from "react";
|
|
5
|
+
import { DSDialogContext } from "../DSDialogCTX";
|
|
6
|
+
import { DSDialogContent } from "./dialogContent/DSDialogContent";
|
|
7
|
+
const DSDialogPortal = () => {
|
|
8
|
+
const {
|
|
9
|
+
props: { isOpen },
|
|
10
|
+
actualPortalRef
|
|
11
|
+
} = useContext(DSDialogContext);
|
|
12
|
+
if (isOpen && actualPortalRef.current) {
|
|
13
|
+
return ReactDOM.createPortal(/* @__PURE__ */ React2.createElement(DSDialogContent, null), actualPortalRef.current);
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
DSDialogPortal
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=DSDialogPortal.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 { useContext } from 'react';\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;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
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import * as React from "react";
|
|
33
|
+
import React2, { useContext } from "react";
|
|
34
|
+
import { useGetGlobalAttributes } from "@elliemae/ds-utilities";
|
|
35
|
+
import { PortalStyles, StyledDialogBackground, StyledDialogContainer } from "../../styles";
|
|
36
|
+
import { getSpaceProps } from "../../utils";
|
|
37
|
+
import { DSDialogDatatestid } from "../../DSDialogDatatestid";
|
|
38
|
+
import { DSDialogContext } from "../../DSDialogCTX";
|
|
39
|
+
import { useDialogContent } from "./useDialogContent";
|
|
40
|
+
const DSDialogContent = () => {
|
|
41
|
+
const { handleOutsideClick, handleOnKeyDown } = useDialogContent();
|
|
42
|
+
const { props, containerRef, portalInfo, portalClassName } = useContext(DSDialogContext);
|
|
43
|
+
const _a = props, { removeAutoFocus, zIndex, centered, size, children } = _a, rest = __objRest(_a, ["removeAutoFocus", "zIndex", "centered", "size", "children"]);
|
|
44
|
+
const _b = useGetGlobalAttributes(props, {
|
|
45
|
+
onClick: handleOutsideClick,
|
|
46
|
+
onKeyDown: handleOnKeyDown
|
|
47
|
+
}), { className } = _b, restOfGlobalAttributes = __objRest(_b, ["className"]);
|
|
48
|
+
return /* @__PURE__ */ React2.createElement(StyledDialogBackground, {
|
|
49
|
+
className,
|
|
50
|
+
onClick: handleOutsideClick,
|
|
51
|
+
"data-portalbg": true,
|
|
52
|
+
"data-testid": DSDialogDatatestid.BACKGROUND,
|
|
53
|
+
zIndex
|
|
54
|
+
}, /* @__PURE__ */ React2.createElement(PortalStyles, {
|
|
55
|
+
portalInfo,
|
|
56
|
+
portalClassName
|
|
57
|
+
}), /* @__PURE__ */ React2.createElement(StyledDialogContainer, __spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
58
|
+
role: "dialog",
|
|
59
|
+
"aria-modal": true,
|
|
60
|
+
ref: containerRef,
|
|
61
|
+
tabIndex: !removeAutoFocus ? 0 : void 0,
|
|
62
|
+
onKeyDown: handleOnKeyDown
|
|
63
|
+
}, getSpaceProps(rest)), {
|
|
64
|
+
centered,
|
|
65
|
+
"data-testid": DSDialogDatatestid.CONTAINER
|
|
66
|
+
}), restOfGlobalAttributes), {
|
|
67
|
+
size
|
|
68
|
+
}), children));
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
DSDialogContent
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=DSDialogContent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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={containerRef}\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,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
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useEffect, useContext } from "react";
|
|
3
|
+
import { DSDialogContext } from "../../DSDialogCTX";
|
|
4
|
+
const useDialogContent = () => {
|
|
5
|
+
const {
|
|
6
|
+
props: { onClickOutside, onClose, removeAutoFocus },
|
|
7
|
+
containerRef
|
|
8
|
+
} = useContext(DSDialogContext);
|
|
9
|
+
const handleOutsideClick = useCallback((e) => {
|
|
10
|
+
if (e.target.dataset.portalbg)
|
|
11
|
+
onClickOutside();
|
|
12
|
+
}, [onClickOutside]);
|
|
13
|
+
const handleOnKeyDown = useCallback((e) => {
|
|
14
|
+
if (e.key === "Escape")
|
|
15
|
+
onClose();
|
|
16
|
+
}, [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
|
+
return {
|
|
33
|
+
handleOutsideClick,
|
|
34
|
+
handleOnKeyDown
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
useDialogContent
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=useDialogContent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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, useEffect, useContext } from 'react';\nimport { DSDialogContext } from '../../DSDialogCTX';\n\nexport const useDialogContent = () => {\n const {\n props: { onClickOutside, onClose, removeAutoFocus },\n containerRef,\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 useEffect(() => {\n if (!removeAutoFocus) containerRef?.current?.focus();\n }, [containerRef, removeAutoFocus]);\n\n const focusContainer = useCallback(() => {\n setTimeout(() => {\n const isContainerOrChildFocused = containerRef.current?.contains(document.activeElement);\n if (!isContainerOrChildFocused) containerRef.current?.focus?.();\n });\n }, [containerRef]);\n\n useEffect(() => {\n document.addEventListener('focusin', focusContainer);\n return () => document.removeEventListener('focusin', focusContainer);\n }, [focusContainer]);\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,SAAS;AAAA,IAClC;AAAA,MACE,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,YAAU,MAAM;AACd,QAAI,CAAC;AAAiB,oBAAc,SAAS,MAAM;AAAA,EACrD,GAAG,CAAC,cAAc,eAAe,CAAC;AAElC,QAAM,iBAAiB,YAAY,MAAM;AACvC,eAAW,MAAM;AACf,YAAM,4BAA4B,aAAa,SAAS,SAAS,SAAS,aAAa;AACvF,UAAI,CAAC;AAA2B,qBAAa,SAAS,QAAQ;AAAA,IAChE,CAAC;AAAA,EACH,GAAG,CAAC,YAAY,CAAC;AAEjB,YAAU,MAAM;AACd,aAAS,iBAAiB,WAAW,cAAc;AACnD,WAAO,MAAM,SAAS,oBAAoB,WAAW,cAAc;AAAA,EACrE,GAAG,CAAC,cAAc,CAAC;AAEnB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/propTypes.js
CHANGED
|
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import * as React from "react";
|
|
21
|
-
import { globalAttributesPropTypes, PropTypes } from "@elliemae/ds-
|
|
21
|
+
import { globalAttributesPropTypes, PropTypes } from "@elliemae/ds-utilities";
|
|
22
22
|
import { DSDialogSizes, DSDialogSizesArrayValues } from "./utils";
|
|
23
23
|
const propTypes = __spreadProps(__spreadValues({}, globalAttributesPropTypes), {
|
|
24
24
|
isOpen: PropTypes.bool.description("Whether the Dialog is open or not.").defaultValue(false),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/propTypes.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-len */\nimport { globalAttributesPropTypes, GlobalAttributesT, PropTypes } from '@elliemae/ds-
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-len */\nimport { globalAttributesPropTypes, GlobalAttributesT, PropTypes } from '@elliemae/ds-utilities';\nimport { DSDialogSizes, DSDialogSizesArrayValues } from './utils';\n\nexport declare namespace DSDialogT {\n export type Sizes = 'default' | 'small' | 'medium' | 'large' | 'x-large' | 'xx-large';\n export interface DefaultProps {\n [key: string]: unknown;\n isOpen: boolean;\n centered: boolean;\n size: Sizes;\n removeAutoFocus: boolean;\n zIndex: number;\n onClickOutside: () => void;\n onClose: () => void;\n portalRef: null;\n children: React.ReactNode[] | [];\n }\n\n export interface PropsRequired {\n children: React.ReactNode[] | [];\n }\n\n export interface PropsOptional {\n portalRef: React.MutableRefObject<HTMLElement | null> | null;\n }\n\n export interface InternalProps extends Omit<DefaultProps, 'portalRef'>, PropsRequired, PropsOptional {}\n\n export interface Props\n extends Omit<DefaultProps, 'portalRef'>,\n PropsRequired,\n PropsOptional,\n Omit<GlobalAttributesT<HTMLDivElement>, 'size' | 'children'> {}\n}\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n isOpen: PropTypes.bool.description('Whether the Dialog is open or not.').defaultValue(false),\n children: PropTypes.node.description('Nested components.').isRequired,\n centered: PropTypes.bool.description('Centers the Dialog.').defaultValue(false),\n removeAutoFocus: PropTypes.bool\n .description(\n 'Removes focus in the Dialog container when is open. If you want to focus an specific element in the Dialog, it should be set to true.',\n )\n .defaultValue(false),\n onClickOutside: PropTypes.func\n .description('Callback that should be used to close the modal when the user clicks outside.')\n .defaultValue(() => {}),\n onClose: PropTypes.func.description('Callback triggered with ESC key.').defaultValue(() => {}),\n size: PropTypes.oneOf(DSDialogSizesArrayValues)\n .description(`Dialog's width size.`)\n .defaultValue(DSDialogSizes.DEFAULT),\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AAkCO,MAAM,YAAY,iCACpB,4BADoB;AAAA,EAEvB,QAAQ,UAAU,KAAK,YAAY,oCAAoC,EAAE,aAAa,KAAK;AAAA,EAC3F,UAAU,UAAU,KAAK,YAAY,oBAAoB,EAAE;AAAA,EAC3D,UAAU,UAAU,KAAK,YAAY,qBAAqB,EAAE,aAAa,KAAK;AAAA,EAC9E,iBAAiB,UAAU,KACxB,YACC,uIACF,EACC,aAAa,KAAK;AAAA,EACrB,gBAAgB,UAAU,KACvB,YAAY,+EAA+E,EAC3F,aAAa,MAAM;AAAA,EAAC,CAAC;AAAA,EACxB,SAAS,UAAU,KAAK,YAAY,kCAAkC,EAAE,aAAa,MAAM;AAAA,EAAC,CAAC;AAAA,EAC7F,MAAM,UAAU,MAAM,wBAAwB,EAC3C,YAAY,sBAAsB,EAClC,aAAa,cAAc,OAAO;AACvC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/styles.js
CHANGED
|
@@ -3,14 +3,14 @@ import styled from "styled-components";
|
|
|
3
3
|
import { createGlobalStyle } from "@elliemae/ds-system";
|
|
4
4
|
import { space, flexboxes, layout, sizing } from "@xstyled/styled-components";
|
|
5
5
|
import { allSizes } from "./utils";
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const PortalStyles = createGlobalStyle`
|
|
7
|
+
${({ portalClassName }) => `.${portalClassName}`} {
|
|
8
8
|
overflow: hidden;
|
|
9
|
-
${({
|
|
9
|
+
${({ portalInfo }) => portalInfo.scrollbarWidth !== "0px" ? `padding-right: calc( ${portalInfo.paddingRight} + ${portalInfo.scrollbarWidth} ) !important;` : ``}
|
|
10
10
|
}
|
|
11
11
|
`;
|
|
12
12
|
const StyledDialogBackground = styled.div`
|
|
13
|
-
position:
|
|
13
|
+
position: absolute;
|
|
14
14
|
top: 0;
|
|
15
15
|
bottom: 0;
|
|
16
16
|
left: 0;
|
|
@@ -117,7 +117,7 @@ export {
|
|
|
117
117
|
DSDialogSecondaryMessage,
|
|
118
118
|
DSDialogSeparator,
|
|
119
119
|
DSDialogTitle,
|
|
120
|
-
|
|
120
|
+
PortalStyles,
|
|
121
121
|
StyledDialogBackground,
|
|
122
122
|
StyledDialogContainer
|
|
123
123
|
};
|