@elliemae/ds-modal 2.2.0-alpha.3 → 3.0.0-next.0
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 +184 -86
- package/cjs/constants.js +28 -67
- package/cjs/index.js +18 -39
- package/cjs/v1/DSModal.js +130 -159
- package/cjs/v1/DSModalType.js +7 -45
- package/cjs/v1/DSModalWrapper.js +113 -76
- package/cjs/v1/ModalFeedBack/ModalFeedBack.js +72 -77
- package/cjs/v2/DSModal.js +186 -143
- package/cjs/v2/blocks.js +86 -69
- package/cjs/v2/components/DecisionHeader.js +37 -47
- package/cjs/v2/components/FeedbackIcon.js +50 -59
- package/cjs/v2/components/Footer.js +65 -68
- package/cjs/v2/components/FormHeader.js +46 -53
- package/cjs/v2/components/ModalContent.js +111 -95
- package/cjs/v2/components/SelectionHeader.js +48 -50
- package/cjs/v2/components/Title.js +25 -40
- package/cjs/v2/helpers.js +40 -49
- package/esm/DSModal.js +142 -26
- package/esm/constants.js +20 -38
- package/esm/index.js +4 -10
- package/esm/v1/DSModal.js +121 -130
- package/esm/v1/DSModalType.js +3 -16
- package/esm/v1/DSModalWrapper.js +105 -45
- package/esm/v1/ModalFeedBack/ModalFeedBack.js +66 -48
- package/esm/v2/DSModal.js +173 -112
- package/esm/v2/blocks.js +77 -42
- package/esm/v2/components/DecisionHeader.js +27 -18
- package/esm/v2/components/FeedbackIcon.js +36 -25
- package/esm/v2/components/Footer.js +54 -39
- package/esm/v2/components/FormHeader.js +36 -24
- package/esm/v2/components/ModalContent.js +102 -72
- package/esm/v2/components/SelectionHeader.js +38 -21
- package/esm/v2/components/Title.js +16 -11
- package/esm/v2/helpers.js +28 -16
- package/package.json +8 -8
- package/types/DSModal.d.ts +1 -1
- package/cjs/DSModal.js.map +0 -7
- package/cjs/constants.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/v1/DSModal.js.map +0 -7
- package/cjs/v1/DSModalType.js.map +0 -7
- package/cjs/v1/DSModalWrapper.js.map +0 -7
- package/cjs/v1/ModalFeedBack/ModalFeedBack.js.map +0 -7
- package/cjs/v2/DSModal.js.map +0 -7
- package/cjs/v2/blocks.js.map +0 -7
- package/cjs/v2/components/DecisionHeader.js.map +0 -7
- package/cjs/v2/components/FeedbackIcon.js.map +0 -7
- package/cjs/v2/components/Footer.js.map +0 -7
- package/cjs/v2/components/FormHeader.js.map +0 -7
- package/cjs/v2/components/ModalContent.js.map +0 -7
- package/cjs/v2/components/SelectionHeader.js.map +0 -7
- package/cjs/v2/components/Title.js.map +0 -7
- package/cjs/v2/helpers.js.map +0 -7
- package/esm/DSModal.js.map +0 -7
- package/esm/constants.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/v1/DSModal.js.map +0 -7
- package/esm/v1/DSModalType.js.map +0 -7
- package/esm/v1/DSModalWrapper.js.map +0 -7
- package/esm/v1/ModalFeedBack/ModalFeedBack.js.map +0 -7
- package/esm/v2/DSModal.js.map +0 -7
- package/esm/v2/blocks.js.map +0 -7
- package/esm/v2/components/DecisionHeader.js.map +0 -7
- package/esm/v2/components/FeedbackIcon.js.map +0 -7
- package/esm/v2/components/Footer.js.map +0 -7
- package/esm/v2/components/FormHeader.js.map +0 -7
- package/esm/v2/components/ModalContent.js.map +0 -7
- package/esm/v2/components/SelectionHeader.js.map +0 -7
- package/esm/v2/components/Title.js.map +0 -7
- package/esm/v2/helpers.js.map +0 -7
package/esm/constants.js
CHANGED
|
@@ -1,44 +1,26 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
const MODAL_TYPE = {
|
|
3
|
-
DEFAULT:
|
|
4
|
-
ALERT:
|
|
5
|
-
CONFIRM:
|
|
6
|
-
NOTIFICATION:
|
|
7
|
-
WARNING:
|
|
8
|
-
ERROR:
|
|
9
|
-
SUCCESS:
|
|
10
|
-
HELP:
|
|
11
|
-
INFO:
|
|
2
|
+
DEFAULT: 'default',
|
|
3
|
+
ALERT: 'alert',
|
|
4
|
+
CONFIRM: 'confirm',
|
|
5
|
+
NOTIFICATION: 'notification',
|
|
6
|
+
WARNING: 'warning',
|
|
7
|
+
ERROR: 'error',
|
|
8
|
+
SUCCESS: 'success',
|
|
9
|
+
HELP: 'help',
|
|
10
|
+
INFO: 'info'
|
|
12
11
|
};
|
|
13
|
-
const modalTypes = [
|
|
14
|
-
MODAL_TYPE.DEFAULT,
|
|
15
|
-
MODAL_TYPE.ALERT,
|
|
16
|
-
MODAL_TYPE.CONFIRM,
|
|
17
|
-
MODAL_TYPE.NOTIFICATION,
|
|
18
|
-
MODAL_TYPE.WARNING,
|
|
19
|
-
MODAL_TYPE.ERROR,
|
|
20
|
-
MODAL_TYPE.SUCCESS,
|
|
21
|
-
MODAL_TYPE.HELP,
|
|
22
|
-
MODAL_TYPE.INFO
|
|
23
|
-
];
|
|
12
|
+
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];
|
|
24
13
|
const MODAL_TYPE_V2 = {
|
|
25
|
-
INFORMATION:
|
|
26
|
-
DECISION:
|
|
27
|
-
SELECTION:
|
|
28
|
-
FORM:
|
|
14
|
+
INFORMATION: 'information',
|
|
15
|
+
DECISION: 'decision',
|
|
16
|
+
SELECTION: 'selection',
|
|
17
|
+
FORM: 'form'
|
|
29
18
|
};
|
|
30
19
|
const MODAL_SUB_TYPE_V2 = {
|
|
31
|
-
SUCCESS:
|
|
32
|
-
WARNING:
|
|
33
|
-
ERROR:
|
|
34
|
-
INFORMATION:
|
|
20
|
+
SUCCESS: 'success',
|
|
21
|
+
WARNING: 'warning',
|
|
22
|
+
ERROR: 'error',
|
|
23
|
+
INFORMATION: 'information'
|
|
35
24
|
};
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
MODAL_SUB_TYPE_V2,
|
|
39
|
-
MODAL_TYPE,
|
|
40
|
-
MODAL_TYPE_V2,
|
|
41
|
-
constants_default as default,
|
|
42
|
-
modalTypes
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=constants.js.map
|
|
25
|
+
|
|
26
|
+
export { MODAL_SUB_TYPE_V2, MODAL_TYPE, MODAL_TYPE_V2, MODAL_TYPE as default, modalTypes };
|
package/esm/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
import { default as default2 } from "./DSModal";
|
|
6
|
-
export {
|
|
7
|
-
DSModalWithSchema,
|
|
8
|
-
default2 as default
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { default } from './DSModal.js';
|
|
2
|
+
export { MODAL_SUB_TYPE_V2, MODAL_TYPE, MODAL_TYPE_V2, modalTypes } from './constants.js';
|
|
3
|
+
export { DSModalWithSchema } from './v2/DSModal.js';
|
|
4
|
+
export { DSModalContent } from './v2/components/ModalContent.js';
|
package/esm/v1/DSModal.js
CHANGED
|
@@ -1,148 +1,139 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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';
|
|
8
|
+
import 'react';
|
|
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); 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 = 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; }
|
|
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, {
|
|
47
68
|
hasError,
|
|
48
69
|
hasWarning,
|
|
49
70
|
hasSuccess,
|
|
50
71
|
modalType,
|
|
51
72
|
size
|
|
52
73
|
});
|
|
53
|
-
const {
|
|
74
|
+
const {
|
|
75
|
+
WARNING,
|
|
76
|
+
ERROR,
|
|
77
|
+
SUCCESS,
|
|
78
|
+
HELP,
|
|
79
|
+
INFO
|
|
80
|
+
} = MODAL_TYPE;
|
|
54
81
|
const isAFeedbackType = [WARNING, ERROR, SUCCESS, HELP, INFO].indexOf(modalType) > -1;
|
|
55
82
|
const showFeedBack = isAFeedbackType || hasError || hasWarning || hasSuccess || hasInfo || hasHelp;
|
|
56
|
-
return
|
|
83
|
+
return /*#__PURE__*/_jsx(ReactModal, {
|
|
57
84
|
testId: dataTestId,
|
|
58
85
|
className: cssClassName,
|
|
59
86
|
contentLabel: modalTitle,
|
|
60
|
-
isOpen,
|
|
61
|
-
onAfterOpen,
|
|
87
|
+
isOpen: isOpen,
|
|
88
|
+
onAfterOpen: onAfterOpen,
|
|
62
89
|
onRequestClose: onClose,
|
|
63
|
-
overlayClassName:
|
|
64
|
-
shouldCloseOnOverlayClick,
|
|
90
|
+
overlayClassName: "".concat(classNameBlock('overlay'), " ").concat(classNameModifier(centered && 'center')),
|
|
91
|
+
shouldCloseOnOverlayClick: shouldCloseOnOverlayClick,
|
|
65
92
|
style: {
|
|
66
|
-
content: {
|
|
67
|
-
...style
|
|
68
|
-
},
|
|
93
|
+
content: _objectSpread({}, style),
|
|
69
94
|
overlay: {
|
|
70
95
|
zIndex
|
|
71
96
|
}
|
|
72
97
|
}
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
})))));
|
|
113
|
-
};
|
|
114
|
-
DSModal.propTypes = {
|
|
115
|
-
className: PropTypes.string,
|
|
116
|
-
additionalFooterCssClass: PropTypes.string,
|
|
117
|
-
style: PropTypes.shape({}),
|
|
118
|
-
iconCloseSize: PropTypes.oneOf(iconSizes),
|
|
119
|
-
modalType: PropTypes.oneOf(modalTypes),
|
|
120
|
-
showHeader: PropTypes.bool,
|
|
121
|
-
showFooter: PropTypes.bool,
|
|
122
|
-
children: PropTypes.oneOfType([PropTypes.element, PropTypes.string, PropTypes.any]).isRequired,
|
|
123
|
-
centered: PropTypes.bool,
|
|
124
|
-
confirmLabel: PropTypes.string,
|
|
125
|
-
modalTitle: PropTypes.string,
|
|
126
|
-
size: PropTypes.oneOf(sizes),
|
|
127
|
-
isOpen: PropTypes.bool,
|
|
128
|
-
onClose: PropTypes.func,
|
|
129
|
-
onAfterOpen: PropTypes.func,
|
|
130
|
-
onConfirm: PropTypes.func,
|
|
131
|
-
onReject: PropTypes.func,
|
|
132
|
-
rejectLabel: PropTypes.string,
|
|
133
|
-
shouldCloseOnOverlayClick: PropTypes.bool,
|
|
134
|
-
hasError: PropTypes.bool,
|
|
135
|
-
hasWarning: PropTypes.bool,
|
|
136
|
-
hasSuccess: PropTypes.bool,
|
|
137
|
-
hasInfo: PropTypes.bool,
|
|
138
|
-
hasHelp: PropTypes.bool,
|
|
139
|
-
actionsRef: PropTypes.func,
|
|
140
|
-
appElement: PropTypes.string,
|
|
141
|
-
overridePropsConfirmButton: PropTypes.shape({}),
|
|
142
|
-
overridePropsRejectButton: PropTypes.shape({})
|
|
143
|
-
};
|
|
144
|
-
var DSModal_default = DSModal;
|
|
145
|
-
export {
|
|
146
|
-
DSModal_default as default
|
|
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
|
+
})));
|
|
147
137
|
};
|
|
148
|
-
|
|
138
|
+
|
|
139
|
+
export { DSModal as default };
|
package/esm/v1/DSModalType.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
MODAL_TYPE.ALERT,
|
|
5
|
-
MODAL_TYPE.CONFIRM,
|
|
6
|
-
MODAL_TYPE.NOTIFICATION,
|
|
7
|
-
MODAL_TYPE.WARNING,
|
|
8
|
-
MODAL_TYPE.ERROR,
|
|
9
|
-
MODAL_TYPE.SUCCESS,
|
|
10
|
-
MODAL_TYPE.HELP,
|
|
11
|
-
MODAL_TYPE.INFO
|
|
12
|
-
];
|
|
13
|
-
export {
|
|
14
|
-
modalTypes
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=DSModalType.js.map
|
|
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
|
+
|
|
3
|
+
export { modalTypes };
|
package/esm/v1/DSModalWrapper.js
CHANGED
|
@@ -1,82 +1,143 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
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 { Component, createElement } from 'react';
|
|
9
|
+
import { MODAL_TYPE } from '../constants.js';
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
14
|
+
var DSModalWrapper = (WrappedComponent => {
|
|
5
15
|
class DSModalWrapper extends Component {
|
|
6
16
|
constructor() {
|
|
7
17
|
super(...arguments);
|
|
8
18
|
this.state = {
|
|
9
19
|
childready: false,
|
|
10
|
-
additionalFooterCssClass:
|
|
20
|
+
additionalFooterCssClass: 'loading',
|
|
11
21
|
container: null,
|
|
12
22
|
actions: null,
|
|
13
|
-
height:
|
|
23
|
+
height: '100%'
|
|
14
24
|
};
|
|
15
|
-
|
|
25
|
+
|
|
26
|
+
this.onHeaderHeight = e => {
|
|
16
27
|
this.heightHeaderFlag = true;
|
|
17
28
|
this.heightHeader = e.height || 0;
|
|
18
29
|
};
|
|
19
|
-
|
|
30
|
+
|
|
31
|
+
this.onFooterHeight = e => {
|
|
20
32
|
this.heightFooterFlag = true;
|
|
21
33
|
this.heightFooter = e.height || 0;
|
|
22
34
|
};
|
|
23
|
-
|
|
35
|
+
|
|
36
|
+
this.onResize = _ref => {
|
|
37
|
+
let {
|
|
38
|
+
bounds
|
|
39
|
+
} = _ref;
|
|
40
|
+
|
|
24
41
|
if (this.heightFooterFlag && this.heightHeaderFlag) {
|
|
25
42
|
return this.setState({
|
|
26
43
|
height: bounds.height - this.heightFooter - this.heightHeader
|
|
27
44
|
});
|
|
28
45
|
}
|
|
29
|
-
|
|
46
|
+
|
|
47
|
+
return setTimeout(this.onResize({
|
|
48
|
+
bounds
|
|
49
|
+
}), 0);
|
|
30
50
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
51
|
+
|
|
52
|
+
this.handleContainer = node => {
|
|
53
|
+
if (node) this.setState({
|
|
54
|
+
container: node
|
|
55
|
+
});
|
|
34
56
|
this.handleResize();
|
|
35
57
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
|
|
59
|
+
this.handleActions = node => {
|
|
60
|
+
if (node) this.setState({
|
|
61
|
+
actions: node
|
|
62
|
+
});
|
|
39
63
|
this.handleResize();
|
|
40
64
|
};
|
|
41
65
|
}
|
|
66
|
+
|
|
42
67
|
componentDidMount() {
|
|
43
|
-
window.addEventListener(
|
|
68
|
+
window.addEventListener('resize', this.handleResize);
|
|
44
69
|
}
|
|
70
|
+
|
|
45
71
|
componentWillUnmount() {
|
|
46
|
-
window.removeEventListener(
|
|
72
|
+
window.removeEventListener('resize', this.handleResize);
|
|
47
73
|
}
|
|
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
|
+
*/
|
|
48
79
|
handleResize() {
|
|
49
|
-
if (!this.state)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
|
|
57
98
|
if (containerWidth && actionsWidth && actionsWidth / containerWidth * 100 > 50) {
|
|
58
|
-
return this.setState({
|
|
99
|
+
return this.setState({
|
|
100
|
+
additionalFooterCssClass: 'fluid-actions'
|
|
101
|
+
});
|
|
59
102
|
}
|
|
60
|
-
|
|
103
|
+
|
|
104
|
+
return this.setState({
|
|
105
|
+
additionalFooterCssClass: null
|
|
106
|
+
});
|
|
61
107
|
}
|
|
108
|
+
|
|
62
109
|
verifyNodes() {
|
|
63
|
-
const {
|
|
110
|
+
const {
|
|
111
|
+
modalType
|
|
112
|
+
} = this.props;
|
|
113
|
+
|
|
64
114
|
if (modalType !== MODAL_TYPE.DEFAULT) {
|
|
65
115
|
const nodesInterval = setInterval(() => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
116
|
+
// !important it checks when nodes are availables
|
|
117
|
+
const {
|
|
118
|
+
container,
|
|
119
|
+
actions
|
|
120
|
+
} = this.state;
|
|
121
|
+
if (!container || !actions) return null;
|
|
69
122
|
clearInterval(nodesInterval);
|
|
70
|
-
this.setState({
|
|
123
|
+
this.setState({
|
|
124
|
+
childready: true
|
|
125
|
+
});
|
|
71
126
|
return this.handleResize();
|
|
72
127
|
}, 100);
|
|
73
128
|
}
|
|
74
129
|
}
|
|
130
|
+
|
|
75
131
|
render() {
|
|
76
|
-
const {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
132
|
+
const {
|
|
133
|
+
props,
|
|
134
|
+
state
|
|
135
|
+
} = this;
|
|
136
|
+
const {
|
|
137
|
+
additionalFooterCssClass,
|
|
138
|
+
height
|
|
139
|
+
} = state;
|
|
140
|
+
return /*#__PURE__*/createElement(WrappedComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
80
141
|
height,
|
|
81
142
|
onResize: this.onResize,
|
|
82
143
|
onFooterHeight: this.onFooterHeight,
|
|
@@ -85,16 +146,15 @@ var DSModalWrapper_default = (WrappedComponent) => {
|
|
|
85
146
|
actionsRef: this.handleActions,
|
|
86
147
|
additionalFooterCssClass,
|
|
87
148
|
onAfterOpen: () => {
|
|
88
|
-
if (props.onAfterOpen)
|
|
89
|
-
props.onAfterOpen();
|
|
149
|
+
if (props.onAfterOpen) props.onAfterOpen();
|
|
90
150
|
this.verifyNodes();
|
|
91
151
|
}
|
|
92
|
-
});
|
|
152
|
+
}));
|
|
93
153
|
}
|
|
154
|
+
|
|
94
155
|
}
|
|
156
|
+
|
|
95
157
|
return DSModalWrapper;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
};
|
|
100
|
-
//# sourceMappingURL=DSModalWrapper.js.map
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
export { DSModalWrapper as default };
|