@elliemae/ds-dialog 2.4.1-rc.2 → 2.4.1-rc.6

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/esm/DSDialog.js CHANGED
@@ -1,149 +1,18 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.constructor.js';
3
- import 'core-js/modules/esnext.iterator.filter.js';
4
- import 'core-js/modules/esnext.async-iterator.for-each.js';
5
- import 'core-js/modules/esnext.iterator.for-each.js';
6
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
7
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
8
- import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
9
- import 'core-js/modules/web.dom-collections.iterator.js';
10
- import ReactDOM from 'react-dom';
11
- import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
12
- import { debounce } from 'lodash';
13
- import { describe, useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
14
- import { StyledDialogBackground, FixedBody, StyledDialogContainer } from './styles.js';
2
+ import 'react';
3
+ import { describe } from '@elliemae/ds-props-helpers';
15
4
  import { propTypes } from './propTypes.js';
16
- import { defaultProps } from './defaultProps.js';
17
- import { getSpaceProps } from './utils.js';
18
- import { DSDialogDatatestid } from './DSDialogDatatestid.js';
19
- import { jsx } from 'react/jsx-runtime';
5
+ import { useDialog } from './config/useDialog.js';
6
+ import { DSDialogPortal } from './parts/DSDialogPortal.js';
7
+ import { DSDialogContext } from './DSDialogCTX.js';
20
8
 
21
- const _excluded = ["children", "isOpen", "onClickOutside", "onClose", "centered", "size", "removeAutoFocus", "zIndex"],
22
- _excluded2 = ["className"];
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+ var _DSDialogPortal;
27
10
 
28
11
  const DSDialog = props => {
29
- var _FixedBody;
30
-
31
- const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
32
- const [bodyInfo, setBodyInfo] = useState({
33
- overflow: false,
34
- paddingRight: '0px',
35
- scrollbarWidth: '0px'
36
- });
37
- useValidateTypescriptPropTypes(propsWithDefault, propTypes);
38
-
39
- const {
40
- children,
41
- isOpen,
42
- onClickOutside,
43
- onClose,
44
- centered,
45
- size,
46
- removeAutoFocus,
47
- zIndex
48
- } = propsWithDefault,
49
- rest = _objectWithoutProperties(propsWithDefault, _excluded);
50
-
51
- const containerRef = useRef(null);
52
- const focusContainer = useCallback(() => {
53
- var _containerRef$current, _containerRef$current2, _containerRef$current3;
54
-
55
- const isContainerOrChildFocused = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.contains(document.activeElement);
56
- if (!isContainerOrChildFocused) (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : (_containerRef$current3 = _containerRef$current2.focus) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.call(_containerRef$current2);
57
- }, []);
58
- useEffect(() => {
59
- document.addEventListener('focusin', focusContainer);
60
- return () => document.removeEventListener('focusin', focusContainer);
61
- }, [focusContainer]);
62
- const handleOutsideClick = useCallback(e => {
63
- if (e.target.dataset.portalbg) onClickOutside();
64
- }, [onClickOutside]);
65
- const handleOnKeyDown = useCallback(e => {
66
- if (e.key === 'Escape') onClose();
67
- }, [onClose]);
68
-
69
- const _useGetGlobalAttribut = useGetGlobalAttributes(propsWithDefault, {
70
- onClick: handleOutsideClick,
71
- onKeyDown: handleOnKeyDown
72
- }),
73
- {
74
- className
75
- } = _useGetGlobalAttribut,
76
- restOfGlobalAttributes = _objectWithoutProperties(_useGetGlobalAttribut, _excluded2);
77
-
78
- const calculateScrollbar = useCallback(() => {
79
- const body = document.getElementsByTagName('body')[0];
80
- const {
81
- clientWidth
82
- } = body;
83
- setBodyInfo(prev => _objectSpread(_objectSpread({}, prev), {}, {
84
- scrollbarWidth: "".concat(window.innerWidth - clientWidth, "px")
85
- }));
86
- }, []);
87
- const debouncedCalculateScrollbar = useMemo(() => debounce(calculateScrollbar, 300), [calculateScrollbar]);
88
- useEffect(() => {
89
- calculateScrollbar();
90
- }, [calculateScrollbar]);
91
- useEffect(() => {
92
- window.addEventListener('resize', debouncedCalculateScrollbar);
93
- return () => {
94
- window.removeEventListener('resize', debouncedCalculateScrollbar);
95
- };
96
- }, [calculateScrollbar, debouncedCalculateScrollbar]);
97
- useEffect(() => {
98
- if (isOpen) {
99
- var _window$getComputedSt;
100
-
101
- const body = document.getElementsByTagName('body')[0];
102
- const {
103
- clientHeight,
104
- scrollHeight
105
- } = body;
106
- const paddingRight = (_window$getComputedSt = window.getComputedStyle(body, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
107
- setBodyInfo(prev => _objectSpread(_objectSpread({}, prev), {}, {
108
- overflow: scrollHeight > clientHeight,
109
- paddingRight
110
- }));
111
- } else setBodyInfo(prev => _objectSpread(_objectSpread({}, prev), {}, {
112
- overflow: false,
113
- paddingRight: '0px'
114
- }));
115
- }, [isOpen]);
116
- useEffect(() => {
117
- var _containerRef$current4;
118
-
119
- if (isOpen && !removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.focus();
120
- }, [isOpen, removeAutoFocus]);
121
-
122
- if (isOpen) {
123
- return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/_jsx(StyledDialogBackground, {
124
- className: className,
125
- onClick: handleOutsideClick,
126
- "data-portalbg": true,
127
- "data-testid": DSDialogDatatestid.BACKGROUND,
128
- zIndex: zIndex
129
- }, void 0, _FixedBody || (_FixedBody = /*#__PURE__*/_jsx(FixedBody, {
130
- bodyInfo: bodyInfo
131
- })), /*#__PURE__*/jsx(StyledDialogContainer, _objectSpread(_objectSpread(_objectSpread({
132
- role: "dialog",
133
- "aria-modal": true,
134
- ref: containerRef,
135
- tabIndex: !removeAutoFocus ? 0 : undefined
136
- }, getSpaceProps(rest)), {}, {
137
- centered: centered,
138
- "data-testid": DSDialogDatatestid.CONTAINER,
139
- onKeyDown: handleOnKeyDown
140
- }, restOfGlobalAttributes), {}, {
141
- size: size,
142
- children: children
143
- }))), document.getElementsByTagName('body')[0]);
144
- }
145
-
146
- return null;
12
+ const ctx = useDialog(props);
13
+ return /*#__PURE__*/_jsx(DSDialogContext.Provider, {
14
+ value: ctx
15
+ }, void 0, _DSDialogPortal || (_DSDialogPortal = /*#__PURE__*/_jsx(DSDialogPortal, {})));
147
16
  };
148
17
 
149
18
  const DSDialogWithSchema = describe(DSDialog);
@@ -0,0 +1,17 @@
1
+ import { createContext, createRef } from 'react';
2
+ import { defaultProps } from './defaultProps.js';
3
+
4
+ const defaultContext = {
5
+ props: defaultProps,
6
+ actualPortalRef: /*#__PURE__*/createRef(),
7
+ containerRef: /*#__PURE__*/createRef(),
8
+ portalClassName: '',
9
+ portalInfo: {
10
+ overflow: false,
11
+ paddingRight: '0px',
12
+ scrollbarWidth: '0px'
13
+ }
14
+ };
15
+ const DSDialogContext = /*#__PURE__*/createContext(defaultContext);
16
+
17
+ export { DSDialogContext };
@@ -0,0 +1,89 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import 'core-js/modules/web.dom-collections.iterator.js';
8
+ import { useRef, useState, useMemo, useEffect, useLayoutEffect, useCallback } from 'react';
9
+ import { debounce } from 'lodash';
10
+ import { uid } from 'uid';
11
+ import { useValidateTypescriptPropTypes, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
12
+ import { defaultProps } from '../defaultProps.js';
13
+ import { propTypes } from '../propTypes.js';
14
+
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
+
17
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
+ const useDialog = props => {
19
+ useValidateTypescriptPropTypes(props, propTypes);
20
+ const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
21
+ const {
22
+ portalRef,
23
+ isOpen
24
+ } = propsWithDefault;
25
+ const actualPortalRef = useRef(null);
26
+ const containerRef = useRef(null);
27
+ const [portalInfo, setPortalInfo] = useState({
28
+ paddingRight: '0px',
29
+ scrollbarWidth: '0px',
30
+ overflow: false
31
+ });
32
+ const portalClassName = useMemo(() => "ds-dialog-".concat(uid(8)), []);
33
+ useEffect(() => {
34
+ if (portalRef) actualPortalRef.current = portalRef.current;else actualPortalRef.current = document.getElementsByTagName('body')['0'];
35
+ }, [portalRef]);
36
+ useLayoutEffect(() => {
37
+ if (actualPortalRef.current) {
38
+ if (isOpen) {
39
+ actualPortalRef.current.classList.add(portalClassName);
40
+ } else {
41
+ actualPortalRef.current.classList.remove(portalClassName);
42
+ }
43
+ }
44
+ }, [actualPortalRef, isOpen, portalClassName]);
45
+ useEffect(() => {
46
+ if (actualPortalRef.current) {
47
+ var _window$getComputedSt;
48
+
49
+ const paddingRight = (_window$getComputedSt = window.getComputedStyle(actualPortalRef.current, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
50
+ setPortalInfo(prev => _objectSpread(_objectSpread({}, prev), {}, {
51
+ paddingRight
52
+ }));
53
+ }
54
+ }, []);
55
+ const calculateScrollbarAndOverflow = useCallback(() => {
56
+ if (actualPortalRef.current) {
57
+ const body = actualPortalRef.current;
58
+ const {
59
+ clientWidth,
60
+ clientHeight,
61
+ scrollHeight
62
+ } = body;
63
+ setPortalInfo(prev => _objectSpread(_objectSpread({}, prev), {}, {
64
+ scrollbarWidth: "".concat(window.innerWidth - clientWidth, "px"),
65
+ overflow: scrollHeight > clientHeight
66
+ }));
67
+ }
68
+ }, [actualPortalRef]);
69
+ const debouncedCalculateScrollbarAndOverflow = useMemo(() => debounce(calculateScrollbarAndOverflow, 300), [calculateScrollbarAndOverflow]);
70
+ useEffect(() => {
71
+ window.addEventListener('resize', debouncedCalculateScrollbarAndOverflow);
72
+ return () => {
73
+ window.removeEventListener('resize', debouncedCalculateScrollbarAndOverflow);
74
+ };
75
+ }, [calculateScrollbarAndOverflow, debouncedCalculateScrollbarAndOverflow]);
76
+ useEffect(() => {
77
+ calculateScrollbarAndOverflow();
78
+ }, [calculateScrollbarAndOverflow]);
79
+ const ctx = useMemo(() => ({
80
+ props: propsWithDefault,
81
+ actualPortalRef,
82
+ containerRef,
83
+ portalInfo,
84
+ portalClassName
85
+ }), [portalClassName, portalInfo, propsWithDefault]);
86
+ return ctx;
87
+ };
88
+
89
+ export { useDialog };
@@ -9,7 +9,9 @@ const defaultProps = {
9
9
  removeAutoFocus: false,
10
10
  onClickOutside: noop,
11
11
  onClose: noop,
12
- zIndex: 10
12
+ zIndex: 10,
13
+ portalRef: null,
14
+ children: []
13
15
  };
14
16
 
15
17
  export { defaultProps };
@@ -0,0 +1,23 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import ReactDOM from 'react-dom';
3
+ import { useContext } from 'react';
4
+ import { DSDialogContext } from '../DSDialogCTX.js';
5
+ import { DSDialogContent } from './dialogContent/DSDialogContent.js';
6
+
7
+ var _DSDialogContent;
8
+ const DSDialogPortal = () => {
9
+ const {
10
+ props: {
11
+ isOpen
12
+ },
13
+ actualPortalRef
14
+ } = useContext(DSDialogContext);
15
+
16
+ if (isOpen && actualPortalRef.current) {
17
+ return /*#__PURE__*/ReactDOM.createPortal(_DSDialogContent || (_DSDialogContent = /*#__PURE__*/_jsx(DSDialogContent, {})), actualPortalRef.current);
18
+ }
19
+
20
+ return null;
21
+ };
22
+
23
+ export { DSDialogPortal };
@@ -0,0 +1,77 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
8
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
9
+ import { useContext } from 'react';
10
+ import { useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
11
+ import { StyledDialogBackground, PortalStyles, StyledDialogContainer } from '../../styles.js';
12
+ import { getSpaceProps } from '../../utils.js';
13
+ import { DSDialogDatatestid } from '../../DSDialogDatatestid.js';
14
+ import { DSDialogContext } from '../../DSDialogCTX.js';
15
+ import { useDialogContent } from './useDialogContent.js';
16
+ import { jsx } from 'react/jsx-runtime';
17
+
18
+ const _excluded = ["removeAutoFocus", "zIndex", "centered", "size", "children"],
19
+ _excluded2 = ["className"];
20
+
21
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
+
23
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
+ const DSDialogContent = () => {
25
+ const {
26
+ handleOutsideClick,
27
+ handleOnKeyDown
28
+ } = useDialogContent();
29
+ const {
30
+ props,
31
+ containerRef,
32
+ portalInfo,
33
+ portalClassName
34
+ } = useContext(DSDialogContext);
35
+
36
+ const {
37
+ removeAutoFocus,
38
+ zIndex,
39
+ centered,
40
+ size,
41
+ children
42
+ } = props,
43
+ rest = _objectWithoutProperties(props, _excluded);
44
+
45
+ const _useGetGlobalAttribut = useGetGlobalAttributes(props, {
46
+ onClick: handleOutsideClick,
47
+ onKeyDown: handleOnKeyDown
48
+ }),
49
+ {
50
+ className
51
+ } = _useGetGlobalAttribut,
52
+ restOfGlobalAttributes = _objectWithoutProperties(_useGetGlobalAttribut, _excluded2);
53
+
54
+ return /*#__PURE__*/_jsx(StyledDialogBackground, {
55
+ className: className,
56
+ onClick: handleOutsideClick,
57
+ "data-portalbg": true,
58
+ "data-testid": DSDialogDatatestid.BACKGROUND,
59
+ zIndex: zIndex
60
+ }, void 0, /*#__PURE__*/_jsx(PortalStyles, {
61
+ portalInfo: portalInfo,
62
+ portalClassName: portalClassName
63
+ }), /*#__PURE__*/jsx(StyledDialogContainer, _objectSpread(_objectSpread(_objectSpread({
64
+ role: "dialog",
65
+ "aria-modal": true,
66
+ ref: containerRef,
67
+ tabIndex: !removeAutoFocus ? 0 : undefined
68
+ }, getSpaceProps(rest)), {}, {
69
+ centered: centered,
70
+ "data-testid": DSDialogDatatestid.CONTAINER
71
+ }, restOfGlobalAttributes), {}, {
72
+ size: size,
73
+ children: children
74
+ })));
75
+ };
76
+
77
+ export { DSDialogContent };
@@ -0,0 +1,42 @@
1
+ import { useContext, useCallback, useEffect } from 'react';
2
+ import { DSDialogContext } from '../../DSDialogCTX.js';
3
+
4
+ const useDialogContent = () => {
5
+ const {
6
+ props: {
7
+ onClickOutside,
8
+ onClose,
9
+ removeAutoFocus
10
+ },
11
+ containerRef
12
+ } = useContext(DSDialogContext);
13
+ const handleOutsideClick = useCallback(e => {
14
+ if (e.target.dataset.portalbg) onClickOutside();
15
+ }, [onClickOutside]);
16
+ const handleOnKeyDown = useCallback(e => {
17
+ if (e.key === 'Escape') onClose();
18
+ }, [onClose]);
19
+ useEffect(() => {
20
+ var _containerRef$current;
21
+
22
+ if (!removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.focus();
23
+ }, [containerRef, removeAutoFocus]);
24
+ const focusContainer = useCallback(() => {
25
+ setTimeout(() => {
26
+ var _containerRef$current2, _containerRef$current3, _containerRef$current4;
27
+
28
+ const isContainerOrChildFocused = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.contains(document.activeElement);
29
+ if (!isContainerOrChildFocused) (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : (_containerRef$current4 = _containerRef$current3.focus) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.call(_containerRef$current3);
30
+ });
31
+ }, [containerRef]);
32
+ useEffect(() => {
33
+ document.addEventListener('focusin', focusContainer);
34
+ return () => document.removeEventListener('focusin', focusContainer);
35
+ }, [focusContainer]);
36
+ return {
37
+ handleOutsideClick,
38
+ handleOnKeyDown
39
+ };
40
+ };
41
+
42
+ export { useDialogContent };
package/esm/styles.js CHANGED
@@ -5,49 +5,54 @@ import { space, sizing, layout, flexboxes } from '@xstyled/styled-components';
5
5
  import { allSizes } from './utils.js';
6
6
 
7
7
  var _templateObject;
8
- const FixedBody = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n body {\n overflow: hidden;\n ", "\n }\n"])), _ref => {
8
+ const PortalStyles = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", " {\n overflow: hidden;\n ", "\n }\n"])), _ref => {
9
9
  let {
10
- bodyInfo
10
+ portalClassName
11
11
  } = _ref;
12
- return bodyInfo.overflow ? "padding-right: calc( ".concat(bodyInfo.paddingRight, " + ").concat(bodyInfo.scrollbarWidth, " ) !important;") : "";
12
+ return ".".concat(portalClassName);
13
+ }, _ref2 => {
14
+ let {
15
+ portalInfo
16
+ } = _ref2;
17
+ return portalInfo.overflow ? "padding-right: calc( ".concat(portalInfo.paddingRight, " + ").concat(portalInfo.scrollbarWidth, " ) !important;") : "";
13
18
  });
14
19
  const StyledDialogBackground = /*#__PURE__*/styled.div.withConfig({
15
20
  componentId: "sc-106vqwv-0"
16
- })(["position:fixed;top:0;bottom:0;left:0;width:100%;height:100%;background:rgba(37,41,47,50%);overflow-y:auto;z-index:", ";"], _ref2 => {
21
+ })(["position:absolute;top:0;bottom:0;left:0;width:100%;height:100%;background:rgba(37,41,47,50%);overflow-y:auto;z-index:", ";"], _ref3 => {
17
22
  let {
18
23
  zIndex
19
- } = _ref2;
24
+ } = _ref3;
20
25
  return zIndex;
21
26
  });
22
27
  const StyledDialogContainer = /*#__PURE__*/styled.div.withConfig({
23
28
  componentId: "sc-106vqwv-1"
24
- })(["height:fit-content;position:absolute;top:0;bottom:0;left:0;right:0;margin:", ";width:", ";min-width:300px;box-shadow:0 10px 20px 0 ", ";background:", ";overflow-y:auto;", " &:focus{outline:none;}"], _ref3 => {
29
+ })(["height:fit-content;position:absolute;top:0;bottom:0;left:0;right:0;margin:", ";width:", ";min-width:300px;box-shadow:0 10px 20px 0 ", ";background:", ";overflow-y:auto;", " &:focus{outline:none;}"], _ref4 => {
25
30
  let {
26
31
  centered
27
- } = _ref3;
32
+ } = _ref4;
28
33
  return centered ? 'auto' : '20vh auto auto auto';
29
- }, _ref4 => {
34
+ }, _ref5 => {
30
35
  let {
31
36
  size
32
- } = _ref4;
37
+ } = _ref5;
33
38
  return allSizes[size];
34
- }, _ref5 => {
39
+ }, _ref6 => {
35
40
  let {
36
41
  theme
37
- } = _ref5;
42
+ } = _ref6;
38
43
  return theme.colors.neutral[500];
39
- }, _ref6 => {
44
+ }, _ref7 => {
40
45
  let {
41
46
  theme
42
- } = _ref6;
47
+ } = _ref7;
43
48
  return theme.colors.neutral['000'];
44
49
  }, space);
45
50
  const DSDialogTitle = /*#__PURE__*/styled.h3.withConfig({
46
51
  componentId: "sc-106vqwv-2"
47
- })(["font-size:", ";display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:28px;margin:0;"], _ref7 => {
52
+ })(["font-size:", ";display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:28px;margin:0;"], _ref8 => {
48
53
  let {
49
54
  theme
50
- } = _ref7;
55
+ } = _ref8;
51
56
  return theme.fontSizes.title[700];
52
57
  });
53
58
  const DSDialogAddon = /*#__PURE__*/styled.div.withConfig({
@@ -55,33 +60,33 @@ const DSDialogAddon = /*#__PURE__*/styled.div.withConfig({
55
60
  })([""]);
56
61
  const DSDialogHeader = /*#__PURE__*/styled.div.withConfig({
57
62
  componentId: "sc-106vqwv-4"
58
- })(["display:grid;align-items:center;grid-auto-flow:column;min-height:", ";padding:10px ", ";& ", " + ", "{align-self:flex-start;justify-self:flex-end;}& ", ":only-child{justify-self:flex-end;}", " ", ""], _ref8 => {
63
+ })(["display:grid;align-items:center;grid-auto-flow:column;min-height:", ";padding:10px ", ";& ", " + ", "{align-self:flex-start;justify-self:flex-end;}& ", ":only-child{justify-self:flex-end;}", " ", ""], _ref9 => {
59
64
  let {
60
65
  theme
61
- } = _ref8;
66
+ } = _ref9;
62
67
  return theme.space.m;
63
- }, _ref9 => {
68
+ }, _ref10 => {
64
69
  let {
65
70
  theme
66
- } = _ref9;
71
+ } = _ref10;
67
72
  return theme.space.xs;
68
73
  }, DSDialogTitle, DSDialogAddon, DSDialogAddon, space, sizing);
69
74
  const DSDialogSeparator = /*#__PURE__*/styled.hr.attrs(() => ({
70
75
  'aria-hidden': true
71
76
  })).withConfig({
72
77
  componentId: "sc-106vqwv-5"
73
- })(["margin:0;border-top:1px solid ", ";"], _ref10 => {
78
+ })(["margin:0;border-top:1px solid ", ";"], _ref11 => {
74
79
  let {
75
80
  theme
76
- } = _ref10;
81
+ } = _ref11;
77
82
  return theme.colors.neutral['080'];
78
83
  });
79
84
  const DSDialogBody = /*#__PURE__*/styled.div.withConfig({
80
85
  componentId: "sc-106vqwv-6"
81
- })(["padding:", ";overflow-y:auto;", " ", " ", " ", ""], _ref11 => {
86
+ })(["padding:", ";overflow-y:auto;", " ", " ", " ", ""], _ref12 => {
82
87
  let {
83
88
  theme
84
- } = _ref11;
89
+ } = _ref12;
85
90
  return theme.space.xs;
86
91
  }, layout, space, flexboxes, sizing);
87
92
  const DSDialogPrimaryMessage = /*#__PURE__*/styled.h3.withConfig({
@@ -89,37 +94,37 @@ const DSDialogPrimaryMessage = /*#__PURE__*/styled.h3.withConfig({
89
94
  })(["margin:0;"]);
90
95
  const DSDialogSecondaryMessage = /*#__PURE__*/styled.p.withConfig({
91
96
  componentId: "sc-106vqwv-8"
92
- })(["margin:0;color:", ";"], _ref12 => {
97
+ })(["margin:0;color:", ";"], _ref13 => {
93
98
  let {
94
99
  theme
95
- } = _ref12;
100
+ } = _ref13;
96
101
  return theme.colors.neutral[500];
97
102
  });
98
103
  const DSDialogDefaultLayout = /*#__PURE__*/styled.div.withConfig({
99
104
  componentId: "sc-106vqwv-9"
100
- })(["display:grid;grid-auto-flow:row;justify-items:center;align-items:center;grid-gap:", ";", "{text-align:center;}"], _ref13 => {
105
+ })(["display:grid;grid-auto-flow:row;justify-items:center;align-items:center;grid-gap:", ";", "{text-align:center;}"], _ref14 => {
101
106
  let {
102
107
  theme
103
- } = _ref13;
108
+ } = _ref14;
104
109
  return theme.space.xxs;
105
110
  }, DSDialogSecondaryMessage);
106
111
  const DSDialogFooter = /*#__PURE__*/styled.div.withConfig({
107
112
  componentId: "sc-106vqwv-10"
108
- })(["display:grid;grid-auto-flow:column;align-items:center;justify-content:flex-end;grid-gap:", ";min-height:", ";padding:0 ", ";", " ", " ", ""], _ref14 => {
113
+ })(["display:grid;grid-auto-flow:column;align-items:center;justify-content:flex-end;grid-gap:", ";min-height:", ";padding:0 ", ";", " ", " ", ""], _ref15 => {
109
114
  let {
110
115
  theme
111
- } = _ref14;
116
+ } = _ref15;
112
117
  return theme.space.xxs;
113
- }, _ref15 => {
118
+ }, _ref16 => {
114
119
  let {
115
120
  theme
116
- } = _ref15;
121
+ } = _ref16;
117
122
  return theme.space.m;
118
- }, _ref16 => {
123
+ }, _ref17 => {
119
124
  let {
120
125
  theme
121
- } = _ref16;
126
+ } = _ref17;
122
127
  return theme.space.xs;
123
128
  }, space, flexboxes, sizing);
124
129
 
125
- export { DSDialogAddon, DSDialogBody, DSDialogDefaultLayout, DSDialogFooter, DSDialogHeader, DSDialogPrimaryMessage, DSDialogSecondaryMessage, DSDialogSeparator, DSDialogTitle, FixedBody, StyledDialogBackground, StyledDialogContainer };
130
+ export { DSDialogAddon, DSDialogBody, DSDialogDefaultLayout, DSDialogFooter, DSDialogHeader, DSDialogPrimaryMessage, DSDialogSecondaryMessage, DSDialogSeparator, DSDialogTitle, PortalStyles, StyledDialogBackground, StyledDialogContainer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-dialog",
3
- "version": "2.4.1-rc.2",
3
+ "version": "2.4.1-rc.6",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Dialog",
6
6
  "module": "./esm/index.js",
@@ -27,10 +27,26 @@
27
27
  "import": "./esm/propTypes.js",
28
28
  "require": "./cjs/propTypes.js"
29
29
  },
30
+ "./parts/DSDialogPortal": {
31
+ "import": "./esm/parts/DSDialogPortal.js",
32
+ "require": "./cjs/parts/DSDialogPortal.js"
33
+ },
34
+ "./parts/dialogContent/useDialogContent": {
35
+ "import": "./esm/parts/dialogContent/useDialogContent.js",
36
+ "require": "./cjs/parts/dialogContent/useDialogContent.js"
37
+ },
38
+ "./parts/dialogContent/DSDialogContent": {
39
+ "import": "./esm/parts/dialogContent/DSDialogContent.js",
40
+ "require": "./cjs/parts/dialogContent/DSDialogContent.js"
41
+ },
30
42
  "./DSDialogDatatestid": {
31
43
  "import": "./esm/DSDialogDatatestid.js",
32
44
  "require": "./cjs/DSDialogDatatestid.js"
33
45
  },
46
+ "./DSDialogCTX": {
47
+ "import": "./esm/DSDialogCTX.js",
48
+ "require": "./cjs/DSDialogCTX.js"
49
+ },
34
50
  "./DSDialog": {
35
51
  "import": "./esm/DSDialog.js",
36
52
  "require": "./cjs/DSDialog.js"
@@ -38,6 +54,10 @@
38
54
  "./defaultProps": {
39
55
  "import": "./esm/defaultProps.js",
40
56
  "require": "./cjs/defaultProps.js"
57
+ },
58
+ "./config/useDialog": {
59
+ "import": "./esm/config/useDialog.js",
60
+ "require": "./cjs/config/useDialog.js"
41
61
  }
42
62
  },
43
63
  "sideEffects": [
@@ -60,10 +80,10 @@
60
80
  "build": "node ../../scripts/build/build.js"
61
81
  },
62
82
  "dependencies": {
63
- "@elliemae/ds-button": "2.4.1-rc.2",
64
- "@elliemae/ds-icons": "2.4.1-rc.2",
65
- "@elliemae/ds-props-helpers": "2.4.1-rc.2",
66
- "@elliemae/ds-system": "2.4.1-rc.2",
83
+ "@elliemae/ds-button": "2.4.1-rc.6",
84
+ "@elliemae/ds-icons": "2.4.1-rc.6",
85
+ "@elliemae/ds-props-helpers": "2.4.1-rc.6",
86
+ "@elliemae/ds-system": "2.4.1-rc.6",
67
87
  "react-desc": "~4.1.3"
68
88
  },
69
89
  "devDependencies": {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type { DSDialogT } from './propTypes';
3
- declare const DSDialog: (props: DSDialogT.Props) => JSX.Element | null;
3
+ declare const DSDialog: (props: DSDialogT.Props) => JSX.Element;
4
4
  declare const DSDialogWithSchema: import("@elliemae/ds-props-helpers/types/propTypes/types").DocumentedReactComponent<DSDialogT.Props>;
5
5
  export { DSDialog, DSDialogWithSchema };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { DSDialogInternalsT } from './sharedTypes';
3
+ export declare const DSDialogContext: import("react").Context<DSDialogInternalsT.DSDialogContext>;
@@ -0,0 +1,3 @@
1
+ import type { DSDialogT } from '../propTypes';
2
+ import type { DSDialogInternalsT } from '../sharedTypes';
3
+ export declare const useDialog: (props: DSDialogT.Props) => DSDialogInternalsT.DSDialogContext;