@elliemae/ds-modal 1.57.1-rc.0 → 2.0.0-alpha.11
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/DSModal.js +54 -68
- package/cjs/constants.js +5 -6
- package/cjs/index.js +6 -29
- package/cjs/v1/DSModal.js +137 -13
- package/cjs/v1/DSModalType.js +1 -2
- package/cjs/v1/DSModalWrapper.js +110 -146
- package/cjs/v1/ModalFeedBack/ModalFeedBack.js +60 -56
- package/cjs/v2/DSModal.js +56 -102
- package/cjs/v2/blocks.js +49 -51
- package/cjs/v2/components/DecisionHeader.js +25 -27
- package/cjs/v2/components/FeedbackIcon.js +35 -28
- package/cjs/v2/components/Footer.js +33 -31
- package/cjs/v2/components/FormHeader.js +34 -36
- package/cjs/v2/components/ModalContent.js +68 -89
- package/cjs/v2/components/SelectionHeader.js +32 -30
- package/cjs/v2/components/Title.js +13 -17
- package/cjs/v2/helpers.js +17 -13
- package/esm/DSModal.js +18 -32
- package/esm/constants.js +4 -5
- package/esm/index.js +0 -23
- package/esm/v1/DSModal.js +132 -12
- package/esm/v1/DSModalType.js +1 -2
- package/esm/v1/DSModalWrapper.js +109 -139
- package/esm/v1/ModalFeedBack/ModalFeedBack.js +55 -55
- package/esm/v2/DSModal.js +48 -94
- package/esm/v2/blocks.js +49 -47
- package/esm/v2/components/DecisionHeader.js +21 -24
- package/esm/v2/components/FeedbackIcon.js +27 -25
- package/esm/v2/components/Footer.js +29 -27
- package/esm/v2/components/FormHeader.js +29 -32
- package/esm/v2/components/ModalContent.js +54 -76
- package/esm/v2/components/SelectionHeader.js +26 -26
- package/esm/v2/components/Title.js +10 -14
- package/esm/v2/helpers.js +17 -13
- package/package.json +92 -14
- package/types/DSModal.d.ts +14 -0
- package/types/constants.d.ts +25 -0
- package/types/index.d.ts +4 -0
- package/types/v1/DSModal.d.ts +143 -0
- package/types/v1/DSModalType.d.ts +1 -0
- package/types/v1/ModalFeedBack/ModalFeedBack.d.ts +11 -0
- package/types/v2/DSModal.d.ts +91 -0
- package/types/v2/blocks.d.ts +9 -0
- package/types/v2/components/DecisionHeader.d.ts +6 -0
- package/types/v2/components/FeedbackIcon.d.ts +5 -0
- package/types/v2/components/Footer.d.ts +13 -0
- package/types/v2/components/FormHeader.d.ts +8 -0
- package/types/v2/components/ModalContent.d.ts +21 -0
- package/types/v2/components/SelectionHeader.d.ts +8 -0
- package/types/v2/components/Title.d.ts +6 -0
- package/types/v2/components/tests/DecisionHeader.test.d.ts +1 -0
- package/types/v2/components/tests/FeedbackIcon.test.d.ts +1 -0
- package/types/v2/components/tests/Footer.test.d.ts +1 -0
- package/types/v2/components/tests/FormHeader.test.d.ts +1 -0
- package/types/v2/components/tests/SelectionHeader.test.d.ts +1 -0
- package/types/v2/helpers.d.ts +16 -0
- package/types/v2/tests/DSModal.test.d.ts +1 -0
- package/DSModal/package.json +0 -10
- package/cjs/DSModal-3126a986.js +0 -316
- package/cjs/DSModal-3126a986.js.map +0 -1
- package/cjs/DSModal.js.map +0 -1
- package/cjs/constants.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/v1/DSModal.js.map +0 -1
- package/cjs/v1/DSModalType.js.map +0 -1
- package/cjs/v1/DSModalWrapper.js.map +0 -1
- package/cjs/v1/ModalFeedBack/ModalFeedBack.js.map +0 -1
- package/cjs/v2/DSModal.js.map +0 -1
- package/cjs/v2/blocks.js.map +0 -1
- package/cjs/v2/components/DecisionHeader.js.map +0 -1
- package/cjs/v2/components/FeedbackIcon.js.map +0 -1
- package/cjs/v2/components/Footer.js.map +0 -1
- package/cjs/v2/components/FormHeader.js.map +0 -1
- package/cjs/v2/components/ModalContent.js.map +0 -1
- package/cjs/v2/components/SelectionHeader.js.map +0 -1
- package/cjs/v2/components/Title.js.map +0 -1
- package/cjs/v2/helpers.js.map +0 -1
- package/constants/package.json +0 -10
- package/esm/DSModal-a8b0fbf0.js +0 -303
- package/esm/DSModal-a8b0fbf0.js.map +0 -1
- package/esm/DSModal.js.map +0 -1
- package/esm/constants.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/v1/DSModal.js.map +0 -1
- package/esm/v1/DSModalType.js.map +0 -1
- package/esm/v1/DSModalWrapper.js.map +0 -1
- package/esm/v1/ModalFeedBack/ModalFeedBack.js.map +0 -1
- package/esm/v2/DSModal.js.map +0 -1
- package/esm/v2/blocks.js.map +0 -1
- package/esm/v2/components/DecisionHeader.js.map +0 -1
- package/esm/v2/components/FeedbackIcon.js.map +0 -1
- package/esm/v2/components/Footer.js.map +0 -1
- package/esm/v2/components/FormHeader.js.map +0 -1
- package/esm/v2/components/ModalContent.js.map +0 -1
- package/esm/v2/components/SelectionHeader.js.map +0 -1
- package/esm/v2/components/Title.js.map +0 -1
- package/esm/v2/helpers.js.map +0 -1
- package/v1/DSModal/package.json +0 -10
- package/v1/DSModalType/package.json +0 -10
- package/v1/DSModalWrapper/package.json +0 -10
- package/v1/ModalFeedBack/ModalFeedBack/package.json +0 -10
- package/v2/DSModal/package.json +0 -10
- package/v2/blocks/package.json +0 -10
- package/v2/components/DecisionHeader/package.json +0 -10
- package/v2/components/FeedbackIcon/package.json +0 -10
- package/v2/components/Footer/package.json +0 -10
- package/v2/components/FormHeader/package.json +0 -10
- package/v2/components/ModalContent/package.json +0 -10
- package/v2/components/SelectionHeader/package.json +0 -10
- package/v2/components/Title/package.json +0 -10
- package/v2/helpers/package.json +0 -10
package/esm/v1/DSModal.js
CHANGED
|
@@ -1,13 +1,133 @@
|
|
|
1
|
-
import '@babel/runtime/helpers/esm/
|
|
2
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
3
|
import 'react';
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
6
|
-
import '@elliemae/ds-
|
|
7
|
-
import '@elliemae/ds-
|
|
8
|
-
import '@elliemae/ds-
|
|
9
|
-
import '
|
|
10
|
-
import '
|
|
11
|
-
import '
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
import ReactModal from 'react-modal';
|
|
5
|
+
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
6
|
+
import CloseIcon from '@elliemae/ds-icons/Close';
|
|
7
|
+
import { DSIconSizes } from '@elliemae/ds-basic/Icon';
|
|
8
|
+
import DSButton from '@elliemae/ds-basic/Button';
|
|
9
|
+
import { MODAL_TYPE } from '../constants.js';
|
|
10
|
+
import ModalFeedBack from './ModalFeedBack/ModalFeedBack.js';
|
|
11
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
|
+
|
|
13
|
+
var _CloseIcon;
|
|
14
|
+
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
18
|
+
|
|
19
|
+
const DSModal = ({
|
|
20
|
+
containerProps = {},
|
|
21
|
+
className = '',
|
|
22
|
+
dataTestId = 'ds-modal',
|
|
23
|
+
additionalFooterCssClass = '',
|
|
24
|
+
style = {},
|
|
25
|
+
iconCloseSize = DSIconSizes.S,
|
|
26
|
+
modalType = MODAL_TYPE.DEFAULT,
|
|
27
|
+
showHeader = true,
|
|
28
|
+
showFooter = true,
|
|
29
|
+
children,
|
|
30
|
+
centered = true,
|
|
31
|
+
confirmLabel = 'Accept',
|
|
32
|
+
modalTitle = '',
|
|
33
|
+
size = 'medium',
|
|
34
|
+
isOpen = false,
|
|
35
|
+
onClose = () => null,
|
|
36
|
+
onAfterOpen = () => null,
|
|
37
|
+
onConfirm = () => null,
|
|
38
|
+
onReject = () => null,
|
|
39
|
+
rejectLabel = 'Cancel',
|
|
40
|
+
shouldCloseOnOverlayClick = false,
|
|
41
|
+
hasError = false,
|
|
42
|
+
hasWarning = false,
|
|
43
|
+
hasSuccess = false,
|
|
44
|
+
hasInfo = false,
|
|
45
|
+
hasHelp = false,
|
|
46
|
+
actionsRef = () => null,
|
|
47
|
+
appElement = '#root',
|
|
48
|
+
overridePropsConfirmButton = {},
|
|
49
|
+
overridePropsRejectButton = {},
|
|
50
|
+
zIndex = 10
|
|
51
|
+
}) => {
|
|
52
|
+
// http://reactcommunity.org/react-modal/accessibility/ https://github.com/reactjs/react-modal#examples
|
|
53
|
+
typeof document !== 'undefined' && document && ReactModal.setAppElement && ReactModal.setAppElement(appElement); // eslint-disable-line
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
cssClassName,
|
|
57
|
+
classNameElement,
|
|
58
|
+
classNameBlock,
|
|
59
|
+
classNameModifier,
|
|
60
|
+
classNameBlockModifier
|
|
61
|
+
} = convertPropToCssClassName('modal', className, {
|
|
62
|
+
hasError,
|
|
63
|
+
hasWarning,
|
|
64
|
+
hasSuccess,
|
|
65
|
+
modalType,
|
|
66
|
+
size
|
|
67
|
+
});
|
|
68
|
+
const {
|
|
69
|
+
WARNING,
|
|
70
|
+
ERROR,
|
|
71
|
+
SUCCESS,
|
|
72
|
+
HELP,
|
|
73
|
+
INFO
|
|
74
|
+
} = MODAL_TYPE;
|
|
75
|
+
const isAFeedbackType = [WARNING, ERROR, SUCCESS, HELP, INFO].indexOf(modalType) > -1;
|
|
76
|
+
const showFeedBack = isAFeedbackType || hasError || hasWarning || hasSuccess || hasInfo || hasHelp;
|
|
77
|
+
return /*#__PURE__*/_jsx(ReactModal, {
|
|
78
|
+
testId: dataTestId,
|
|
79
|
+
className: cssClassName,
|
|
80
|
+
contentLabel: modalTitle,
|
|
81
|
+
isOpen: isOpen,
|
|
82
|
+
onAfterOpen: onAfterOpen,
|
|
83
|
+
onRequestClose: onClose,
|
|
84
|
+
overlayClassName: "".concat(classNameBlock('overlay'), " ").concat(classNameModifier(centered && 'center')),
|
|
85
|
+
shouldCloseOnOverlayClick: shouldCloseOnOverlayClick,
|
|
86
|
+
style: {
|
|
87
|
+
content: _objectSpread({}, style),
|
|
88
|
+
overlay: {
|
|
89
|
+
zIndex
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, void 0, /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
93
|
+
children: [showHeader && /*#__PURE__*/_jsx("div", {
|
|
94
|
+
className: classNameBlock('modal-header')
|
|
95
|
+
}, void 0, /*#__PURE__*/_jsx("div", {
|
|
96
|
+
className: classNameElement('title', 'modal-header')
|
|
97
|
+
}, void 0, modalTitle), /*#__PURE__*/_jsx("div", {
|
|
98
|
+
className: classNameElement('icon', 'modal-header')
|
|
99
|
+
}, void 0, /*#__PURE__*/_jsx(DSButton, {
|
|
100
|
+
buttonType: "link",
|
|
101
|
+
icon: _CloseIcon || (_CloseIcon = /*#__PURE__*/_jsx(CloseIcon, {})),
|
|
102
|
+
onClick: onClose,
|
|
103
|
+
size: iconCloseSize
|
|
104
|
+
}))), /*#__PURE__*/_jsx("div", {
|
|
105
|
+
className: classNameElement('body')
|
|
106
|
+
}, void 0, showFeedBack && /*#__PURE__*/_jsx(ModalFeedBack, {
|
|
107
|
+
hasError: hasError,
|
|
108
|
+
hasHelp: hasHelp,
|
|
109
|
+
hasInfo: hasInfo,
|
|
110
|
+
hasSuccess: hasSuccess,
|
|
111
|
+
hasWarning: hasWarning,
|
|
112
|
+
modalType: modalType
|
|
113
|
+
}), children), showFooter && !isAFeedbackType && /*#__PURE__*/_jsx("div", {
|
|
114
|
+
className: "".concat(classNameBlock('modal-footer'), " ").concat(additionalFooterCssClass ? classNameBlockModifier(additionalFooterCssClass, 'modal-footer') : '')
|
|
115
|
+
}, void 0, /*#__PURE__*/jsxs("div", {
|
|
116
|
+
ref: actionsRef,
|
|
117
|
+
className: classNameBlock('modal-footer-actions'),
|
|
118
|
+
children: [modalType === MODAL_TYPE.CONFIRM && /*#__PURE__*/jsx(DSButton, _objectSpread({
|
|
119
|
+
buttonType: "secondary",
|
|
120
|
+
className: "".concat(classNameElement('button-action'), " ").concat(classNameModifier('reject', 'button-action'), " "),
|
|
121
|
+
labelText: rejectLabel,
|
|
122
|
+
onClick: onReject
|
|
123
|
+
}, overridePropsRejectButton)), /*#__PURE__*/jsx(DSButton, _objectSpread({
|
|
124
|
+
buttonType: "primary",
|
|
125
|
+
className: "".concat(classNameElement('button-action'), " ").concat(classNameModifier('confirm', 'button-action'), " "),
|
|
126
|
+
labelText: confirmLabel,
|
|
127
|
+
onClick: onConfirm
|
|
128
|
+
}, overridePropsConfirmButton))]
|
|
129
|
+
}))]
|
|
130
|
+
})));
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export { DSModal as default };
|
package/esm/v1/DSModalType.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
const modalTypes = [MODAL_TYPE.DEFAULT, MODAL_TYPE.ALERT, MODAL_TYPE.CONFIRM, MODAL_TYPE.NOTIFICATION, MODAL_TYPE.WARNING, MODAL_TYPE.ERROR, MODAL_TYPE.SUCCESS, MODAL_TYPE.HELP, MODAL_TYPE.INFO];
|
|
2
2
|
|
|
3
3
|
export { modalTypes };
|
|
4
|
-
//# sourceMappingURL=DSModalType.js.map
|
package/esm/v1/DSModalWrapper.js
CHANGED
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
|
|
2
|
-
import _createClass from '@babel/runtime/helpers/esm/createClass';
|
|
3
|
-
import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
4
|
-
import _inherits from '@babel/runtime/helpers/esm/inherits';
|
|
5
|
-
import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
|
|
6
|
-
import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
|
|
7
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
-
import
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import { Component, createElement } from 'react';
|
|
9
4
|
import { MODAL_TYPE } from '../constants.js';
|
|
10
5
|
|
|
11
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
12
7
|
|
|
13
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
|
+
var DSModalWrapper = (WrappedComponent => {
|
|
10
|
+
class DSModalWrapper extends Component {
|
|
11
|
+
constructor(...args) {
|
|
12
|
+
super(...args);
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
-
var DSModalWrapper = (function (WrappedComponent) {
|
|
19
|
-
var DSModalWrapper = /*#__PURE__*/function (_Component) {
|
|
20
|
-
_inherits(DSModalWrapper, _Component);
|
|
21
|
-
|
|
22
|
-
var _super = _createSuper(DSModalWrapper);
|
|
23
|
-
|
|
24
|
-
function DSModalWrapper() {
|
|
25
|
-
var _this;
|
|
26
|
-
|
|
27
|
-
_classCallCheck(this, DSModalWrapper);
|
|
28
|
-
|
|
29
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
|
-
args[_key] = arguments[_key];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
-
|
|
35
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
14
|
+
_defineProperty(this, "state", {
|
|
36
15
|
childready: false,
|
|
37
16
|
additionalFooterCssClass: 'loading',
|
|
38
17
|
container: null,
|
|
@@ -40,145 +19,136 @@ var DSModalWrapper = (function (WrappedComponent) {
|
|
|
40
19
|
height: '100%'
|
|
41
20
|
});
|
|
42
21
|
|
|
43
|
-
_defineProperty(
|
|
44
|
-
|
|
45
|
-
|
|
22
|
+
_defineProperty(this, "onHeaderHeight", e => {
|
|
23
|
+
this.heightHeaderFlag = true;
|
|
24
|
+
this.heightHeader = e.height || 0;
|
|
46
25
|
});
|
|
47
26
|
|
|
48
|
-
_defineProperty(
|
|
49
|
-
|
|
50
|
-
|
|
27
|
+
_defineProperty(this, "onFooterHeight", e => {
|
|
28
|
+
this.heightFooterFlag = true;
|
|
29
|
+
this.heightFooter = e.height || 0;
|
|
51
30
|
});
|
|
52
31
|
|
|
53
|
-
_defineProperty(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
58
|
-
height: bounds.height -
|
|
32
|
+
_defineProperty(this, "onResize", ({
|
|
33
|
+
bounds
|
|
34
|
+
}) => {
|
|
35
|
+
if (this.heightFooterFlag && this.heightHeaderFlag) {
|
|
36
|
+
return this.setState({
|
|
37
|
+
height: bounds.height - this.heightFooter - this.heightHeader
|
|
59
38
|
});
|
|
60
39
|
}
|
|
61
40
|
|
|
62
|
-
return setTimeout(
|
|
63
|
-
bounds
|
|
41
|
+
return setTimeout(this.onResize({
|
|
42
|
+
bounds
|
|
64
43
|
}), 0);
|
|
65
44
|
});
|
|
66
45
|
|
|
67
|
-
_defineProperty(
|
|
68
|
-
if (node)
|
|
46
|
+
_defineProperty(this, "handleContainer", node => {
|
|
47
|
+
if (node) this.setState({
|
|
69
48
|
container: node
|
|
70
49
|
});
|
|
71
|
-
|
|
72
|
-
_this.handleResize();
|
|
50
|
+
this.handleResize();
|
|
73
51
|
});
|
|
74
52
|
|
|
75
|
-
_defineProperty(
|
|
76
|
-
if (node)
|
|
53
|
+
_defineProperty(this, "handleActions", node => {
|
|
54
|
+
if (node) this.setState({
|
|
77
55
|
actions: node
|
|
78
56
|
});
|
|
79
|
-
|
|
80
|
-
_this.handleResize();
|
|
57
|
+
this.handleResize();
|
|
81
58
|
});
|
|
59
|
+
}
|
|
82
60
|
|
|
83
|
-
|
|
61
|
+
componentDidMount() {
|
|
62
|
+
window.addEventListener('resize', this.handleResize);
|
|
84
63
|
}
|
|
85
64
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
window.addEventListener('resize', this.handleResize);
|
|
90
|
-
}
|
|
91
|
-
}, {
|
|
92
|
-
key: "componentWillUnmount",
|
|
93
|
-
value: function componentWillUnmount() {
|
|
94
|
-
window.removeEventListener('resize', this.handleResize);
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "handleResize",
|
|
98
|
-
value:
|
|
99
|
-
/**
|
|
100
|
-
* Change button width to 100% if the
|
|
101
|
-
* combined width of the button (or button group) exceed 50% of the container width.
|
|
102
|
-
*/
|
|
103
|
-
function handleResize() {
|
|
104
|
-
if (!this.state) return null;
|
|
105
|
-
var _this$state = this.state,
|
|
106
|
-
container = _this$state.container,
|
|
107
|
-
actions = _this$state.actions,
|
|
108
|
-
childready = _this$state.childready;
|
|
109
|
-
if (!childready) return null;
|
|
110
|
-
this.setState({
|
|
111
|
-
additionalFooterCssClass: null
|
|
112
|
-
}); // !important reset to default state to recalculate
|
|
113
|
-
|
|
114
|
-
var containerWidth = container.clientWidth;
|
|
115
|
-
var actionsWidth = actions.clientWidth; // Change button width to 100% if the combined width of the button (or button group) exceed 50% of the container width.
|
|
116
|
-
|
|
117
|
-
if (containerWidth && actionsWidth && actionsWidth / containerWidth * 100 > 50) {
|
|
118
|
-
return this.setState({
|
|
119
|
-
additionalFooterCssClass: 'fluid-actions'
|
|
120
|
-
});
|
|
121
|
-
}
|
|
65
|
+
componentWillUnmount() {
|
|
66
|
+
window.removeEventListener('resize', this.handleResize);
|
|
67
|
+
}
|
|
122
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Change button width to 100% if the
|
|
71
|
+
* combined width of the button (or button group) exceed 50% of the container width.
|
|
72
|
+
*/
|
|
73
|
+
handleResize() {
|
|
74
|
+
if (!this.state) return null;
|
|
75
|
+
const {
|
|
76
|
+
container,
|
|
77
|
+
actions,
|
|
78
|
+
childready
|
|
79
|
+
} = this.state;
|
|
80
|
+
if (!childready) return null;
|
|
81
|
+
this.setState({
|
|
82
|
+
additionalFooterCssClass: null
|
|
83
|
+
}); // !important reset to default state to recalculate
|
|
84
|
+
|
|
85
|
+
const {
|
|
86
|
+
clientWidth: containerWidth
|
|
87
|
+
} = container;
|
|
88
|
+
const {
|
|
89
|
+
clientWidth: actionsWidth
|
|
90
|
+
} = actions; // Change button width to 100% if the combined width of the button (or button group) exceed 50% of the container width.
|
|
91
|
+
|
|
92
|
+
if (containerWidth && actionsWidth && actionsWidth / containerWidth * 100 > 50) {
|
|
123
93
|
return this.setState({
|
|
124
|
-
additionalFooterCssClass:
|
|
94
|
+
additionalFooterCssClass: 'fluid-actions'
|
|
125
95
|
});
|
|
126
96
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
key: "render",
|
|
153
|
-
value: function render() {
|
|
154
|
-
var _this3 = this;
|
|
155
|
-
|
|
156
|
-
var props = this.props,
|
|
157
|
-
state = this.state;
|
|
158
|
-
var additionalFooterCssClass = state.additionalFooterCssClass,
|
|
159
|
-
height = state.height;
|
|
160
|
-
return /*#__PURE__*/createElement(WrappedComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
161
|
-
height: height,
|
|
162
|
-
onResize: this.onResize,
|
|
163
|
-
onFooterHeight: this.onFooterHeight,
|
|
164
|
-
onHeaderHeight: this.onHeaderHeight,
|
|
165
|
-
containerRef: this.handleContainer,
|
|
166
|
-
actionsRef: this.handleActions,
|
|
167
|
-
additionalFooterCssClass: additionalFooterCssClass,
|
|
168
|
-
onAfterOpen: function onAfterOpen() {
|
|
169
|
-
if (props.onAfterOpen) props.onAfterOpen();
|
|
170
|
-
|
|
171
|
-
_this3.verifyNodes();
|
|
172
|
-
}
|
|
173
|
-
}));
|
|
97
|
+
|
|
98
|
+
return this.setState({
|
|
99
|
+
additionalFooterCssClass: null
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
verifyNodes() {
|
|
104
|
+
const {
|
|
105
|
+
modalType
|
|
106
|
+
} = this.props;
|
|
107
|
+
|
|
108
|
+
if (modalType !== MODAL_TYPE.DEFAULT) {
|
|
109
|
+
const nodesInterval = setInterval(() => {
|
|
110
|
+
// !important it checks when nodes are availables
|
|
111
|
+
const {
|
|
112
|
+
container,
|
|
113
|
+
actions
|
|
114
|
+
} = this.state;
|
|
115
|
+
if (!container || !actions) return null;
|
|
116
|
+
clearInterval(nodesInterval);
|
|
117
|
+
this.setState({
|
|
118
|
+
childready: true
|
|
119
|
+
});
|
|
120
|
+
return this.handleResize();
|
|
121
|
+
}, 100);
|
|
174
122
|
}
|
|
175
|
-
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
render() {
|
|
126
|
+
const {
|
|
127
|
+
props,
|
|
128
|
+
state
|
|
129
|
+
} = this;
|
|
130
|
+
const {
|
|
131
|
+
additionalFooterCssClass,
|
|
132
|
+
height
|
|
133
|
+
} = state;
|
|
134
|
+
return /*#__PURE__*/createElement(WrappedComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
135
|
+
height,
|
|
136
|
+
onResize: this.onResize,
|
|
137
|
+
onFooterHeight: this.onFooterHeight,
|
|
138
|
+
onHeaderHeight: this.onHeaderHeight,
|
|
139
|
+
containerRef: this.handleContainer,
|
|
140
|
+
actionsRef: this.handleActions,
|
|
141
|
+
additionalFooterCssClass,
|
|
142
|
+
onAfterOpen: () => {
|
|
143
|
+
if (props.onAfterOpen) props.onAfterOpen();
|
|
144
|
+
this.verifyNodes();
|
|
145
|
+
}
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
176
148
|
|
|
177
|
-
|
|
178
|
-
}(Component);
|
|
149
|
+
}
|
|
179
150
|
|
|
180
151
|
return DSModalWrapper;
|
|
181
152
|
});
|
|
182
153
|
|
|
183
154
|
export { DSModalWrapper as default };
|
|
184
|
-
//# sourceMappingURL=DSModalWrapper.js.map
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import WarningCircle from '@elliemae/ds-icons/WarningCircle';
|
|
4
|
+
import CheckmarkCircle from '@elliemae/ds-icons/CheckmarkCircle';
|
|
5
|
+
import HelpCircle from '@elliemae/ds-icons/HelpCircle';
|
|
6
|
+
import InfoCircle from '@elliemae/ds-icons/InfoCircle';
|
|
3
7
|
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
4
8
|
import { MODAL_TYPE } from '../../constants.js';
|
|
5
9
|
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var _WarningCircle, _CheckmarkCircle, _HelpCircle, _InfoCircle, _InfoCircle2;
|
|
11
|
+
const feedbackIconSize = 'xxl';
|
|
12
|
+
const {
|
|
13
|
+
WARNING,
|
|
14
|
+
ERROR,
|
|
15
|
+
SUCCESS,
|
|
16
|
+
HELP,
|
|
17
|
+
INFO
|
|
18
|
+
} = MODAL_TYPE;
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
const getModalType = (modalType, {
|
|
21
|
+
hasError,
|
|
22
|
+
hasWarning,
|
|
23
|
+
hasSuccess,
|
|
24
|
+
hasInfo,
|
|
25
|
+
hasHelp
|
|
26
|
+
}) => {
|
|
19
27
|
if ([WARNING, ERROR, SUCCESS, HELP, INFO].indexOf(modalType) > -1) return modalType;
|
|
20
28
|
if (hasError) return ERROR;
|
|
21
29
|
if (hasWarning) return WARNING;
|
|
@@ -25,69 +33,61 @@ var getModalType = function getModalType(modalType, _ref) {
|
|
|
25
33
|
return INFO;
|
|
26
34
|
};
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
const getIconType = modalType => {
|
|
29
37
|
switch (modalType) {
|
|
30
38
|
case WARNING:
|
|
31
39
|
case ERROR:
|
|
32
|
-
return /*#__PURE__*/
|
|
40
|
+
return _WarningCircle || (_WarningCircle = /*#__PURE__*/_jsx(WarningCircle, {
|
|
33
41
|
size: feedbackIconSize
|
|
34
|
-
});
|
|
42
|
+
}));
|
|
35
43
|
|
|
36
44
|
case SUCCESS:
|
|
37
|
-
return /*#__PURE__*/
|
|
45
|
+
return _CheckmarkCircle || (_CheckmarkCircle = /*#__PURE__*/_jsx(CheckmarkCircle, {
|
|
38
46
|
size: feedbackIconSize
|
|
39
|
-
});
|
|
47
|
+
}));
|
|
40
48
|
|
|
41
49
|
case HELP:
|
|
42
|
-
return /*#__PURE__*/
|
|
50
|
+
return _HelpCircle || (_HelpCircle = /*#__PURE__*/_jsx(HelpCircle, {
|
|
43
51
|
size: feedbackIconSize
|
|
44
|
-
});
|
|
52
|
+
}));
|
|
45
53
|
|
|
46
54
|
case INFO:
|
|
47
|
-
return /*#__PURE__*/
|
|
55
|
+
return _InfoCircle || (_InfoCircle = /*#__PURE__*/_jsx(InfoCircle, {
|
|
48
56
|
size: feedbackIconSize
|
|
49
|
-
});
|
|
57
|
+
}));
|
|
50
58
|
|
|
51
59
|
default:
|
|
52
|
-
return /*#__PURE__*/
|
|
60
|
+
return _InfoCircle2 || (_InfoCircle2 = /*#__PURE__*/_jsx(InfoCircle, {
|
|
53
61
|
size: feedbackIconSize
|
|
54
|
-
});
|
|
62
|
+
}));
|
|
55
63
|
}
|
|
56
64
|
};
|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var type = getModalType(modalType, {
|
|
74
|
-
hasError: hasError,
|
|
75
|
-
hasWarning: hasWarning,
|
|
76
|
-
hasSuccess: hasSuccess,
|
|
77
|
-
hasInfo: hasInfo,
|
|
78
|
-
hasHelp: hasHelp
|
|
66
|
+
const ModalFeedBack = ({
|
|
67
|
+
className = '',
|
|
68
|
+
modalType = null,
|
|
69
|
+
hasError = false,
|
|
70
|
+
hasWarning = false,
|
|
71
|
+
hasSuccess = false,
|
|
72
|
+
hasInfo = false,
|
|
73
|
+
hasHelp = false
|
|
74
|
+
}) => {
|
|
75
|
+
const type = getModalType(modalType, {
|
|
76
|
+
hasError,
|
|
77
|
+
hasWarning,
|
|
78
|
+
hasSuccess,
|
|
79
|
+
hasInfo,
|
|
80
|
+
hasHelp
|
|
79
81
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
const {
|
|
83
|
+
cssClassName
|
|
84
|
+
} = convertPropToCssClassName('modal-feedback', className, {
|
|
82
85
|
modalType: type
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var feedbackIcon = getIconType(type);
|
|
87
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
});
|
|
87
|
+
const feedbackIcon = getIconType(type);
|
|
88
|
+
return /*#__PURE__*/_jsx("div", {
|
|
88
89
|
className: cssClassName
|
|
89
|
-
}, feedbackIcon);
|
|
90
|
+
}, void 0, feedbackIcon);
|
|
90
91
|
};
|
|
91
92
|
|
|
92
93
|
export { ModalFeedBack as default };
|
|
93
|
-
//# sourceMappingURL=ModalFeedBack.js.map
|