@elliemae/ds-dialog 2.4.2-rc.12 → 2.4.2-rc.15
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/cjs/config/useDialog.js +2 -3
- package/cjs/parts/dialogContent/useDialogContent.js +3 -7
- package/cjs/propTypes.js +1 -1
- package/cjs/styles.js +11 -8
- package/cjs/utils.js +2 -7
- package/esm/config/useDialog.js +1 -2
- package/esm/parts/dialogContent/useDialogContent.js +3 -7
- package/esm/propTypes.js +1 -1
- package/esm/styles.js +11 -7
- package/esm/utils.js +2 -7
- package/package.json +5 -5
package/cjs/config/useDialog.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
5
|
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
8
6
|
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
7
|
require('core-js/modules/esnext.iterator.filter.js');
|
|
10
8
|
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
9
|
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
12
11
|
var react = require('react');
|
|
13
12
|
var lodash = require('lodash');
|
|
14
13
|
var uid = require('uid');
|
|
@@ -37,7 +36,7 @@ const useDialog = props => {
|
|
|
37
36
|
paddingRight: '0px',
|
|
38
37
|
scrollbarWidth: '0px'
|
|
39
38
|
});
|
|
40
|
-
const portalClassName = react.useMemo(() =>
|
|
39
|
+
const portalClassName = react.useMemo(() => `ds-dialog-${uid.uid(8)}`, []);
|
|
41
40
|
react.useEffect(() => {
|
|
42
41
|
if (portalRef) actualPortalRef.current = portalRef.current;else actualPortalRef.current = document.getElementsByTagName('body')['0'];
|
|
43
42
|
}, [portalRef]);
|
|
@@ -21,16 +21,12 @@ const useDialogContent = () => {
|
|
|
21
21
|
if (e.key === 'Escape') onClose();
|
|
22
22
|
}, [onClose]);
|
|
23
23
|
react.useEffect(() => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.focus();
|
|
24
|
+
if (!removeAutoFocus) containerRef?.current?.focus();
|
|
27
25
|
}, [containerRef, removeAutoFocus]);
|
|
28
26
|
const focusContainer = react.useCallback(() => {
|
|
29
27
|
setTimeout(() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const isContainerOrChildFocused = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.contains(document.activeElement);
|
|
33
|
-
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);
|
|
28
|
+
const isContainerOrChildFocused = containerRef.current?.contains(document.activeElement);
|
|
29
|
+
if (!isContainerOrChildFocused) containerRef.current?.focus?.();
|
|
34
30
|
});
|
|
35
31
|
}, [containerRef]);
|
|
36
32
|
react.useEffect(() => {
|
package/cjs/propTypes.js
CHANGED
|
@@ -25,7 +25,7 @@ const propTypes = _objectSpread(_objectSpread({}, dsPropsHelpers.globalAttribute
|
|
|
25
25
|
removeAutoFocus: dsPropsHelpers.PropTypes.bool.description('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.').defaultValue(false),
|
|
26
26
|
onClickOutside: dsPropsHelpers.PropTypes.func.description('Callback that should be used to close the modal when the user clicks outside.').defaultValue(() => {}),
|
|
27
27
|
onClose: dsPropsHelpers.PropTypes.func.description('Callback triggered with ESC key.').defaultValue(() => {}),
|
|
28
|
-
size: dsPropsHelpers.PropTypes.oneOf(utils.DSDialogSizesArrayValues).description(
|
|
28
|
+
size: dsPropsHelpers.PropTypes.oneOf(utils.DSDialogSizesArrayValues).description(`Dialog's width size.`).defaultValue(utils.DSDialogSizes.DEFAULT)
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
exports.propTypes = propTypes;
|
package/cjs/styles.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
5
|
var styled = require('styled-components');
|
|
7
6
|
var dsSystem = require('@elliemae/ds-system');
|
|
8
7
|
var styledComponents = require('@xstyled/styled-components');
|
|
@@ -10,21 +9,25 @@ var utils = require('./utils.js');
|
|
|
10
9
|
|
|
11
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
11
|
|
|
13
|
-
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
14
12
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
const PortalStyles = dsSystem.createGlobalStyle
|
|
14
|
+
/* eslint-disable max-lines */
|
|
15
|
+
const PortalStyles = dsSystem.createGlobalStyle`
|
|
16
|
+
${_ref => {
|
|
18
17
|
let {
|
|
19
18
|
portalClassName
|
|
20
19
|
} = _ref;
|
|
21
|
-
return
|
|
22
|
-
}
|
|
20
|
+
return `.${portalClassName}`;
|
|
21
|
+
}} {
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
${_ref2 => {
|
|
23
24
|
let {
|
|
24
25
|
portalInfo
|
|
25
26
|
} = _ref2;
|
|
26
|
-
return portalInfo.scrollbarWidth !== '0px' ?
|
|
27
|
-
}
|
|
27
|
+
return portalInfo.scrollbarWidth !== '0px' ? `padding-right: calc( ${portalInfo.paddingRight} + ${portalInfo.scrollbarWidth} ) !important;` : ``;
|
|
28
|
+
}}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
28
31
|
const StyledDialogBackground = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
29
32
|
componentId: "sc-106vqwv-0"
|
|
30
33
|
})(["position:absolute;top:0;bottom:0;left:0;width:100%;height:100%;background:rgba(37,41,47,50%);overflow-y:auto;z-index:", ";"], _ref3 => {
|
package/cjs/utils.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
6
|
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
7
|
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
8
|
|
|
10
9
|
const getSpaceProps = props => Object.fromEntries(Object.entries(props).filter(_ref => {
|
|
11
10
|
let [key] = _ref;
|
|
@@ -28,12 +27,8 @@ const allSizes = {
|
|
|
28
27
|
'x-large': '1042px',
|
|
29
28
|
'xx-large': '1440px'
|
|
30
29
|
};
|
|
31
|
-
const getScrollbarWidth = element => element.tagName === 'BODY' ?
|
|
32
|
-
const getCurrentRightPadding = element =>
|
|
33
|
-
var _window$getComputedSt;
|
|
34
|
-
|
|
35
|
-
return (_window$getComputedSt = window.getComputedStyle(element, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
|
|
36
|
-
};
|
|
30
|
+
const getScrollbarWidth = element => element.tagName === 'BODY' ? `${window.innerWidth - element.clientWidth}px` : `${element.offsetWidth - element.clientWidth}px`;
|
|
31
|
+
const getCurrentRightPadding = element => window.getComputedStyle(element, null)?.getPropertyValue('padding-right');
|
|
37
32
|
|
|
38
33
|
exports.DSDialogSizes = DSDialogSizes;
|
|
39
34
|
exports.DSDialogSizesArrayValues = DSDialogSizesArrayValues;
|
package/esm/config/useDialog.js
CHANGED
|
@@ -4,7 +4,6 @@ import 'core-js/modules/esnext.iterator.filter.js';
|
|
|
4
4
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
7
|
import { useRef, useState, useMemo, useEffect, useLayoutEffect, useCallback } from 'react';
|
|
9
8
|
import { debounce } from 'lodash';
|
|
10
9
|
import { uid } from 'uid';
|
|
@@ -29,7 +28,7 @@ const useDialog = props => {
|
|
|
29
28
|
paddingRight: '0px',
|
|
30
29
|
scrollbarWidth: '0px'
|
|
31
30
|
});
|
|
32
|
-
const portalClassName = useMemo(() =>
|
|
31
|
+
const portalClassName = useMemo(() => `ds-dialog-${uid(8)}`, []);
|
|
33
32
|
useEffect(() => {
|
|
34
33
|
if (portalRef) actualPortalRef.current = portalRef.current;else actualPortalRef.current = document.getElementsByTagName('body')['0'];
|
|
35
34
|
}, [portalRef]);
|
|
@@ -17,16 +17,12 @@ const useDialogContent = () => {
|
|
|
17
17
|
if (e.key === 'Escape') onClose();
|
|
18
18
|
}, [onClose]);
|
|
19
19
|
useEffect(() => {
|
|
20
|
-
|
|
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();
|
|
20
|
+
if (!removeAutoFocus) containerRef?.current?.focus();
|
|
23
21
|
}, [containerRef, removeAutoFocus]);
|
|
24
22
|
const focusContainer = useCallback(() => {
|
|
25
23
|
setTimeout(() => {
|
|
26
|
-
|
|
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);
|
|
24
|
+
const isContainerOrChildFocused = containerRef.current?.contains(document.activeElement);
|
|
25
|
+
if (!isContainerOrChildFocused) containerRef.current?.focus?.();
|
|
30
26
|
});
|
|
31
27
|
}, [containerRef]);
|
|
32
28
|
useEffect(() => {
|
package/esm/propTypes.js
CHANGED
|
@@ -17,7 +17,7 @@ const propTypes = _objectSpread(_objectSpread({}, globalAttributesPropTypes), {}
|
|
|
17
17
|
removeAutoFocus: PropTypes.bool.description('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.').defaultValue(false),
|
|
18
18
|
onClickOutside: PropTypes.func.description('Callback that should be used to close the modal when the user clicks outside.').defaultValue(() => {}),
|
|
19
19
|
onClose: PropTypes.func.description('Callback triggered with ESC key.').defaultValue(() => {}),
|
|
20
|
-
size: PropTypes.oneOf(DSDialogSizesArrayValues).description(
|
|
20
|
+
size: PropTypes.oneOf(DSDialogSizesArrayValues).description(`Dialog's width size.`).defaultValue(DSDialogSizes.DEFAULT)
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
export { propTypes };
|
package/esm/styles.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
1
|
import styled from 'styled-components';
|
|
3
2
|
import { createGlobalStyle } from '@elliemae/ds-system';
|
|
4
3
|
import { space, sizing, layout, flexboxes } from '@xstyled/styled-components';
|
|
5
4
|
import { allSizes } from './utils.js';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
const PortalStyles = createGlobalStyle
|
|
6
|
+
/* eslint-disable max-lines */
|
|
7
|
+
const PortalStyles = createGlobalStyle`
|
|
8
|
+
${_ref => {
|
|
9
9
|
let {
|
|
10
10
|
portalClassName
|
|
11
11
|
} = _ref;
|
|
12
|
-
return
|
|
13
|
-
}
|
|
12
|
+
return `.${portalClassName}`;
|
|
13
|
+
}} {
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
${_ref2 => {
|
|
14
16
|
let {
|
|
15
17
|
portalInfo
|
|
16
18
|
} = _ref2;
|
|
17
|
-
return portalInfo.scrollbarWidth !== '0px' ?
|
|
18
|
-
}
|
|
19
|
+
return portalInfo.scrollbarWidth !== '0px' ? `padding-right: calc( ${portalInfo.paddingRight} + ${portalInfo.scrollbarWidth} ) !important;` : ``;
|
|
20
|
+
}}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
19
23
|
const StyledDialogBackground = /*#__PURE__*/styled.div.withConfig({
|
|
20
24
|
componentId: "sc-106vqwv-0"
|
|
21
25
|
})(["position:absolute;top:0;bottom:0;left:0;width:100%;height:100%;background:rgba(37,41,47,50%);overflow-y:auto;z-index:", ";"], _ref3 => {
|
package/esm/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
2
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
3
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
4
|
|
|
6
5
|
const getSpaceProps = props => Object.fromEntries(Object.entries(props).filter(_ref => {
|
|
7
6
|
let [key] = _ref;
|
|
@@ -24,11 +23,7 @@ const allSizes = {
|
|
|
24
23
|
'x-large': '1042px',
|
|
25
24
|
'xx-large': '1440px'
|
|
26
25
|
};
|
|
27
|
-
const getScrollbarWidth = element => element.tagName === 'BODY' ?
|
|
28
|
-
const getCurrentRightPadding = element =>
|
|
29
|
-
var _window$getComputedSt;
|
|
30
|
-
|
|
31
|
-
return (_window$getComputedSt = window.getComputedStyle(element, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
|
|
32
|
-
};
|
|
26
|
+
const getScrollbarWidth = element => element.tagName === 'BODY' ? `${window.innerWidth - element.clientWidth}px` : `${element.offsetWidth - element.clientWidth}px`;
|
|
27
|
+
const getCurrentRightPadding = element => window.getComputedStyle(element, null)?.getPropertyValue('padding-right');
|
|
33
28
|
|
|
34
29
|
export { DSDialogSizes, DSDialogSizesArrayValues, allSizes, getCurrentRightPadding, getScrollbarWidth, getSpaceProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-dialog",
|
|
3
|
-
"version": "2.4.2-rc.
|
|
3
|
+
"version": "2.4.2-rc.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Dialog",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -80,10 +80,10 @@
|
|
|
80
80
|
"build": "node ../../scripts/build/build.js"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@elliemae/ds-button": "2.4.2-rc.
|
|
84
|
-
"@elliemae/ds-icons": "2.4.2-rc.
|
|
85
|
-
"@elliemae/ds-props-helpers": "2.4.2-rc.
|
|
86
|
-
"@elliemae/ds-system": "2.4.2-rc.
|
|
83
|
+
"@elliemae/ds-button": "2.4.2-rc.15",
|
|
84
|
+
"@elliemae/ds-icons": "2.4.2-rc.15",
|
|
85
|
+
"@elliemae/ds-props-helpers": "2.4.2-rc.15",
|
|
86
|
+
"@elliemae/ds-system": "2.4.2-rc.15",
|
|
87
87
|
"react-desc": "~4.1.3"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|