@elliemae/ds-dialog 2.4.2-rc.3 → 2.4.2-rc.9
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/DSDialogCTX.js +1 -12
- package/cjs/config/useDialog.js +13 -23
- package/cjs/styles.js +1 -1
- package/cjs/utils.js +8 -0
- package/esm/DSDialogCTX.js +2 -13
- package/esm/config/useDialog.js +15 -25
- package/esm/styles.js +1 -1
- package/esm/utils.js +7 -1
- package/package.json +5 -5
- package/types/sharedTypes.d.ts +0 -1
- package/types/utils.d.ts +2 -0
package/cjs/DSDialogCTX.js
CHANGED
|
@@ -3,19 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var react = require('react');
|
|
6
|
-
var defaultProps = require('./defaultProps.js');
|
|
7
6
|
|
|
8
|
-
const defaultContext = {
|
|
9
|
-
props: defaultProps.defaultProps,
|
|
10
|
-
actualPortalRef: /*#__PURE__*/react.createRef(),
|
|
11
|
-
containerRef: /*#__PURE__*/react.createRef(),
|
|
12
|
-
portalClassName: '',
|
|
13
|
-
portalInfo: {
|
|
14
|
-
overflow: false,
|
|
15
|
-
paddingRight: '0px',
|
|
16
|
-
scrollbarWidth: '0px'
|
|
17
|
-
}
|
|
18
|
-
};
|
|
7
|
+
const defaultContext = {};
|
|
19
8
|
const DSDialogContext = /*#__PURE__*/react.createContext(defaultContext);
|
|
20
9
|
|
|
21
10
|
exports.DSDialogContext = DSDialogContext;
|
package/cjs/config/useDialog.js
CHANGED
|
@@ -15,6 +15,7 @@ var uid = require('uid');
|
|
|
15
15
|
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
16
16
|
var defaultProps = require('../defaultProps.js');
|
|
17
17
|
var propTypes = require('../propTypes.js');
|
|
18
|
+
var utils = require('../utils.js');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
21
|
|
|
@@ -34,8 +35,7 @@ const useDialog = props => {
|
|
|
34
35
|
const containerRef = react.useRef(null);
|
|
35
36
|
const [portalInfo, setPortalInfo] = react.useState({
|
|
36
37
|
paddingRight: '0px',
|
|
37
|
-
scrollbarWidth: '0px'
|
|
38
|
-
overflow: false
|
|
38
|
+
scrollbarWidth: '0px'
|
|
39
39
|
});
|
|
40
40
|
const portalClassName = react.useMemo(() => "ds-dialog-".concat(uid.uid(8)), []);
|
|
41
41
|
react.useEffect(() => {
|
|
@@ -52,38 +52,28 @@ const useDialog = props => {
|
|
|
52
52
|
}, [actualPortalRef, isOpen, portalClassName]);
|
|
53
53
|
react.useEffect(() => {
|
|
54
54
|
if (actualPortalRef.current) {
|
|
55
|
-
var _window$getComputedSt;
|
|
56
|
-
|
|
57
|
-
const paddingRight = (_window$getComputedSt = window.getComputedStyle(actualPortalRef.current, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
|
|
58
55
|
setPortalInfo(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
59
|
-
paddingRight
|
|
56
|
+
paddingRight: utils.getCurrentRightPadding(actualPortalRef.current)
|
|
60
57
|
}));
|
|
61
58
|
}
|
|
62
59
|
}, []);
|
|
63
|
-
const
|
|
64
|
-
if (actualPortalRef.current) {
|
|
65
|
-
const body = actualPortalRef.current;
|
|
66
|
-
const {
|
|
67
|
-
clientWidth,
|
|
68
|
-
clientHeight,
|
|
69
|
-
scrollHeight
|
|
70
|
-
} = body;
|
|
60
|
+
const calculateScrollbar = react.useCallback(() => {
|
|
61
|
+
if (actualPortalRef.current && !isOpen) {
|
|
71
62
|
setPortalInfo(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
72
|
-
scrollbarWidth:
|
|
73
|
-
overflow: scrollHeight > clientHeight
|
|
63
|
+
scrollbarWidth: utils.getScrollbarWidth(actualPortalRef.current)
|
|
74
64
|
}));
|
|
75
65
|
}
|
|
76
|
-
}, [
|
|
77
|
-
const
|
|
66
|
+
}, [isOpen]);
|
|
67
|
+
const debouncedCalculateScrollbar = react.useMemo(() => lodash.debounce(calculateScrollbar, 300), [calculateScrollbar]);
|
|
78
68
|
react.useEffect(() => {
|
|
79
|
-
window.addEventListener('resize',
|
|
69
|
+
window.addEventListener('resize', debouncedCalculateScrollbar);
|
|
80
70
|
return () => {
|
|
81
|
-
window.removeEventListener('resize',
|
|
71
|
+
window.removeEventListener('resize', debouncedCalculateScrollbar);
|
|
82
72
|
};
|
|
83
|
-
}, [
|
|
73
|
+
}, [calculateScrollbar, debouncedCalculateScrollbar]);
|
|
84
74
|
react.useEffect(() => {
|
|
85
|
-
|
|
86
|
-
}, [
|
|
75
|
+
calculateScrollbar();
|
|
76
|
+
}, [calculateScrollbar, isOpen]);
|
|
87
77
|
const ctx = react.useMemo(() => ({
|
|
88
78
|
props: propsWithDefault,
|
|
89
79
|
actualPortalRef,
|
package/cjs/styles.js
CHANGED
|
@@ -23,7 +23,7 @@ const PortalStyles = dsSystem.createGlobalStyle(_templateObject || (_templateObj
|
|
|
23
23
|
let {
|
|
24
24
|
portalInfo
|
|
25
25
|
} = _ref2;
|
|
26
|
-
return portalInfo.
|
|
26
|
+
return portalInfo.scrollbarWidth !== '0px' ? "padding-right: calc( ".concat(portalInfo.paddingRight, " + ").concat(portalInfo.scrollbarWidth, " ) !important;") : "";
|
|
27
27
|
});
|
|
28
28
|
const StyledDialogBackground = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
29
29
|
componentId: "sc-106vqwv-0"
|
package/cjs/utils.js
CHANGED
|
@@ -28,8 +28,16 @@ const allSizes = {
|
|
|
28
28
|
'x-large': '1042px',
|
|
29
29
|
'xx-large': '1440px'
|
|
30
30
|
};
|
|
31
|
+
const getScrollbarWidth = element => element.tagName === 'BODY' ? "".concat(window.innerWidth - element.clientWidth, "px") : "".concat(element.offsetWidth - element.clientWidth, "px");
|
|
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
|
+
};
|
|
31
37
|
|
|
32
38
|
exports.DSDialogSizes = DSDialogSizes;
|
|
33
39
|
exports.DSDialogSizesArrayValues = DSDialogSizesArrayValues;
|
|
34
40
|
exports.allSizes = allSizes;
|
|
41
|
+
exports.getCurrentRightPadding = getCurrentRightPadding;
|
|
42
|
+
exports.getScrollbarWidth = getScrollbarWidth;
|
|
35
43
|
exports.getSpaceProps = getSpaceProps;
|
package/esm/DSDialogCTX.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import { createContext
|
|
2
|
-
import { defaultProps } from './defaultProps.js';
|
|
1
|
+
import { createContext } from 'react';
|
|
3
2
|
|
|
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
|
-
};
|
|
3
|
+
const defaultContext = {};
|
|
15
4
|
const DSDialogContext = /*#__PURE__*/createContext(defaultContext);
|
|
16
5
|
|
|
17
6
|
export { DSDialogContext };
|
package/esm/config/useDialog.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
1
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
4
2
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
3
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
6
4
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
7
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
8
|
import { useRef, useState, useMemo, useEffect, useLayoutEffect, useCallback } from 'react';
|
|
9
9
|
import { debounce } from 'lodash';
|
|
10
10
|
import { uid } from 'uid';
|
|
11
11
|
import { useValidateTypescriptPropTypes, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
12
12
|
import { defaultProps } from '../defaultProps.js';
|
|
13
13
|
import { propTypes } from '../propTypes.js';
|
|
14
|
+
import { getCurrentRightPadding, getScrollbarWidth } from '../utils.js';
|
|
14
15
|
|
|
15
16
|
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
|
|
|
@@ -26,8 +27,7 @@ const useDialog = props => {
|
|
|
26
27
|
const containerRef = useRef(null);
|
|
27
28
|
const [portalInfo, setPortalInfo] = useState({
|
|
28
29
|
paddingRight: '0px',
|
|
29
|
-
scrollbarWidth: '0px'
|
|
30
|
-
overflow: false
|
|
30
|
+
scrollbarWidth: '0px'
|
|
31
31
|
});
|
|
32
32
|
const portalClassName = useMemo(() => "ds-dialog-".concat(uid(8)), []);
|
|
33
33
|
useEffect(() => {
|
|
@@ -44,38 +44,28 @@ const useDialog = props => {
|
|
|
44
44
|
}, [actualPortalRef, isOpen, portalClassName]);
|
|
45
45
|
useEffect(() => {
|
|
46
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
47
|
setPortalInfo(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
51
|
-
paddingRight
|
|
48
|
+
paddingRight: getCurrentRightPadding(actualPortalRef.current)
|
|
52
49
|
}));
|
|
53
50
|
}
|
|
54
51
|
}, []);
|
|
55
|
-
const
|
|
56
|
-
if (actualPortalRef.current) {
|
|
57
|
-
const body = actualPortalRef.current;
|
|
58
|
-
const {
|
|
59
|
-
clientWidth,
|
|
60
|
-
clientHeight,
|
|
61
|
-
scrollHeight
|
|
62
|
-
} = body;
|
|
52
|
+
const calculateScrollbar = useCallback(() => {
|
|
53
|
+
if (actualPortalRef.current && !isOpen) {
|
|
63
54
|
setPortalInfo(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
64
|
-
scrollbarWidth:
|
|
65
|
-
overflow: scrollHeight > clientHeight
|
|
55
|
+
scrollbarWidth: getScrollbarWidth(actualPortalRef.current)
|
|
66
56
|
}));
|
|
67
57
|
}
|
|
68
|
-
}, [
|
|
69
|
-
const
|
|
58
|
+
}, [isOpen]);
|
|
59
|
+
const debouncedCalculateScrollbar = useMemo(() => debounce(calculateScrollbar, 300), [calculateScrollbar]);
|
|
70
60
|
useEffect(() => {
|
|
71
|
-
window.addEventListener('resize',
|
|
61
|
+
window.addEventListener('resize', debouncedCalculateScrollbar);
|
|
72
62
|
return () => {
|
|
73
|
-
window.removeEventListener('resize',
|
|
63
|
+
window.removeEventListener('resize', debouncedCalculateScrollbar);
|
|
74
64
|
};
|
|
75
|
-
}, [
|
|
65
|
+
}, [calculateScrollbar, debouncedCalculateScrollbar]);
|
|
76
66
|
useEffect(() => {
|
|
77
|
-
|
|
78
|
-
}, [
|
|
67
|
+
calculateScrollbar();
|
|
68
|
+
}, [calculateScrollbar, isOpen]);
|
|
79
69
|
const ctx = useMemo(() => ({
|
|
80
70
|
props: propsWithDefault,
|
|
81
71
|
actualPortalRef,
|
package/esm/styles.js
CHANGED
|
@@ -14,7 +14,7 @@ const PortalStyles = createGlobalStyle(_templateObject || (_templateObject = _ta
|
|
|
14
14
|
let {
|
|
15
15
|
portalInfo
|
|
16
16
|
} = _ref2;
|
|
17
|
-
return portalInfo.
|
|
17
|
+
return portalInfo.scrollbarWidth !== '0px' ? "padding-right: calc( ".concat(portalInfo.paddingRight, " + ").concat(portalInfo.scrollbarWidth, " ) !important;") : "";
|
|
18
18
|
});
|
|
19
19
|
const StyledDialogBackground = /*#__PURE__*/styled.div.withConfig({
|
|
20
20
|
componentId: "sc-106vqwv-0"
|
package/esm/utils.js
CHANGED
|
@@ -24,5 +24,11 @@ const allSizes = {
|
|
|
24
24
|
'x-large': '1042px',
|
|
25
25
|
'xx-large': '1440px'
|
|
26
26
|
};
|
|
27
|
+
const getScrollbarWidth = element => element.tagName === 'BODY' ? "".concat(window.innerWidth - element.clientWidth, "px") : "".concat(element.offsetWidth - element.clientWidth, "px");
|
|
28
|
+
const getCurrentRightPadding = element => {
|
|
29
|
+
var _window$getComputedSt;
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
return (_window$getComputedSt = window.getComputedStyle(element, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
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.9",
|
|
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.9",
|
|
84
|
+
"@elliemae/ds-icons": "2.4.2-rc.9",
|
|
85
|
+
"@elliemae/ds-props-helpers": "2.4.2-rc.9",
|
|
86
|
+
"@elliemae/ds-system": "2.4.2-rc.9",
|
|
87
87
|
"react-desc": "~4.1.3"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
package/types/sharedTypes.d.ts
CHANGED
package/types/utils.d.ts
CHANGED