@elliemae/ds-dialog 3.0.0-next.47 → 3.0.0-next.48

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.
Files changed (40) hide show
  1. package/dist/cjs/DSDialog.js +7 -114
  2. package/dist/cjs/DSDialog.js.map +2 -2
  3. package/dist/cjs/DSDialogCTX.js +30 -0
  4. package/dist/cjs/DSDialogCTX.js.map +7 -0
  5. package/dist/cjs/config/useDialog.js +110 -0
  6. package/dist/cjs/config/useDialog.js.map +7 -0
  7. package/dist/cjs/defaultProps.js +3 -1
  8. package/dist/cjs/defaultProps.js.map +2 -2
  9. package/dist/cjs/parts/DSDialogPortal.js +42 -0
  10. package/dist/cjs/parts/DSDialogPortal.js.map +7 -0
  11. package/dist/cjs/parts/dialogContent/DSDialogContent.js +93 -0
  12. package/dist/cjs/parts/dialogContent/DSDialogContent.js.map +7 -0
  13. package/dist/cjs/parts/dialogContent/useDialogContent.js +62 -0
  14. package/dist/cjs/parts/dialogContent/useDialogContent.js.map +7 -0
  15. package/dist/cjs/propTypes.js.map +2 -2
  16. package/dist/cjs/sharedTypes.js.map +1 -1
  17. package/dist/cjs/styles.js +5 -5
  18. package/dist/cjs/styles.js.map +2 -2
  19. package/dist/cjs/utils.js +4 -0
  20. package/dist/cjs/utils.js.map +2 -2
  21. package/dist/esm/DSDialog.js +9 -123
  22. package/dist/esm/DSDialog.js.map +2 -2
  23. package/dist/esm/DSDialogCTX.js +8 -0
  24. package/dist/esm/DSDialogCTX.js.map +7 -0
  25. package/dist/esm/config/useDialog.js +90 -0
  26. package/dist/esm/config/useDialog.js.map +7 -0
  27. package/dist/esm/defaultProps.js +3 -1
  28. package/dist/esm/defaultProps.js.map +2 -2
  29. package/dist/esm/parts/DSDialogPortal.js +20 -0
  30. package/dist/esm/parts/DSDialogPortal.js.map +7 -0
  31. package/dist/esm/parts/dialogContent/DSDialogContent.js +73 -0
  32. package/dist/esm/parts/dialogContent/DSDialogContent.js.map +7 -0
  33. package/dist/esm/parts/dialogContent/useDialogContent.js +40 -0
  34. package/dist/esm/parts/dialogContent/useDialogContent.js.map +7 -0
  35. package/dist/esm/propTypes.js.map +2 -2
  36. package/dist/esm/styles.js +5 -5
  37. package/dist/esm/styles.js.map +2 -2
  38. package/dist/esm/utils.js +4 -0
  39. package/dist/esm/utils.js.map +2 -2
  40. package/package.json +4 -4
@@ -1,38 +1,9 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __getProtoOf = Object.getPrototypeOf;
9
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __objRest = (source, exclude) => {
25
- var target = {};
26
- for (var prop in source)
27
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
- target[prop] = source[prop];
29
- if (source != null && __getOwnPropSymbols)
30
- for (var prop of __getOwnPropSymbols(source)) {
31
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
- target[prop] = source[prop];
33
- }
34
- return target;
35
- };
36
7
  var __export = (target, all) => {
37
8
  for (var name in all)
38
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -54,95 +25,17 @@ __export(DSDialog_exports, {
54
25
  });
55
26
  module.exports = __toCommonJS(DSDialog_exports);
56
27
  var React = __toESM(require("react"));
57
- var import_react_dom = __toESM(require("react-dom"));
58
28
  var import_react = __toESM(require("react"));
59
- var import_lodash = require("lodash");
60
29
  var import_ds_utilities = require("@elliemae/ds-utilities");
61
- var import_styles = require("./styles");
62
30
  var import_propTypes = require("./propTypes");
63
- var import_defaultProps = require("./defaultProps");
64
- var import_utils = require("./utils");
65
- var import_DSDialogDatatestid = require("./DSDialogDatatestid");
31
+ var import_useDialog = require("./config/useDialog");
32
+ var import_DSDialogPortal = require("./parts/DSDialogPortal");
33
+ var import_DSDialogCTX = require("./DSDialogCTX");
66
34
  const DSDialog = (props) => {
67
- const propsWithDefault = (0, import_ds_utilities.useMemoMergePropsWithDefault)(props, import_defaultProps.defaultProps);
68
- const [bodyInfo, setBodyInfo] = (0, import_react.useState)({
69
- overflow: false,
70
- paddingRight: "0px",
71
- scrollbarWidth: "0px"
72
- });
73
- (0, import_ds_utilities.useValidateTypescriptPropTypes)(propsWithDefault, import_propTypes.propTypes);
74
- const _a = propsWithDefault, { children, isOpen, onClickOutside, onClose, centered, size, removeAutoFocus, zIndex } = _a, rest = __objRest(_a, ["children", "isOpen", "onClickOutside", "onClose", "centered", "size", "removeAutoFocus", "zIndex"]);
75
- const containerRef = (0, import_react.useRef)(null);
76
- const focusContainer = (0, import_react.useCallback)(() => {
77
- const isContainerOrChildFocused = containerRef.current?.contains(document.activeElement);
78
- if (!isContainerOrChildFocused)
79
- containerRef.current?.focus?.();
80
- }, []);
81
- (0, import_react.useEffect)(() => {
82
- document.addEventListener("focusin", focusContainer);
83
- return () => document.removeEventListener("focusin", focusContainer);
84
- }, [focusContainer]);
85
- const handleOutsideClick = (0, import_react.useCallback)((e) => {
86
- if (e.target.dataset.portalbg)
87
- onClickOutside();
88
- }, [onClickOutside]);
89
- const handleOnKeyDown = (0, import_react.useCallback)((e) => {
90
- if (e.key === "Escape")
91
- onClose();
92
- }, [onClose]);
93
- const _b = (0, import_ds_utilities.useGetGlobalAttributes)(propsWithDefault, {
94
- onClick: handleOutsideClick,
95
- onKeyDown: handleOnKeyDown
96
- }), { className } = _b, restOfGlobalAttributes = __objRest(_b, ["className"]);
97
- const calculateScrollbar = (0, import_react.useCallback)(() => {
98
- const body = document.getElementsByTagName("body")[0];
99
- const { clientWidth } = body;
100
- setBodyInfo((prev) => __spreadProps(__spreadValues({}, prev), { scrollbarWidth: `${window.innerWidth - clientWidth}px` }));
101
- }, []);
102
- const debouncedCalculateScrollbar = (0, import_react.useMemo)(() => (0, import_lodash.debounce)(calculateScrollbar, 300), [calculateScrollbar]);
103
- (0, import_react.useEffect)(() => {
104
- calculateScrollbar();
105
- }, [calculateScrollbar]);
106
- (0, import_react.useEffect)(() => {
107
- window.addEventListener("resize", debouncedCalculateScrollbar);
108
- return () => {
109
- window.removeEventListener("resize", debouncedCalculateScrollbar);
110
- };
111
- }, [calculateScrollbar, debouncedCalculateScrollbar]);
112
- (0, import_react.useEffect)(() => {
113
- if (isOpen) {
114
- const body = document.getElementsByTagName("body")[0];
115
- const { clientHeight, scrollHeight } = body;
116
- const paddingRight = window.getComputedStyle(body, null)?.getPropertyValue("padding-right");
117
- setBodyInfo((prev) => __spreadProps(__spreadValues({}, prev), { overflow: scrollHeight > clientHeight, paddingRight }));
118
- } else
119
- setBodyInfo((prev) => __spreadProps(__spreadValues({}, prev), { overflow: false, paddingRight: "0px" }));
120
- }, [isOpen]);
121
- (0, import_react.useEffect)(() => {
122
- if (isOpen && !removeAutoFocus)
123
- containerRef?.current?.focus();
124
- }, [isOpen, removeAutoFocus]);
125
- if (isOpen) {
126
- return import_react_dom.default.createPortal(/* @__PURE__ */ import_react.default.createElement(import_styles.StyledDialogBackground, {
127
- className,
128
- onClick: handleOutsideClick,
129
- "data-portalbg": true,
130
- "data-testid": import_DSDialogDatatestid.DSDialogDatatestid.BACKGROUND,
131
- zIndex
132
- }, /* @__PURE__ */ import_react.default.createElement(import_styles.FixedBody, {
133
- bodyInfo
134
- }), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledDialogContainer, __spreadProps(__spreadValues(__spreadValues({
135
- role: "dialog",
136
- "aria-modal": true,
137
- ref: containerRef,
138
- tabIndex: !removeAutoFocus ? 0 : void 0,
139
- centered,
140
- "data-testid": import_DSDialogDatatestid.DSDialogDatatestid.CONTAINER
141
- }, (0, import_utils.getSpaceProps)(rest)), restOfGlobalAttributes), {
142
- size
143
- }), children)), document.getElementsByTagName("body")[0]);
144
- }
145
- return null;
35
+ const ctx = (0, import_useDialog.useDialog)(props);
36
+ return /* @__PURE__ */ import_react.default.createElement(import_DSDialogCTX.DSDialogContext.Provider, {
37
+ value: ctx
38
+ }, /* @__PURE__ */ import_react.default.createElement(import_DSDialogPortal.DSDialogPortal, null));
146
39
  };
147
40
  const DSDialogWithSchema = (0, import_ds_utilities.describe)(DSDialog);
148
41
  DSDialogWithSchema.propTypes = import_propTypes.propTypes;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/DSDialog.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import ReactDOM from 'react-dom';\nimport React, { useCallback, useRef, useEffect, useState, WeakValidationMap, useMemo } from 'react';\nimport { debounce } from 'lodash';\nimport {\n useMemoMergePropsWithDefault,\n useGetGlobalAttributes,\n useValidateTypescriptPropTypes,\n describe,\n} from '@elliemae/ds-utilities';\nimport { FixedBody, StyledDialogBackground, StyledDialogContainer } from './styles';\nimport { propTypes } from './propTypes';\nimport { defaultProps } from './defaultProps';\nimport { getSpaceProps } from './utils';\nimport { DSDialogDatatestid } from './DSDialogDatatestid';\nimport type { DSDialogT } from './propTypes';\nimport type { DSDialogInternalsT } from './sharedTypes';\n\nconst DSDialog = (props: DSDialogT.Props): JSX.Element | null => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSDialogT.Props>(props, defaultProps);\n const [bodyInfo, setBodyInfo] = useState<DSDialogInternalsT.BodyInfoT>({\n overflow: false,\n paddingRight: '0px',\n scrollbarWidth: '0px',\n });\n\n useValidateTypescriptPropTypes<DSDialogT.Props>(propsWithDefault, propTypes);\n\n const { children, isOpen, onClickOutside, onClose, centered, size, removeAutoFocus, zIndex, ...rest } =\n propsWithDefault;\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n const focusContainer = useCallback(() => {\n const isContainerOrChildFocused = containerRef.current?.contains(document.activeElement);\n if (!isContainerOrChildFocused) containerRef.current?.focus?.();\n }, []);\n\n useEffect(() => {\n document.addEventListener('focusin', focusContainer);\n return () => document.removeEventListener('focusin', focusContainer);\n }, [focusContainer]);\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 const { className, ...restOfGlobalAttributes } = useGetGlobalAttributes(propsWithDefault, {\n onClick: handleOutsideClick,\n onKeyDown: handleOnKeyDown,\n });\n\n const calculateScrollbar = useCallback(() => {\n const body = document.getElementsByTagName('body')[0];\n const { clientWidth } = body;\n setBodyInfo((prev) => ({ ...prev, scrollbarWidth: `${window.innerWidth - clientWidth}px` }));\n }, []);\n\n const debouncedCalculateScrollbar = useMemo(() => debounce(calculateScrollbar, 300), [calculateScrollbar]);\n\n useEffect(() => {\n calculateScrollbar();\n }, [calculateScrollbar]);\n\n useEffect(() => {\n window.addEventListener('resize', debouncedCalculateScrollbar);\n return () => {\n window.removeEventListener('resize', debouncedCalculateScrollbar);\n };\n }, [calculateScrollbar, debouncedCalculateScrollbar]);\n\n useEffect(() => {\n if (isOpen) {\n const body = document.getElementsByTagName('body')[0];\n const { clientHeight, scrollHeight } = body;\n const paddingRight = window.getComputedStyle(body, null)?.getPropertyValue('padding-right');\n\n setBodyInfo((prev) => ({ ...prev, overflow: scrollHeight > clientHeight, paddingRight }));\n } else setBodyInfo((prev) => ({ ...prev, overflow: false, paddingRight: '0px' }));\n }, [isOpen]);\n\n useEffect(() => {\n if (isOpen && !removeAutoFocus) containerRef?.current?.focus();\n }, [isOpen, removeAutoFocus]);\n\n if (isOpen) {\n return ReactDOM.createPortal(\n <StyledDialogBackground\n className={className}\n onClick={handleOutsideClick}\n data-portalbg\n data-testid={DSDialogDatatestid.BACKGROUND}\n zIndex={zIndex}\n >\n <FixedBody bodyInfo={bodyInfo} />\n <StyledDialogContainer\n role=\"dialog\"\n aria-modal\n ref={containerRef}\n tabIndex={!removeAutoFocus ? 0 : undefined}\n centered={centered}\n data-testid={DSDialogDatatestid.CONTAINER}\n {...getSpaceProps(rest)}\n {...restOfGlobalAttributes}\n size={size}\n >\n {children}\n </StyledDialogContainer>\n </StyledDialogBackground>,\n document.getElementsByTagName('body')[0],\n );\n }\n\n return null;\n};\n\nconst DSDialogWithSchema = describe<DSDialogT.Props>(DSDialog);\nDSDialogWithSchema.propTypes = propTypes as WeakValidationMap<unknown>;\n\nexport { DSDialog, DSDialogWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": "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",
4
+ "sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AACzC,0BAAyB;AACzB,uBAA0B;AAC1B,uBAA0B;AAC1B,4BAA+B;AAC/B,yBAAgC;AAGhC,MAAM,WAAW,CAAC,UAAwC;AACxD,QAAM,MAAM,gCAAU,KAAK;AAE3B,SACE,mDAAC,mCAAgB,UAAhB;AAAA,IAAyB,OAAO;AAAA,KAC/B,mDAAC,0CAAe,CAClB;AAEJ;AAEA,MAAM,qBAAqB,kCAAS,QAAQ;AAC5C,mBAAmB,YAAY;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,30 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var DSDialogCTX_exports = {};
22
+ __export(DSDialogCTX_exports, {
23
+ DSDialogContext: () => DSDialogContext
24
+ });
25
+ module.exports = __toCommonJS(DSDialogCTX_exports);
26
+ var React = __toESM(require("react"));
27
+ var import_react = require("react");
28
+ const defaultContext = {};
29
+ const DSDialogContext = (0, import_react.createContext)(defaultContext);
30
+ //# sourceMappingURL=DSDialogCTX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/DSDialogCTX.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { createContext } from 'react';\nimport type { DSDialogInternalsT } from './sharedTypes';\n\nconst defaultContext = {} as DSDialogInternalsT.DSDialogContext;\n\nexport const DSDialogContext = createContext<DSDialogInternalsT.DSDialogContext>(defaultContext);\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA8B;AAG9B,MAAM,iBAAiB,CAAC;AAEjB,MAAM,kBAAkB,gCAAkD,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,110 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var useDialog_exports = {};
39
+ __export(useDialog_exports, {
40
+ useDialog: () => useDialog
41
+ });
42
+ module.exports = __toCommonJS(useDialog_exports);
43
+ var React = __toESM(require("react"));
44
+ var import_react = require("react");
45
+ var import_lodash = require("lodash");
46
+ var import_uid = require("uid");
47
+ var import_ds_utilities = require("@elliemae/ds-utilities");
48
+ var import_defaultProps = require("../defaultProps");
49
+ var import_propTypes = require("../propTypes");
50
+ var import_utils = require("../utils");
51
+ const useDialog = (props) => {
52
+ (0, import_ds_utilities.useValidateTypescriptPropTypes)(props, import_propTypes.propTypes);
53
+ const propsWithDefault = (0, import_ds_utilities.useMemoMergePropsWithDefault)(props, import_defaultProps.defaultProps);
54
+ const { portalRef, isOpen } = propsWithDefault;
55
+ const actualPortalRef = (0, import_react.useRef)(null);
56
+ const containerRef = (0, import_react.useRef)(null);
57
+ const [portalInfo, setPortalInfo] = (0, import_react.useState)({
58
+ paddingRight: "0px",
59
+ scrollbarWidth: "0px"
60
+ });
61
+ const portalClassName = (0, import_react.useMemo)(() => `ds-dialog-${(0, import_uid.uid)(8)}`, []);
62
+ (0, import_react.useEffect)(() => {
63
+ if (portalRef)
64
+ actualPortalRef.current = portalRef.current;
65
+ else
66
+ actualPortalRef.current = document.getElementsByTagName("body")["0"];
67
+ }, [portalRef]);
68
+ (0, import_react.useLayoutEffect)(() => {
69
+ if (actualPortalRef.current) {
70
+ if (isOpen) {
71
+ actualPortalRef.current.classList.add(portalClassName);
72
+ } else {
73
+ actualPortalRef.current.classList.remove(portalClassName);
74
+ }
75
+ }
76
+ }, [actualPortalRef, isOpen, portalClassName]);
77
+ (0, import_react.useEffect)(() => {
78
+ if (actualPortalRef.current) {
79
+ setPortalInfo((prev) => __spreadProps(__spreadValues({}, prev), {
80
+ paddingRight: (0, import_utils.getCurrentRightPadding)(actualPortalRef.current)
81
+ }));
82
+ }
83
+ }, []);
84
+ const calculateScrollbar = (0, import_react.useCallback)(() => {
85
+ if (actualPortalRef.current && !isOpen) {
86
+ setPortalInfo((prev) => __spreadProps(__spreadValues({}, prev), {
87
+ scrollbarWidth: (0, import_utils.getScrollbarWidth)(actualPortalRef.current)
88
+ }));
89
+ }
90
+ }, [isOpen]);
91
+ const debouncedCalculateScrollbar = (0, import_react.useMemo)(() => (0, import_lodash.debounce)(calculateScrollbar, 300), [calculateScrollbar]);
92
+ (0, import_react.useEffect)(() => {
93
+ window.addEventListener("resize", debouncedCalculateScrollbar);
94
+ return () => {
95
+ window.removeEventListener("resize", debouncedCalculateScrollbar);
96
+ };
97
+ }, [calculateScrollbar, debouncedCalculateScrollbar]);
98
+ (0, import_react.useEffect)(() => {
99
+ calculateScrollbar();
100
+ }, [calculateScrollbar, isOpen]);
101
+ const ctx = (0, import_react.useMemo)(() => ({
102
+ props: propsWithDefault,
103
+ actualPortalRef,
104
+ containerRef,
105
+ portalInfo,
106
+ portalClassName
107
+ }), [portalClassName, portalInfo, propsWithDefault]);
108
+ return ctx;
109
+ };
110
+ //# sourceMappingURL=useDialog.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/config/useDialog.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA0F;AAC1F,oBAAyB;AACzB,iBAAoB;AACpB,0BAA6E;AAC7E,0BAA6B;AAC7B,uBAA0B;AAC1B,mBAA0D;AAInD,MAAM,YAAY,CAAC,UAA+D;AACvF,0DAAgD,OAAO,0BAAS;AAChE,QAAM,mBAAmB,sDAAsD,OAAO,gCAAY;AAClG,QAAM,EAAE,WAAW,WAAW;AAE9B,QAAM,kBAAkB,yBAA2B,IAAI;AACvD,QAAM,eAAe,yBAA8B,IAAI;AAEvD,QAAM,CAAC,YAAY,iBAAiB,2BAAwC;AAAA,IAC1E,cAAc;AAAA,IACd,gBAAgB;AAAA,EAClB,CAAC;AAED,QAAM,kBAAkB,0BAAQ,MAAM,aAAa,oBAAI,CAAC,KAAK,CAAC,CAAC;AAE/D,8BAAU,MAAM;AACd,QAAI;AAAW,sBAAgB,UAAU,UAAU;AAAA;AAC9C,sBAAgB,UAAU,SAAS,qBAAqB,MAAM,EAAE;AAAA,EACvE,GAAG,CAAC,SAAS,CAAC;AAEd,oCAAgB,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,8BAAU,MAAM;AACd,QAAI,gBAAgB,SAAS;AAC3B,oBAAc,CAAC,SAAU,iCACpB,OADoB;AAAA,QAEvB,cAAc,yCAAuB,gBAAgB,OAAsB;AAAA,MAC7E,EAAE;AAAA,IACJ;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,qBAAqB,8BAAY,MAAM;AAC3C,QAAI,gBAAgB,WAAW,CAAC,QAAQ;AACtC,oBAAc,CAAC,SAAU,iCACpB,OADoB;AAAA,QAEvB,gBAAgB,oCAAkB,gBAAgB,OAAsB;AAAA,MAC1E,EAAE;AAAA,IACJ;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AAEX,QAAM,8BAA8B,0BAAQ,MAAM,4BAAS,oBAAoB,GAAG,GAAG,CAAC,kBAAkB,CAAC;AAEzG,8BAAU,MAAM;AACd,WAAO,iBAAiB,UAAU,2BAA2B;AAC7D,WAAO,MAAM;AACX,aAAO,oBAAoB,UAAU,2BAA2B;AAAA,IAClE;AAAA,EACF,GAAG,CAAC,oBAAoB,2BAA2B,CAAC;AAEpD,8BAAU,MAAM;AACd,uBAAmB;AAAA,EACrB,GAAG,CAAC,oBAAoB,MAAM,CAAC;AAE/B,QAAM,MAAM,0BACV,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
+ }
@@ -34,6 +34,8 @@ const defaultProps = {
34
34
  removeAutoFocus: false,
35
35
  onClickOutside: noop,
36
36
  onClose: noop,
37
- zIndex: 10
37
+ zIndex: 10,
38
+ portalRef: null,
39
+ children: []
38
40
  };
39
41
  //# sourceMappingURL=defaultProps.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/defaultProps.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA8B;AAG9B,MAAM,OAAO,MAAM;AAAC;AAEb,MAAM,eAAuC;AAAA,EAClD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM,2BAAc;AAAA,EACpB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,QAAQ;AACV;",
4
+ "sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA8B;AAG9B,MAAM,OAAO,MAAM;AAAC;AAEb,MAAM,eAAuC;AAAA,EAClD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM,2BAAc;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
  }
@@ -0,0 +1,42 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var DSDialogPortal_exports = {};
22
+ __export(DSDialogPortal_exports, {
23
+ DSDialogPortal: () => DSDialogPortal
24
+ });
25
+ module.exports = __toCommonJS(DSDialogPortal_exports);
26
+ var React = __toESM(require("react"));
27
+ var import_react = __toESM(require("react"));
28
+ var import_react_dom = __toESM(require("react-dom"));
29
+ var import_react2 = require("react");
30
+ var import_DSDialogCTX = require("../DSDialogCTX");
31
+ var import_DSDialogContent = require("./dialogContent/DSDialogContent");
32
+ const DSDialogPortal = () => {
33
+ const {
34
+ props: { isOpen },
35
+ actualPortalRef
36
+ } = (0, import_react2.useContext)(import_DSDialogCTX.DSDialogContext);
37
+ if (isOpen && actualPortalRef.current) {
38
+ return import_react_dom.default.createPortal(/* @__PURE__ */ import_react.default.createElement(import_DSDialogContent.DSDialogContent, null), actualPortalRef.current);
39
+ }
40
+ return null;
41
+ };
42
+ //# sourceMappingURL=DSDialogPortal.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 { 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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,uBAAqB;AACrB,oBAA2B;AAC3B,yBAAgC;AAChC,6BAAgC;AAEzB,MAAM,iBAAiB,MAA0B;AACtD,QAAM;AAAA,IACJ,OAAO,EAAE;AAAA,IACT;AAAA,MACE,8BAAW,kCAAe;AAE9B,MAAI,UAAU,gBAAgB,SAAS;AACrC,WAAO,yBAAS,aAAa,mDAAC,4CAAgB,GAAI,gBAAgB,OAAO;AAAA,EAC3E;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,93 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __objRest = (source, exclude) => {
25
+ var target = {};
26
+ for (var prop in source)
27
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
+ target[prop] = source[prop];
29
+ if (source != null && __getOwnPropSymbols)
30
+ for (var prop of __getOwnPropSymbols(source)) {
31
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
+ target[prop] = source[prop];
33
+ }
34
+ return target;
35
+ };
36
+ var __export = (target, all) => {
37
+ for (var name in all)
38
+ __defProp(target, name, { get: all[name], enumerable: true });
39
+ };
40
+ var __copyProps = (to, from, except, desc) => {
41
+ if (from && typeof from === "object" || typeof from === "function") {
42
+ for (let key of __getOwnPropNames(from))
43
+ if (!__hasOwnProp.call(to, key) && key !== except)
44
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
45
+ }
46
+ return to;
47
+ };
48
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
49
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
50
+ var DSDialogContent_exports = {};
51
+ __export(DSDialogContent_exports, {
52
+ DSDialogContent: () => DSDialogContent
53
+ });
54
+ module.exports = __toCommonJS(DSDialogContent_exports);
55
+ var React = __toESM(require("react"));
56
+ var import_react = __toESM(require("react"));
57
+ var import_ds_utilities = require("@elliemae/ds-utilities");
58
+ var import_styles = require("../../styles");
59
+ var import_utils = require("../../utils");
60
+ var import_DSDialogDatatestid = require("../../DSDialogDatatestid");
61
+ var import_DSDialogCTX = require("../../DSDialogCTX");
62
+ var import_useDialogContent = require("./useDialogContent");
63
+ const DSDialogContent = () => {
64
+ const { handleOutsideClick, handleOnKeyDown } = (0, import_useDialogContent.useDialogContent)();
65
+ const { props, containerRef, portalInfo, portalClassName } = (0, import_react.useContext)(import_DSDialogCTX.DSDialogContext);
66
+ const _a = props, { removeAutoFocus, zIndex, centered, size, children } = _a, rest = __objRest(_a, ["removeAutoFocus", "zIndex", "centered", "size", "children"]);
67
+ const _b = (0, import_ds_utilities.useGetGlobalAttributes)(props, {
68
+ onClick: handleOutsideClick,
69
+ onKeyDown: handleOnKeyDown
70
+ }), { className } = _b, restOfGlobalAttributes = __objRest(_b, ["className"]);
71
+ return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledDialogBackground, {
72
+ className,
73
+ onClick: handleOutsideClick,
74
+ "data-portalbg": true,
75
+ "data-testid": import_DSDialogDatatestid.DSDialogDatatestid.BACKGROUND,
76
+ zIndex
77
+ }, /* @__PURE__ */ import_react.default.createElement(import_styles.PortalStyles, {
78
+ portalInfo,
79
+ portalClassName
80
+ }), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledDialogContainer, __spreadProps(__spreadValues(__spreadProps(__spreadValues({
81
+ role: "dialog",
82
+ "aria-modal": true,
83
+ ref: containerRef,
84
+ tabIndex: !removeAutoFocus ? 0 : void 0,
85
+ onKeyDown: handleOnKeyDown
86
+ }, (0, import_utils.getSpaceProps)(rest)), {
87
+ centered,
88
+ "data-testid": import_DSDialogDatatestid.DSDialogDatatestid.CONTAINER
89
+ }), restOfGlobalAttributes), {
90
+ size
91
+ }), children));
92
+ };
93
+ //# sourceMappingURL=DSDialogContent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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={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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkC;AAClC,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,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
+ "names": []
7
+ }
@@ -0,0 +1,62 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var useDialogContent_exports = {};
22
+ __export(useDialogContent_exports, {
23
+ useDialogContent: () => useDialogContent
24
+ });
25
+ module.exports = __toCommonJS(useDialogContent_exports);
26
+ var React = __toESM(require("react"));
27
+ var import_react = require("react");
28
+ var import_DSDialogCTX = require("../../DSDialogCTX");
29
+ const useDialogContent = () => {
30
+ const {
31
+ props: { onClickOutside, onClose, removeAutoFocus },
32
+ containerRef
33
+ } = (0, import_react.useContext)(import_DSDialogCTX.DSDialogContext);
34
+ const handleOutsideClick = (0, import_react.useCallback)((e) => {
35
+ if (e.target.dataset.portalbg)
36
+ onClickOutside();
37
+ }, [onClickOutside]);
38
+ const handleOnKeyDown = (0, import_react.useCallback)((e) => {
39
+ if (e.key === "Escape")
40
+ onClose();
41
+ }, [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
+ return {
58
+ handleOutsideClick,
59
+ handleOnKeyDown
60
+ };
61
+ };
62
+ //# sourceMappingURL=useDialogContent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/parts/dialogContent/useDialogContent.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA0D;AAC1D,yBAAgC;AAEzB,MAAM,mBAAmB,MAAM;AACpC,QAAM;AAAA,IACJ,OAAO,EAAE,gBAAgB,SAAS;AAAA,IAClC;AAAA,MACE,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,8BAAU,MAAM;AACd,QAAI,CAAC;AAAiB,oBAAc,SAAS,MAAM;AAAA,EACrD,GAAG,CAAC,cAAc,eAAe,CAAC;AAElC,QAAM,iBAAiB,8BAAY,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,8BAAU,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
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/propTypes.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* 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 }\n\n export interface PropsRequired {\n children: React.ReactNode;\n }\n\n export interface Props\n extends DefaultProps,\n PropsRequired,\n Omit<GlobalAttributesT<HTMLDivElement>, 'size' | 'children'> {\n [key: string]: unknown;\n }\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", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,0BAAwE;AACxE,mBAAwD;AA2BjD,MAAM,YAAY,iCACpB,gDADoB;AAAA,EAEvB,QAAQ,8BAAU,KAAK,YAAY,oCAAoC,EAAE,aAAa,KAAK;AAAA,EAC3F,UAAU,8BAAU,KAAK,YAAY,oBAAoB,EAAE;AAAA,EAC3D,UAAU,8BAAU,KAAK,YAAY,qBAAqB,EAAE,aAAa,KAAK;AAAA,EAC9E,iBAAiB,8BAAU,KACxB,YACC,uIACF,EACC,aAAa,KAAK;AAAA,EACrB,gBAAgB,8BAAU,KACvB,YAAY,+EAA+E,EAC3F,aAAa,MAAM;AAAA,EAAC,CAAC;AAAA,EACxB,SAAS,8BAAU,KAAK,YAAY,kCAAkC,EAAE,aAAa,MAAM;AAAA,EAAC,CAAC;AAAA,EAC7F,MAAM,8BAAU,MAAM,qCAAwB,EAC3C,YAAY,sBAAsB,EAClC,aAAa,2BAAc,OAAO;AACvC;",
4
+ "sourcesContent": ["/* 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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,0BAAwE;AACxE,mBAAwD;AAkCjD,MAAM,YAAY,iCACpB,gDADoB;AAAA,EAEvB,QAAQ,8BAAU,KAAK,YAAY,oCAAoC,EAAE,aAAa,KAAK;AAAA,EAC3F,UAAU,8BAAU,KAAK,YAAY,oBAAoB,EAAE;AAAA,EAC3D,UAAU,8BAAU,KAAK,YAAY,qBAAqB,EAAE,aAAa,KAAK;AAAA,EAC9E,iBAAiB,8BAAU,KACxB,YACC,uIACF,EACC,aAAa,KAAK;AAAA,EACrB,gBAAgB,8BAAU,KACvB,YAAY,+EAA+E,EAC3F,aAAa,MAAM;AAAA,EAAC,CAAC;AAAA,EACxB,SAAS,8BAAU,KAAK,YAAY,kCAAkC,EAAE,aAAa,MAAM;AAAA,EAAC,CAAC;AAAA,EAC7F,MAAM,8BAAU,MAAM,qCAAwB,EAC3C,YAAY,sBAAsB,EAClC,aAAa,2BAAc,OAAO;AACvC;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/sharedTypes.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export namespace DSDialogInternalsT {\n export interface BodyInfoT {\n overflow: boolean;\n scrollbarWidth: string;\n paddingRight: string;\n }\n}\n", "import * as React from 'react';\nexport { React };\n"],
4
+ "sourcesContent": ["import type { DSDialogT } from './propTypes';\nexport namespace DSDialogInternalsT {\n export interface PortalInfo {\n scrollbarWidth: string;\n paddingRight: string;\n }\n\n export interface DSDialogContext {\n props: DSDialogT.InternalProps;\n actualPortalRef: React.MutableRefObject<HTMLElement | null>;\n containerRef: React.MutableRefObject<HTMLDivElement | null>;\n portalInfo: DSDialogInternalsT.PortalInfo;\n portalClassName: string;\n }\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
6
6
  "names": []
7
7
  }