blue-react 8.6.4 → 8.7.1

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.
@@ -73,7 +73,7 @@ var Layout = /*#__PURE__*/function (_Component) {
73
73
  window.blueLayoutRef = _assertThisInitialized(_this);
74
74
  _this.defaultMatch = ["home"];
75
75
  _this.state = {
76
- sidebarIn: props.sidebarIn,
76
+ sidebarIn: props.sidebarIn || false,
77
77
  match: null,
78
78
  history: [],
79
79
  hash: window.location.hash,
@@ -121,6 +121,16 @@ var Layout = /*#__PURE__*/function (_Component) {
121
121
  value: function componentDidUpdate(prevProps, prevState) {
122
122
  var _this3 = this;
123
123
 
124
+ if (prevProps.sidebarIn !== this.props.sidebarIn) {
125
+ this.setState({
126
+ sidebarIn: this.props.sidebarIn || false
127
+ });
128
+ }
129
+
130
+ if (this.props.onChangeSidebarIn && prevState.sidebarIn !== this.state.sidebarIn) {
131
+ this.props.onChangeSidebarIn(this.state.sidebarIn);
132
+ }
133
+
124
134
  if (prevProps.blockRouting !== this.props.blockRouting && this.props.blockRouting !== this.state.blockRouting) {
125
135
  this.setState({
126
136
  blockRouting: this.props.blockRouting
@@ -38,6 +38,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
38
38
  function Modal(_ref) {
39
39
  var modalContent = _ref.modalContent,
40
40
  modalTitle = _ref.modalTitle,
41
+ modalIcon = _ref.modalIcon,
41
42
  unSetModalContent = _ref.unSetModalContent,
42
43
  onSubmit = _ref.onSubmit,
43
44
  defaultInput = _ref.defaultInput,
@@ -120,8 +121,10 @@ function Modal(_ref) {
120
121
  }, /*#__PURE__*/_react.default.createElement("form", {
121
122
  onSubmit: submit
122
123
  }, /*#__PURE__*/_react.default.createElement("div", {
123
- className: "modal-header"
124
- }, /*#__PURE__*/_react.default.createElement("h5", {
124
+ className: "modal-header align-items-center"
125
+ }, modalIcon !== undefined && /*#__PURE__*/_react.default.createElement("div", {
126
+ className: "me-2"
127
+ }, modalIcon), /*#__PURE__*/_react.default.createElement("h5", {
125
128
  className: "modal-title"
126
129
  }, modalTitle || (0, _shared.getPhrase)("Message")), /*#__PURE__*/_react.default.createElement("button", {
127
130
  type: "button",
@@ -64,23 +64,29 @@ var ModalProvider = function ModalProvider(_ref) {
64
64
 
65
65
  var _useState7 = (0, _react.useState)(),
66
66
  _useState8 = _slicedToArray(_useState7, 2),
67
- defaultInput = _useState8[0],
68
- setDefaultInput = _useState8[1];
67
+ modalIcon = _useState8[0],
68
+ setModalIcon = _useState8[1];
69
+
70
+ var _useState9 = (0, _react.useState)(),
71
+ _useState10 = _slicedToArray(_useState9, 2),
72
+ defaultInput = _useState10[0],
73
+ setDefaultInput = _useState10[1];
69
74
 
70
75
  var unSetModalContent = (0, _react.useCallback)(function () {
71
76
  setModalContent(undefined);
72
77
  }, [setModalContent]);
73
78
 
74
- var _useState9 = (0, _react.useState)(),
75
- _useState10 = _slicedToArray(_useState9, 2),
76
- onSubmit = _useState10[0],
77
- setOnSubmit = _useState10[1];
79
+ var _useState11 = (0, _react.useState)(),
80
+ _useState12 = _slicedToArray(_useState11, 2),
81
+ onSubmit = _useState12[0],
82
+ setOnSubmit = _useState12[1];
78
83
 
79
- var ask = function ask(text, title) {
84
+ var ask = function ask(text, title, icon) {
80
85
  return new Promise(function (resolve) {
81
86
  setType("ask");
82
87
  setModalContent(text);
83
88
  setModalTitle(title);
89
+ setModalIcon(icon);
84
90
  setDefaultInput("");
85
91
  setOnSubmit(function () {
86
92
  return function (input) {
@@ -92,11 +98,12 @@ var ModalProvider = function ModalProvider(_ref) {
92
98
  });
93
99
  };
94
100
 
95
- var tell = function tell(text, title) {
101
+ var tell = function tell(text, title, icon) {
96
102
  return new Promise(function (resolve) {
97
103
  setType("tell");
98
104
  setModalContent(text);
99
105
  setModalTitle(title);
106
+ setModalIcon(icon);
100
107
  setOnSubmit(function () {
101
108
  return function (input) {
102
109
  resolve(input ? true : false);
@@ -106,11 +113,12 @@ var ModalProvider = function ModalProvider(_ref) {
106
113
  });
107
114
  };
108
115
 
109
- var verify = function verify(text, title) {
116
+ var verify = function verify(text, title, icon) {
110
117
  return new Promise(function (resolve) {
111
118
  setType("verify");
112
119
  setModalContent(text);
113
120
  setModalTitle(title);
121
+ setModalIcon(icon);
114
122
  setOnSubmit(function () {
115
123
  return function (input) {
116
124
  resolve(input ? true : false);
@@ -129,6 +137,7 @@ var ModalProvider = function ModalProvider(_ref) {
129
137
  }, rest), children, /*#__PURE__*/_react.default.createElement(_Modal.default, {
130
138
  modalContent: modalContent,
131
139
  modalTitle: modalTitle,
140
+ modalIcon: modalIcon,
132
141
  unSetModalContent: unSetModalContent,
133
142
  onSubmit: onSubmit,
134
143
  defaultInput: defaultInput,
@@ -147,6 +147,18 @@ function scrollToTop() {
147
147
  });
148
148
  }
149
149
 
150
+ var httpStatusCodes = {
151
+ 400: "Bad Request",
152
+ 401: "Unauthorized",
153
+ 403: "Forbidden",
154
+ 404: "Not Found",
155
+ 405: "Method Not Allowed",
156
+ 408: "Request Timeout",
157
+ 409: "Conflict",
158
+ 500: "Internal Server Error",
159
+ 502: "Bad Gateway"
160
+ };
161
+
150
162
  function fetchData(input, init) {
151
163
  var showErrorDetail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
152
164
  var onError = arguments.length > 3 ? arguments[3] : undefined;
@@ -156,7 +168,7 @@ function fetchData(input, init) {
156
168
  }).catch(function (reason) {
157
169
  if (reason.text) {
158
170
  reason.text().then(function (errorMessage) {
159
- setAlertMessage("".concat(reason.status, " - ").concat(reason.statusText), "danger", true, showErrorDetail ? errorMessage : undefined);
171
+ setAlertMessage("".concat(reason.status, " - ").concat(reason.statusText || httpStatusCodes[reason.status] || "Error"), "danger", true, showErrorDetail ? errorMessage.toString().replace(/(<style[\w\W]+style>)/g, "").replace(/<[^>]+>/g, "") : undefined);
160
172
 
161
173
  if (onError) {
162
174
  onError(errorMessage, reason);