@elliemae/ds-modal 2.2.0-alpha.4 → 3.0.0-next.2
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/cjs/v1/DSModal.js
CHANGED
|
@@ -1,177 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const { cssClassName, classNameElement, classNameBlock, classNameModifier, classNameBlockModifier } = (0, import_ds_classnames.convertPropToCssClassName)("modal", className, {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
4
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
9
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
|
+
require('react');
|
|
11
|
+
var ReactModal = require('react-modal');
|
|
12
|
+
var dsClassnames = require('@elliemae/ds-classnames');
|
|
13
|
+
var dsIcon = require('@elliemae/ds-icon');
|
|
14
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
15
|
+
var DSButton = require('@elliemae/ds-button');
|
|
16
|
+
var constants = require('../constants.js');
|
|
17
|
+
var ModalFeedBack = require('./ModalFeedBack/ModalFeedBack.js');
|
|
18
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
19
|
+
|
|
20
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
+
|
|
22
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
23
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
24
|
+
var ReactModal__default = /*#__PURE__*/_interopDefaultLegacy(ReactModal);
|
|
25
|
+
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
26
|
+
|
|
27
|
+
var _Close;
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
|
|
31
|
+
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__default["default"](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; }
|
|
32
|
+
|
|
33
|
+
const DSModal = _ref => {
|
|
34
|
+
let {
|
|
35
|
+
containerProps = {},
|
|
36
|
+
className = '',
|
|
37
|
+
dataTestId = 'ds-modal',
|
|
38
|
+
additionalFooterCssClass = '',
|
|
39
|
+
style = {},
|
|
40
|
+
iconCloseSize = dsIcon.DSIconSizes.S,
|
|
41
|
+
modalType = constants.MODAL_TYPE.DEFAULT,
|
|
42
|
+
showHeader = true,
|
|
43
|
+
showFooter = true,
|
|
44
|
+
children,
|
|
45
|
+
centered = true,
|
|
46
|
+
confirmLabel = 'Accept',
|
|
47
|
+
modalTitle = '',
|
|
48
|
+
size = 'medium',
|
|
49
|
+
isOpen = false,
|
|
50
|
+
onClose = () => null,
|
|
51
|
+
onAfterOpen = () => null,
|
|
52
|
+
onConfirm = () => null,
|
|
53
|
+
onReject = () => null,
|
|
54
|
+
rejectLabel = 'Cancel',
|
|
55
|
+
shouldCloseOnOverlayClick = false,
|
|
56
|
+
hasError = false,
|
|
57
|
+
hasWarning = false,
|
|
58
|
+
hasSuccess = false,
|
|
59
|
+
hasInfo = false,
|
|
60
|
+
hasHelp = false,
|
|
61
|
+
actionsRef = () => null,
|
|
62
|
+
appElement = '#root',
|
|
63
|
+
overridePropsConfirmButton = {},
|
|
64
|
+
overridePropsRejectButton = {},
|
|
65
|
+
zIndex = 10
|
|
66
|
+
} = _ref;
|
|
67
|
+
// http://reactcommunity.org/react-modal/accessibility/ https://github.com/reactjs/react-modal#examples
|
|
68
|
+
typeof document !== 'undefined' && document && ReactModal__default["default"].setAppElement && ReactModal__default["default"].setAppElement(appElement); // eslint-disable-line
|
|
69
|
+
|
|
70
|
+
const {
|
|
71
|
+
cssClassName,
|
|
72
|
+
classNameElement,
|
|
73
|
+
classNameBlock,
|
|
74
|
+
classNameModifier,
|
|
75
|
+
classNameBlockModifier
|
|
76
|
+
} = dsClassnames.convertPropToCssClassName('modal', className, {
|
|
78
77
|
hasError,
|
|
79
78
|
hasWarning,
|
|
80
79
|
hasSuccess,
|
|
81
80
|
modalType,
|
|
82
81
|
size
|
|
83
82
|
});
|
|
84
|
-
const {
|
|
83
|
+
const {
|
|
84
|
+
WARNING,
|
|
85
|
+
ERROR,
|
|
86
|
+
SUCCESS,
|
|
87
|
+
HELP,
|
|
88
|
+
INFO
|
|
89
|
+
} = constants.MODAL_TYPE;
|
|
85
90
|
const isAFeedbackType = [WARNING, ERROR, SUCCESS, HELP, INFO].indexOf(modalType) > -1;
|
|
86
91
|
const showFeedBack = isAFeedbackType || hasError || hasWarning || hasSuccess || hasInfo || hasHelp;
|
|
87
|
-
return
|
|
92
|
+
return /*#__PURE__*/_jsx__default["default"](ReactModal__default["default"], {
|
|
88
93
|
testId: dataTestId,
|
|
89
94
|
className: cssClassName,
|
|
90
95
|
contentLabel: modalTitle,
|
|
91
|
-
isOpen,
|
|
92
|
-
onAfterOpen,
|
|
96
|
+
isOpen: isOpen,
|
|
97
|
+
onAfterOpen: onAfterOpen,
|
|
93
98
|
onRequestClose: onClose,
|
|
94
|
-
overlayClassName:
|
|
95
|
-
shouldCloseOnOverlayClick,
|
|
99
|
+
overlayClassName: "".concat(classNameBlock('overlay'), " ").concat(classNameModifier(centered && 'center')),
|
|
100
|
+
shouldCloseOnOverlayClick: shouldCloseOnOverlayClick,
|
|
96
101
|
style: {
|
|
97
|
-
content: {
|
|
98
|
-
...style
|
|
99
|
-
},
|
|
102
|
+
content: _objectSpread({}, style),
|
|
100
103
|
overlay: {
|
|
101
104
|
zIndex
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
})))));
|
|
144
|
-
};
|
|
145
|
-
DSModal.propTypes = {
|
|
146
|
-
className: import_prop_types.default.string,
|
|
147
|
-
additionalFooterCssClass: import_prop_types.default.string,
|
|
148
|
-
style: import_prop_types.default.shape({}),
|
|
149
|
-
iconCloseSize: import_prop_types.default.oneOf(import_prop_types2.iconSizes),
|
|
150
|
-
modalType: import_prop_types.default.oneOf(import_constants.modalTypes),
|
|
151
|
-
showHeader: import_prop_types.default.bool,
|
|
152
|
-
showFooter: import_prop_types.default.bool,
|
|
153
|
-
children: import_prop_types.default.oneOfType([import_prop_types.default.element, import_prop_types.default.string, import_prop_types.default.any]).isRequired,
|
|
154
|
-
centered: import_prop_types.default.bool,
|
|
155
|
-
confirmLabel: import_prop_types.default.string,
|
|
156
|
-
modalTitle: import_prop_types.default.string,
|
|
157
|
-
size: import_prop_types.default.oneOf(import_prop_types2.sizes),
|
|
158
|
-
isOpen: import_prop_types.default.bool,
|
|
159
|
-
onClose: import_prop_types.default.func,
|
|
160
|
-
onAfterOpen: import_prop_types.default.func,
|
|
161
|
-
onConfirm: import_prop_types.default.func,
|
|
162
|
-
onReject: import_prop_types.default.func,
|
|
163
|
-
rejectLabel: import_prop_types.default.string,
|
|
164
|
-
shouldCloseOnOverlayClick: import_prop_types.default.bool,
|
|
165
|
-
hasError: import_prop_types.default.bool,
|
|
166
|
-
hasWarning: import_prop_types.default.bool,
|
|
167
|
-
hasSuccess: import_prop_types.default.bool,
|
|
168
|
-
hasInfo: import_prop_types.default.bool,
|
|
169
|
-
hasHelp: import_prop_types.default.bool,
|
|
170
|
-
actionsRef: import_prop_types.default.func,
|
|
171
|
-
appElement: import_prop_types.default.string,
|
|
172
|
-
overridePropsConfirmButton: import_prop_types.default.shape({}),
|
|
173
|
-
overridePropsRejectButton: import_prop_types.default.shape({})
|
|
107
|
+
}, void 0, /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
108
|
+
children: [showHeader && /*#__PURE__*/_jsx__default["default"]("div", {
|
|
109
|
+
className: classNameBlock('modal-header')
|
|
110
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"]("div", {
|
|
111
|
+
className: classNameElement('title', 'modal-header')
|
|
112
|
+
}, void 0, modalTitle), /*#__PURE__*/_jsx__default["default"]("div", {
|
|
113
|
+
className: classNameElement('icon', 'modal-header')
|
|
114
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
115
|
+
buttonType: "link",
|
|
116
|
+
icon: _Close || (_Close = /*#__PURE__*/_jsx__default["default"](dsIcons.Close, {})),
|
|
117
|
+
onClick: onClose,
|
|
118
|
+
size: iconCloseSize
|
|
119
|
+
}))), /*#__PURE__*/_jsx__default["default"]("div", {
|
|
120
|
+
className: classNameElement('body')
|
|
121
|
+
}, void 0, showFeedBack && /*#__PURE__*/_jsx__default["default"](ModalFeedBack, {
|
|
122
|
+
hasError: hasError,
|
|
123
|
+
hasHelp: hasHelp,
|
|
124
|
+
hasInfo: hasInfo,
|
|
125
|
+
hasSuccess: hasSuccess,
|
|
126
|
+
hasWarning: hasWarning,
|
|
127
|
+
modalType: modalType
|
|
128
|
+
}), children), showFooter && !isAFeedbackType && /*#__PURE__*/_jsx__default["default"]("div", {
|
|
129
|
+
className: "".concat(classNameBlock('modal-footer'), " ").concat(additionalFooterCssClass ? classNameBlockModifier(additionalFooterCssClass, 'modal-footer') : '')
|
|
130
|
+
}, void 0, /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
131
|
+
ref: actionsRef,
|
|
132
|
+
className: classNameBlock('modal-footer-actions'),
|
|
133
|
+
children: [modalType === constants.MODAL_TYPE.CONFIRM && /*#__PURE__*/jsxRuntime.jsx(DSButton__default["default"], _objectSpread({
|
|
134
|
+
buttonType: "secondary",
|
|
135
|
+
className: "".concat(classNameElement('button-action'), " ").concat(classNameModifier('reject', 'button-action'), " "),
|
|
136
|
+
labelText: rejectLabel,
|
|
137
|
+
onClick: onReject
|
|
138
|
+
}, overridePropsRejectButton)), /*#__PURE__*/jsxRuntime.jsx(DSButton__default["default"], _objectSpread({
|
|
139
|
+
buttonType: "primary",
|
|
140
|
+
className: "".concat(classNameElement('button-action'), " ").concat(classNameModifier('confirm', 'button-action'), " "),
|
|
141
|
+
labelText: confirmLabel,
|
|
142
|
+
onClick: onConfirm
|
|
143
|
+
}, overridePropsConfirmButton))]
|
|
144
|
+
}))]
|
|
145
|
+
})));
|
|
174
146
|
};
|
|
175
|
-
|
|
176
|
-
module.exports =
|
|
177
|
-
//# sourceMappingURL=DSModal.js.map
|
|
147
|
+
|
|
148
|
+
module.exports = DSModal;
|
package/cjs/v1/DSModalType.js
CHANGED
|
@@ -1,45 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var DSModalType_exports = {};
|
|
29
|
-
__export(DSModalType_exports, {
|
|
30
|
-
modalTypes: () => modalTypes
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
const modalTypes = [
|
|
34
|
-
MODAL_TYPE.DEFAULT,
|
|
35
|
-
MODAL_TYPE.ALERT,
|
|
36
|
-
MODAL_TYPE.CONFIRM,
|
|
37
|
-
MODAL_TYPE.NOTIFICATION,
|
|
38
|
-
MODAL_TYPE.WARNING,
|
|
39
|
-
MODAL_TYPE.ERROR,
|
|
40
|
-
MODAL_TYPE.SUCCESS,
|
|
41
|
-
MODAL_TYPE.HELP,
|
|
42
|
-
MODAL_TYPE.INFO
|
|
43
|
-
];
|
|
44
|
-
module.exports = __toCommonJS(DSModalType_exports);
|
|
45
|
-
//# sourceMappingURL=DSModalType.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
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];
|
|
6
|
+
|
|
7
|
+
exports.modalTypes = modalTypes;
|
package/cjs/v1/DSModalWrapper.js
CHANGED
|
@@ -1,113 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var DSModalWrapper_exports = {};
|
|
29
|
-
__export(DSModalWrapper_exports, {
|
|
30
|
-
default: () => DSModalWrapper_default
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = require("react");
|
|
34
|
-
var import_constants = require("../constants");
|
|
35
|
-
var DSModalWrapper_default = (WrappedComponent) => {
|
|
36
|
-
class DSModalWrapper extends import_react.Component {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var react = require('react');
|
|
11
|
+
var constants = require('../constants.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
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__default["default"](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; }
|
|
20
|
+
var DSModalWrapper = (WrappedComponent => {
|
|
21
|
+
class DSModalWrapper extends react.Component {
|
|
37
22
|
constructor() {
|
|
38
23
|
super(...arguments);
|
|
39
24
|
this.state = {
|
|
40
25
|
childready: false,
|
|
41
|
-
additionalFooterCssClass:
|
|
26
|
+
additionalFooterCssClass: 'loading',
|
|
42
27
|
container: null,
|
|
43
28
|
actions: null,
|
|
44
|
-
height:
|
|
29
|
+
height: '100%'
|
|
45
30
|
};
|
|
46
|
-
|
|
31
|
+
|
|
32
|
+
this.onHeaderHeight = e => {
|
|
47
33
|
this.heightHeaderFlag = true;
|
|
48
34
|
this.heightHeader = e.height || 0;
|
|
49
35
|
};
|
|
50
|
-
|
|
36
|
+
|
|
37
|
+
this.onFooterHeight = e => {
|
|
51
38
|
this.heightFooterFlag = true;
|
|
52
39
|
this.heightFooter = e.height || 0;
|
|
53
40
|
};
|
|
54
|
-
|
|
41
|
+
|
|
42
|
+
this.onResize = _ref => {
|
|
43
|
+
let {
|
|
44
|
+
bounds
|
|
45
|
+
} = _ref;
|
|
46
|
+
|
|
55
47
|
if (this.heightFooterFlag && this.heightHeaderFlag) {
|
|
56
48
|
return this.setState({
|
|
57
49
|
height: bounds.height - this.heightFooter - this.heightHeader
|
|
58
50
|
});
|
|
59
51
|
}
|
|
60
|
-
|
|
52
|
+
|
|
53
|
+
return setTimeout(this.onResize({
|
|
54
|
+
bounds
|
|
55
|
+
}), 0);
|
|
61
56
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
|
|
58
|
+
this.handleContainer = node => {
|
|
59
|
+
if (node) this.setState({
|
|
60
|
+
container: node
|
|
61
|
+
});
|
|
65
62
|
this.handleResize();
|
|
66
63
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
|
|
65
|
+
this.handleActions = node => {
|
|
66
|
+
if (node) this.setState({
|
|
67
|
+
actions: node
|
|
68
|
+
});
|
|
70
69
|
this.handleResize();
|
|
71
70
|
};
|
|
72
71
|
}
|
|
72
|
+
|
|
73
73
|
componentDidMount() {
|
|
74
|
-
window.addEventListener(
|
|
74
|
+
window.addEventListener('resize', this.handleResize);
|
|
75
75
|
}
|
|
76
|
+
|
|
76
77
|
componentWillUnmount() {
|
|
77
|
-
window.removeEventListener(
|
|
78
|
+
window.removeEventListener('resize', this.handleResize);
|
|
78
79
|
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Change button width to 100% if the
|
|
83
|
+
* combined width of the button (or button group) exceed 50% of the container width.
|
|
84
|
+
*/
|
|
79
85
|
handleResize() {
|
|
80
|
-
if (!this.state)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
if (!this.state) return null;
|
|
87
|
+
const {
|
|
88
|
+
container,
|
|
89
|
+
actions,
|
|
90
|
+
childready
|
|
91
|
+
} = this.state;
|
|
92
|
+
if (!childready) return null;
|
|
93
|
+
this.setState({
|
|
94
|
+
additionalFooterCssClass: null
|
|
95
|
+
}); // !important reset to default state to recalculate
|
|
96
|
+
|
|
97
|
+
const {
|
|
98
|
+
clientWidth: containerWidth
|
|
99
|
+
} = container;
|
|
100
|
+
const {
|
|
101
|
+
clientWidth: actionsWidth
|
|
102
|
+
} = actions; // Change button width to 100% if the combined width of the button (or button group) exceed 50% of the container width.
|
|
103
|
+
|
|
88
104
|
if (containerWidth && actionsWidth && actionsWidth / containerWidth * 100 > 50) {
|
|
89
|
-
return this.setState({
|
|
105
|
+
return this.setState({
|
|
106
|
+
additionalFooterCssClass: 'fluid-actions'
|
|
107
|
+
});
|
|
90
108
|
}
|
|
91
|
-
|
|
109
|
+
|
|
110
|
+
return this.setState({
|
|
111
|
+
additionalFooterCssClass: null
|
|
112
|
+
});
|
|
92
113
|
}
|
|
114
|
+
|
|
93
115
|
verifyNodes() {
|
|
94
|
-
const {
|
|
95
|
-
|
|
116
|
+
const {
|
|
117
|
+
modalType
|
|
118
|
+
} = this.props;
|
|
119
|
+
|
|
120
|
+
if (modalType !== constants.MODAL_TYPE.DEFAULT) {
|
|
96
121
|
const nodesInterval = setInterval(() => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
122
|
+
// !important it checks when nodes are availables
|
|
123
|
+
const {
|
|
124
|
+
container,
|
|
125
|
+
actions
|
|
126
|
+
} = this.state;
|
|
127
|
+
if (!container || !actions) return null;
|
|
100
128
|
clearInterval(nodesInterval);
|
|
101
|
-
this.setState({
|
|
129
|
+
this.setState({
|
|
130
|
+
childready: true
|
|
131
|
+
});
|
|
102
132
|
return this.handleResize();
|
|
103
133
|
}, 100);
|
|
104
134
|
}
|
|
105
135
|
}
|
|
136
|
+
|
|
106
137
|
render() {
|
|
107
|
-
const {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
138
|
+
const {
|
|
139
|
+
props,
|
|
140
|
+
state
|
|
141
|
+
} = this;
|
|
142
|
+
const {
|
|
143
|
+
additionalFooterCssClass,
|
|
144
|
+
height
|
|
145
|
+
} = state;
|
|
146
|
+
return /*#__PURE__*/react.createElement(WrappedComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
111
147
|
height,
|
|
112
148
|
onResize: this.onResize,
|
|
113
149
|
onFooterHeight: this.onFooterHeight,
|
|
@@ -116,14 +152,15 @@ var DSModalWrapper_default = (WrappedComponent) => {
|
|
|
116
152
|
actionsRef: this.handleActions,
|
|
117
153
|
additionalFooterCssClass,
|
|
118
154
|
onAfterOpen: () => {
|
|
119
|
-
if (props.onAfterOpen)
|
|
120
|
-
props.onAfterOpen();
|
|
155
|
+
if (props.onAfterOpen) props.onAfterOpen();
|
|
121
156
|
this.verifyNodes();
|
|
122
157
|
}
|
|
123
|
-
});
|
|
158
|
+
}));
|
|
124
159
|
}
|
|
160
|
+
|
|
125
161
|
}
|
|
162
|
+
|
|
126
163
|
return DSModalWrapper;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
module.exports = DSModalWrapper;
|