@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.
Files changed (70) hide show
  1. package/cjs/DSModal.js +184 -86
  2. package/cjs/constants.js +28 -67
  3. package/cjs/index.js +18 -39
  4. package/cjs/v1/DSModal.js +130 -159
  5. package/cjs/v1/DSModalType.js +7 -45
  6. package/cjs/v1/DSModalWrapper.js +113 -76
  7. package/cjs/v1/ModalFeedBack/ModalFeedBack.js +72 -77
  8. package/cjs/v2/DSModal.js +186 -143
  9. package/cjs/v2/blocks.js +86 -69
  10. package/cjs/v2/components/DecisionHeader.js +37 -47
  11. package/cjs/v2/components/FeedbackIcon.js +50 -59
  12. package/cjs/v2/components/Footer.js +65 -68
  13. package/cjs/v2/components/FormHeader.js +46 -53
  14. package/cjs/v2/components/ModalContent.js +111 -95
  15. package/cjs/v2/components/SelectionHeader.js +48 -50
  16. package/cjs/v2/components/Title.js +25 -40
  17. package/cjs/v2/helpers.js +40 -49
  18. package/esm/DSModal.js +142 -26
  19. package/esm/constants.js +20 -38
  20. package/esm/index.js +4 -10
  21. package/esm/v1/DSModal.js +121 -130
  22. package/esm/v1/DSModalType.js +3 -16
  23. package/esm/v1/DSModalWrapper.js +105 -45
  24. package/esm/v1/ModalFeedBack/ModalFeedBack.js +66 -48
  25. package/esm/v2/DSModal.js +173 -112
  26. package/esm/v2/blocks.js +77 -42
  27. package/esm/v2/components/DecisionHeader.js +27 -18
  28. package/esm/v2/components/FeedbackIcon.js +36 -25
  29. package/esm/v2/components/Footer.js +54 -39
  30. package/esm/v2/components/FormHeader.js +36 -24
  31. package/esm/v2/components/ModalContent.js +102 -72
  32. package/esm/v2/components/SelectionHeader.js +38 -21
  33. package/esm/v2/components/Title.js +16 -11
  34. package/esm/v2/helpers.js +28 -16
  35. package/package.json +8 -8
  36. package/types/DSModal.d.ts +1 -1
  37. package/cjs/DSModal.js.map +0 -7
  38. package/cjs/constants.js.map +0 -7
  39. package/cjs/index.js.map +0 -7
  40. package/cjs/v1/DSModal.js.map +0 -7
  41. package/cjs/v1/DSModalType.js.map +0 -7
  42. package/cjs/v1/DSModalWrapper.js.map +0 -7
  43. package/cjs/v1/ModalFeedBack/ModalFeedBack.js.map +0 -7
  44. package/cjs/v2/DSModal.js.map +0 -7
  45. package/cjs/v2/blocks.js.map +0 -7
  46. package/cjs/v2/components/DecisionHeader.js.map +0 -7
  47. package/cjs/v2/components/FeedbackIcon.js.map +0 -7
  48. package/cjs/v2/components/Footer.js.map +0 -7
  49. package/cjs/v2/components/FormHeader.js.map +0 -7
  50. package/cjs/v2/components/ModalContent.js.map +0 -7
  51. package/cjs/v2/components/SelectionHeader.js.map +0 -7
  52. package/cjs/v2/components/Title.js.map +0 -7
  53. package/cjs/v2/helpers.js.map +0 -7
  54. package/esm/DSModal.js.map +0 -7
  55. package/esm/constants.js.map +0 -7
  56. package/esm/index.js.map +0 -7
  57. package/esm/v1/DSModal.js.map +0 -7
  58. package/esm/v1/DSModalType.js.map +0 -7
  59. package/esm/v1/DSModalWrapper.js.map +0 -7
  60. package/esm/v1/ModalFeedBack/ModalFeedBack.js.map +0 -7
  61. package/esm/v2/DSModal.js.map +0 -7
  62. package/esm/v2/blocks.js.map +0 -7
  63. package/esm/v2/components/DecisionHeader.js.map +0 -7
  64. package/esm/v2/components/FeedbackIcon.js.map +0 -7
  65. package/esm/v2/components/Footer.js.map +0 -7
  66. package/esm/v2/components/FormHeader.js.map +0 -7
  67. package/esm/v2/components/ModalContent.js.map +0 -7
  68. package/esm/v2/components/SelectionHeader.js.map +0 -7
  69. package/esm/v2/components/Title.js.map +0 -7
  70. 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: "default",
4
- ALERT: "alert",
5
- CONFIRM: "confirm",
6
- NOTIFICATION: "notification",
7
- WARNING: "warning",
8
- ERROR: "error",
9
- SUCCESS: "success",
10
- HELP: "help",
11
- INFO: "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: "information",
26
- DECISION: "decision",
27
- SELECTION: "selection",
28
- FORM: "form"
14
+ INFORMATION: 'information',
15
+ DECISION: 'decision',
16
+ SELECTION: 'selection',
17
+ FORM: 'form'
29
18
  };
30
19
  const MODAL_SUB_TYPE_V2 = {
31
- SUCCESS: "success",
32
- WARNING: "warning",
33
- ERROR: "error",
34
- INFORMATION: "information"
20
+ SUCCESS: 'success',
21
+ WARNING: 'warning',
22
+ ERROR: 'error',
23
+ INFORMATION: 'information'
35
24
  };
36
- var constants_default = MODAL_TYPE;
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
- import * as React from "react";
2
- export * from "./DSModal";
3
- export * from "./constants";
4
- import { DSModalWithSchema } from "./v2/DSModal";
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 * as React from "react";
2
- import React2 from "react";
3
- import PropTypes from "prop-types";
4
- import ReactModal from "react-modal";
5
- import { convertPropToCssClassName } from "@elliemae/ds-classnames";
6
- import { DSIconSizes } from "@elliemae/ds-icon";
7
- import { Close } from "@elliemae/ds-icons";
8
- import DSButton from "@elliemae/ds-button";
9
- import MODAL_TYPE, { modalTypes } from "../constants";
10
- import ModalFeedBack from "./ModalFeedBack/ModalFeedBack";
11
- import { sizes, iconSizes } from "@elliemae/ds-shared/prop-types";
12
- const DSModal = ({
13
- containerProps = {},
14
- className = "",
15
- dataTestId = "ds-modal",
16
- additionalFooterCssClass = "",
17
- style = {},
18
- iconCloseSize = DSIconSizes.S,
19
- modalType = MODAL_TYPE.DEFAULT,
20
- showHeader = true,
21
- showFooter = true,
22
- children,
23
- centered = true,
24
- confirmLabel = "Accept",
25
- modalTitle = "",
26
- size = "medium",
27
- isOpen = false,
28
- onClose = () => null,
29
- onAfterOpen = () => null,
30
- onConfirm = () => null,
31
- onReject = () => null,
32
- rejectLabel = "Cancel",
33
- shouldCloseOnOverlayClick = false,
34
- hasError = false,
35
- hasWarning = false,
36
- hasSuccess = false,
37
- hasInfo = false,
38
- hasHelp = false,
39
- actionsRef = () => null,
40
- appElement = "#root",
41
- overridePropsConfirmButton = {},
42
- overridePropsRejectButton = {},
43
- zIndex = 10
44
- }) => {
45
- typeof document !== "undefined" && document && ReactModal.setAppElement && ReactModal.setAppElement(appElement);
46
- const { cssClassName, classNameElement, classNameBlock, classNameModifier, classNameBlockModifier } = convertPropToCssClassName("modal", className, {
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 { WARNING, ERROR, SUCCESS, HELP, INFO } = MODAL_TYPE;
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 /* @__PURE__ */ React2.createElement(ReactModal, {
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: `${classNameBlock("overlay")} ${classNameModifier(centered && "center")}`,
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
- }, /* @__PURE__ */ React2.createElement("div", {
74
- ...containerProps
75
- }, showHeader && /* @__PURE__ */ React2.createElement("div", {
76
- className: classNameBlock("modal-header")
77
- }, /* @__PURE__ */ React2.createElement("div", {
78
- className: classNameElement("title", "modal-header")
79
- }, modalTitle), /* @__PURE__ */ React2.createElement("div", {
80
- className: classNameElement("icon", "modal-header")
81
- }, /* @__PURE__ */ React2.createElement(DSButton, {
82
- buttonType: "link",
83
- icon: /* @__PURE__ */ React2.createElement(Close, null),
84
- onClick: onClose,
85
- size: iconCloseSize
86
- }))), /* @__PURE__ */ React2.createElement("div", {
87
- className: classNameElement("body")
88
- }, showFeedBack && /* @__PURE__ */ React2.createElement(ModalFeedBack, {
89
- hasError,
90
- hasHelp,
91
- hasInfo,
92
- hasSuccess,
93
- hasWarning,
94
- modalType
95
- }), children), showFooter && !isAFeedbackType && /* @__PURE__ */ React2.createElement("div", {
96
- className: `${classNameBlock("modal-footer")} ${additionalFooterCssClass ? classNameBlockModifier(additionalFooterCssClass, "modal-footer") : ""}`
97
- }, /* @__PURE__ */ React2.createElement("div", {
98
- ref: actionsRef,
99
- className: classNameBlock("modal-footer-actions")
100
- }, modalType === MODAL_TYPE.CONFIRM && /* @__PURE__ */ React2.createElement(DSButton, {
101
- buttonType: "secondary",
102
- className: `${classNameElement("button-action")} ${classNameModifier("reject", "button-action")} `,
103
- labelText: rejectLabel,
104
- onClick: onReject,
105
- ...overridePropsRejectButton
106
- }), /* @__PURE__ */ React2.createElement(DSButton, {
107
- buttonType: "primary",
108
- className: `${classNameElement("button-action")} ${classNameModifier("confirm", "button-action")} `,
109
- labelText: confirmLabel,
110
- onClick: onConfirm,
111
- ...overridePropsConfirmButton
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
- //# sourceMappingURL=DSModal.js.map
138
+
139
+ export { DSModal as default };
@@ -1,16 +1,3 @@
1
- import * as React from "react";
2
- const modalTypes = [
3
- MODAL_TYPE.DEFAULT,
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 };
@@ -1,82 +1,143 @@
1
- import * as React from "react";
2
- import { Component, createElement } from "react";
3
- import { MODAL_TYPE } from "../constants";
4
- var DSModalWrapper_default = (WrappedComponent) => {
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: "loading",
20
+ additionalFooterCssClass: 'loading',
11
21
  container: null,
12
22
  actions: null,
13
- height: "100%"
23
+ height: '100%'
14
24
  };
15
- this.onHeaderHeight = (e) => {
25
+
26
+ this.onHeaderHeight = e => {
16
27
  this.heightHeaderFlag = true;
17
28
  this.heightHeader = e.height || 0;
18
29
  };
19
- this.onFooterHeight = (e) => {
30
+
31
+ this.onFooterHeight = e => {
20
32
  this.heightFooterFlag = true;
21
33
  this.heightFooter = e.height || 0;
22
34
  };
23
- this.onResize = ({ bounds }) => {
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
- return setTimeout(this.onResize({ bounds }), 0);
46
+
47
+ return setTimeout(this.onResize({
48
+ bounds
49
+ }), 0);
30
50
  };
31
- this.handleContainer = (node) => {
32
- if (node)
33
- this.setState({ container: node });
51
+
52
+ this.handleContainer = node => {
53
+ if (node) this.setState({
54
+ container: node
55
+ });
34
56
  this.handleResize();
35
57
  };
36
- this.handleActions = (node) => {
37
- if (node)
38
- this.setState({ actions: node });
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("resize", this.handleResize);
68
+ window.addEventListener('resize', this.handleResize);
44
69
  }
70
+
45
71
  componentWillUnmount() {
46
- window.removeEventListener("resize", this.handleResize);
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
- return null;
51
- const { container, actions, childready } = this.state;
52
- if (!childready)
53
- return null;
54
- this.setState({ additionalFooterCssClass: null });
55
- const { clientWidth: containerWidth } = container;
56
- const { clientWidth: actionsWidth } = actions;
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({ additionalFooterCssClass: "fluid-actions" });
99
+ return this.setState({
100
+ additionalFooterCssClass: 'fluid-actions'
101
+ });
59
102
  }
60
- return this.setState({ additionalFooterCssClass: null });
103
+
104
+ return this.setState({
105
+ additionalFooterCssClass: null
106
+ });
61
107
  }
108
+
62
109
  verifyNodes() {
63
- const { modalType } = this.props;
110
+ const {
111
+ modalType
112
+ } = this.props;
113
+
64
114
  if (modalType !== MODAL_TYPE.DEFAULT) {
65
115
  const nodesInterval = setInterval(() => {
66
- const { container, actions } = this.state;
67
- if (!container || !actions)
68
- return null;
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({ childready: true });
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 { props, state } = this;
77
- const { additionalFooterCssClass, height } = state;
78
- return createElement(WrappedComponent, {
79
- ...props,
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
- export {
98
- DSModalWrapper_default as default
99
- };
100
- //# sourceMappingURL=DSModalWrapper.js.map
158
+ });
159
+
160
+ export { DSModalWrapper as default };