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